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.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@164403
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-02-19 Ryosuke Niwa <rniwa@webkit.org>
+
+ 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 <rniwa@webkit.org>
Changing selection shouldn't synchronously update editor UI components
--- /dev/null
+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
+
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../../resources/js-test-pre.js"></script>
+<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="../../../resources/js-test-post.js"></script>
+</body>
+</html>
+2014-02-19 Ryosuke Niwa <rniwa@webkit.org>
+
+ 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 <rniwa@webkit.org>
Changing selection shouldn't synchronously update editor UI components
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()