| 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } else if (name == disabledAttr) { | 145 } else if (name == disabledAttr) { |
| 146 bool oldDisabled = m_disabled; | 146 bool oldDisabled = m_disabled; |
| 147 m_disabled = !value.isNull(); | 147 m_disabled = !value.isNull(); |
| 148 if (oldDisabled != m_disabled) | 148 if (oldDisabled != m_disabled) |
| 149 disabledAttributeChanged(); | 149 disabledAttributeChanged(); |
| 150 } else if (name == readonlyAttr) { | 150 } else if (name == readonlyAttr) { |
| 151 bool wasReadOnly = m_isReadOnly; | 151 bool wasReadOnly = m_isReadOnly; |
| 152 m_isReadOnly = !value.isNull(); | 152 m_isReadOnly = !value.isNull(); |
| 153 if (wasReadOnly != m_isReadOnly) { | 153 if (wasReadOnly != m_isReadOnly) { |
| 154 setNeedsWillValidateCheck(); | 154 setNeedsWillValidateCheck(); |
| 155 setNeedsStyleRecalc(SubtreeStyleChange); | 155 setNeedsStyleRecalc(StyleChangeReasonForTracing::fromAttribute(name)
, SubtreeStyleChange); |
| 156 if (renderer() && renderer()->style()->hasAppearance()) | 156 if (renderer() && renderer()->style()->hasAppearance()) |
| 157 RenderTheme::theme().stateChanged(renderer(), ReadOnlyControlSta
te); | 157 RenderTheme::theme().stateChanged(renderer(), ReadOnlyControlSta
te); |
| 158 } | 158 } |
| 159 } else if (name == requiredAttr) { | 159 } else if (name == requiredAttr) { |
| 160 bool wasRequired = m_isRequired; | 160 bool wasRequired = m_isRequired; |
| 161 m_isRequired = !value.isNull(); | 161 m_isRequired = !value.isNull(); |
| 162 if (wasRequired != m_isRequired) | 162 if (wasRequired != m_isRequired) |
| 163 requiredAttributeChanged(); | 163 requiredAttributeChanged(); |
| 164 UseCounter::count(document(), UseCounter::RequiredAttribute); | 164 UseCounter::count(document(), UseCounter::RequiredAttribute); |
| 165 } else if (name == autofocusAttr) { | 165 } else if (name == autofocusAttr) { |
| 166 HTMLElement::parseAttribute(name, value); | 166 HTMLElement::parseAttribute(name, value); |
| 167 UseCounter::count(document(), UseCounter::AutoFocusAttribute); | 167 UseCounter::count(document(), UseCounter::AutoFocusAttribute); |
| 168 } else | 168 } else |
| 169 HTMLElement::parseAttribute(name, value); | 169 HTMLElement::parseAttribute(name, value); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void HTMLFormControlElement::disabledAttributeChanged() | 172 void HTMLFormControlElement::disabledAttributeChanged() |
| 173 { | 173 { |
| 174 setNeedsWillValidateCheck(); | 174 setNeedsWillValidateCheck(); |
| 175 didAffectSelector(AffectedSelectorDisabled | AffectedSelectorEnabled); | 175 didAffectSelector(StyleChangeReasonForTracing::createWithExtraData(StyleChan
geReason::PseudoClass, StyleChangeExtraData::Disabled), AffectedSelectorDisabled
| AffectedSelectorEnabled); |
| 176 if (renderer() && renderer()->style()->hasAppearance()) | 176 if (renderer() && renderer()->style()->hasAppearance()) |
| 177 RenderTheme::theme().stateChanged(renderer(), EnabledControlState); | 177 RenderTheme::theme().stateChanged(renderer(), EnabledControlState); |
| 178 if (isDisabledFormControl() && treeScope().adjustedFocusedElement() == this)
{ | 178 if (isDisabledFormControl() && treeScope().adjustedFocusedElement() == this)
{ |
| 179 // We might want to call blur(), but it's dangerous to dispatch events | 179 // We might want to call blur(), but it's dangerous to dispatch events |
| 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(StyleChangeReasonForTracing::fromAttribute(requiredAttr)
, SubtreeStyleChange); |
| 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(StyleChangeReasonForTracing::create(StyleChangeReason::C
ontrolValue), SubtreeStyleChange); |
| 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(StyleChangeReasonForTracing::create(StyleChangeReason::V
alidate), SubtreeStyleChange); |
| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // correctly when something which changes validity is updated. | 490 // correctly when something which changes validity is updated. |
| 491 ASSERT(m_isValid == valid()); | 491 ASSERT(m_isValid == valid()); |
| 492 } | 492 } |
| 493 return m_isValid; | 493 return m_isValid; |
| 494 } | 494 } |
| 495 | 495 |
| 496 void HTMLFormControlElement::setNeedsValidityCheck() | 496 void HTMLFormControlElement::setNeedsValidityCheck() |
| 497 { | 497 { |
| 498 if (!m_validityIsDirty && willValidate()) { | 498 if (!m_validityIsDirty && willValidate()) { |
| 499 // Update style for pseudo classes such as :valid :invalid. | 499 // Update style for pseudo classes such as :valid :invalid. |
| 500 setNeedsStyleRecalc(SubtreeStyleChange); | 500 setNeedsStyleRecalc(StyleChangeReasonForTracing::create(StyleChangeReaso
n::Validate), SubtreeStyleChange); |
| 501 m_validityIsDirty = true; | 501 m_validityIsDirty = true; |
| 502 } | 502 } |
| 503 | 503 |
| 504 // Updates only if this control already has a validation message. | 504 // Updates only if this control already has a validation message. |
| 505 if (isValidationMessageVisible()) { | 505 if (isValidationMessageVisible()) { |
| 506 // Calls updateVisibleValidationMessage() even if m_isValid is not | 506 // Calls updateVisibleValidationMessage() even if m_isValid is not |
| 507 // changed because a validation message can be changed. | 507 // changed because a validation message can be changed. |
| 508 updateVisibleValidationMessage(); | 508 updateVisibleValidationMessage(); |
| 509 } | 509 } |
| 510 } | 510 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 | 551 |
| 552 void HTMLFormControlElement::setFocus(bool flag) | 552 void HTMLFormControlElement::setFocus(bool flag) |
| 553 { | 553 { |
| 554 LabelableElement::setFocus(flag); | 554 LabelableElement::setFocus(flag); |
| 555 | 555 |
| 556 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 556 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
| 557 dispatchFormControlChangeEvent(); | 557 dispatchFormControlChangeEvent(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 } // namespace blink | 560 } // namespace blink |
| OLD | NEW |