Index: Source/WebCore/html/HTMLFormControlElement.cpp |
=================================================================== |
--- Source/WebCore/html/HTMLFormControlElement.cpp (revision 119622) |
+++ Source/WebCore/html/HTMLFormControlElement.cpp (working copy) |
@@ -48,13 +48,11 @@ |
HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Document* document, HTMLFormElement* form) |
: LabelableElement(tagName, document) |
- , m_fieldSetAncestor(0) |
- , m_legendAncestor(0) |
- , m_fieldSetAncestorValid(false) |
, m_disabled(false) |
, m_readOnly(false) |
, m_required(false) |
, m_valueMatchesRenderer(false) |
+ , m_ancestorDisabledState(AncestorDisabledStateUnknown) |
, m_dataListAncestorState(Unknown) |
, m_willValidateInitialized(false) |
, m_willValidate(true) |
@@ -101,23 +99,24 @@ |
return fastHasAttribute(formnovalidateAttr); |
} |
-void HTMLFormControlElement::updateFieldSetAndLegendAncestor() const |
+void HTMLFormControlElement::updateAncestorDisabledState() const |
{ |
- m_fieldSetAncestor = 0; |
- m_legendAncestor = 0; |
+ HTMLFieldSetElement* fieldSetAncestor = 0; |
+ ContainerNode* legendAncestor = 0; |
for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) { |
- if (!m_legendAncestor && ancestor->hasTagName(legendTag)) |
- m_legendAncestor = static_cast<HTMLLegendElement*>(ancestor); |
+ if (!legendAncestor && ancestor->hasTagName(legendTag)) |
+ legendAncestor = ancestor; |
if (ancestor->hasTagName(fieldsetTag)) { |
- m_fieldSetAncestor = static_cast<HTMLFieldSetElement*>(ancestor); |
+ fieldSetAncestor = static_cast<HTMLFieldSetElement*>(ancestor); |
break; |
} |
} |
- m_fieldSetAncestorValid = true; |
+ m_ancestorDisabledState = (fieldSetAncestor && fieldSetAncestor->disabled() && !(legendAncestor && legendAncestor == fieldSetAncestor->legend())) ? AncestorDisabledStateDisabled : AncestorDisabledStateEnabled; |
} |
void HTMLFormControlElement::ancestorDisabledStateWasChanged() |
{ |
+ m_ancestorDisabledState = AncestorDisabledStateUnknown; |
disabledAttributeChanged(); |
} |
@@ -230,7 +229,7 @@ |
Node::InsertionNotificationRequest HTMLFormControlElement::insertedInto(Node* insertionPoint) |
{ |
- m_fieldSetAncestorValid = false; |
+ m_ancestorDisabledState = AncestorDisabledStateUnknown; |
m_dataListAncestorState = Unknown; |
setNeedsWillValidateCheck(); |
HTMLElement::insertedInto(insertionPoint); |
@@ -240,7 +239,7 @@ |
void HTMLFormControlElement::removedFrom(Node* insertionPoint) |
{ |
- m_fieldSetAncestorValid = false; |
+ m_ancestorDisabledState = AncestorDisabledStateUnknown; |
m_dataListAncestorState = Unknown; |
HTMLElement::removedFrom(insertionPoint); |
FormAssociatedElement::removedFrom(insertionPoint); |
@@ -284,13 +283,9 @@ |
if (m_disabled) |
return true; |
- if (!m_fieldSetAncestorValid) |
- updateFieldSetAndLegendAncestor(); |
- |
- // Form controls in the first legend element inside a fieldset are not affected by fieldset.disabled. |
- if (m_fieldSetAncestor && m_fieldSetAncestor->disabled()) |
- return !(m_legendAncestor && m_legendAncestor == m_fieldSetAncestor->legend()); |
- return false; |
+ if (m_ancestorDisabledState == AncestorDisabledStateUnknown) |
+ updateAncestorDisabledState(); |
+ return m_ancestorDisabledState == AncestorDisabledStateDisabled; |
} |
void HTMLFormControlElement::setDisabled(bool b) |
@@ -366,7 +361,7 @@ |
{ |
if (m_dataListAncestorState == Unknown) { |
for (ContainerNode* ancestor = parentNode(); ancestor; ancestor = ancestor->parentNode()) { |
- if (!m_legendAncestor && ancestor->hasTagName(datalistTag)) { |
+ if (ancestor->hasTagName(datalistTag)) { |
m_dataListAncestorState = InsideDataList; |
break; |
} |