fieldset:disabled fieldset > legend:first-child input should be disabled
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Feb 2014 02:08:30 +0000 (02:08 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Feb 2014 02:08:30 +0000 (02:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129077

Reviewed by Antti Koivisto.

Source/WebCore:

Similar to r164403. When a fieldset inside a disabled fieldset, input elements inside
the inner fieldset's first legend element child should be disabled.

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

* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::legend): Fixed the bug where it was returning the first
legend element descendent. It should be the first legend element _child_.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::updateAncestorDisabledState): Fixed the algorithm
to look for any ancestor fieldset that has been disabled instead of the first fieldset
ancestor and checking its disabledness.

LayoutTests:

Added a test case.o

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164407 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/forms/fieldset/fieldset-disabled-2-expected.txt
LayoutTests/fast/forms/fieldset/fieldset-disabled-2.html
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLFieldSetElement.cpp
Source/WebCore/html/HTMLFormControlElement.cpp

index 25a5e82fa178c2f61f0c4553aa94d3bdf478f648..b047100ef713bd01bd988cfe4885964f8fe0f375 100644 (file)
@@ -1,3 +1,15 @@
+2014-02-19  Ryosuke Niwa  <rniwa@webkit.org>
+
+        fieldset:disabled fieldset > legend:first-child input should be disabled
+        https://bugs.webkit.org/show_bug.cgi?id=129077
+
+        Reviewed by Antti Koivisto.
+
+        Added a test case.o
+
+        * fast/forms/fieldset/fieldset-disabled-2-expected.txt:
+        * fast/forms/fieldset/fieldset-disabled-2.html:
+
 2014-02-19  Ryosuke Niwa  <rniwa@webkit.org>
 
         fieldset:disabled > legend:first-child legend input should not be disabled
index 8a8912921e82a486062f9eace2f59c39944e4d43..b4c780a231f29b6c5f3f5afad06a05d03f7e1e34 100644 (file)
@@ -7,12 +7,14 @@ PASS isInputDisabledById("inputOutsideLegend") is true
 PASS isInputDisabledById("inputInsideFirstLegend") is false
 PASS isInputDisabledById("inputInsideSecondLegend") is true
 PASS isInputDisabledById("inputInsideNestedFirstLegend") is false
+PASS isInputDisabledById("inputInsideFirstLegendWithDisabledOuterFieldset") is true
 
 setDisabledOnAllFieldsets(false)
 PASS isInputDisabledById("inputOutsideLegend") is false
 PASS isInputDisabledById("inputInsideFirstLegend") is false
 PASS isInputDisabledById("inputInsideSecondLegend") is false
 PASS isInputDisabledById("inputInsideNestedFirstLegend") is false
+PASS isInputDisabledById("inputInsideFirstLegendWithDisabledOuterFieldset") is false
 PASS successfullyParsed is true
 
 TEST COMPLETE
index a3a7712439cfd24acc0169bd3275d96a4905a699..4ad36ff96dcefc388fa87a684790a5b719b4c20e 100644 (file)
@@ -12,6 +12,7 @@ input:disabled { color: #666; }
 <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>
+<fieldset disabled><fieldset><legend><input id="inputInsideFirstLegendWithDisabledOuterFieldset"></legend></fieldset></fieldset>
 </div>
 <script>
 
@@ -26,6 +27,7 @@ shouldBeTrue('isInputDisabledById("inputOutsideLegend")');
 shouldBeFalse('isInputDisabledById("inputInsideFirstLegend")');
 shouldBeTrue('isInputDisabledById("inputInsideSecondLegend")');
 shouldBeFalse('isInputDisabledById("inputInsideNestedFirstLegend")');
+shouldBeTrue('isInputDisabledById("inputInsideFirstLegendWithDisabledOuterFieldset")');
 
 function setDisabledOnAllFieldsets(value) {
     var fieldsets = document.querySelectorAll('fieldset');
@@ -39,6 +41,7 @@ shouldBeFalse('isInputDisabledById("inputOutsideLegend")');
 shouldBeFalse('isInputDisabledById("inputInsideFirstLegend")');
 shouldBeFalse('isInputDisabledById("inputInsideSecondLegend")');
 shouldBeFalse('isInputDisabledById("inputInsideNestedFirstLegend")');
+shouldBeFalse('isInputDisabledById("inputInsideFirstLegendWithDisabledOuterFieldset")');
 
 document.getElementById('container').style.display = 'none';
 
index f1785b995de0ebff4a28c399c9bb06eeddb3aa47..c5baa6bc2b6b094c86125ca5a4ad63c94cfa2ad9 100644 (file)
@@ -1,3 +1,23 @@
+2014-02-19  Ryosuke Niwa  <rniwa@webkit.org>
+
+        fieldset:disabled fieldset > legend:first-child input should be disabled
+        https://bugs.webkit.org/show_bug.cgi?id=129077
+
+        Reviewed by Antti Koivisto.
+
+        Similar to r164403. When a fieldset inside a disabled fieldset, input elements inside
+        the inner fieldset's first legend element child should be disabled.
+
+        Test: fast/forms/fieldset/fieldset-disabled-2.html
+
+        * html/HTMLFieldSetElement.cpp:
+        (WebCore::HTMLFieldSetElement::legend): Fixed the bug where it was returning the first
+        legend element descendent. It should be the first legend element _child_.
+        * html/HTMLFormControlElement.cpp:
+        (WebCore::HTMLFormControlElement::updateAncestorDisabledState): Fixed the algorithm
+        to look for any ancestor fieldset that has been disabled instead of the first fieldset
+        ancestor and checking its disabledness.
+
 2014-02-19  Ryosuke Niwa  <rniwa@webkit.org>
 
         Debug build fix after r164401. Removed a bogus assertion in comparePositions.
index 0dab60d5538c26af3c3d4c834cc31870b3018e27..9fa083b897ad9a1aa5bfb5eeb029e52e4bf86a8d 100644 (file)
@@ -88,7 +88,7 @@ RenderPtr<RenderElement> HTMLFieldSetElement::createElementRenderer(PassRef<Rend
 
 HTMLLegendElement* HTMLFieldSetElement::legend() const
 {
-    return const_cast<HTMLLegendElement*>(descendantsOfType<HTMLLegendElement>(*this).first());
+    return const_cast<HTMLLegendElement*>(childrenOfType<HTMLLegendElement>(*this).first());
 }
 
 PassRefPtr<HTMLCollection> HTMLFieldSetElement::elements()
index 9eb604f916f9f370a613e7fcf2b08759f398bfc6..d7fdb76fd5b521145447e4516a3f9dca6b9df62a 100644 (file)
@@ -103,10 +103,10 @@ void HTMLFormControlElement::updateAncestorDisabledState() const
 {
     Element* previousAncestor = nullptr;
     for (Element* ancestor = parentElement(); ancestor; ancestor = ancestor->parentElement()) {
-        if (isHTMLFieldSetElement(ancestor)) {
+        if (isHTMLFieldSetElement(ancestor) && ancestor->hasAttribute(disabledAttr)) {
             HTMLFieldSetElement& fieldSetAncestor = toHTMLFieldSetElement(*ancestor);
             bool isInFirstLegend = previousAncestor && isHTMLLegendElement(previousAncestor) && previousAncestor == fieldSetAncestor.legend();
-            m_ancestorDisabledState = !fieldSetAncestor.isDisabledFormControl() || isInFirstLegend ? AncestorDisabledStateEnabled : AncestorDisabledStateDisabled;
+            m_ancestorDisabledState = isInFirstLegend ? AncestorDisabledStateEnabled : AncestorDisabledStateDisabled;
             return;
         }
         previousAncestor = ancestor;