OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |