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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLFormControlElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com) 6 * (C) 2006 Alexey Proskuryakov (ap@nypop.com)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "core/page/ValidationMessageClient.h" 42 #include "core/page/ValidationMessageClient.h"
43 #include "platform/text/BidiTextRun.h" 43 #include "platform/text/BidiTextRun.h"
44 #include "wtf/Vector.h" 44 #include "wtf/Vector.h"
45 45
46 namespace blink { 46 namespace blink {
47 47
48 using namespace HTMLNames; 48 using namespace HTMLNames;
49 49
50 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc ument& document, HTMLFormElement* form) 50 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc ument& document, HTMLFormElement* form)
51 : LabelableElement(tagName, document) 51 : LabelableElement(tagName, document)
52 , m_disabled(false)
53 , m_isAutofilled(false)
54 , m_isReadOnly(false)
55 , m_isRequired(false)
56 , m_hasValidationMessage(false)
57 , m_ancestorDisabledState(AncestorDisabledStateUnknown) 52 , m_ancestorDisabledState(AncestorDisabledStateUnknown)
58 , m_dataListAncestorState(Unknown) 53 , m_dataListAncestorState(Unknown)
54 , m_isAutofilled(false)
55 , m_hasValidationMessage(false)
59 , m_willValidateInitialized(false) 56 , m_willValidateInitialized(false)
60 , m_willValidate(true) 57 , m_willValidate(true)
61 , m_isValid(true) 58 , m_isValid(true)
62 , m_validityIsDirty(false) 59 , m_validityIsDirty(false)
63 , m_wasChangedSinceLastFormControlChangeEvent(false) 60 , m_wasChangedSinceLastFormControlChangeEvent(false)
64 , m_wasFocusedByMouse(false) 61 , m_wasFocusedByMouse(false)
65 { 62 {
66 setHasCustomStyleCallbacks(); 63 setHasCustomStyleCallbacks();
67 associateByParser(form); 64 associateByParser(form);
68 } 65 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 setAutofilled(false); 153 setAutofilled(false);
157 resetImpl(); 154 resetImpl();
158 } 155 }
159 156
160 void HTMLFormControlElement::parseAttribute(const QualifiedName& name, const Ato micString& oldValue, const AtomicString& value) 157 void HTMLFormControlElement::parseAttribute(const QualifiedName& name, const Ato micString& oldValue, const AtomicString& value)
161 { 158 {
162 if (name == formAttr) { 159 if (name == formAttr) {
163 formAttributeChanged(); 160 formAttributeChanged();
164 UseCounter::count(document(), UseCounter::FormAttribute); 161 UseCounter::count(document(), UseCounter::FormAttribute);
165 } else if (name == disabledAttr) { 162 } else if (name == disabledAttr) {
166 bool oldDisabled = m_disabled; 163 if (oldValue.isNull() != value.isNull())
167 m_disabled = !value.isNull();
168 if (oldDisabled != m_disabled)
169 disabledAttributeChanged(); 164 disabledAttributeChanged();
170 } else if (name == readonlyAttr) { 165 } else if (name == readonlyAttr) {
171 bool wasReadOnly = m_isReadOnly; 166 if (oldValue.isNull() != value.isNull()) {
172 m_isReadOnly = !value.isNull();
173 if (wasReadOnly != m_isReadOnly) {
174 setNeedsWillValidateCheck(); 167 setNeedsWillValidateCheck();
175 pseudoStateChanged(CSSSelector::PseudoReadOnly); 168 pseudoStateChanged(CSSSelector::PseudoReadOnly);
176 pseudoStateChanged(CSSSelector::PseudoReadWrite); 169 pseudoStateChanged(CSSSelector::PseudoReadWrite);
177 if (layoutObject()) 170 if (layoutObject())
178 LayoutTheme::theme().controlStateChanged(*layoutObject(), ReadOn lyControlState); 171 LayoutTheme::theme().controlStateChanged(*layoutObject(), ReadOn lyControlState);
179 } 172 }
180 } else if (name == requiredAttr) { 173 } else if (name == requiredAttr) {
181 bool wasRequired = m_isRequired; 174 if (oldValue.isNull() != value.isNull())
182 m_isRequired = !value.isNull();
183 if (wasRequired != m_isRequired)
184 requiredAttributeChanged(); 175 requiredAttributeChanged();
185 UseCounter::count(document(), UseCounter::RequiredAttribute); 176 UseCounter::count(document(), UseCounter::RequiredAttribute);
186 } else if (name == autofocusAttr) { 177 } else if (name == autofocusAttr) {
187 HTMLElement::parseAttribute(name, oldValue, value); 178 HTMLElement::parseAttribute(name, oldValue, value);
188 UseCounter::count(document(), UseCounter::AutoFocusAttribute); 179 UseCounter::count(document(), UseCounter::AutoFocusAttribute);
189 } else { 180 } else {
190 HTMLElement::parseAttribute(name, oldValue, value); 181 HTMLElement::parseAttribute(name, oldValue, value);
191 } 182 }
192 } 183 }
193 184
(...skipping 11 matching lines...) Expand all
205 } 196 }
206 } 197 }
207 198
208 void HTMLFormControlElement::requiredAttributeChanged() 199 void HTMLFormControlElement::requiredAttributeChanged()
209 { 200 {
210 setNeedsValidityCheck(); 201 setNeedsValidityCheck();
211 pseudoStateChanged(CSSSelector::PseudoRequired); 202 pseudoStateChanged(CSSSelector::PseudoRequired);
212 pseudoStateChanged(CSSSelector::PseudoOptional); 203 pseudoStateChanged(CSSSelector::PseudoOptional);
213 } 204 }
214 205
206 bool HTMLFormControlElement::isReadOnly() const
207 {
208 return fastHasAttribute(HTMLNames::readonlyAttr);
209 }
210
211 bool HTMLFormControlElement::isDisabledOrReadOnly() const
212 {
213 return isDisabledFormControl() || isReadOnly();
214 }
215
215 bool HTMLFormControlElement::supportsAutofocus() const 216 bool HTMLFormControlElement::supportsAutofocus() const
216 { 217 {
217 return false; 218 return false;
218 } 219 }
219 220
220 bool HTMLFormControlElement::isAutofocusable() const 221 bool HTMLFormControlElement::isAutofocusable() const
221 { 222 {
222 return fastHasAttribute(autofocusAttr) && supportsAutofocus(); 223 return fastHasAttribute(autofocusAttr) && supportsAutofocus();
223 } 224 }
224 225
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 HTMLElement::dispatchInputEvent(); 350 HTMLElement::dispatchInputEvent();
350 } 351 }
351 352
352 HTMLFormElement* HTMLFormControlElement::formOwner() const 353 HTMLFormElement* HTMLFormControlElement::formOwner() const
353 { 354 {
354 return FormAssociatedElement::form(); 355 return FormAssociatedElement::form();
355 } 356 }
356 357
357 bool HTMLFormControlElement::isDisabledFormControl() const 358 bool HTMLFormControlElement::isDisabledFormControl() const
358 { 359 {
359 if (m_disabled) 360 if (fastHasAttribute(disabledAttr))
360 return true; 361 return true;
361 362
362 if (m_ancestorDisabledState == AncestorDisabledStateUnknown) 363 if (m_ancestorDisabledState == AncestorDisabledStateUnknown)
363 updateAncestorDisabledState(); 364 updateAncestorDisabledState();
364 return m_ancestorDisabledState == AncestorDisabledStateDisabled; 365 return m_ancestorDisabledState == AncestorDisabledStateDisabled;
365 } 366 }
366 367
367 bool HTMLFormControlElement::isRequired() const 368 bool HTMLFormControlElement::isRequired() const
368 { 369 {
369 return m_isRequired; 370 return fastHasAttribute(requiredAttr);
370 } 371 }
371 372
372 String HTMLFormControlElement::resultForDialogSubmit() 373 String HTMLFormControlElement::resultForDialogSubmit()
373 { 374 {
374 return fastGetAttribute(valueAttr); 375 return fastGetAttribute(valueAttr);
375 } 376 }
376 377
377 void HTMLFormControlElement::didRecalcStyle(StyleRecalcChange) 378 void HTMLFormControlElement::didRecalcStyle(StyleRecalcChange)
378 { 379 {
379 if (LayoutObject* layoutObject = this->layoutObject()) 380 if (LayoutObject* layoutObject = this->layoutObject())
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 dispatchFormControlChangeEvent(); 664 dispatchFormControlChangeEvent();
664 } 665 }
665 666
666 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element & source) 667 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element & source)
667 { 668 {
668 HTMLElement::copyNonAttributePropertiesFromElement(source); 669 HTMLElement::copyNonAttributePropertiesFromElement(source);
669 setNeedsValidityCheck(); 670 setNeedsValidityCheck();
670 } 671 }
671 672
672 } // namespace blink 673 } // namespace blink
OLDNEW
« 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