Title: [164403] trunk
Revision
164403
Author
[email protected]
Date
2014-02-19 17:06:52 -0800 (Wed, 19 Feb 2014)

Log Message

fieldset:disabled > legend:first-child legend input should not be disabled
https://bugs.webkit.org/show_bug.cgi?id=129068

Reviewed by Andreas Kling.

Source/WebCore: 

An input element inside a disabled fieldset element is ordinarily disabled unless it's inside
a legend element that is the first of its kind to appear in the fieldset's child node list.

Prior to this patch, an input element inside such a legend element was erroneously disabled if
we had another legend element between the two as in <fieldset disabled><legend><legend><input>.

Fixed the bug by correcting the algorithm in updateAncestorDisabledState.

Test: fast/forms/fieldset/fieldset-disabled-2.html

* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::updateAncestorDisabledState):

LayoutTests: 

Added a new regression test.

* fast/forms/fieldset/fieldset-disabled-2-expected.txt: Added.
* fast/forms/fieldset/fieldset-disabled-2.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (164402 => 164403)


--- trunk/LayoutTests/ChangeLog	2014-02-20 01:06:49 UTC (rev 164402)
+++ trunk/LayoutTests/ChangeLog	2014-02-20 01:06:52 UTC (rev 164403)
@@ -1,3 +1,15 @@
+2014-02-19  Ryosuke Niwa  <[email protected]>
+
+        fieldset:disabled > legend:first-child legend input should not be disabled
+        https://bugs.webkit.org/show_bug.cgi?id=129068
+
+        Reviewed by Andreas Kling.
+
+        Added a new regression test.
+
+        * fast/forms/fieldset/fieldset-disabled-2-expected.txt: Added.
+        * fast/forms/fieldset/fieldset-disabled-2.html: Added.
+
 2014-02-18  Ryosuke Niwa  <[email protected]>
 
         Changing selection shouldn't synchronously update editor UI components

Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-disabled-2-expected.txt (0 => 164403)


--- trunk/LayoutTests/fast/forms/fieldset/fieldset-disabled-2-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-disabled-2-expected.txt	2014-02-20 01:06:52 UTC (rev 164403)
@@ -0,0 +1,19 @@
+Additional tests for fieldset element disabling descendent input elements
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS isInputDisabledById("inputOutsideLegend") is true
+PASS isInputDisabledById("inputInsideFirstLegend") is false
+PASS isInputDisabledById("inputInsideSecondLegend") is true
+PASS isInputDisabledById("inputInsideNestedFirstLegend") is false
+
+setDisabledOnAllFieldsets(false)
+PASS isInputDisabledById("inputOutsideLegend") is false
+PASS isInputDisabledById("inputInsideFirstLegend") is false
+PASS isInputDisabledById("inputInsideSecondLegend") is false
+PASS isInputDisabledById("inputInsideNestedFirstLegend") is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/fieldset/fieldset-disabled-2.html (0 => 164403)


--- trunk/LayoutTests/fast/forms/fieldset/fieldset-disabled-2.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/fieldset-disabled-2.html	2014-02-20 01:06:52 UTC (rev 164403)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<style type="text/css">
+input:enabled { color: #000; }
+input:disabled { color: #666; }
+</style>
+<div id="container">
+<input id="randomInput">
+<fieldset disabled><input id="inputOutsideLegend"></fieldset>
+<fieldset disabled><legend><input id="inputInsideFirstLegend"></legend></fieldset>
+<fieldset disabled><legend></legend><legend><input id="inputInsideSecondLegend"></legend></fieldset>
+<fieldset disabled><legend><legend><input id="inputInsideNestedFirstLegend"></legend></legend></fieldset>
+</div>
+<script>
+
+description("Additional tests for fieldset element disabling descendent input elements");
+
+function isInputDisabledById(id) {
+    var input = document.getElementById(id);
+    return getComputedStyle(input).color == 'rgb(102, 102, 102)';
+}
+
+shouldBeTrue('isInputDisabledById("inputOutsideLegend")');
+shouldBeFalse('isInputDisabledById("inputInsideFirstLegend")');
+shouldBeTrue('isInputDisabledById("inputInsideSecondLegend")');
+shouldBeFalse('isInputDisabledById("inputInsideNestedFirstLegend")');
+
+function setDisabledOnAllFieldsets(value) {
+    var fieldsets = document.querySelectorAll('fieldset');
+    for (var i = 0; i < fieldsets.length; i++)
+        fieldsets[i].disabled = value;
+}
+
+debug('');
+evalAndLog('setDisabledOnAllFieldsets(false)');
+shouldBeFalse('isInputDisabledById("inputOutsideLegend")');
+shouldBeFalse('isInputDisabledById("inputInsideFirstLegend")');
+shouldBeFalse('isInputDisabledById("inputInsideSecondLegend")');
+shouldBeFalse('isInputDisabledById("inputInsideNestedFirstLegend")');
+
+document.getElementById('container').style.display = 'none';
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (164402 => 164403)


--- trunk/Source/WebCore/ChangeLog	2014-02-20 01:06:49 UTC (rev 164402)
+++ trunk/Source/WebCore/ChangeLog	2014-02-20 01:06:52 UTC (rev 164403)
@@ -1,3 +1,23 @@
+2014-02-19  Ryosuke Niwa  <[email protected]>
+
+        fieldset:disabled > legend:first-child legend input should not be disabled
+        https://bugs.webkit.org/show_bug.cgi?id=129068
+
+        Reviewed by Andreas Kling.
+
+        An input element inside a disabled fieldset element is ordinarily disabled unless it's inside
+        a legend element that is the first of its kind to appear in the fieldset's child node list.
+
+        Prior to this patch, an input element inside such a legend element was erroneously disabled if
+        we had another legend element between the two as in <fieldset disabled><legend><legend><input>.
+
+        Fixed the bug by correcting the algorithm in updateAncestorDisabledState.
+
+        Test: fast/forms/fieldset/fieldset-disabled-2.html
+
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::updateAncestorDisabledState):
+
 2014-02-18  Ryosuke Niwa  <[email protected]>
 
         Changing selection shouldn't synchronously update editor UI components

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (164402 => 164403)


--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2014-02-20 01:06:49 UTC (rev 164402)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2014-02-20 01:06:52 UTC (rev 164403)
@@ -101,17 +101,17 @@
 
 void HTMLFormControlElement::updateAncestorDisabledState() const
 {
-    HTMLFieldSetElement* fieldSetAncestor = 0;
-    ContainerNode* legendAncestor = 0;
-    for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) {
-        if (!legendAncestor && ancestor->hasTagName(legendTag))
-            legendAncestor = ancestor;
-        if (ancestor->hasTagName(fieldsetTag)) {
-            fieldSetAncestor = toHTMLFieldSetElement(ancestor);
-            break;
+    Element* previousAncestor = nullptr;
+    for (Element* ancestor = parentElement(); ancestor; ancestor = ancestor->parentElement()) {
+        if (isHTMLFieldSetElement(ancestor)) {
+            HTMLFieldSetElement& fieldSetAncestor = toHTMLFieldSetElement(*ancestor);
+            bool isInFirstLegend = previousAncestor && isHTMLLegendElement(previousAncestor) && previousAncestor == fieldSetAncestor.legend();
+            m_ancestorDisabledState = !fieldSetAncestor.isDisabledFormControl() || isInFirstLegend ? AncestorDisabledStateEnabled : AncestorDisabledStateDisabled;
+            return;
         }
+        previousAncestor = ancestor;
     }
-    m_ancestorDisabledState = (fieldSetAncestor && fieldSetAncestor->isDisabledFormControl() && !(legendAncestor && legendAncestor == fieldSetAncestor->legend())) ? AncestorDisabledStateDisabled : AncestorDisabledStateEnabled;
+    m_ancestorDisabledState = AncestorDisabledStateEnabled;
 }
 
 void HTMLFormControlElement::ancestorDisabledStateWasChanged()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to