Title: [175952] releases/WebKitGTK/webkit-2.6
Revision
175952
Author
carlo...@webkit.org
Date
2014-11-11 09:52:42 -0800 (Tue, 11 Nov 2014)

Log Message

Merge r175622 - Stop special-casing the empty string in HTMLInputElement.type setter
https://bugs.webkit.org/show_bug.cgi?id=138403

Reviewed by Ryosuke Niwa.

Source/WebCore:

Stop special-casing the empty string in HTMLInputElement.type setter.
Previously, if input.type is set to "", we would remove the type
attribute. This is inconsistent with the specification and the behavior
of other browsers (tested Firefox 33 and Chrome 38). Instead, we should
set the attribute to the empty string.

Also stop treating null as a null string to align with the
specification and other browsers (tested Firefox 33 and Chrome 38).

Finally, update HTMLInputElement::setType() to take an AtomicString in
argument instead of a String as it ends up calling setAttribute(), and
thus needing an AtomicString.

Test: fast/dom/HTMLInputElement/input-type-attribute.html

* html/FileInputType.cpp:
(WebCore::UploadButtonElement::UploadButtonElement):
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setType):
* html/HTMLInputElement.h:
* html/HTMLInputElement.idl:

LayoutTests:

Add layout test to check the functionality of the HTMLInputElement.type
getter and setter.

* fast/dom/HTMLInputElement/input-type-attribute-expected.txt: Added.
* fast/dom/HTMLInputElement/input-type-attribute.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.6/LayoutTests/ChangeLog (175951 => 175952)


--- releases/WebKitGTK/webkit-2.6/LayoutTests/ChangeLog	2014-11-11 17:44:16 UTC (rev 175951)
+++ releases/WebKitGTK/webkit-2.6/LayoutTests/ChangeLog	2014-11-11 17:52:42 UTC (rev 175952)
@@ -1,3 +1,16 @@
+2014-11-05  Chris Dumez  <cdu...@apple.com>
+
+        Stop special-casing the empty string in HTMLInputElement.type setter
+        https://bugs.webkit.org/show_bug.cgi?id=138403
+
+        Reviewed by Ryosuke Niwa.
+
+        Add layout test to check the functionality of the HTMLInputElement.type
+        getter and setter.
+
+        * fast/dom/HTMLInputElement/input-type-attribute-expected.txt: Added.
+        * fast/dom/HTMLInputElement/input-type-attribute.html: Added.
+
 2014-11-04  Nikos Andrkos Andronikos  <nikos.andronikos-web...@cisra.canon.com.au>
 
         Fix animation of orient attribute on marker element

Added: releases/WebKitGTK/webkit-2.6/LayoutTests/fast/dom/HTMLInputElement/input-type-attribute-expected.txt (0 => 175952)


--- releases/WebKitGTK/webkit-2.6/LayoutTests/fast/dom/HTMLInputElement/input-type-attribute-expected.txt	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.6/LayoutTests/fast/dom/HTMLInputElement/input-type-attribute-expected.txt	2014-11-11 17:52:42 UTC (rev 175952)
@@ -0,0 +1,37 @@
+Tests the HTMLInputElement type attribute
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+input = document.createElement('input')
+PASS input.type is "text"
+PASS input.hasAttribute('type') is false
+PASS input.getAttribute('type') is null
+input.type = 'button'
+PASS input.type is "button"
+PASS input.hasAttribute('type') is true
+PASS input.getAttribute('type') is "button"
+input.type = ''
+PASS input.type is "text"
+PASS input.hasAttribute('type') is true
+PASS input.getAttribute('type') is ""
+input.type = 'text'
+PASS input.type is "text"
+PASS input.hasAttribute('type') is true
+PASS input.getAttribute('type') is "text"
+input.type = 'invalid'
+PASS input.type is "text"
+PASS input.hasAttribute('type') is true
+PASS input.getAttribute('type') is "invalid"
+input.type = null
+PASS input.type is "text"
+PASS input.hasAttribute('type') is true
+PASS input.getAttribute('type') is "null"
+input.removeAttribute('type')
+PASS input.type is "text"
+PASS input.hasAttribute('type') is false
+PASS input.getAttribute('type') is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: releases/WebKitGTK/webkit-2.6/LayoutTests/fast/dom/HTMLInputElement/input-type-attribute.html (0 => 175952)


--- releases/WebKitGTK/webkit-2.6/LayoutTests/fast/dom/HTMLInputElement/input-type-attribute.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.6/LayoutTests/fast/dom/HTMLInputElement/input-type-attribute.html	2014-11-11 17:52:42 UTC (rev 175952)
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<script src=""
+<script>
+description("Tests the HTMLInputElement type attribute");
+
+var input;
+evalAndLog("input = document.createElement('input')");
+
+shouldBeEqualToString("input.type", "text");
+shouldBeFalse("input.hasAttribute('type')");
+shouldBeNull("input.getAttribute('type')");
+
+evalAndLog("input.type = 'button'");
+shouldBeEqualToString("input.type", "button");
+shouldBeTrue("input.hasAttribute('type')");
+shouldBeEqualToString("input.getAttribute('type')", "button");
+
+evalAndLog("input.type = ''");
+shouldBeEqualToString("input.type", "text");
+shouldBeTrue("input.hasAttribute('type')");
+shouldBeEqualToString("input.getAttribute('type')", "");
+
+evalAndLog("input.type = 'text'");
+shouldBeEqualToString("input.type", "text");
+shouldBeTrue("input.hasAttribute('type')");
+shouldBeEqualToString("input.getAttribute('type')", "text");
+
+evalAndLog("input.type = 'invalid'");
+shouldBeEqualToString("input.type", "text");
+shouldBeTrue("input.hasAttribute('type')");
+shouldBeEqualToString("input.getAttribute('type')", "invalid");
+
+evalAndLog("input.type = null");
+shouldBeEqualToString("input.type", "text");
+shouldBeTrue("input.hasAttribute('type')");
+shouldBeEqualToString("input.getAttribute('type')", "null");
+
+evalAndLog("input.removeAttribute('type')");
+shouldBeEqualToString("input.type", "text");
+shouldBeFalse("input.hasAttribute('type')");
+shouldBeNull("input.getAttribute('type')");
+</script>
+<script src=""

Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog (175951 => 175952)


--- releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog	2014-11-11 17:44:16 UTC (rev 175951)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog	2014-11-11 17:52:42 UTC (rev 175952)
@@ -1,3 +1,33 @@
+2014-11-05  Chris Dumez  <cdu...@apple.com>
+
+        Stop special-casing the empty string in HTMLInputElement.type setter
+        https://bugs.webkit.org/show_bug.cgi?id=138403
+
+        Reviewed by Ryosuke Niwa.
+
+        Stop special-casing the empty string in HTMLInputElement.type setter.
+        Previously, if input.type is set to "", we would remove the type
+        attribute. This is inconsistent with the specification and the behavior
+        of other browsers (tested Firefox 33 and Chrome 38). Instead, we should
+        set the attribute to the empty string.
+
+        Also stop treating null as a null string to align with the
+        specification and other browsers (tested Firefox 33 and Chrome 38).
+
+        Finally, update HTMLInputElement::setType() to take an AtomicString in
+        argument instead of a String as it ends up calling setAttribute(), and
+        thus needing an AtomicString.
+
+
+        Test: fast/dom/HTMLInputElement/input-type-attribute.html
+
+        * html/FileInputType.cpp:
+        (WebCore::UploadButtonElement::UploadButtonElement):
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::setType):
+        * html/HTMLInputElement.h:
+        * html/HTMLInputElement.idl:
+
 2014-11-04  Chris Dumez  <cdu...@apple.com>
 
         Avoid double hash table lookup in SpaceSplitStringData::create()

Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/html/FileInputType.cpp (175951 => 175952)


--- releases/WebKitGTK/webkit-2.6/Source/WebCore/html/FileInputType.cpp	2014-11-11 17:44:16 UTC (rev 175951)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/html/FileInputType.cpp	2014-11-11 17:52:42 UTC (rev 175952)
@@ -71,7 +71,7 @@
 UploadButtonElement::UploadButtonElement(Document& document)
     : HTMLInputElement(inputTag, document, 0, false)
 {
-    setType(ASCIILiteral("button"));
+    setType(AtomicString("button", AtomicString::ConstructFromLiteral));
     setPseudo(AtomicString("-webkit-file-upload-button", AtomicString::ConstructFromLiteral));
 }
 

Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/html/HTMLInputElement.cpp (175951 => 175952)


--- releases/WebKitGTK/webkit-2.6/Source/WebCore/html/HTMLInputElement.cpp	2014-11-11 17:44:16 UTC (rev 175951)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/html/HTMLInputElement.cpp	2014-11-11 17:52:42 UTC (rev 175952)
@@ -425,16 +425,9 @@
     m_inputType->handleBlurEvent();
 }
 
-void HTMLInputElement::setType(const String& type)
+void HTMLInputElement::setType(const AtomicString& type)
 {
-    // FIXME: This should just call setAttribute. No reason to handle the empty string specially.
-    // We should write a test case to show that setting to the empty string does not remove the
-    // attribute in other browsers and then fix this. Note that setting to null *does* remove
-    // the attribute and setAttribute implements that.
-    if (type.isEmpty())
-        removeAttribute(typeAttr);
-    else
-        setAttribute(typeAttr, type);
+    setAttribute(typeAttr, type);
 }
 
 void HTMLInputElement::updateType()

Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/html/HTMLInputElement.h (175951 => 175952)


--- releases/WebKitGTK/webkit-2.6/Source/WebCore/html/HTMLInputElement.h	2014-11-11 17:44:16 UTC (rev 175951)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/html/HTMLInputElement.h	2014-11-11 17:52:42 UTC (rev 175952)
@@ -167,7 +167,7 @@
     bool sizeShouldIncludeDecoration(int& preferredSize) const;
     float decorationWidth() const;
 
-    void setType(const String&);
+    void setType(const AtomicString&);
 
     virtual String value() const override;
     void setValue(const String&, ExceptionCode&, TextFieldEventBehavior = DispatchNoEvent);

Modified: releases/WebKitGTK/webkit-2.6/Source/WebCore/html/HTMLInputElement.idl (175951 => 175952)


--- releases/WebKitGTK/webkit-2.6/Source/WebCore/html/HTMLInputElement.idl	2014-11-11 17:44:16 UTC (rev 175951)
+++ releases/WebKitGTK/webkit-2.6/Source/WebCore/html/HTMLInputElement.idl	2014-11-11 17:52:42 UTC (rev 175952)
@@ -54,7 +54,7 @@
 #endif
     [Reflect, URL] attribute DOMString src;
     [Reflect] attribute DOMString step;
-    [TreatNullAs=NullString] attribute DOMString type; // readonly dropped as part of DOM level 2
+    attribute DOMString type; // readonly dropped as part of DOM level 2
     [TreatNullAs=NullString] attribute DOMString defaultValue;
     // See the discussion in https://bugs.webkit.org/show_bug.cgi?id=100085
 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to