<!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>[197458] trunk</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/197458">197458</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-03-02 12:38:23 -0800 (Wed, 02 Mar 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Align HTMLInputElement.maxLength with the specification
https://bugs.webkit.org/show_bug.cgi?id=154906

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline W3C tests now that more checks are passing.

* web-platform-tests/html/dom/reflection-forms-expected.txt:
* web-platform-tests/html/semantics/forms/the-input-element/maxlength-expected.txt:

Source/WebCore:

Align HTMLInputElement.maxLength with the specification:
- https://html.spec.whatwg.org/multipage/forms.html#dom-input-maxlength
- https://html.spec.whatwg.org/multipage/forms.html#attr-input-maxlength

In particular, the following Web-facing change was made:
- HTMLInputElement.maxLength returns -1 instead of 524288 when
  the corresponding content attribute is missing, cannot be parsed
  or out of range (i.e. negative), as per:
  - https://html.spec.whatwg.org/multipage/infrastructure.html#limited-to-only-non-negative-numbers

Note that HTMLTextAreaElement.maxLength was already returning -1 in
this case.

The new behavior matches Firefox. Chrome however, still seems to
return 524288.

Note that we keep using 524288 as a maximum maxLength internally for
performance reasons. However, we stop exposing this arbitrary value to
the Web as this is an internal limitation.

No new tests, already covered by existing tests.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::HTMLInputElement):
Initialize m_maxLength to -1 initially, instead of 524288.

(WebCore::HTMLInputElement::tooLong):
Call effectiveMaxLength() instead of maxLength(), which no longer
exists. effectiveMaxLength() makes sure of returning a value in
the range [0, 524288].

(WebCore::HTMLInputElement::parseAttribute):

(WebCore::HTMLInputElement::effectiveMaxLength):
Split maxLength() into maxLengthForBindings() and effectiveMaxLength().
effectiveMaxLength() returns a value in the range [0, 524288], while
maxLengthForBindings() returns values in the range [-1, 2147483647].

(WebCore::HTMLInputElement::setMaxLength): Deleted.
The implementation was moved to the parent class so that it can be
shared with HTMLTextAreaElement.

(WebCore::HTMLInputElement::maxLengthAttributeChanged):
Rename for clarity.

* html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::parseAttribute):
(WebCore::HTMLTextAreaElement::maxLengthAttributeChanged):
Cache the parsed maxLength when the content attribute changes, similarly
to what is already done in HTMLInputElement.

(WebCore::HTMLTextAreaElement::handleBeforeTextInsertedEvent):
(WebCore::HTMLTextAreaElement::validationMessage):
(WebCore::HTMLTextAreaElement::tooLong):
Call effectiveMaxLength() instead of maxLength() which no longer exists.
effectiveMaxLength() returns a cached value and is therefore a lot more
efficient.

* html/HTMLTextAreaElement.h:
* html/HTMLTextAreaElement.idl:
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setMaxLengthForBindings):
This was moved up from HTMLInputElement / HTMLTextAreaElement to avoid code
duplication.

* html/HTMLTextFormControlElement.h:

* html/InputType.cpp:
(WebCore::InputType::validationMessage):
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):
Call HTMLInputElement::effectiveMaxLength() instead of
HTMLInputElement::maxLength() which no longer exists.

LayoutTests:

Update test now that input.maxLength initially returns -1
instead of 524288.

* fast/forms/input-maxlength-expected.txt:
* fast/forms/input-maxlength.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastformsinputmaxlengthexpectedtxt">trunk/LayoutTests/fast/forms/input-maxlength-expected.txt</a></li>
<li><a href="#trunkLayoutTestsfastformsinputmaxlengthhtml">trunk/LayoutTests/fast/forms/input-maxlength.html</a></li>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmldomreflectionformsexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-forms-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsformstheinputelementmaxlengthexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/maxlength-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</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="#trunkSourceWebCorehtmlHTMLInputElementidl">trunk/Source/WebCore/html/HTMLInputElement.idl</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTextAreaElementcpp">trunk/Source/WebCore/html/HTMLTextAreaElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTextAreaElementh">trunk/Source/WebCore/html/HTMLTextAreaElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTextAreaElementidl">trunk/Source/WebCore/html/HTMLTextAreaElement.idl</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTextFormControlElementcpp">trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLTextFormControlElementh">trunk/Source/WebCore/html/HTMLTextFormControlElement.h</a></li>
<li><a href="#trunkSourceWebCorehtmlInputTypecpp">trunk/Source/WebCore/html/InputType.cpp</a></li>
<li><a href="#trunkSourceWebCorehtmlTextFieldInputTypecpp">trunk/Source/WebCore/html/TextFieldInputType.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/LayoutTests/ChangeLog        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2016-03-02  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Align HTMLInputElement.maxLength with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=154906
+
+        Reviewed by Ryosuke Niwa.
+
+        Update test now that input.maxLength initially returns -1
+        instead of 524288.
+
+        * fast/forms/input-maxlength-expected.txt:
+        * fast/forms/input-maxlength.html:
+
</ins><span class="cx"> 2016-03-02  Zalan Bujtas  &lt;zalan@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Subpixel layout: Enable vertical/horizontal subpixel spacing for tables.
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsinputmaxlengthexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/forms/input-maxlength-expected.txt (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/input-maxlength-expected.txt        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/LayoutTests/fast/forms/input-maxlength-expected.txt        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx"> Attempting to insert 530000 characters with maxLength = 600000.
</span><span class="cx"> PASS 
</span><span class="cx"> Some tests for .maxLength property.
</span><del>-PASS input.maxLength is implicitMaxLength
</del><ins>+PASS input.maxLength is -1
</ins><span class="cx"> PASS input.maxLength = -1 threw exception Error: IndexSizeError: DOM Exception 1.
</span><span class="cx"> PASS input.getAttribute('maxlength') is '100'
</span><span class="cx"> PASS successfullyParsed is true
</span></span></pre></div>
<a id="trunkLayoutTestsfastformsinputmaxlengthhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/forms/input-maxlength.html (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/forms/input-maxlength.html        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/LayoutTests/fast/forms/input-maxlength.html        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> 
</span><span class="cx">     debug('Some tests for .maxLength property.');
</span><span class="cx">     input = document.createElement(&quot;input&quot;);
</span><del>-    shouldBe(&quot;input.maxLength&quot;, &quot;implicitMaxLength&quot;);
</del><ins>+    shouldBe(&quot;input.maxLength&quot;, &quot;-1&quot;);
</ins><span class="cx">     shouldThrow(&quot;input.maxLength = -1&quot;, &quot;'Error: IndexSizeError: DOM Exception 1'&quot;);
</span><span class="cx">     input.maxLength = 100;
</span><span class="cx">     shouldBe(&quot;input.getAttribute('maxlength')&quot;, &quot;'100'&quot;);
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/LayoutTests/imported/w3c/ChangeLog        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2016-03-02  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Align HTMLInputElement.maxLength with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=154906
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline W3C tests now that more checks are passing.
+
+        * web-platform-tests/html/dom/reflection-forms-expected.txt:
+        * web-platform-tests/html/semantics/forms/the-input-element/maxlength-expected.txt:
+
</ins><span class="cx"> 2016-03-01  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
</span><span class="cx"> 
</span><span class="cx">         [Fetch API] Support Request and Response blob() when body data is a blob
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmldomreflectionformsexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-forms-expected.txt (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-forms-expected.txt        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/reflection-forms-expected.txt        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -6173,15 +6173,15 @@
</span><span class="cx"> PASS input.max: IDL set to object &quot;test-valueOf&quot; followed by getAttribute() 
</span><span class="cx"> PASS input.max: IDL set to object &quot;test-valueOf&quot; followed by IDL get 
</span><span class="cx"> PASS input.maxLength: typeof IDL attribute 
</span><del>-FAIL input.maxLength: IDL get with DOM attribute unset assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: IDL get with DOM attribute unset 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to -2147483649 followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to -2147483649 followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to -2147483649 followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to -2147483648 followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to -2147483648 followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to -2147483648 followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to -36 followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to -36 followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to -36 followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to -1 followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to -1 followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to -1 followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to -0 followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to -0 followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to 0 followed by getAttribute() 
</span><span class="lines">@@ -6189,17 +6189,17 @@
</span><span class="cx"> PASS input.maxLength: setAttribute() to 1 followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to 1 followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to 2147483647 followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to 2147483647 followed by IDL get assert_equals: expected 2147483647 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to 2147483647 followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to 2147483648 followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to 2147483648 followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to 2147483648 followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to 4294967295 followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to 4294967295 followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to 4294967295 followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to 4294967296 followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to 4294967296 followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to 4294967296 followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot;&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot;&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;-1&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot;-1&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot;-1&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;-0&quot; followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;-0&quot; followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;0&quot; followed by getAttribute() 
</span><span class="lines">@@ -6207,79 +6207,79 @@
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;1&quot; followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;1&quot; followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot; \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f  foo &quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f  foo &quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; \0\x01\x02\x03\x04\x05\x06\x07 \b\t\n\v\f\r\x0e\x0f \x10\x11\x12\x13\x14\x15\x16\x17 \x18\x19\x1a\x1b\x1c\x1d\x1e\x1f  foo &quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\t7&quot; followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\t7&quot; followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\v7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot;\v7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot;\v7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\f7&quot; followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\f7&quot; followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot;7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot;7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\n7&quot; followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\n7&quot; followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\r7&quot; followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\r7&quot; followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to &quot;
7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot;
7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot;
7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;
7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot;
7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot;
7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;᠎7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot;᠎7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot;᠎7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot; 7&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to undefined followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to undefined followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to undefined followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to 1.5 followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to 1.5 followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to true followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to true followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to true followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to false followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to false followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to false followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to object &quot;[object Object]&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to object &quot;[object Object]&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to object &quot;[object Object]&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to NaN followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to NaN followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to NaN followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to Infinity followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to Infinity followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to Infinity followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to -Infinity followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to -Infinity followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to -Infinity followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to &quot;\0&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to &quot;\0&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to &quot;\0&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: setAttribute() to object &quot;2&quot; followed by getAttribute() 
</span><span class="cx"> PASS input.maxLength: setAttribute() to object &quot;2&quot; followed by IDL get 
</span><span class="cx"> PASS input.maxLength: setAttribute() to object &quot;3&quot; followed by getAttribute() 
</span><del>-FAIL input.maxLength: setAttribute() to object &quot;3&quot; followed by IDL get assert_equals: expected -1 but got 524288
</del><ins>+PASS input.maxLength: setAttribute() to object &quot;3&quot; followed by IDL get 
</ins><span class="cx"> PASS input.maxLength: IDL set to -2147483648 must throw INDEX_SIZE_ERR 
</span><span class="cx"> PASS input.maxLength: IDL set to -36 must throw INDEX_SIZE_ERR 
</span><span class="cx"> PASS input.maxLength: IDL set to -1 must throw INDEX_SIZE_ERR 
</span><span class="lines">@@ -6291,7 +6291,7 @@
</span><span class="cx"> PASS input.maxLength: IDL set to 1 followed by IDL get 
</span><span class="cx"> PASS input.maxLength: IDL set to 2147483647 should not throw 
</span><span class="cx"> PASS input.maxLength: IDL set to 2147483647 followed by getAttribute() 
</span><del>-FAIL input.maxLength: IDL set to 2147483647 followed by IDL get assert_equals: expected 2147483647 but got 524288
</del><ins>+PASS input.maxLength: IDL set to 2147483647 followed by IDL get 
</ins><span class="cx"> PASS input.min: typeof IDL attribute 
</span><span class="cx"> PASS input.min: IDL get with DOM attribute unset 
</span><span class="cx"> PASS input.min: setAttribute() to &quot;&quot; followed by getAttribute() 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestshtmlsemanticsformstheinputelementmaxlengthexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/maxlength-expected.txt (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/maxlength-expected.txt        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/forms/the-input-element/maxlength-expected.txt        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -1,9 +1,9 @@
</span><span class="cx"> Text input element
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-FAIL Unset maxlength is -1 assert_equals: expected -1 but got 524288
-FAIL Negative maxlength is always -1 assert_equals: expected -1 but got 524288
-FAIL Non-numeric maxlength is -1 assert_equals: expected -1 but got 524288
</del><ins>+PASS Unset maxlength is -1 
+PASS Negative maxlength is always -1 
+PASS Non-numeric maxlength is -1 
</ins><span class="cx"> PASS Assigning negative integer throws IndexSizeError 
</span><span class="cx"> PASS Assigning non-numeric to maxlength sets maxlength to 0 
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/ChangeLog        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -1,3 +1,84 @@
</span><ins>+2016-03-02  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Align HTMLInputElement.maxLength with the specification
+        https://bugs.webkit.org/show_bug.cgi?id=154906
+
+        Reviewed by Ryosuke Niwa.
+
+        Align HTMLInputElement.maxLength with the specification:
+        - https://html.spec.whatwg.org/multipage/forms.html#dom-input-maxlength
+        - https://html.spec.whatwg.org/multipage/forms.html#attr-input-maxlength
+
+        In particular, the following Web-facing change was made:
+        - HTMLInputElement.maxLength returns -1 instead of 524288 when
+          the corresponding content attribute is missing, cannot be parsed
+          or out of range (i.e. negative), as per:
+          - https://html.spec.whatwg.org/multipage/infrastructure.html#limited-to-only-non-negative-numbers
+
+        Note that HTMLTextAreaElement.maxLength was already returning -1 in
+        this case.
+
+        The new behavior matches Firefox. Chrome however, still seems to
+        return 524288.
+
+        Note that we keep using 524288 as a maximum maxLength internally for
+        performance reasons. However, we stop exposing this arbitrary value to
+        the Web as this is an internal limitation.
+
+        No new tests, already covered by existing tests.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::HTMLInputElement):
+        Initialize m_maxLength to -1 initially, instead of 524288.
+
+        (WebCore::HTMLInputElement::tooLong):
+        Call effectiveMaxLength() instead of maxLength(), which no longer
+        exists. effectiveMaxLength() makes sure of returning a value in
+        the range [0, 524288].
+
+        (WebCore::HTMLInputElement::parseAttribute):
+
+        (WebCore::HTMLInputElement::effectiveMaxLength):
+        Split maxLength() into maxLengthForBindings() and effectiveMaxLength().
+        effectiveMaxLength() returns a value in the range [0, 524288], while
+        maxLengthForBindings() returns values in the range [-1, 2147483647].
+
+        (WebCore::HTMLInputElement::setMaxLength): Deleted.
+        The implementation was moved to the parent class so that it can be
+        shared with HTMLTextAreaElement.
+
+        (WebCore::HTMLInputElement::maxLengthAttributeChanged):
+        Rename for clarity.
+
+        * html/HTMLTextAreaElement.cpp:
+        (WebCore::HTMLTextAreaElement::parseAttribute):
+        (WebCore::HTMLTextAreaElement::maxLengthAttributeChanged):
+        Cache the parsed maxLength when the content attribute changes, similarly
+        to what is already done in HTMLInputElement.
+
+        (WebCore::HTMLTextAreaElement::handleBeforeTextInsertedEvent):
+        (WebCore::HTMLTextAreaElement::validationMessage):
+        (WebCore::HTMLTextAreaElement::tooLong):
+        Call effectiveMaxLength() instead of maxLength() which no longer exists.
+        effectiveMaxLength() returns a cached value and is therefore a lot more
+        efficient.
+
+        * html/HTMLTextAreaElement.h:
+        * html/HTMLTextAreaElement.idl:
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::setMaxLengthForBindings):
+        This was moved up from HTMLInputElement / HTMLTextAreaElement to avoid code
+        duplication.
+
+        * html/HTMLTextFormControlElement.h:
+
+        * html/InputType.cpp:
+        (WebCore::InputType::validationMessage):
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::handleBeforeTextInsertedEvent):
+        Call HTMLInputElement::effectiveMaxLength() instead of
+        HTMLInputElement::maxLength() which no longer exists.
+
</ins><span class="cx"> 2016-03-02  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r197434 and r197436.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.cpp        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -89,14 +89,14 @@
</span><span class="cx"> // large. However, due to https://bugs.webkit.org/show_bug.cgi?id=14536 things
</span><span class="cx"> // get rather sluggish when a text field has a larger number of characters than
</span><span class="cx"> // this, even when just clicking in the text field.
</span><del>-const int HTMLInputElement::maximumLength = 524288;
</del><ins>+const unsigned HTMLInputElement::maxEffectiveLength = 524288;
</ins><span class="cx"> const int defaultSize = 20;
</span><span class="cx"> const int maxSavedResults = 256;
</span><span class="cx"> 
</span><span class="cx"> HTMLInputElement::HTMLInputElement(const QualifiedName&amp; tagName, Document&amp; document, HTMLFormElement* form, bool createdByParser)
</span><span class="cx">     : HTMLTextFormControlElement(tagName, document, form)
</span><span class="cx">     , m_size(defaultSize)
</span><del>-    , m_maxLength(maximumLength)
</del><ins>+    , m_maxLength(-1)
</ins><span class="cx">     , m_maxResults(-1)
</span><span class="cx">     , m_isChecked(false)
</span><span class="cx">     , m_reflectsCheckedAttribute(true)
</span><span class="lines">@@ -283,16 +283,14 @@
</span><span class="cx">     // 'virtual' overhead.
</span><span class="cx">     if (!isTextType())
</span><span class="cx">         return false;
</span><del>-    int max = maxLength();
-    if (max &lt; 0)
-        return false;
</del><ins>+    unsigned max = effectiveMaxLength();
</ins><span class="cx">     if (check == CheckDirtyFlag) {
</span><span class="cx">         // Return false for the default value or a value set by a script even if
</span><span class="cx">         // it is longer than maxLength.
</span><span class="cx">         if (!hasDirtyValue() || !m_wasModifiedByUser)
</span><span class="cx">             return false;
</span><span class="cx">     }
</span><del>-    return numGraphemeClusters(value) &gt; static_cast&lt;unsigned&gt;(max);
</del><ins>+    return numGraphemeClusters(value) &gt; max;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool HTMLInputElement::rangeUnderflow() const
</span><span class="lines">@@ -682,7 +680,7 @@
</span><span class="cx">             m_reflectsCheckedAttribute = true;
</span><span class="cx">         }
</span><span class="cx">     } else if (name == maxlengthAttr)
</span><del>-        parseMaxLengthAttribute(value);
</del><ins>+        maxLengthAttributeChanged(value);
</ins><span class="cx">     else if (name == sizeAttr) {
</span><span class="cx">         unsigned oldSize = m_size;
</span><span class="cx">         m_size = limitToOnlyHTMLNonNegativeNumbersGreaterThanZero(value, defaultSize);
</span><span class="lines">@@ -1254,19 +1252,12 @@
</span><span class="cx">     return fastGetAttribute(altAttr);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int HTMLInputElement::maxLength() const
</del><ins>+unsigned HTMLInputElement::effectiveMaxLength() const
</ins><span class="cx"> {
</span><del>-    return m_maxLength;
</del><ins>+    // The number -1 represents no maximum at all; conveniently it becomes a super-large value when converted to unsigned.
+    return std::min&lt;unsigned&gt;(m_maxLength, maxEffectiveLength);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLInputElement::setMaxLength(int maxLength, ExceptionCode&amp; ec)
-{
-    if (maxLength &lt; 0)
-        ec = INDEX_SIZE_ERR;
-    else
-        setIntegralAttribute(maxlengthAttr, maxLength);
-}
-
</del><span class="cx"> bool HTMLInputElement::multiple() const
</span><span class="cx"> {
</span><span class="cx">     return fastHasAttribute(multipleAttr);
</span><span class="lines">@@ -1740,13 +1731,14 @@
</span><span class="cx">     return m_inputType-&gt;isEmptyValue();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void HTMLInputElement::parseMaxLengthAttribute(const AtomicString&amp; value)
</del><ins>+void HTMLInputElement::maxLengthAttributeChanged(const AtomicString&amp; newValue)
</ins><span class="cx"> {
</span><del>-    int maxLength = std::min(parseHTMLNonNegativeInteger(value).valueOr(maximumLength), maximumLength);
-    int oldMaxLength = m_maxLength;
-    m_maxLength = maxLength;
-    if (oldMaxLength != maxLength)
</del><ins>+    unsigned oldEffectiveMaxLength = effectiveMaxLength();
+    m_maxLength = parseHTMLNonNegativeInteger(newValue).valueOr(-1);
+    if (oldEffectiveMaxLength != effectiveMaxLength())
</ins><span class="cx">         updateValueIfNeeded();
</span><ins>+
+    // FIXME: Do we really need to do this if the effective maxLength has not changed?
</ins><span class="cx">     setNeedsStyleRecalc();
</span><span class="cx">     updateValidity();
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.h (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.h        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/HTMLInputElement.h        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -232,8 +232,8 @@
</span><span class="cx"> 
</span><span class="cx">     URL src() const;
</span><span class="cx"> 
</span><del>-    virtual int maxLength() const override final;
-    void setMaxLength(int, ExceptionCode&amp;);
</del><ins>+    int maxLengthForBindings() const { return m_maxLength; }
+    unsigned effectiveMaxLength() const;
</ins><span class="cx"> 
</span><span class="cx">     bool multiple() const;
</span><span class="cx"> 
</span><span class="lines">@@ -292,7 +292,7 @@
</span><span class="cx">     bool shouldUseMediaCapture() const;
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    static const int maximumLength;
</del><ins>+    static const unsigned maxEffectiveLength;
</ins><span class="cx"> 
</span><span class="cx">     unsigned height() const;
</span><span class="cx">     unsigned width() const;
</span><span class="lines">@@ -414,7 +414,7 @@
</span><span class="cx"> #if ENABLE(DATALIST_ELEMENT)
</span><span class="cx">     void resetListAttributeTargetObserver();
</span><span class="cx"> #endif
</span><del>-    void parseMaxLengthAttribute(const AtomicString&amp;);
</del><ins>+    void maxLengthAttributeChanged(const AtomicString&amp; newValue);
</ins><span class="cx">     void updateValueIfNeeded();
</span><span class="cx"> 
</span><span class="cx">     // Returns null if this isn't associated with any radio button group.
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLInputElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLInputElement.idl (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLInputElement.idl        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/HTMLInputElement.idl        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx">     attribute boolean indeterminate;
</span><span class="cx">     [Conditional=DATALIST_ELEMENT] readonly attribute HTMLElement list;
</span><span class="cx">     [Reflect] attribute DOMString max;
</span><del>-    [SetterRaisesException] attribute long maxLength;
</del><ins>+    [ImplementedAs=maxLengthForBindings, SetterRaisesException] attribute long maxLength;
</ins><span class="cx">     [Reflect] attribute DOMString min;
</span><span class="cx">     [Reflect] attribute boolean multiple;
</span><span class="cx">     [Reflect] attribute DOMString name;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTextAreaElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -201,11 +201,17 @@
</span><span class="cx">     } else if (name == accesskeyAttr) {
</span><span class="cx">         // ignore for the moment
</span><span class="cx">     } else if (name == maxlengthAttr)
</span><del>-        updateValidity();
</del><ins>+        maxLengthAttributeChanged(value);
</ins><span class="cx">     else
</span><span class="cx">         HTMLTextFormControlElement::parseAttribute(name, value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void HTMLTextAreaElement::maxLengthAttributeChanged(const AtomicString&amp; newValue)
+{
+    m_maxLength = parseHTMLNonNegativeInteger(newValue).valueOr(-1);
+    updateValidity();
+}
+
</ins><span class="cx"> RenderPtr&lt;RenderElement&gt; HTMLTextAreaElement::createElementRenderer(Ref&lt;RenderStyle&gt;&amp;&amp; style, const RenderTreePosition&amp;)
</span><span class="cx"> {
</span><span class="cx">     return createRenderer&lt;RenderTextControlMultiLine&gt;(*this, WTFMove(style));
</span><span class="lines">@@ -291,7 +297,7 @@
</span><span class="cx"> {
</span><span class="cx">     ASSERT(event);
</span><span class="cx">     ASSERT(renderer());
</span><del>-    int signedMaxLength = maxLength();
</del><ins>+    int signedMaxLength = effectiveMaxLength();
</ins><span class="cx">     if (signedMaxLength &lt; 0)
</span><span class="cx">         return;
</span><span class="cx">     unsigned unsignedMaxLength = static_cast&lt;unsigned&gt;(signedMaxLength);
</span><span class="lines">@@ -421,19 +427,6 @@
</span><span class="cx">         setNonDirtyValue(value);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-int HTMLTextAreaElement::maxLength() const
-{
-    return parseHTMLNonNegativeInteger(fastGetAttribute(maxlengthAttr)).valueOr(-1);
-}
-
-void HTMLTextAreaElement::setMaxLength(int newValue, ExceptionCode&amp; ec)
-{
-    if (newValue &lt; 0)
-        ec = INDEX_SIZE_ERR;
-    else
-        setIntegralAttribute(maxlengthAttr, newValue);
-}
-
</del><span class="cx"> String HTMLTextAreaElement::validationMessage() const
</span><span class="cx"> {
</span><span class="cx">     if (!willValidate())
</span><span class="lines">@@ -446,7 +439,7 @@
</span><span class="cx">         return validationMessageValueMissingText();
</span><span class="cx"> 
</span><span class="cx">     if (tooLong())
</span><del>-        return validationMessageTooLongText(computeLengthForSubmission(value()), maxLength());
</del><ins>+        return validationMessageTooLongText(computeLengthForSubmission(value()), effectiveMaxLength());
</ins><span class="cx"> 
</span><span class="cx">     return String();
</span><span class="cx"> }
</span><span class="lines">@@ -468,7 +461,7 @@
</span><span class="cx">     if (check == CheckDirtyFlag &amp;&amp; !m_wasModifiedByUser)
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><del>-    int max = maxLength();
</del><ins>+    int max = effectiveMaxLength();
</ins><span class="cx">     if (max &lt; 0)
</span><span class="cx">         return false;
</span><span class="cx">     unsigned unsignedMax = static_cast&lt;unsigned&gt;(max);
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTextAreaElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTextAreaElement.h        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -45,8 +45,8 @@
</span><span class="cx">     String defaultValue() const;
</span><span class="cx">     void setDefaultValue(const String&amp;);
</span><span class="cx">     int textLength() const { return value().length(); }
</span><del>-    virtual int maxLength() const override;
-    void setMaxLength(int, ExceptionCode&amp;);
</del><ins>+    int maxLengthForBindings() const { return m_maxLength; }
+    int effectiveMaxLength() const { return m_maxLength; }
</ins><span class="cx">     // For ValidityState
</span><span class="cx">     virtual String validationMessage() const override;
</span><span class="cx">     virtual bool valueMissing() const override;
</span><span class="lines">@@ -71,6 +71,8 @@
</span><span class="cx">     virtual void didAddUserAgentShadowRoot(ShadowRoot*) override;
</span><span class="cx">     virtual bool canHaveUserAgentShadowRoot() const override final { return true; }
</span><span class="cx"> 
</span><ins>+    void maxLengthAttributeChanged(const AtomicString&amp; newValue);
+
</ins><span class="cx">     void handleBeforeTextInsertedEvent(BeforeTextInsertedEvent*) const;
</span><span class="cx">     static String sanitizeUserInputValue(const String&amp;, unsigned maxLength);
</span><span class="cx">     void updateValue() const;
</span><span class="lines">@@ -121,6 +123,7 @@
</span><span class="cx"> 
</span><span class="cx">     unsigned m_rows;
</span><span class="cx">     unsigned m_cols;
</span><ins>+    int m_maxLength { -1 };
</ins><span class="cx">     WrapMethod m_wrap;
</span><span class="cx">     HTMLElement* m_placeholder;
</span><span class="cx">     mutable String m_value;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTextAreaElementidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.idl (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTextAreaElement.idl        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.idl        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx">     [Reflect] attribute DOMString dirName;
</span><span class="cx">     [Reflect] attribute boolean disabled;
</span><span class="cx">     readonly attribute HTMLFormElement form;
</span><del>-    [SetterRaisesException] attribute long maxLength;
</del><ins>+    [ImplementedAs=maxLengthForBindings, SetterRaisesException] attribute long maxLength;
</ins><span class="cx">     [Reflect] attribute DOMString name;
</span><span class="cx">     [Reflect] attribute DOMString placeholder;
</span><span class="cx">     [Reflect] attribute boolean readOnly;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTextFormControlElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.cpp        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -37,6 +37,7 @@
</span><span class="cx"> #include &quot;HTMLFormElement.h&quot;
</span><span class="cx"> #include &quot;HTMLInputElement.h&quot;
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><ins>+#include &quot;HTMLParserIdioms.h&quot;
</ins><span class="cx"> #include &quot;NodeTraversal.h&quot;
</span><span class="cx"> #include &quot;Page.h&quot;
</span><span class="cx"> #include &quot;RenderBlockFlow.h&quot;
</span><span class="lines">@@ -759,6 +760,14 @@
</span><span class="cx">     return &quot;ltr&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void HTMLTextFormControlElement::setMaxLengthForBindings(int maxLength, ExceptionCode&amp; ec)
+{
+    if (maxLength &lt; 0)
+        ec = INDEX_SIZE_ERR;
+    else
+        setIntegralAttribute(maxlengthAttr, maxLength);
+}
+
</ins><span class="cx"> void HTMLTextFormControlElement::adjustInnerTextStyle(const RenderStyle&amp; parentStyle, RenderStyle&amp; textBlockStyle) const
</span><span class="cx"> {
</span><span class="cx">     // The inner block, if present, always has its direction set to LTR,
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLTextFormControlElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLTextFormControlElement.h (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLTextFormControlElement.h        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/HTMLTextFormControlElement.h        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -48,6 +48,8 @@
</span><span class="cx">     void didEditInnerTextValue();
</span><span class="cx">     void forwardEvent(Event*);
</span><span class="cx"> 
</span><ins>+    void setMaxLengthForBindings(int, ExceptionCode&amp;);
+
</ins><span class="cx">     virtual InsertionNotificationRequest insertedInto(ContainerNode&amp;) override;
</span><span class="cx"> 
</span><span class="cx">     // The derived class should return true if placeholder processing is needed.
</span><span class="lines">@@ -75,7 +77,6 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void dispatchFormControlChangeEvent() override final;
</span><span class="cx"> 
</span><del>-    virtual int maxLength() const = 0;
</del><span class="cx">     virtual String value() const = 0;
</span><span class="cx"> 
</span><span class="cx">     virtual TextControlInnerTextElement* innerTextElement() const = 0;
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlInputTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/InputType.cpp (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/InputType.cpp        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/InputType.cpp        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -406,7 +406,7 @@
</span><span class="cx">         return validationMessagePatternMismatchText();
</span><span class="cx"> 
</span><span class="cx">     if (element().tooLong())
</span><del>-        return validationMessageTooLongText(numGraphemeClusters(value), element().maxLength());
</del><ins>+        return validationMessageTooLongText(numGraphemeClusters(value), element().effectiveMaxLength());
</ins><span class="cx"> 
</span><span class="cx">     if (!isSteppable())
</span><span class="cx">         return emptyString();
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlTextFieldInputTypecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (197457 => 197458)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/TextFieldInputType.cpp        2016-03-02 19:17:18 UTC (rev 197457)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp        2016-03-02 20:38:23 UTC (rev 197458)
</span><span class="lines">@@ -430,7 +430,7 @@
</span><span class="cx"> 
</span><span class="cx"> String TextFieldInputType::sanitizeValue(const String&amp; proposedValue) const
</span><span class="cx"> {
</span><del>-    return limitLength(proposedValue.removeCharacters(isASCIILineBreak), HTMLInputElement::maximumLength);
</del><ins>+    return limitLength(proposedValue.removeCharacters(isASCIILineBreak), HTMLInputElement::maxEffectiveLength);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextFieldInputType::handleBeforeTextInsertedEvent(BeforeTextInsertedEvent* event)
</span><span class="lines">@@ -460,7 +460,7 @@
</span><span class="cx"> 
</span><span class="cx">     // Selected characters will be removed by the next text event.
</span><span class="cx">     unsigned baseLength = oldLength - selectionLength;
</span><del>-    unsigned maxLength = static_cast&lt;unsigned&gt;(isTextType() ? element().maxLength() : HTMLInputElement::maximumLength); // maxLength can never be negative.
</del><ins>+    unsigned maxLength = isTextType() ? element().effectiveMaxLength() : HTMLInputElement::maxEffectiveLength;
</ins><span class="cx">     unsigned appendableLength = maxLength &gt; baseLength ? maxLength - baseLength : 0;
</span><span class="cx"> 
</span><span class="cx">     // Truncate the inserted text to avoid violating the maxLength and other constraints.
</span></span></pre>
</div>
</div>

</body>
</html>