<!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>[191876] trunk/Source/WebCore</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/191876">191876</a></dd>
<dt>Author</dt> <dd>darin@apple.com</dd>
<dt>Date</dt> <dd>2015-11-01 22:01:37 -0800 (Sun, 01 Nov 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Tidy handling of type=color in HTMLInputElement a bit
https://bugs.webkit.org/show_bug.cgi?id=150786

Reviewed by Andreas Kling.

* html/ColorInputType.cpp: Fix formatting.
(WebCore::ColorInputType::fallbackValue): Use ASCIILiteral for slightly
better performance.
(WebCore::ColorInputType::sanitizeValue): Use convertToASCIILowercase,
since there is no need for the general purpose Unicode lowercasing here;
those non-ASCII characters aren't allowed by isValidColorString.
(WebCore::ColorInputType::suggestions): Rewrote data list code to remove
peculiarities such as using a null check to terminate the loop instead of
the collection length, calling back to HTMLInputElement just to get the
isValidColorString function called. Also used reserveInitialCapacity and
uncheckedAppend for better memory use in the result vector.
(WebCore::ColorInputType::selectColor): Added.

* html/ColorInputType.h: Made derivation from ColorChooserClient private.
Made most functions private. Added overrides for valueAsColor and selectColor,
now both virtual functions in InputType.

* html/HTMLInputElement.cpp: Removed now-unneeded include of ColorInputType.h.
(WebCore::HTMLInputElement::valueAsColor): Added. Calls through to the InputType.
In a later patch, will be used by accessibility code to get the color so it
does not have to replicate the color parsing logic from this element.
(WebCore::HTMLInputElement::selectColor): Renamed from selectColorInColorChooser,
because the longer name is not clearer. Also made this non-conditional.

* html/HTMLInputElement.h: Added valueAsColor, renamed selectColorInColorChooser
to selectColor and made it available unconditionally.

* html/InputType.cpp:
(WebCore::InputType::valueAsColor): Added. Returns transparent color.
(WebCore::InputType::selectColor): Added. Does nothing by default.

* html/InputType.h: Added virtual valueAsColor and selectColor. Also tidied
up the header a bit and removed unneeded Noncopyable (since this class has
a reference for one of the data members and so is intrinsically not copyable).
Made isColorControl available unconditionally.

* testing/Internals.cpp:
(WebCore::Internals::selectColorInColorChooser): Removed conditionals and
made this call selectColor rather than selectColorInColorChooser.

* testing/Internals.h: Made selectColorInColorChooser unconditional.

* testing/Internals.idl: Made selectColorInColorChooser unconditionally
present. Not important to optimize the test internals class by leaving it
out when INPUT_TYPE_COLOR is not enabled.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlColorInputTypecpp">trunk/Source/WebCore/html/ColorInputType.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlColorInputTypeh">trunk/Source/WebCore/html/ColorInputType.h</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="#trunkSourceWebCorehtmlInputTypecpp">trunk/Source/WebCore/html/InputType.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlInputTypeh">trunk/Source/WebCore/html/InputType.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalscpp">trunk/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsh">trunk/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#trunkSourceWebCoretestingInternalsidl">trunk/Source/WebCore/testing/Internals.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/ChangeLog        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -1,3 +1,56 @@
</span><ins>+2015-11-01  Darin Adler  &lt;darin@apple.com&gt;
+
+        Tidy handling of type=color in HTMLInputElement a bit
+        https://bugs.webkit.org/show_bug.cgi?id=150786
+
+        Reviewed by Andreas Kling.
+
+        * html/ColorInputType.cpp: Fix formatting.
+        (WebCore::ColorInputType::fallbackValue): Use ASCIILiteral for slightly
+        better performance.
+        (WebCore::ColorInputType::sanitizeValue): Use convertToASCIILowercase,
+        since there is no need for the general purpose Unicode lowercasing here;
+        those non-ASCII characters aren't allowed by isValidColorString.
+        (WebCore::ColorInputType::suggestions): Rewrote data list code to remove
+        peculiarities such as using a null check to terminate the loop instead of
+        the collection length, calling back to HTMLInputElement just to get the
+        isValidColorString function called. Also used reserveInitialCapacity and
+        uncheckedAppend for better memory use in the result vector.
+        (WebCore::ColorInputType::selectColor): Added.
+
+        * html/ColorInputType.h: Made derivation from ColorChooserClient private.
+        Made most functions private. Added overrides for valueAsColor and selectColor,
+        now both virtual functions in InputType.
+
+        * html/HTMLInputElement.cpp: Removed now-unneeded include of ColorInputType.h.
+        (WebCore::HTMLInputElement::valueAsColor): Added. Calls through to the InputType.
+        In a later patch, will be used by accessibility code to get the color so it
+        does not have to replicate the color parsing logic from this element.
+        (WebCore::HTMLInputElement::selectColor): Renamed from selectColorInColorChooser,
+        because the longer name is not clearer. Also made this non-conditional.
+
+        * html/HTMLInputElement.h: Added valueAsColor, renamed selectColorInColorChooser
+        to selectColor and made it available unconditionally.
+
+        * html/InputType.cpp:
+        (WebCore::InputType::valueAsColor): Added. Returns transparent color.
+        (WebCore::InputType::selectColor): Added. Does nothing by default.
+
+        * html/InputType.h: Added virtual valueAsColor and selectColor. Also tidied
+        up the header a bit and removed unneeded Noncopyable (since this class has
+        a reference for one of the data members and so is intrinsically not copyable).
+        Made isColorControl available unconditionally.
+
+        * testing/Internals.cpp:
+        (WebCore::Internals::selectColorInColorChooser): Removed conditionals and
+        made this call selectColor rather than selectColorInColorChooser.
+
+        * testing/Internals.h: Made selectColorInColorChooser unconditional.
+
+        * testing/Internals.idl: Made selectColorInColorChooser unconditionally
+        present. Not important to optimize the test internals class by leaving it
+        out when INPUT_TYPE_COLOR is not enabled.
+
</ins><span class="cx"> 2015-11-01  Yusuke Suzuki  &lt;utatane.tea@gmail.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [ES6] Support Generator Syntax
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlColorInputTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/ColorInputType.cpp (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/ColorInputType.cpp        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/html/ColorInputType.cpp        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2010 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2015 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -29,7 +30,9 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #include &quot;config.h&quot;
</span><ins>+
</ins><span class="cx"> #if ENABLE(INPUT_TYPE_COLOR)
</span><ins>+
</ins><span class="cx"> #include &quot;ColorInputType.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CSSPropertyNames.h&quot;
</span><span class="lines">@@ -86,7 +89,7 @@
</span><span class="cx"> 
</span><span class="cx"> String ColorInputType::fallbackValue() const
</span><span class="cx"> {
</span><del>-    return String(&quot;#000000&quot;);
</del><ins>+    return ASCIILiteral(&quot;#000000&quot;);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> String ColorInputType::sanitizeValue(const String&amp; proposedValue) const
</span><span class="lines">@@ -94,7 +97,7 @@
</span><span class="cx">     if (!isValidColorString(proposedValue))
</span><span class="cx">         return fallbackValue();
</span><span class="cx"> 
</span><del>-    return proposedValue.lower();
</del><ins>+    return proposedValue.convertToASCIILowercase();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Color ColorInputType::valueAsColor() const
</span><span class="lines">@@ -227,22 +230,25 @@
</span><span class="cx"> {
</span><span class="cx">     Vector&lt;Color&gt; suggestions;
</span><span class="cx"> #if ENABLE(DATALIST_ELEMENT)
</span><del>-    HTMLDataListElement* dataList = element().dataList();
-    if (dataList) {
</del><ins>+    if (auto* dataList = element().dataList()) {
</ins><span class="cx">         Ref&lt;HTMLCollection&gt; options = dataList-&gt;options();
</span><del>-        for (unsigned i = 0; HTMLOptionElement* option = downcast&lt;HTMLOptionElement&gt;(options-&gt;item(i)); ++i) {
-            if (!element().isValidValue(option-&gt;value()))
-                continue;
-            Color color(option-&gt;value());
-            if (!color.isValid())
-                continue;
-            suggestions.append(color);
</del><ins>+        unsigned length = options-&gt;length();
+        suggestions.reserveInitialCapacity(length);
+        for (unsigned i = 0; i != length; ++i) {
+            auto value = downcast&lt;HTMLOptionElement&gt;(*options-&gt;item(i)).value();
+            if (isValidColorString(value))
+                suggestions.uncheckedAppend(Color(value));
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx">     return suggestions;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ColorInputType::selectColor(const Color&amp; color)
+{
+    didChooseColor(color);
+}
+
</ins><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(INPUT_TYPE_COLOR)
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlColorInputTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/ColorInputType.h (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/ColorInputType.h        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/html/ColorInputType.h        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -1,5 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2010 Google Inc. All rights reserved.
</span><ins>+ * Copyright (C) 2015 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions are
</span><span class="lines">@@ -32,25 +33,24 @@
</span><span class="cx"> #define ColorInputType_h
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(INPUT_TYPE_COLOR)
</span><ins>+
</ins><span class="cx"> #include &quot;BaseClickableWithKeyInputType.h&quot;
</span><span class="cx"> #include &quot;ColorChooserClient.h&quot;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class ColorInputType final : public BaseClickableWithKeyInputType, public ColorChooserClient {
</del><ins>+class ColorInputType final : public BaseClickableWithKeyInputType, private ColorChooserClient {
</ins><span class="cx"> public:
</span><span class="cx">     explicit ColorInputType(HTMLInputElement&amp; element) : BaseClickableWithKeyInputType(element) { }
</span><span class="cx">     virtual ~ColorInputType();
</span><span class="cx"> 
</span><del>-    // ColorChooserClient implementation.
</del><ins>+private:
</ins><span class="cx">     virtual void didChooseColor(const Color&amp;) override;
</span><span class="cx">     virtual void didEndChooser() override;
</span><span class="cx">     virtual IntRect elementRectRelativeToRootView() const override;
</span><span class="cx">     virtual Color currentColor() override;
</span><span class="cx">     virtual bool shouldShowSuggestions() const override;
</span><span class="cx">     virtual Vector&lt;Color&gt; suggestions() const override;
</span><del>-
-private:
</del><span class="cx">     virtual bool isColorControl() const override;
</span><span class="cx">     virtual const AtomicString&amp; formControlType() const override;
</span><span class="cx">     virtual bool supportsRequired() const override;
</span><span class="lines">@@ -63,8 +63,9 @@
</span><span class="cx">     virtual bool shouldRespectListAttribute() override;
</span><span class="cx">     virtual bool typeMismatchFor(const String&amp;) const override;
</span><span class="cx">     virtual bool shouldResetOnDocumentActivation() override;
</span><ins>+    virtual Color valueAsColor() const override;
+    virtual void selectColor(const Color&amp;) override;
</ins><span class="cx"> 
</span><del>-    Color valueAsColor() const;
</del><span class="cx">     void endColorChooser();
</span><span class="cx">     void updateColorSwatch();
</span><span class="cx">     HTMLElement* shadowColorSwatch() const;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.cpp        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -64,10 +64,6 @@
</span><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> #include &lt;wtf/Ref.h&gt;
</span><span class="cx"> 
</span><del>-#if ENABLE(INPUT_TYPE_COLOR)
-#include &quot;ColorInputType.h&quot;
-#endif
-
</del><span class="cx"> #if ENABLE(TOUCH_EVENTS)
</span><span class="cx"> #include &quot;TouchEvent.h&quot;
</span><span class="cx"> #endif
</span><span class="lines">@@ -1546,15 +1542,16 @@
</span><span class="cx">     m_inputType-&gt;requiredAttributeChanged();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(INPUT_TYPE_COLOR)
-void HTMLInputElement::selectColorInColorChooser(const Color&amp; color)
</del><ins>+Color HTMLInputElement::valueAsColor() const
</ins><span class="cx"> {
</span><del>-    if (!m_inputType-&gt;isColorControl())
-        return;
-    static_cast&lt;ColorInputType*&gt;(m_inputType.get())-&gt;didChooseColor(color);
</del><ins>+    return m_inputType-&gt;valueAsColor();
</ins><span class="cx"> }
</span><del>-#endif
-    
</del><ins>+
+void HTMLInputElement::selectColor(const Color&amp; color)
+{
+    m_inputType-&gt;selectColor(color);
+}
+
</ins><span class="cx"> #if ENABLE(DATALIST_ELEMENT)
</span><span class="cx"> HTMLElement* HTMLInputElement::list() const
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.h (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.h        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/html/HTMLInputElement.h        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -280,10 +280,8 @@
</span><span class="cx"> 
</span><span class="cx">     void cacheSelectionInResponseToSetValue(int caretOffset) { cacheSelection(caretOffset, caretOffset, SelectionHasNoDirection); }
</span><span class="cx"> 
</span><del>-#if ENABLE(INPUT_TYPE_COLOR)
-    // For test purposes.
-    WEBCORE_EXPORT void selectColorInColorChooser(const Color&amp;);
-#endif
</del><ins>+    Color valueAsColor() const; // Returns transparent color if not type=color.
+    WEBCORE_EXPORT void selectColor(const Color&amp;); // Does nothing if not type=color. Simulates user selection of color; intended for testing.
</ins><span class="cx"> 
</span><span class="cx">     String defaultToolTip() const;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlInputTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/InputType.cpp (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/InputType.cpp        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/html/InputType.cpp        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -874,12 +874,10 @@
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(INPUT_TYPE_COLOR)
</del><span class="cx"> bool InputType::isColorControl() const
</span><span class="cx"> {
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> bool InputType::shouldRespectHeightAndWidthAttributes()
</span><span class="cx"> {
</span><span class="lines">@@ -1149,4 +1147,13 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+Color InputType::valueAsColor() const
+{
+    return Color::transparent;
+}
+
+void InputType::selectColor(const Color&amp;)
+{
+}
+
</ins><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlInputTypeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/InputType.h (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/InputType.h        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/html/InputType.h        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx">  * Copyright (C) 2010 Google Inc. All rights reserved.
</span><del>- * Copyright (C) 2011, 2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2011, 2014-2015 Apple Inc. All rights reserved.
</ins><span class="cx">  * Copyright (C) 2012 Samsung Electronics. All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="lines">@@ -38,7 +38,6 @@
</span><span class="cx"> #include &quot;StepRange.h&quot;
</span><span class="cx"> #include &lt;wtf/FastMalloc.h&gt;
</span><span class="cx"> #include &lt;wtf/Forward.h&gt;
</span><del>-#include &lt;wtf/Noncopyable.h&gt;
</del><span class="cx"> #include &lt;wtf/RefPtr.h&gt;
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="lines">@@ -73,7 +72,6 @@
</span><span class="cx"> // Do not expose instances of InputType and classes derived from it to classes
</span><span class="cx"> // other than HTMLInputElement.
</span><span class="cx"> class InputType {
</span><del>-    WTF_MAKE_NONCOPYABLE(InputType);
</del><span class="cx">     WTF_MAKE_FAST_ALLOCATED;
</span><span class="cx"> 
</span><span class="cx"> public:
</span><span class="lines">@@ -86,7 +84,7 @@
</span><span class="cx">     virtual const AtomicString&amp; formControlType() const = 0;
</span><span class="cx">     virtual bool canChangeFromAnotherType() const;
</span><span class="cx"> 
</span><del>-    // Type query functions
</del><ins>+    // Type query functions.
</ins><span class="cx"> 
</span><span class="cx">     // Any time we are using one of these functions it's best to refactor
</span><span class="cx">     // to add a virtual function to allow the input type object to do the
</span><span class="lines">@@ -96,6 +94,7 @@
</span><span class="cx">     // scattered code with special cases for various types.
</span><span class="cx"> 
</span><span class="cx">     virtual bool isCheckbox() const;
</span><ins>+    virtual bool isColorControl() const;
</ins><span class="cx">     virtual bool isDateField() const;
</span><span class="cx">     virtual bool isDateTimeField() const;
</span><span class="cx">     virtual bool isDateTimeLocalField() const;
</span><span class="lines">@@ -119,19 +118,15 @@
</span><span class="cx">     virtual bool isURLField() const;
</span><span class="cx">     virtual bool isWeekField() const;
</span><span class="cx"> 
</span><del>-#if ENABLE(INPUT_TYPE_COLOR)
-    virtual bool isColorControl() const;
-#endif
</del><ins>+    // Form value functions.
</ins><span class="cx"> 
</span><del>-    // Form value functions
-
</del><span class="cx">     virtual bool shouldSaveAndRestoreFormControlState() const;
</span><span class="cx">     virtual FormControlState saveFormControlState() const;
</span><span class="cx">     virtual void restoreFormControlState(const FormControlState&amp;);
</span><span class="cx">     virtual bool isFormDataAppendable() const;
</span><span class="cx">     virtual bool appendFormData(FormDataList&amp;, bool multipart) const;
</span><span class="cx"> 
</span><del>-    // DOM property functions
</del><ins>+    // DOM property functions.
</ins><span class="cx"> 
</span><span class="cx">     virtual bool getTypeSpecificValue(String&amp;); // Checked first, before internal storage or the value attribute.
</span><span class="cx">     virtual String fallbackValue() const; // Checked last, if both internal storage and value attribute are missing.
</span><span class="lines">@@ -142,14 +137,11 @@
</span><span class="cx">     virtual void setValueAsDouble(double, TextFieldEventBehavior, ExceptionCode&amp;) const;
</span><span class="cx">     virtual void setValueAsDecimal(const Decimal&amp;, TextFieldEventBehavior, ExceptionCode&amp;) const;
</span><span class="cx"> 
</span><del>-    // Validation functions
</del><ins>+    // Validation functions.
+
</ins><span class="cx">     virtual String validationMessage() const;
</span><span class="cx">     virtual bool supportsValidation() const;
</span><span class="cx">     virtual bool typeMismatchFor(const String&amp;) const;
</span><del>-    // Type check for the current input value. We do nothing for some types
-    // though typeMismatchFor() does something for them because of value
-    // sanitization.
-    virtual bool typeMismatch() const;
</del><span class="cx">     virtual bool supportsRequired() const;
</span><span class="cx">     virtual bool valueMissing(const String&amp;) const;
</span><span class="cx">     virtual bool hasBadInput() const;
</span><span class="lines">@@ -175,11 +167,16 @@
</span><span class="cx">     virtual String localizeValue(const String&amp;) const;
</span><span class="cx">     virtual String visibleValue() const;
</span><span class="cx">     virtual bool isEmptyValue() const;
</span><del>-    // Returing the null string means &quot;use the default value.&quot;
</del><ins>+
+    // Type check for the current input value. We do nothing for some types
+    // though typeMismatchFor() does something for them because of value sanitization.
+    virtual bool typeMismatch() const;
+
+    // Return value of null string means &quot;use the default value&quot;.
</ins><span class="cx">     // This function must be called only by HTMLInputElement::sanitizeValue().
</span><span class="cx">     virtual String sanitizeValue(const String&amp;) const;
</span><span class="cx"> 
</span><del>-    // Event handlers
</del><ins>+    // Event handlers.
</ins><span class="cx"> 
</span><span class="cx">     virtual void handleClickEvent(MouseEvent*);
</span><span class="cx">     virtual void handleMouseDownEvent(MouseEvent*);
</span><span class="lines">@@ -197,6 +194,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     // Helpers for event handlers.
</span><ins>+
</ins><span class="cx">     virtual bool shouldSubmitImplicitly(Event*);
</span><span class="cx">     virtual PassRefPtr&lt;HTMLFormElement&gt; formForSubmission() const;
</span><span class="cx">     virtual bool hasCustomFocusLogic() const;
</span><span class="lines">@@ -208,15 +206,14 @@
</span><span class="cx">     virtual void accessKeyAction(bool sendMouseEvents);
</span><span class="cx">     virtual bool canBeSuccessfulSubmitButton();
</span><span class="cx">     virtual void subtreeHasChanged();
</span><ins>+    virtual void blur();
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(TOUCH_EVENTS)
</span><span class="cx">     virtual bool hasTouchEventHandler() const;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    virtual void blur();
</del><ins>+    // Shadow tree handling.
</ins><span class="cx"> 
</span><del>-    // Shadow tree handling
-
</del><span class="cx">     virtual void createShadowSubtree();
</span><span class="cx">     virtual void destroyShadowSubtree();
</span><span class="cx"> 
</span><span class="lines">@@ -232,7 +229,8 @@
</span><span class="cx">     virtual HTMLElement* sliderTrackElement() const { return nullptr; }
</span><span class="cx">     virtual HTMLElement* placeholderElement() const;
</span><span class="cx"> 
</span><del>-    // Miscellaneous functions
</del><ins>+    // Miscellaneous functions.
+
</ins><span class="cx">     virtual bool rendererIsNeeded();
</span><span class="cx">     virtual RenderPtr&lt;RenderElement&gt; createInputRenderer(Ref&lt;RenderStyle&gt;&amp;&amp;);
</span><span class="cx">     virtual void addSearchResult();
</span><span class="lines">@@ -246,15 +244,7 @@
</span><span class="cx">     virtual bool shouldRespectAlignAttribute();
</span><span class="cx">     virtual FileList* files();
</span><span class="cx">     virtual void setFiles(PassRefPtr&lt;FileList&gt;);
</span><del>-#if ENABLE(DRAG_SUPPORT)
-    // Should return true if the given DragData has more than one dropped files.
-    virtual bool receiveDroppedFiles(const DragData&amp;);
-#endif
</del><span class="cx">     virtual Icon* icon() const;
</span><del>-#if PLATFORM(IOS)
-    virtual String displayString() const;
-#endif
-
</del><span class="cx">     virtual bool shouldSendChangeEventAfterCheckedChanged();
</span><span class="cx">     virtual bool canSetValue(const String&amp;);
</span><span class="cx">     virtual bool storesValueSeparateFromAttribute();
</span><span class="lines">@@ -277,12 +267,11 @@
</span><span class="cx">     virtual void capsLockStateMayHaveChanged();
</span><span class="cx">     virtual void updateAutoFillButton();
</span><span class="cx">     virtual String defaultToolTip() const;
</span><ins>+    virtual bool supportsIndeterminateAppearance() const;
+    virtual bool supportsSelectionAPI() const;
+    virtual Color valueAsColor() const;
+    virtual void selectColor(const Color&amp;);
</ins><span class="cx"> 
</span><del>-#if ENABLE(DATALIST_ELEMENT)
-    virtual void listAttributeTargetChanged();
-    virtual Decimal findClosestTickMarkValue(const Decimal&amp;);
-#endif
-
</del><span class="cx">     // Parses the specified string for the type, and return
</span><span class="cx">     // the Decimal value for the parsing result if the parsing
</span><span class="cx">     // succeeds; Returns defaultValue otherwise. This function can
</span><span class="lines">@@ -292,7 +281,7 @@
</span><span class="cx">     // Parses the specified string for this InputType, and returns true if it
</span><span class="cx">     // is successfully parsed. An instance pointed by the DateComponents*
</span><span class="cx">     // parameter will have parsed values and be modified even if the parsing
</span><del>-    // fails. The DateComponents* parameter may be 0.
</del><ins>+    // fails. The DateComponents* parameter may be null.
</ins><span class="cx">     virtual bool parseToDateComponents(const String&amp;, DateComponents*) const;
</span><span class="cx"> 
</span><span class="cx">     // Create a string representation of the specified Decimal value for the
</span><span class="lines">@@ -300,14 +289,6 @@
</span><span class="cx">     // string. This should not be called for types without valueAsNumber.
</span><span class="cx">     virtual String serialize(const Decimal&amp;) const;
</span><span class="cx"> 
</span><del>-#if PLATFORM(IOS)
-    virtual DateComponents::Type dateType() const;
-#endif
-
-    virtual bool supportsIndeterminateAppearance() const;
-
-    virtual bool supportsSelectionAPI() const;
-
</del><span class="cx">     // Gets width and height of the input element if the type of the
</span><span class="cx">     // element is image. It returns 0 if the element is not image type.
</span><span class="cx">     virtual unsigned height() const;
</span><span class="lines">@@ -315,6 +296,20 @@
</span><span class="cx"> 
</span><span class="cx">     void dispatchSimulatedClickIfActive(KeyboardEvent*) const;
</span><span class="cx"> 
</span><ins>+#if ENABLE(DATALIST_ELEMENT)
+    virtual void listAttributeTargetChanged();
+    virtual Decimal findClosestTickMarkValue(const Decimal&amp;);
+#endif
+
+#if ENABLE(DRAG_SUPPORT)
+    virtual bool receiveDroppedFiles(const DragData&amp;);
+#endif
+
+#if PLATFORM(IOS)
+    virtual DateComponents::Type dateType() const;
+    virtual String displayString() const;
+#endif
+
</ins><span class="cx"> protected:
</span><span class="cx">     explicit InputType(HTMLInputElement&amp; element) : m_element(element) { }
</span><span class="cx">     HTMLInputElement&amp; element() const { return m_element; }
</span><span class="lines">@@ -330,4 +325,5 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span><ins>+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.cpp (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.cpp        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/testing/Internals.cpp        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -886,15 +886,13 @@
</span><span class="cx">     return String();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#if ENABLE(INPUT_TYPE_COLOR)
</del><span class="cx"> void Internals::selectColorInColorChooser(Element* element, const String&amp; colorValue)
</span><span class="cx"> {
</span><span class="cx">     if (!is&lt;HTMLInputElement&gt;(element))
</span><span class="cx">         return;
</span><span class="cx">     auto&amp; inputElement = downcast&lt;HTMLInputElement&gt;(*element);
</span><del>-    inputElement.selectColorInColorChooser(Color(colorValue));
</del><ins>+    inputElement.selectColor(Color(colorValue));
</ins><span class="cx"> }
</span><del>-#endif
</del><span class="cx"> 
</span><span class="cx"> Vector&lt;String&gt; Internals::formControlStateOfPreviousHistoryItem(ExceptionCode&amp; ec)
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.h (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.h        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/testing/Internals.h        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -142,9 +142,7 @@
</span><span class="cx">     bool attached(Node*, ExceptionCode&amp;);
</span><span class="cx"> 
</span><span class="cx">     String visiblePlaceholder(Element*);
</span><del>-#if ENABLE(INPUT_TYPE_COLOR)
</del><span class="cx">     void selectColorInColorChooser(Element*, const String&amp; colorValue);
</span><del>-#endif
</del><span class="cx">     Vector&lt;String&gt; formControlStateOfPreviousHistoryItem(ExceptionCode&amp;);
</span><span class="cx">     void setFormControlStateOfPreviousHistoryItem(const Vector&lt;String&gt;&amp;, ExceptionCode&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/testing/Internals.idl (191875 => 191876)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/testing/Internals.idl        2015-11-02 05:46:17 UTC (rev 191875)
+++ trunk/Source/WebCore/testing/Internals.idl        2015-11-02 06:01:37 UTC (rev 191876)
</span><span class="lines">@@ -115,9 +115,7 @@
</span><span class="cx">     [RaisesException] boolean attached(Node node);
</span><span class="cx"> 
</span><span class="cx">     DOMString visiblePlaceholder(Element element);
</span><del>-#if defined(ENABLE_INPUT_TYPE_COLOR) &amp;&amp; ENABLE_INPUT_TYPE_COLOR
</del><span class="cx">     void selectColorInColorChooser(Element element, DOMString colorValue);
</span><del>-#endif
</del><span class="cx">     [RaisesException] DOMString[] formControlStateOfPreviousHistoryItem();
</span><span class="cx">     [RaisesException] void setFormControlStateOfPreviousHistoryItem(sequence&lt;DOMString&gt; values);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>