Title: [110665] trunk
Revision
110665
Author
[email protected]
Date
2012-03-13 23:54:01 -0700 (Tue, 13 Mar 2012)

Log Message

Source/WebCore: [Forms] Hidden input element should not have labels.
https://bugs.webkit.org/show_bug.cgi?id=80403

Patch by Yosifumi Inoue <[email protected]> on 2012-03-13
Reviewed by Kent Tamura.

This patch changes "labels" attribute behavior for hidden input type.
It returns null instead of NodeList of labels or empty node list.

Note: The HTML5 specification isn't clear for non-labelable element's "labels"
attribute return value. Firefox and Opera return empty node list. IE returns null.

No new tests. Existing tests are updated.

* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::isLabelable): Added. Dispatch to InputType.
* html/HiddenInputType.h:  Added isLabelable returning false.
* html/InputType.cpp:
(WebCore::InputType::isLabelable): Added. Returning true for all input types except for "hidden" type.
(WebCore):
* html/InputType.h:
(InputType): Added isLabelable declaration.

LayoutTests: [Forms] Hidden input element should not have labels.
https://bugs.webkit.org/show_bug.cgi?id=80403

Patch by Yosifumi Inoue <[email protected]> on 2012-03-13
Reviewed by Kent Tamura.

This patch changes expected text for null value of labels attribute
of hidden input type and labelable-elements to check null value for
the labels attribute of input type.

* fast/forms/label/labelable-elements-expected.txt:
* fast/forms/label/labelable-elements.html:
* fast/forms/label/labels-add-htmlFor-label-expected.txt:
* fast/forms/label/labels-add-parent-label-expected.txt:
* fast/forms/label/labels-change-htmlFor-attribute-expected.txt:
* fast/forms/label/labels-multiple-sibling-labels-expected.txt:
* fast/forms/label/labels-parent-and-sibling-labels-expected.txt:
* fast/forms/label/labels-remove-htmlFor-attribute-expected.txt:
* fast/forms/label/labels-remove-htmlFor-label-expected.txt:
* fast/forms/label/labels-remove-parent-label-expected.txt:
* fast/forms/label/labels-set-htmlFor-attribute-expected.txt:
* platform/chromium/fast/forms/label/labelable-elements-expected.txt:
* platform/mac/fast/forms/label/labelable-elements-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (110664 => 110665)


--- trunk/LayoutTests/ChangeLog	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/ChangeLog	2012-03-14 06:54:01 UTC (rev 110665)
@@ -1,5 +1,30 @@
 2012-03-13  Yosifumi Inoue  <[email protected]>
 
+        [Forms] Hidden input element should not have labels.
+        https://bugs.webkit.org/show_bug.cgi?id=80403
+
+        Reviewed by Kent Tamura.
+
+        This patch changes expected text for null value of labels attribute
+        of hidden input type and labelable-elements to check null value for
+        the labels attribute of input type.
+
+        * fast/forms/label/labelable-elements-expected.txt:
+        * fast/forms/label/labelable-elements.html:
+        * fast/forms/label/labels-add-htmlFor-label-expected.txt:
+        * fast/forms/label/labels-add-parent-label-expected.txt:
+        * fast/forms/label/labels-change-htmlFor-attribute-expected.txt:
+        * fast/forms/label/labels-multiple-sibling-labels-expected.txt:
+        * fast/forms/label/labels-parent-and-sibling-labels-expected.txt:
+        * fast/forms/label/labels-remove-htmlFor-attribute-expected.txt:
+        * fast/forms/label/labels-remove-htmlFor-label-expected.txt:
+        * fast/forms/label/labels-remove-parent-label-expected.txt:
+        * fast/forms/label/labels-set-htmlFor-attribute-expected.txt:
+        * platform/chromium/fast/forms/label/labelable-elements-expected.txt:
+        * platform/mac/fast/forms/label/labelable-elements-expected.txt:
+
+2012-03-13  Yosifumi Inoue  <[email protected]>
+
         [Forms] The "output" element should have labels.
         https://bugs.webkit.org/show_bug.cgi?id=80466
 

Modified: trunk/LayoutTests/fast/forms/label/labelable-elements-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labelable-elements-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labelable-elements-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -81,8 +81,7 @@
 PASS element.labels.length is 1
 
 Not labelable: hiddenType [object HTMLInputElement]
-FAIL element.labels should be undefined. Was [object NodeList]
-PASS element.labels is not null
+PASS element.labels is null
 
 Labelable: imageType [object HTMLInputElement]
 PASS element.labels.length is 1

Modified: trunk/LayoutTests/fast/forms/label/labelable-elements.html (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labelable-elements.html	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labelable-elements.html	2012-03-14 06:54:01 UTC (rev 110665)
@@ -21,8 +21,14 @@
         shouldNotBe('element.labels', 'null');
     } else if (!data.isLabelable) {
         debug('\nNot labelable: ' + name + ' ' + element);
-        shouldBeUndefined('element.labels');
-        shouldNotBe('element.labels', 'null');
+        if (data.inputType) {
+            // Note: labels attribute of input element isn't undefined,
+            // because HTMLInputElement.idl defines labels attribute.
+            shouldBe('element.labels', 'null');
+        } else {
+            shouldBeUndefined('element.labels');
+            shouldNotBe('element.labels', 'null');
+        }
     } else {
         debug('\nLabelable: ' + name + ' ' + element);
         shouldBe('element.labels.length', '1');

Modified: trunk/LayoutTests/fast/forms/label/labels-add-htmlFor-label-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labels-add-htmlFor-label-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labels-add-htmlFor-label-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -51,9 +51,6 @@
 Check fileType
 PASS element.labels.length is 0
 PASS element.labels.length is 1
-Check hiddenType
-PASS element.labels.length is 0
-PASS element.labels.length is 1
 Check imageType
 PASS element.labels.length is 0
 PASS element.labels.length is 1

Modified: trunk/LayoutTests/fast/forms/label/labels-add-parent-label-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labels-add-parent-label-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labels-add-parent-label-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -51,9 +51,6 @@
 Check fileType
 PASS element.labels.length is 0
 PASS element.labels.length is 1
-Check hiddenType
-PASS element.labels.length is 0
-PASS element.labels.length is 1
 Check imageType
 PASS element.labels.length is 0
 PASS element.labels.length is 1

Modified: trunk/LayoutTests/fast/forms/label/labels-change-htmlFor-attribute-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labels-change-htmlFor-attribute-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labels-change-htmlFor-attribute-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -51,9 +51,6 @@
 Check fileType
 PASS element.labels.length is 0
 PASS element.labels.length is 1
-Check hiddenType
-PASS element.labels.length is 0
-PASS element.labels.length is 1
 Check imageType
 PASS element.labels.length is 0
 PASS element.labels.length is 1

Modified: trunk/LayoutTests/fast/forms/label/labels-multiple-sibling-labels-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labels-multiple-sibling-labels-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labels-multiple-sibling-labels-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -35,8 +35,6 @@
 PASS element.labels.length is 2
 Check fileType
 PASS element.labels.length is 2
-Check hiddenType
-PASS element.labels.length is 2
 Check imageType
 PASS element.labels.length is 2
 Check monthType

Modified: trunk/LayoutTests/fast/forms/label/labels-parent-and-sibling-labels-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labels-parent-and-sibling-labels-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labels-parent-and-sibling-labels-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -35,8 +35,6 @@
 PASS element.labels.length is 2
 Check fileType
 PASS element.labels.length is 2
-Check hiddenType
-PASS element.labels.length is 2
 Check imageType
 PASS element.labels.length is 2
 Check monthType

Modified: trunk/LayoutTests/fast/forms/label/labels-remove-htmlFor-attribute-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labels-remove-htmlFor-attribute-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labels-remove-htmlFor-attribute-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -51,9 +51,6 @@
 Check fileType
 PASS element.labels.length is 1
 PASS element.labels.length is 0
-Check hiddenType
-PASS element.labels.length is 1
-PASS element.labels.length is 0
 Check imageType
 PASS element.labels.length is 1
 PASS element.labels.length is 0

Modified: trunk/LayoutTests/fast/forms/label/labels-remove-htmlFor-label-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labels-remove-htmlFor-label-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labels-remove-htmlFor-label-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -51,9 +51,6 @@
 Check fileType
 PASS element.labels.length is 1
 PASS element.labels.length is 0
-Check hiddenType
-PASS element.labels.length is 1
-PASS element.labels.length is 0
 Check imageType
 PASS element.labels.length is 1
 PASS element.labels.length is 0

Modified: trunk/LayoutTests/fast/forms/label/labels-remove-parent-label-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labels-remove-parent-label-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labels-remove-parent-label-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -51,9 +51,6 @@
 Check fileType
 PASS element.labels.length is 1
 PASS element.labels.length is 0
-Check hiddenType
-PASS element.labels.length is 1
-PASS element.labels.length is 0
 Check imageType
 PASS element.labels.length is 1
 PASS element.labels.length is 0

Modified: trunk/LayoutTests/fast/forms/label/labels-set-htmlFor-attribute-expected.txt (110664 => 110665)


--- trunk/LayoutTests/fast/forms/label/labels-set-htmlFor-attribute-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/fast/forms/label/labels-set-htmlFor-attribute-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -51,9 +51,6 @@
 Check fileType
 PASS element.labels.length is 0
 PASS element.labels.length is 1
-Check hiddenType
-PASS element.labels.length is 0
-PASS element.labels.length is 1
 Check imageType
 PASS element.labels.length is 0
 PASS element.labels.length is 1

Modified: trunk/LayoutTests/platform/chromium/fast/forms/label/labelable-elements-expected.txt (110664 => 110665)


--- trunk/LayoutTests/platform/chromium/fast/forms/label/labelable-elements-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/platform/chromium/fast/forms/label/labelable-elements-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -81,8 +81,7 @@
 PASS element.labels.length is 1
 
 Not labelable: hiddenType [object HTMLInputElement]
-FAIL element.labels should be undefined. Was [object NodeList]
-PASS element.labels is not null
+PASS element.labels is null
 
 Labelable: imageType [object HTMLInputElement]
 PASS element.labels.length is 1

Modified: trunk/LayoutTests/platform/mac/fast/forms/label/labelable-elements-expected.txt (110664 => 110665)


--- trunk/LayoutTests/platform/mac/fast/forms/label/labelable-elements-expected.txt	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/LayoutTests/platform/mac/fast/forms/label/labelable-elements-expected.txt	2012-03-14 06:54:01 UTC (rev 110665)
@@ -81,8 +81,7 @@
 PASS element.labels.length is 1
 
 Not labelable: hiddenType [object HTMLInputElement]
-FAIL element.labels should be undefined. Was [object NodeList]
-PASS element.labels is not null
+PASS element.labels is null
 
 Labelable: imageType [object HTMLInputElement]
 PASS element.labels.length is 1

Modified: trunk/Source/WebCore/ChangeLog (110664 => 110665)


--- trunk/Source/WebCore/ChangeLog	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/Source/WebCore/ChangeLog	2012-03-14 06:54:01 UTC (rev 110665)
@@ -1,5 +1,29 @@
 2012-03-13  Yosifumi Inoue  <[email protected]>
 
+        [Forms] Hidden input element should not have labels. 
+        https://bugs.webkit.org/show_bug.cgi?id=80403
+
+        Reviewed by Kent Tamura.
+
+        This patch changes "labels" attribute behavior for hidden input type.
+        It returns null instead of NodeList of labels or empty node list.
+
+        Note: The HTML5 specification isn't clear for non-labelable element's "labels"
+        attribute return value. Firefox and Opera return empty node list. IE returns null.
+
+        No new tests. Existing tests are updated.
+
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::isLabelable): Added. Dispatch to InputType.
+        * html/HiddenInputType.h:  Added isLabelable returning false.
+        * html/InputType.cpp:
+        (WebCore::InputType::isLabelable): Added. Returning true for all input types except for "hidden" type.
+        (WebCore):
+        * html/InputType.h:
+        (InputType): Added isLabelable declaration.
+
+2012-03-13  Yosifumi Inoue  <[email protected]>
+
         [Forms] The "output" element should have labels.
         https://bugs.webkit.org/show_bug.cgi?id=80466
 

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (110664 => 110665)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2012-03-14 06:54:01 UTC (rev 110665)
@@ -1763,8 +1763,7 @@
 
 bool HTMLInputElement::isLabelable() const
 {
-    // FIXME: We should return false for type="hidden".
-    return true;
+    return m_inputType->isLabelable();
 }
 
 bool HTMLInputElement::shouldAppearChecked() const

Modified: trunk/Source/WebCore/html/HiddenInputType.h (110664 => 110665)


--- trunk/Source/WebCore/html/HiddenInputType.h	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/Source/WebCore/html/HiddenInputType.h	2012-03-14 06:54:01 UTC (rev 110665)
@@ -50,6 +50,7 @@
     virtual bool rendererIsNeeded() OVERRIDE;
     virtual bool storesValueSeparateFromAttribute() OVERRIDE;
     virtual bool isHiddenType() const OVERRIDE;
+    virtual bool isLabelable() const OVERRIDE { return false; }
     virtual bool shouldRespectHeightAndWidthAttributes() OVERRIDE;
     virtual void setValue(const String&, bool, TextFieldEventBehavior) OVERRIDE;
     virtual bool appendFormData(FormDataList&, bool) const OVERRIDE;

Modified: trunk/Source/WebCore/html/InputType.cpp (110664 => 110665)


--- trunk/Source/WebCore/html/InputType.cpp	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/Source/WebCore/html/InputType.cpp	2012-03-14 06:54:01 UTC (rev 110665)
@@ -658,6 +658,11 @@
     return false;
 }
 
+bool InputType::isLabelable() const
+{
+    return true;
+}
+
 bool InputType::isNumberField() const
 {
     return false;

Modified: trunk/Source/WebCore/html/InputType.h (110664 => 110665)


--- trunk/Source/WebCore/html/InputType.h	2012-03-14 06:35:49 UTC (rev 110664)
+++ trunk/Source/WebCore/html/InputType.h	2012-03-14 06:54:01 UTC (rev 110665)
@@ -100,6 +100,7 @@
     virtual bool isFileUpload() const;
     virtual bool isHiddenType() const;
     virtual bool isImageButton() const;
+    virtual bool isLabelable() const;
     virtual bool isNumberField() const;
     virtual bool isPasswordField() const;
     virtual bool isRadioButton() const;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to