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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } else if (name == disabledAttr) { | 144 } else if (name == disabledAttr) { |
145 bool oldDisabled = m_disabled; | 145 bool oldDisabled = m_disabled; |
146 m_disabled = !value.isNull(); | 146 m_disabled = !value.isNull(); |
147 if (oldDisabled != m_disabled) | 147 if (oldDisabled != m_disabled) |
148 disabledAttributeChanged(); | 148 disabledAttributeChanged(); |
149 } else if (name == readonlyAttr) { | 149 } else if (name == readonlyAttr) { |
150 bool wasReadOnly = m_isReadOnly; | 150 bool wasReadOnly = m_isReadOnly; |
151 m_isReadOnly = !value.isNull(); | 151 m_isReadOnly = !value.isNull(); |
152 if (wasReadOnly != m_isReadOnly) { | 152 if (wasReadOnly != m_isReadOnly) { |
153 setNeedsWillValidateCheck(); | 153 setNeedsWillValidateCheck(); |
154 setNeedsStyleRecalc(SubtreeStyleChange); | 154 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:fromAttribute(name)); |
155 if (renderer() && renderer()->style()->hasAppearance()) | 155 if (renderer() && renderer()->style()->hasAppearance()) |
156 RenderTheme::theme().stateChanged(renderer(), ReadOnlyControlSta
te); | 156 RenderTheme::theme().stateChanged(renderer(), ReadOnlyControlSta
te); |
157 } | 157 } |
158 } else if (name == requiredAttr) { | 158 } else if (name == requiredAttr) { |
159 bool wasRequired = m_isRequired; | 159 bool wasRequired = m_isRequired; |
160 m_isRequired = !value.isNull(); | 160 m_isRequired = !value.isNull(); |
161 if (wasRequired != m_isRequired) | 161 if (wasRequired != m_isRequired) |
162 requiredAttributeChanged(); | 162 requiredAttributeChanged(); |
163 UseCounter::count(document(), UseCounter::RequiredAttribute); | 163 UseCounter::count(document(), UseCounter::RequiredAttribute); |
164 } else if (name == autofocusAttr) { | 164 } else if (name == autofocusAttr) { |
(...skipping 15 matching lines...) Expand all Loading... |
180 // here. | 180 // here. |
181 document().setNeedsFocusedElementCheck(); | 181 document().setNeedsFocusedElementCheck(); |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 void HTMLFormControlElement::requiredAttributeChanged() | 185 void HTMLFormControlElement::requiredAttributeChanged() |
186 { | 186 { |
187 setNeedsValidityCheck(); | 187 setNeedsValidityCheck(); |
188 // Style recalculation is needed because style selectors may include | 188 // Style recalculation is needed because style selectors may include |
189 // :required and :optional pseudo-classes. | 189 // :required and :optional pseudo-classes. |
190 setNeedsStyleRecalc(SubtreeStyleChange); | 190 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::fromAtt
ribute(requiredAttr)); |
191 } | 191 } |
192 | 192 |
193 bool HTMLFormControlElement::supportsAutofocus() const | 193 bool HTMLFormControlElement::supportsAutofocus() const |
194 { | 194 { |
195 return false; | 195 return false; |
196 } | 196 } |
197 | 197 |
198 bool HTMLFormControlElement::isAutofocusable() const | 198 bool HTMLFormControlElement::isAutofocusable() const |
199 { | 199 { |
200 return fastHasAttribute(autofocusAttr) && supportsAutofocus(); | 200 return fastHasAttribute(autofocusAttr) && supportsAutofocus(); |
201 } | 201 } |
202 | 202 |
203 void HTMLFormControlElement::setAutofilled(bool autofilled) | 203 void HTMLFormControlElement::setAutofilled(bool autofilled) |
204 { | 204 { |
205 if (autofilled == m_isAutofilled) | 205 if (autofilled == m_isAutofilled) |
206 return; | 206 return; |
207 | 207 |
208 m_isAutofilled = autofilled; | 208 m_isAutofilled = autofilled; |
209 setNeedsStyleRecalc(SubtreeStyleChange); | 209 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(
StyleChangeReason::ControlValue)); |
210 } | 210 } |
211 | 211 |
212 static bool shouldAutofocusOnAttach(const HTMLFormControlElement* element) | 212 static bool shouldAutofocusOnAttach(const HTMLFormControlElement* element) |
213 { | 213 { |
214 if (!element->isAutofocusable()) | 214 if (!element->isAutofocusable()) |
215 return false; | 215 return false; |
216 if (element->document().isSandboxed(SandboxAutomaticFeatures)) { | 216 if (element->document().isSandboxed(SandboxAutomaticFeatures)) { |
217 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. | 217 // FIXME: This message should be moved off the console once a solution t
o https://bugs.webkit.org/show_bug.cgi?id=103274 exists. |
218 element->document().addConsoleMessage(ConsoleMessage::create(SecurityMes
sageSource, ErrorMessageLevel, "Blocked autofocusing on a form control because t
he form's frame is sandboxed and the 'allow-scripts' permission is not set.")); | 218 element->document().addConsoleMessage(ConsoleMessage::create(SecurityMes
sageSource, ErrorMessageLevel, "Blocked autofocusing on a form control because t
he form's frame is sandboxed and the 'allow-scripts' permission is not set.")); |
219 return false; | 219 return false; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 395 |
396 void HTMLFormControlElement::setNeedsWillValidateCheck() | 396 void HTMLFormControlElement::setNeedsWillValidateCheck() |
397 { | 397 { |
398 // We need to recalculate willValidate immediately because willValidate chan
ge can causes style change. | 398 // We need to recalculate willValidate immediately because willValidate chan
ge can causes style change. |
399 bool newWillValidate = recalcWillValidate(); | 399 bool newWillValidate = recalcWillValidate(); |
400 if (m_willValidateInitialized && m_willValidate == newWillValidate) | 400 if (m_willValidateInitialized && m_willValidate == newWillValidate) |
401 return; | 401 return; |
402 m_willValidateInitialized = true; | 402 m_willValidateInitialized = true; |
403 m_willValidate = newWillValidate; | 403 m_willValidate = newWillValidate; |
404 setNeedsValidityCheck(); | 404 setNeedsValidityCheck(); |
405 setNeedsStyleRecalc(SubtreeStyleChange); | 405 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::create(
StyleChangeReason::Validate)); |
406 if (!m_willValidate) | 406 if (!m_willValidate) |
407 hideVisibleValidationMessage(); | 407 hideVisibleValidationMessage(); |
408 } | 408 } |
409 | 409 |
410 void HTMLFormControlElement::findCustomValidationMessageTextDirection(const Stri
ng& message, TextDirection &messageDir, String& subMessage, TextDirection &subMe
ssageDir) | 410 void HTMLFormControlElement::findCustomValidationMessageTextDirection(const Stri
ng& message, TextDirection &messageDir, String& subMessage, TextDirection &subMe
ssageDir) |
411 { | 411 { |
412 bool hasStrongDirection; | 412 bool hasStrongDirection; |
413 subMessage = fastGetAttribute(titleAttr); | 413 subMessage = fastGetAttribute(titleAttr); |
414 messageDir = determineDirectionality(message, hasStrongDirection); | 414 messageDir = determineDirectionality(message, hasStrongDirection); |
415 if (!subMessage.isEmpty()) | 415 if (!subMessage.isEmpty()) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 // correctly when something which changes validity is updated. | 486 // correctly when something which changes validity is updated. |
487 ASSERT(m_isValid == valid()); | 487 ASSERT(m_isValid == valid()); |
488 return m_isValid; | 488 return m_isValid; |
489 } | 489 } |
490 | 490 |
491 void HTMLFormControlElement::setNeedsValidityCheck() | 491 void HTMLFormControlElement::setNeedsValidityCheck() |
492 { | 492 { |
493 bool newIsValid = valid(); | 493 bool newIsValid = valid(); |
494 if (willValidate() && newIsValid != m_isValid) { | 494 if (willValidate() && newIsValid != m_isValid) { |
495 // Update style for pseudo classes such as :valid :invalid. | 495 // Update style for pseudo classes such as :valid :invalid. |
496 setNeedsStyleRecalc(SubtreeStyleChange); | 496 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing::cre
ateWithExtraData(StyleChangeReason::PseudoClass, StyleChangeExtraData::Invalid))
; |
497 } | 497 } |
498 m_isValid = newIsValid; | 498 m_isValid = newIsValid; |
499 | 499 |
500 // Updates only if this control already has a validation message. | 500 // Updates only if this control already has a validation message. |
501 if (isValidationMessageVisible()) { | 501 if (isValidationMessageVisible()) { |
502 // Calls updateVisibleValidationMessage() even if m_isValid is not | 502 // Calls updateVisibleValidationMessage() even if m_isValid is not |
503 // changed because a validation message can be changed. | 503 // changed because a validation message can be changed. |
504 updateVisibleValidationMessage(); | 504 updateVisibleValidationMessage(); |
505 } | 505 } |
506 } | 506 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 547 |
548 void HTMLFormControlElement::setFocus(bool flag) | 548 void HTMLFormControlElement::setFocus(bool flag) |
549 { | 549 { |
550 LabelableElement::setFocus(flag); | 550 LabelableElement::setFocus(flag); |
551 | 551 |
552 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 552 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
553 dispatchFormControlChangeEvent(); | 553 dispatchFormControlChangeEvent(); |
554 } | 554 } |
555 | 555 |
556 } // namespace blink | 556 } // namespace blink |
OLD | NEW |