Index: third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp b/third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp |
index cd7c635bd7043f6e6117e15a99236bc77c855474..7847d89e7a44b4fb2311b5608b20c9dcf8057657 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp |
@@ -49,13 +49,10 @@ using namespace HTMLNames; |
HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Document& document, HTMLFormElement* form) |
: LabelableElement(tagName, document) |
- , m_disabled(false) |
- , m_isAutofilled(false) |
- , m_isReadOnly(false) |
- , m_isRequired(false) |
- , m_hasValidationMessage(false) |
, m_ancestorDisabledState(AncestorDisabledStateUnknown) |
, m_dataListAncestorState(Unknown) |
+ , m_isAutofilled(false) |
+ , m_hasValidationMessage(false) |
, m_willValidateInitialized(false) |
, m_willValidate(true) |
, m_isValid(true) |
@@ -163,14 +160,10 @@ void HTMLFormControlElement::parseAttribute(const QualifiedName& name, const Ato |
formAttributeChanged(); |
UseCounter::count(document(), UseCounter::FormAttribute); |
} else if (name == disabledAttr) { |
- bool oldDisabled = m_disabled; |
- m_disabled = !value.isNull(); |
- if (oldDisabled != m_disabled) |
+ if (oldValue.isNull() != value.isNull()) |
disabledAttributeChanged(); |
} else if (name == readonlyAttr) { |
- bool wasReadOnly = m_isReadOnly; |
- m_isReadOnly = !value.isNull(); |
- if (wasReadOnly != m_isReadOnly) { |
+ if (oldValue.isNull() != value.isNull()) { |
setNeedsWillValidateCheck(); |
pseudoStateChanged(CSSSelector::PseudoReadOnly); |
pseudoStateChanged(CSSSelector::PseudoReadWrite); |
@@ -178,9 +171,7 @@ void HTMLFormControlElement::parseAttribute(const QualifiedName& name, const Ato |
LayoutTheme::theme().controlStateChanged(*layoutObject(), ReadOnlyControlState); |
} |
} else if (name == requiredAttr) { |
- bool wasRequired = m_isRequired; |
- m_isRequired = !value.isNull(); |
- if (wasRequired != m_isRequired) |
+ if (oldValue.isNull() != value.isNull()) |
requiredAttributeChanged(); |
UseCounter::count(document(), UseCounter::RequiredAttribute); |
} else if (name == autofocusAttr) { |
@@ -212,6 +203,16 @@ void HTMLFormControlElement::requiredAttributeChanged() |
pseudoStateChanged(CSSSelector::PseudoOptional); |
} |
+bool HTMLFormControlElement::isReadOnly() const |
+{ |
+ return fastHasAttribute(HTMLNames::readonlyAttr); |
+} |
+ |
+bool HTMLFormControlElement::isDisabledOrReadOnly() const |
+{ |
+ return isDisabledFormControl() || isReadOnly(); |
+} |
+ |
bool HTMLFormControlElement::supportsAutofocus() const |
{ |
return false; |
@@ -356,7 +357,7 @@ HTMLFormElement* HTMLFormControlElement::formOwner() const |
bool HTMLFormControlElement::isDisabledFormControl() const |
{ |
- if (m_disabled) |
+ if (fastHasAttribute(disabledAttr)) |
return true; |
if (m_ancestorDisabledState == AncestorDisabledStateUnknown) |
@@ -366,7 +367,7 @@ bool HTMLFormControlElement::isDisabledFormControl() const |
bool HTMLFormControlElement::isRequired() const |
{ |
- return m_isRequired; |
+ return fastHasAttribute(requiredAttr); |
} |
String HTMLFormControlElement::resultForDialogSubmit() |