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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } else if (name == disabledAttr) { | 134 } else if (name == disabledAttr) { |
135 bool oldDisabled = m_disabled; | 135 bool oldDisabled = m_disabled; |
136 m_disabled = !value.isNull(); | 136 m_disabled = !value.isNull(); |
137 if (oldDisabled != m_disabled) | 137 if (oldDisabled != m_disabled) |
138 disabledAttributeChanged(); | 138 disabledAttributeChanged(); |
139 } else if (name == readonlyAttr) { | 139 } else if (name == readonlyAttr) { |
140 bool wasReadOnly = m_isReadOnly; | 140 bool wasReadOnly = m_isReadOnly; |
141 m_isReadOnly = !value.isNull(); | 141 m_isReadOnly = !value.isNull(); |
142 if (wasReadOnly != m_isReadOnly) { | 142 if (wasReadOnly != m_isReadOnly) { |
143 setNeedsWillValidateCheck(); | 143 setNeedsWillValidateCheck(); |
144 setNeedsStyleRecalc(); | 144 setNeedsStyleRecalc(SubtreeStyleChange); |
145 if (renderer() && renderer()->style()->hasAppearance()) | 145 if (renderer() && renderer()->style()->hasAppearance()) |
146 RenderTheme::theme().stateChanged(renderer(), ReadOnlyState); | 146 RenderTheme::theme().stateChanged(renderer(), ReadOnlyState); |
147 } | 147 } |
148 } else if (name == requiredAttr) { | 148 } else if (name == requiredAttr) { |
149 bool wasRequired = m_isRequired; | 149 bool wasRequired = m_isRequired; |
150 m_isRequired = !value.isNull(); | 150 m_isRequired = !value.isNull(); |
151 if (wasRequired != m_isRequired) | 151 if (wasRequired != m_isRequired) |
152 requiredAttributeChanged(); | 152 requiredAttributeChanged(); |
153 UseCounter::count(document(), UseCounter::RequiredAttribute); | 153 UseCounter::count(document(), UseCounter::RequiredAttribute); |
154 } else if (name == autofocusAttr) { | 154 } else if (name == autofocusAttr) { |
(...skipping 14 matching lines...) Expand all Loading... |
169 // here. | 169 // here. |
170 document().setNeedsFocusedElementCheck(); | 170 document().setNeedsFocusedElementCheck(); |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 void HTMLFormControlElement::requiredAttributeChanged() | 174 void HTMLFormControlElement::requiredAttributeChanged() |
175 { | 175 { |
176 setNeedsValidityCheck(); | 176 setNeedsValidityCheck(); |
177 // Style recalculation is needed because style selectors may include | 177 // Style recalculation is needed because style selectors may include |
178 // :required and :optional pseudo-classes. | 178 // :required and :optional pseudo-classes. |
179 setNeedsStyleRecalc(); | 179 setNeedsStyleRecalc(SubtreeStyleChange); |
180 } | 180 } |
181 | 181 |
182 bool HTMLFormControlElement::supportsAutofocus() const | 182 bool HTMLFormControlElement::supportsAutofocus() const |
183 { | 183 { |
184 return false; | 184 return false; |
185 } | 185 } |
186 | 186 |
187 bool HTMLFormControlElement::isAutofocusable() const | 187 bool HTMLFormControlElement::isAutofocusable() const |
188 { | 188 { |
189 return fastHasAttribute(autofocusAttr) && supportsAutofocus(); | 189 return fastHasAttribute(autofocusAttr) && supportsAutofocus(); |
190 } | 190 } |
191 | 191 |
192 void HTMLFormControlElement::setAutofilled(bool autofilled) | 192 void HTMLFormControlElement::setAutofilled(bool autofilled) |
193 { | 193 { |
194 if (autofilled == m_isAutofilled) | 194 if (autofilled == m_isAutofilled) |
195 return; | 195 return; |
196 | 196 |
197 m_isAutofilled = autofilled; | 197 m_isAutofilled = autofilled; |
198 setNeedsStyleRecalc(); | 198 setNeedsStyleRecalc(SubtreeStyleChange); |
199 } | 199 } |
200 | 200 |
201 static bool shouldAutofocusOnAttach(const HTMLFormControlElement* element) | 201 static bool shouldAutofocusOnAttach(const HTMLFormControlElement* element) |
202 { | 202 { |
203 if (!element->isAutofocusable()) | 203 if (!element->isAutofocusable()) |
204 return false; | 204 return false; |
205 if (element->document().isSandboxed(SandboxAutomaticFeatures)) { | 205 if (element->document().isSandboxed(SandboxAutomaticFeatures)) { |
206 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 206 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
207 element->document().addConsoleMessage(SecurityMessageSource, ErrorMessag
eLevel, "Blocked autofocusing on a form control because the form's frame is sand
boxed and the 'allow-scripts' permission is not set."); | 207 element->document().addConsoleMessage(SecurityMessageSource, ErrorMessag
eLevel, "Blocked autofocusing on a form control because the form's frame is sand
boxed and the 'allow-scripts' permission is not set."); |
208 return false; | 208 return false; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 389 |
390 void HTMLFormControlElement::setNeedsWillValidateCheck() | 390 void HTMLFormControlElement::setNeedsWillValidateCheck() |
391 { | 391 { |
392 // We need to recalculate willValidate immediately because willValidate chan
ge can causes style change. | 392 // We need to recalculate willValidate immediately because willValidate chan
ge can causes style change. |
393 bool newWillValidate = recalcWillValidate(); | 393 bool newWillValidate = recalcWillValidate(); |
394 if (m_willValidateInitialized && m_willValidate == newWillValidate) | 394 if (m_willValidateInitialized && m_willValidate == newWillValidate) |
395 return; | 395 return; |
396 m_willValidateInitialized = true; | 396 m_willValidateInitialized = true; |
397 m_willValidate = newWillValidate; | 397 m_willValidate = newWillValidate; |
398 setNeedsValidityCheck(); | 398 setNeedsValidityCheck(); |
399 setNeedsStyleRecalc(); | 399 setNeedsStyleRecalc(SubtreeStyleChange); |
400 if (!m_willValidate) | 400 if (!m_willValidate) |
401 hideVisibleValidationMessage(); | 401 hideVisibleValidationMessage(); |
402 } | 402 } |
403 | 403 |
404 void HTMLFormControlElement::updateVisibleValidationMessage() | 404 void HTMLFormControlElement::updateVisibleValidationMessage() |
405 { | 405 { |
406 Page* page = document().page(); | 406 Page* page = document().page(); |
407 if (!page) | 407 if (!page) |
408 return; | 408 return; |
409 String message; | 409 String message; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // correctly when something which changes validity is updated. | 441 // correctly when something which changes validity is updated. |
442 ASSERT(m_isValid == valid()); | 442 ASSERT(m_isValid == valid()); |
443 return m_isValid; | 443 return m_isValid; |
444 } | 444 } |
445 | 445 |
446 void HTMLFormControlElement::setNeedsValidityCheck() | 446 void HTMLFormControlElement::setNeedsValidityCheck() |
447 { | 447 { |
448 bool newIsValid = valid(); | 448 bool newIsValid = valid(); |
449 if (willValidate() && newIsValid != m_isValid) { | 449 if (willValidate() && newIsValid != m_isValid) { |
450 // Update style for pseudo classes such as :valid :invalid. | 450 // Update style for pseudo classes such as :valid :invalid. |
451 setNeedsStyleRecalc(); | 451 setNeedsStyleRecalc(SubtreeStyleChange); |
452 } | 452 } |
453 m_isValid = newIsValid; | 453 m_isValid = newIsValid; |
454 | 454 |
455 // Updates only if this control already has a validation message. | 455 // Updates only if this control already has a validation message. |
456 if (m_validationMessage && m_validationMessage->isVisible()) { | 456 if (m_validationMessage && m_validationMessage->isVisible()) { |
457 // Calls updateVisibleValidationMessage() even if m_isValid is not | 457 // Calls updateVisibleValidationMessage() even if m_isValid is not |
458 // changed because a validation message can be chagned. | 458 // changed because a validation message can be chagned. |
459 updateVisibleValidationMessage(); | 459 updateVisibleValidationMessage(); |
460 } | 460 } |
461 } | 461 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 504 |
505 void HTMLFormControlElement::setFocus(bool flag) | 505 void HTMLFormControlElement::setFocus(bool flag) |
506 { | 506 { |
507 LabelableElement::setFocus(flag); | 507 LabelableElement::setFocus(flag); |
508 | 508 |
509 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 509 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
510 dispatchFormControlChangeEvent(); | 510 dispatchFormControlChangeEvent(); |
511 } | 511 } |
512 | 512 |
513 } // namespace Webcore | 513 } // namespace Webcore |
OLD | NEW |