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
+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
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
<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>
shouldBeFalse('isInputDisabledById("inputInsideFirstLegend")');
shouldBeTrue('isInputDisabledById("inputInsideSecondLegend")');
shouldBeFalse('isInputDisabledById("inputInsideNestedFirstLegend")');
+shouldBeTrue('isInputDisabledById("inputInsideFirstLegendWithDisabledOuterFieldset")');
function setDisabledOnAllFieldsets(value) {
var fieldsets = document.querySelectorAll('fieldset');
shouldBeFalse('isInputDisabledById("inputInsideFirstLegend")');
shouldBeFalse('isInputDisabledById("inputInsideSecondLegend")');
shouldBeFalse('isInputDisabledById("inputInsideNestedFirstLegend")');
+shouldBeFalse('isInputDisabledById("inputInsideFirstLegendWithDisabledOuterFieldset")');
document.getElementById('container').style.display = 'none';
+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.
HTMLLegendElement* HTMLFieldSetElement::legend() const
{
- return const_cast<HTMLLegendElement*>(descendantsOfType<HTMLLegendElement>(*this).first());
+ return const_cast<HTMLLegendElement*>(childrenOfType<HTMLLegendElement>(*this).first());
}
PassRefPtr<HTMLCollection> HTMLFieldSetElement::elements()
{
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;