<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[201942] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/201942">201942</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2016-06-10 15:00:23 -0700 (Fri, 10 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add SPI to disable spellchecking on auto-fillable text fields
https://bugs.webkit.org/show_bug.cgi?id=158611

Reviewed by Anders Carlsson.

Source/WebCore:

Added a boolean flag m_isSpellCheckingEnabled to HTMLInputElement. This flag defaults to true, and can be set
to false by WebKit2 C API.

* editing/Editor.cpp:
(WebCore::Editor::isSpellCheckingEnabledFor): Fixed a bug that we were calling isSpellCheckingEnabled on
the div inside an input element's shadow tree instead of the input element itself.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::HTMLInputElement): Initialize m_spellcheckEnabled to true (it's a bit field).
(WebCore::HTMLInputElement::isSpellCheckingEnabled): Added. Return false if m_spellcheckEnabled is false.
* html/HTMLInputElement.h:
(WebCore::HTMLInputElement::setSpellcheckEnabled): Added.

Source/WebKit2:

Added WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled to disable spellchecking on a text field.

This is used by WebKit2 client which desires to disable spellchecking and notably autocorrection on
login forms, etc... where such feature would interfere with user's actions.

* WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
(WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled): Added.
* WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
(WebKit::InjectedBundleNodeHandle::setHTMLInputElementSpellcheckEnabled): Added.
* WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreeditingEditorcpp">trunk/Source/WebCore/editing/Editor.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLInputElementcpp">trunk/Source/WebCore/html/HTMLInputElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLInputElementh">trunk/Source/WebCore/html/HTMLInputElement.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundleNodeHandlecpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundleNodeHandlePrivateh">trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleDOMInjectedBundleNodeHandlecpp">trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessInjectedBundleDOMInjectedBundleNodeHandleh">trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (201941 => 201942)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-06-10 21:26:00 UTC (rev 201941)
+++ trunk/Source/WebCore/ChangeLog        2016-06-10 22:00:23 UTC (rev 201942)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-06-09  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Add SPI to disable spellchecking on auto-fillable text fields
+        https://bugs.webkit.org/show_bug.cgi?id=158611
+
+        Reviewed by Anders Carlsson.
+
+        Added a boolean flag m_isSpellCheckingEnabled to HTMLInputElement. This flag defaults to true, and can be set
+        to false by WebKit2 C API.
+
+        * editing/Editor.cpp:
+        (WebCore::Editor::isSpellCheckingEnabledFor): Fixed a bug that we were calling isSpellCheckingEnabled on
+        the div inside an input element's shadow tree instead of the input element itself.
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::HTMLInputElement): Initialize m_spellcheckEnabled to true (it's a bit field).
+        (WebCore::HTMLInputElement::isSpellCheckingEnabled): Added. Return false if m_spellcheckEnabled is false.
+        * html/HTMLInputElement.h:
+        (WebCore::HTMLInputElement::setSpellcheckEnabled): Added.
+
</ins><span class="cx"> 2016-06-10  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Introduce WTF::UniqueRef
</span></span></pre></div>
<a id="trunkSourceWebCoreeditingEditorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/editing/Editor.cpp (201941 => 201942)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/editing/Editor.cpp        2016-06-10 21:26:00 UTC (rev 201941)
+++ trunk/Source/WebCore/editing/Editor.cpp        2016-06-10 22:00:23 UTC (rev 201942)
</span><span class="lines">@@ -2372,10 +2372,14 @@
</span><span class="cx"> {
</span><span class="cx">     if (!node)
</span><span class="cx">         return false;
</span><del>-    const Element* focusedElement = is&lt;Element&gt;(*node) ? downcast&lt;Element&gt;(node) : node-&gt;parentElement();
-    if (!focusedElement)
</del><ins>+    Element* element = is&lt;Element&gt;(*node) ? downcast&lt;Element&gt;(node) : node-&gt;parentElement();
+    if (!element)
</ins><span class="cx">         return false;
</span><del>-    return focusedElement-&gt;isSpellCheckingEnabled();
</del><ins>+    if (element-&gt;isInUserAgentShadowTree()) {
+        if (HTMLTextFormControlElement* textControl = enclosingTextFormControl(firstPositionInOrBeforeNode(element)))
+            return textControl-&gt;isSpellCheckingEnabled();
+    }
+    return element-&gt;isSpellCheckingEnabled();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool Editor::isSpellCheckingEnabledInFocusedNode() const
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (201941 => 201942)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.cpp        2016-06-10 21:26:00 UTC (rev 201941)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp        2016-06-10 22:00:23 UTC (rev 201942)
</span><span class="lines">@@ -117,6 +117,7 @@
</span><span class="cx"> #if ENABLE(TOUCH_EVENTS)
</span><span class="cx">     , m_hasTouchEventHandler(false)
</span><span class="cx"> #endif
</span><ins>+    , m_isSpellCheckingEnabled(true)
</ins><span class="cx">     // m_inputType is lazily created when constructed by the parser to avoid constructing unnecessarily a text inputType and
</span><span class="cx">     // its shadow subtree, just to destroy them when the |type| attribute gets set by the parser to something else than 'text'.
</span><span class="cx">     , m_inputType(createdByParser ? nullptr : InputType::createText(*this))
</span><span class="lines">@@ -423,6 +424,11 @@
</span><span class="cx">     return m_inputType-&gt;shouldUseInputMethod();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+bool HTMLInputElement::isSpellCheckingEnabled() const
+{
+    return m_isSpellCheckingEnabled &amp;&amp; HTMLTextFormControlElement::isSpellCheckingEnabled();
+}
+
</ins><span class="cx"> void HTMLInputElement::handleFocusEvent(Node* oldFocusedNode, FocusDirection direction)
</span><span class="cx"> {
</span><span class="cx">     m_inputType-&gt;handleFocusEvent(oldFocusedNode, direction);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.h (201941 => 201942)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.h        2016-06-10 21:26:00 UTC (rev 201941)
+++ trunk/Source/WebCore/html/HTMLInputElement.h        2016-06-10 22:00:23 UTC (rev 201942)
</span><span class="lines">@@ -307,6 +307,8 @@
</span><span class="cx"> 
</span><span class="cx">     void endEditing();
</span><span class="cx"> 
</span><ins>+    void setSpellcheckEnabled(bool enabled) { m_isSpellCheckingEnabled = enabled; }
+
</ins><span class="cx">     static Vector&lt;FileChooserFileInfo&gt; filesFromFileInputFormControlState(const FormControlState&amp;);
</span><span class="cx"> 
</span><span class="cx">     bool matchesReadWritePseudoClass() const final;
</span><span class="lines">@@ -348,6 +350,7 @@
</span><span class="cx">     bool supportLabels() const final;
</span><span class="cx">     void updateFocusAppearance(SelectionRestorationMode, SelectionRevealMode) final;
</span><span class="cx">     bool shouldUseInputMethod() final;
</span><ins>+    bool isSpellCheckingEnabled() const final;
</ins><span class="cx"> 
</span><span class="cx">     bool isTextFormControl() const final { return isTextField(); }
</span><span class="cx"> 
</span><span class="lines">@@ -448,6 +451,7 @@
</span><span class="cx"> #if ENABLE(TOUCH_EVENTS)
</span><span class="cx">     bool m_hasTouchEventHandler : 1;
</span><span class="cx"> #endif
</span><ins>+    bool m_isSpellCheckingEnabled : 1;
</ins><span class="cx">     std::unique_ptr&lt;InputType&gt; m_inputType;
</span><span class="cx">     // The ImageLoader must be owned by this element because the loader code assumes
</span><span class="cx">     // that it lives as long as its owning element lives. If we move the loader into
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (201941 => 201942)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-06-10 21:26:00 UTC (rev 201941)
+++ trunk/Source/WebKit2/ChangeLog        2016-06-10 22:00:23 UTC (rev 201942)
</span><span class="lines">@@ -1,3 +1,22 @@
</span><ins>+2016-06-09  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
+        Add SPI to disable spellchecking on auto-fillable text fields
+        https://bugs.webkit.org/show_bug.cgi?id=158611
+
+        Reviewed by Anders Carlsson.
+
+        Added WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled to disable spellchecking on a text field.
+
+        This is used by WebKit2 client which desires to disable spellchecking and notably autocorrection on
+        login forms, etc... where such feature would interfere with user's actions.
+
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp:
+        (WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled): Added.
+        * WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h:
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp:
+        (WebKit::InjectedBundleNodeHandle::setHTMLInputElementSpellcheckEnabled): Added.
+        * WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h:
+
</ins><span class="cx"> 2016-06-10  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Introduce WTF::UniqueRef
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundleNodeHandlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp (201941 => 201942)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp        2016-06-10 21:26:00 UTC (rev 201941)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandle.cpp        2016-06-10 22:00:23 UTC (rev 201942)
</span><span class="lines">@@ -95,6 +95,11 @@
</span><span class="cx">     toImpl(htmlInputElementHandleRef)-&gt;setHTMLInputElementValueForUser(toWTFString(valueRef));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled(WKBundleNodeHandleRef htmlInputElementHandleRef, bool enabled)
+{
+    toImpl(htmlInputElementHandleRef)-&gt;setHTMLInputElementSpellcheckEnabled(enabled);
+}
+
</ins><span class="cx"> bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandleRef)
</span><span class="cx"> {
</span><span class="cx">     return toImpl(htmlInputElementHandleRef)-&gt;isHTMLInputElementAutoFilled();
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleAPIcWKBundleNodeHandlePrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h (201941 => 201942)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h        2016-06-10 21:26:00 UTC (rev 201941)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleNodeHandlePrivate.h        2016-06-10 22:00:23 UTC (rev 201942)
</span><span class="lines">@@ -59,6 +59,7 @@
</span><span class="cx"> 
</span><span class="cx"> /* HTMLInputElement Specific Operations */
</span><span class="cx"> WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementValueForUser(WKBundleNodeHandleRef htmlInputElementHandle, WKStringRef value);
</span><ins>+WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementSpellcheckEnabled(WKBundleNodeHandleRef htmlInputElementHandle, bool enabled);
</ins><span class="cx"> WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle);
</span><span class="cx"> WK_EXPORT void WKBundleNodeHandleSetHTMLInputElementAutoFilled(WKBundleNodeHandleRef htmlInputElementHandle, bool filled);
</span><span class="cx"> WK_EXPORT bool WKBundleNodeHandleGetHTMLInputElementAutoFillButtonEnabled(WKBundleNodeHandleRef htmlInputElementHandle);
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleDOMInjectedBundleNodeHandlecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp (201941 => 201942)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp        2016-06-10 21:26:00 UTC (rev 201941)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.cpp        2016-06-10 22:00:23 UTC (rev 201942)
</span><span class="lines">@@ -210,6 +210,14 @@
</span><span class="cx">     downcast&lt;HTMLInputElement&gt;(m_node.get()).setValueForUser(value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void InjectedBundleNodeHandle::setHTMLInputElementSpellcheckEnabled(bool enabled)
+{
+    if (!is&lt;HTMLInputElement&gt;(m_node))
+        return;
+
+    downcast&lt;HTMLInputElement&gt;(m_node.get()).setSpellcheckEnabled(enabled);
+}
+
</ins><span class="cx"> bool InjectedBundleNodeHandle::isHTMLInputElementAutoFilled() const
</span><span class="cx"> {
</span><span class="cx">     if (!is&lt;HTMLInputElement&gt;(m_node))
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessInjectedBundleDOMInjectedBundleNodeHandleh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h (201941 => 201942)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h        2016-06-10 21:26:00 UTC (rev 201941)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/DOM/InjectedBundleNodeHandle.h        2016-06-10 22:00:23 UTC (rev 201942)
</span><span class="lines">@@ -66,6 +66,7 @@
</span><span class="cx">     PassRefPtr&lt;WebImage&gt; renderedImage(SnapshotOptions);
</span><span class="cx">     PassRefPtr&lt;InjectedBundleRangeHandle&gt; visibleRange();
</span><span class="cx">     void setHTMLInputElementValueForUser(const String&amp;);
</span><ins>+    void setHTMLInputElementSpellcheckEnabled(bool);
</ins><span class="cx">     bool isHTMLInputElementAutoFilled() const;
</span><span class="cx">     void setHTMLInputElementAutoFilled(bool);
</span><span class="cx">     bool isHTMLInputElementAutoFillButtonEnabled() const;
</span></span></pre>
</div>
</div>

</body>
</html>