Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Unified Diff: third_party/WebKit/Source/core/html/HTMLFormControlElement.cpp

Issue 1490973002: Remove HTMLFormControlElement::m_disabled, m_isReadOnly, and m_isRequired. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@attr-hook-2
Patch Set: apply review comments Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormControlElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormControlElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698