- Revision
- 118721
- Author
- [email protected]
- Date
- 2012-05-28 21:08:42 -0700 (Mon, 28 May 2012)
Log Message
Form controls in <fieldset disabled> should not be validated.
https://bugs.webkit.org/show_bug.cgi?id=87381
Reviewed by Hajime Morita.
Source/WebCore:
We need to use disabeld() instead of m_disabled to calculate
willValidate property. Also, we need to update willValidate if
necessary.
Test: fast/forms/fieldset/validation-in-fieldset.html
* html/HTMLFieldSetElement.cpp:
(WebCore::HTMLFieldSetElement::disabledAttributeChanged):
- Do not traverse this.
- Calls ancestorDisabledStateWasChanged() instead of
setNeedsStyleRecalc() because we'd like to do additional tasks.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::ancestorDisabledStateWasChanged):
Added. Just calls disabledAttributeChanged().
(WebCore::HTMLFormControlElement::parseAttribute):
Do not call setNeedsWillValidateCheck() whenever an attribute is updated.
It should be called only if disabled or readonly attribute is updated.
(WebCore::HTMLFormControlElement::disabledAttributeChanged):
Add setNeedsWillValidateCheck(). It was moved from parseAttribute().
(WebCore::HTMLFormControlElement::insertedInto):
Invalidate ancestor information.
(WebCore::HTMLFormControlElement::recalcWillValidate):
Use disabled() instead of m_disabled. disabled() takes care of
ancestor's disabled state.
* html/HTMLFormControlElement.h:
(HTMLFormControlElement):
LayoutTests:
* fast/forms/fieldset/validation-in-fieldset-expected.txt: Added.
* fast/forms/fieldset/validation-in-fieldset.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (118720 => 118721)
--- trunk/LayoutTests/ChangeLog 2012-05-29 03:57:17 UTC (rev 118720)
+++ trunk/LayoutTests/ChangeLog 2012-05-29 04:08:42 UTC (rev 118721)
@@ -1,3 +1,13 @@
+2012-05-28 Kent Tamura <[email protected]>
+
+ Form controls in <fieldset disabled> should not be validated.
+ https://bugs.webkit.org/show_bug.cgi?id=87381
+
+ Reviewed by Hajime Morita.
+
+ * fast/forms/fieldset/validation-in-fieldset-expected.txt: Added.
+ * fast/forms/fieldset/validation-in-fieldset.html: Added.
+
2012-05-28 Rakesh KN <[email protected]>
[Forms] HTMLFieldSetElement.idl doesn't have elements attribute.
Added: trunk/LayoutTests/fast/forms/fieldset/validation-in-fieldset-expected.txt (0 => 118721)
--- trunk/LayoutTests/fast/forms/fieldset/validation-in-fieldset-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/validation-in-fieldset-expected.txt 2012-05-29 04:08:42 UTC (rev 118721)
@@ -0,0 +1,12 @@
+A form control in initially disabled fieldset:
+PASS control1.willValidate is false
+Then, enables the fieldset:
+PASS document.getElementById("f1").disabled = false; control1.willValidate is true
+A form control in initially enabled fieldset:
+PASS control2.willValidate is true
+Then, disables fieldset:
+PASS fieldset2.disabled = true; control2.willValidate is false
+Detach the form control from the fieldset:
+PASS fieldset2.removeChild(control2); control2.willValidate is true
+
+
Property changes on: trunk/LayoutTests/fast/forms/fieldset/validation-in-fieldset-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/forms/fieldset/validation-in-fieldset.html (0 => 118721)
--- trunk/LayoutTests/fast/forms/fieldset/validation-in-fieldset.html (rev 0)
+++ trunk/LayoutTests/fast/forms/fieldset/validation-in-fieldset.html 2012-05-29 04:08:42 UTC (rev 118721)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+
+<fieldset id="f1" disabled>
+ <input required id="i1">
+</fieldset>
+<fieldset id="f2">
+ <input required id="i2">
+</fieldset>
+
+<script>
+debug('A form control in initially disabled fieldset:');
+var control1 = document.getElementById("i1");
+shouldBeFalse('control1.willValidate');
+debug('Then, enables the fieldset:');
+shouldBeTrue('document.getElementById("f1").disabled = false; control1.willValidate');
+
+debug('A form control in initially enabled fieldset:');
+var control2 = document.getElementById("i2");
+var fieldset2 = document.getElementById("f2");
+shouldBeTrue('control2.willValidate');
+debug('Then, disables fieldset:');
+shouldBeFalse('fieldset2.disabled = true; control2.willValidate');
+debug('Detach the form control from the fieldset:');
+shouldBeTrue('fieldset2.removeChild(control2); control2.willValidate');
+
+</script>
+<script src=""
+</body>
Property changes on: trunk/LayoutTests/fast/forms/fieldset/validation-in-fieldset.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (118720 => 118721)
--- trunk/Source/WebCore/ChangeLog 2012-05-29 03:57:17 UTC (rev 118720)
+++ trunk/Source/WebCore/ChangeLog 2012-05-29 04:08:42 UTC (rev 118721)
@@ -1,3 +1,37 @@
+2012-05-28 Kent Tamura <[email protected]>
+
+ Form controls in <fieldset disabled> should not be validated.
+ https://bugs.webkit.org/show_bug.cgi?id=87381
+
+ Reviewed by Hajime Morita.
+
+ We need to use disabeld() instead of m_disabled to calculate
+ willValidate property. Also, we need to update willValidate if
+ necessary.
+
+ Test: fast/forms/fieldset/validation-in-fieldset.html
+
+ * html/HTMLFieldSetElement.cpp:
+ (WebCore::HTMLFieldSetElement::disabledAttributeChanged):
+ - Do not traverse this.
+ - Calls ancestorDisabledStateWasChanged() instead of
+ setNeedsStyleRecalc() because we'd like to do additional tasks.
+ * html/HTMLFormControlElement.cpp:
+ (WebCore::HTMLFormControlElement::ancestorDisabledStateWasChanged):
+ Added. Just calls disabledAttributeChanged().
+ (WebCore::HTMLFormControlElement::parseAttribute):
+ Do not call setNeedsWillValidateCheck() whenever an attribute is updated.
+ It should be called only if disabled or readonly attribute is updated.
+ (WebCore::HTMLFormControlElement::disabledAttributeChanged):
+ Add setNeedsWillValidateCheck(). It was moved from parseAttribute().
+ (WebCore::HTMLFormControlElement::insertedInto):
+ Invalidate ancestor information.
+ (WebCore::HTMLFormControlElement::recalcWillValidate):
+ Use disabled() instead of m_disabled. disabled() takes care of
+ ancestor's disabled state.
+ * html/HTMLFormControlElement.h:
+ (HTMLFormControlElement):
+
2012-05-28 Rakesh KN <[email protected]>
[Forms] HTMLFieldSetElement.idl doesn't have elements attribute.
Modified: trunk/Source/WebCore/html/HTMLFieldSetElement.cpp (118720 => 118721)
--- trunk/Source/WebCore/html/HTMLFieldSetElement.cpp 2012-05-29 03:57:17 UTC (rev 118720)
+++ trunk/Source/WebCore/html/HTMLFieldSetElement.cpp 2012-05-29 04:08:42 UTC (rev 118721)
@@ -52,9 +52,9 @@
// This element must be updated before the style of nodes in its subtree gets recalculated.
HTMLFormControlElement::disabledAttributeChanged();
- for (Node* currentNode = this; currentNode; currentNode = currentNode->traverseNextNode(this)) {
+ for (Node* currentNode = this->traverseNextNode(this); currentNode; currentNode = currentNode->traverseNextNode(this)) {
if (currentNode && currentNode->isElementNode() && toElement(currentNode)->isFormControlElement())
- static_cast<HTMLFormControlElement*>(currentNode)->setNeedsStyleRecalc();
+ static_cast<HTMLFormControlElement*>(currentNode)->ancestorDisabledStateWasChanged();
}
}
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (118720 => 118721)
--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2012-05-29 03:57:17 UTC (rev 118720)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp 2012-05-29 04:08:42 UTC (rev 118721)
@@ -110,6 +110,11 @@
m_fieldSetAncestorValid = true;
}
+void HTMLFormControlElement::ancestorDisabledStateWasChanged()
+{
+ disabledAttributeChanged();
+}
+
void HTMLFormControlElement::parseAttribute(const Attribute& attribute)
{
if (attribute.name() == formAttr)
@@ -123,6 +128,7 @@
bool oldReadOnly = m_readOnly;
m_readOnly = !attribute.isNull();
if (oldReadOnly != m_readOnly) {
+ setNeedsWillValidateCheck();
setNeedsStyleRecalc();
if (renderer() && renderer()->style()->hasAppearance())
renderer()->theme()->stateChanged(renderer(), ReadOnlyState);
@@ -134,11 +140,11 @@
requiredAttributeChanged();
} else
HTMLElement::parseAttribute(attribute);
- setNeedsWillValidateCheck();
}
void HTMLFormControlElement::disabledAttributeChanged()
{
+ setNeedsWillValidateCheck();
setNeedsStyleRecalc();
if (renderer() && renderer()->style()->hasAppearance())
renderer()->theme()->stateChanged(renderer(), EnabledState);
@@ -218,6 +224,7 @@
Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(ContainerNode* insertionPoint)
{
+ m_fieldSetAncestorValid = false;
m_dataListAncestorState = Unknown;
setNeedsWillValidateCheck();
HTMLElement::insertedInto(insertionPoint);
@@ -362,7 +369,7 @@
if (m_dataListAncestorState == Unknown)
m_dataListAncestorState = NotInsideDataList;
}
- return m_dataListAncestorState == NotInsideDataList && !m_disabled && !m_readOnly;
+ return m_dataListAncestorState == NotInsideDataList && !disabled() && !m_readOnly;
}
bool HTMLFormControlElement::willValidate() const
Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (118720 => 118721)
--- trunk/Source/WebCore/html/HTMLFormControlElement.h 2012-05-29 03:57:17 UTC (rev 118720)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h 2012-05-29 04:08:42 UTC (rev 118721)
@@ -52,6 +52,7 @@
bool formNoValidate() const;
void updateFieldSetAndLegendAncestor() const;
+ void ancestorDisabledStateWasChanged();
virtual void reset() { }