| 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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 bool oldDisabled = m_disabled; | 152 bool oldDisabled = m_disabled; |
| 153 m_disabled = !value.isNull(); | 153 m_disabled = !value.isNull(); |
| 154 if (oldDisabled != m_disabled) | 154 if (oldDisabled != m_disabled) |
| 155 disabledAttributeChanged(); | 155 disabledAttributeChanged(); |
| 156 } else if (name == readonlyAttr) { | 156 } else if (name == readonlyAttr) { |
| 157 bool wasReadOnly = m_isReadOnly; | 157 bool wasReadOnly = m_isReadOnly; |
| 158 m_isReadOnly = !value.isNull(); | 158 m_isReadOnly = !value.isNull(); |
| 159 if (wasReadOnly != m_isReadOnly) { | 159 if (wasReadOnly != m_isReadOnly) { |
| 160 setNeedsWillValidateCheck(); | 160 setNeedsWillValidateCheck(); |
| 161 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:fromAttribute(name)); | 161 setNeedsStyleRecalc(SubtreeStyleChange, StyleChangeReasonForTracing:
:fromAttribute(name)); |
| 162 if (renderer() && renderer()->style()->hasAppearance()) | 162 if (layoutObject() && layoutObject()->style()->hasAppearance()) |
| 163 LayoutTheme::theme().stateChanged(renderer(), ReadOnlyControlSta
te); | 163 LayoutTheme::theme().stateChanged(layoutObject(), ReadOnlyContro
lState); |
| 164 } | 164 } |
| 165 } else if (name == requiredAttr) { | 165 } else if (name == requiredAttr) { |
| 166 bool wasRequired = m_isRequired; | 166 bool wasRequired = m_isRequired; |
| 167 m_isRequired = !value.isNull(); | 167 m_isRequired = !value.isNull(); |
| 168 if (wasRequired != m_isRequired) | 168 if (wasRequired != m_isRequired) |
| 169 requiredAttributeChanged(); | 169 requiredAttributeChanged(); |
| 170 UseCounter::count(document(), UseCounter::RequiredAttribute); | 170 UseCounter::count(document(), UseCounter::RequiredAttribute); |
| 171 } else if (name == autofocusAttr) { | 171 } else if (name == autofocusAttr) { |
| 172 HTMLElement::parseAttribute(name, value); | 172 HTMLElement::parseAttribute(name, value); |
| 173 UseCounter::count(document(), UseCounter::AutoFocusAttribute); | 173 UseCounter::count(document(), UseCounter::AutoFocusAttribute); |
| 174 } else | 174 } else |
| 175 HTMLElement::parseAttribute(name, value); | 175 HTMLElement::parseAttribute(name, value); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void HTMLFormControlElement::disabledAttributeChanged() | 178 void HTMLFormControlElement::disabledAttributeChanged() |
| 179 { | 179 { |
| 180 setNeedsWillValidateCheck(); | 180 setNeedsWillValidateCheck(); |
| 181 pseudoStateChanged(CSSSelector::PseudoDisabled); | 181 pseudoStateChanged(CSSSelector::PseudoDisabled); |
| 182 pseudoStateChanged(CSSSelector::PseudoEnabled); | 182 pseudoStateChanged(CSSSelector::PseudoEnabled); |
| 183 if (renderer() && renderer()->style()->hasAppearance()) | 183 if (layoutObject() && layoutObject()->style()->hasAppearance()) |
| 184 LayoutTheme::theme().stateChanged(renderer(), EnabledControlState); | 184 LayoutTheme::theme().stateChanged(layoutObject(), EnabledControlState); |
| 185 if (isDisabledFormControl() && treeScope().adjustedFocusedElement() == this)
{ | 185 if (isDisabledFormControl() && treeScope().adjustedFocusedElement() == this)
{ |
| 186 // We might want to call blur(), but it's dangerous to dispatch events | 186 // We might want to call blur(), but it's dangerous to dispatch events |
| 187 // here. | 187 // here. |
| 188 document().setNeedsFocusedElementCheck(); | 188 document().setNeedsFocusedElementCheck(); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 | 191 |
| 192 void HTMLFormControlElement::requiredAttributeChanged() | 192 void HTMLFormControlElement::requiredAttributeChanged() |
| 193 { | 193 { |
| 194 setNeedsValidityCheck(); | 194 setNeedsValidityCheck(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 225 return false; | 225 return false; |
| 226 } | 226 } |
| 227 | 227 |
| 228 return true; | 228 return true; |
| 229 } | 229 } |
| 230 | 230 |
| 231 void HTMLFormControlElement::attach(const AttachContext& context) | 231 void HTMLFormControlElement::attach(const AttachContext& context) |
| 232 { | 232 { |
| 233 HTMLElement::attach(context); | 233 HTMLElement::attach(context); |
| 234 | 234 |
| 235 if (!renderer()) | 235 if (!layoutObject()) |
| 236 return; | 236 return; |
| 237 | 237 |
| 238 // The call to updateFromElement() needs to go after the call through | 238 // The call to updateFromElement() needs to go after the call through |
| 239 // to the base class's attach() because that can sometimes do a close | 239 // to the base class's attach() because that can sometimes do a close |
| 240 // on the renderer. | 240 // on the renderer. |
| 241 renderer()->updateFromElement(); | 241 layoutObject()->updateFromElement(); |
| 242 | 242 |
| 243 // FIXME: Autofocus handling should be moved to insertedInto according to | 243 // FIXME: Autofocus handling should be moved to insertedInto according to |
| 244 // the standard. | 244 // the standard. |
| 245 if (shouldAutofocusOnAttach(this)) | 245 if (shouldAutofocusOnAttach(this)) |
| 246 document().setAutofocusElement(this); | 246 document().setAutofocusElement(this); |
| 247 } | 247 } |
| 248 | 248 |
| 249 void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument) | 249 void HTMLFormControlElement::didMoveToNewDocument(Document& oldDocument) |
| 250 { | 250 { |
| 251 FormAssociatedElement::didMoveToNewDocument(oldDocument); | 251 FormAssociatedElement::didMoveToNewDocument(oldDocument); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 return m_isRequired; | 353 return m_isRequired; |
| 354 } | 354 } |
| 355 | 355 |
| 356 String HTMLFormControlElement::resultForDialogSubmit() | 356 String HTMLFormControlElement::resultForDialogSubmit() |
| 357 { | 357 { |
| 358 return fastGetAttribute(valueAttr); | 358 return fastGetAttribute(valueAttr); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void HTMLFormControlElement::didRecalcStyle(StyleRecalcChange) | 361 void HTMLFormControlElement::didRecalcStyle(StyleRecalcChange) |
| 362 { | 362 { |
| 363 if (LayoutObject* renderer = this->renderer()) | 363 if (LayoutObject* renderer = this->layoutObject()) |
| 364 renderer->updateFromElement(); | 364 renderer->updateFromElement(); |
| 365 } | 365 } |
| 366 | 366 |
| 367 bool HTMLFormControlElement::supportsFocus() const | 367 bool HTMLFormControlElement::supportsFocus() const |
| 368 { | 368 { |
| 369 return !isDisabledFormControl(); | 369 return !isDisabledFormControl(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 bool HTMLFormControlElement::isKeyboardFocusable() const | 372 bool HTMLFormControlElement::isKeyboardFocusable() const |
| 373 { | 373 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 392 HTMLElement::dispatchFocusEvent(oldFocusedElement, type); | 392 HTMLElement::dispatchFocusEvent(oldFocusedElement, type); |
| 393 } | 393 } |
| 394 | 394 |
| 395 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event) | 395 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event) |
| 396 { | 396 { |
| 397 if (!m_wasFocusedByMouse) | 397 if (!m_wasFocusedByMouse) |
| 398 return; | 398 return; |
| 399 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) | 399 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) |
| 400 return; | 400 return; |
| 401 m_wasFocusedByMouse = false; | 401 m_wasFocusedByMouse = false; |
| 402 if (renderer()) | 402 if (layoutObject()) |
| 403 renderer()->setShouldDoFullPaintInvalidation(); | 403 layoutObject()->setShouldDoFullPaintInvalidation(); |
| 404 } | 404 } |
| 405 | 405 |
| 406 short HTMLFormControlElement::tabIndex() const | 406 short HTMLFormControlElement::tabIndex() const |
| 407 { | 407 { |
| 408 // Skip the supportsFocus check in HTMLElement. | 408 // Skip the supportsFocus check in HTMLElement. |
| 409 return Element::tabIndex(); | 409 return Element::tabIndex(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 bool HTMLFormControlElement::recalcWillValidate() const | 412 bool HTMLFormControlElement::recalcWillValidate() const |
| 413 { | 413 { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 if (!m_willValidate) | 449 if (!m_willValidate) |
| 450 hideVisibleValidationMessage(); | 450 hideVisibleValidationMessage(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void HTMLFormControlElement::findCustomValidationMessageTextDirection(const Stri
ng& message, TextDirection &messageDir, String& subMessage, TextDirection &subMe
ssageDir) | 453 void HTMLFormControlElement::findCustomValidationMessageTextDirection(const Stri
ng& message, TextDirection &messageDir, String& subMessage, TextDirection &subMe
ssageDir) |
| 454 { | 454 { |
| 455 bool hasStrongDirection; | 455 bool hasStrongDirection; |
| 456 subMessage = fastGetAttribute(titleAttr); | 456 subMessage = fastGetAttribute(titleAttr); |
| 457 messageDir = determineDirectionality(message, hasStrongDirection); | 457 messageDir = determineDirectionality(message, hasStrongDirection); |
| 458 if (!subMessage.isEmpty()) | 458 if (!subMessage.isEmpty()) |
| 459 subMessageDir = renderer()->style()->direction(); | 459 subMessageDir = layoutObject()->style()->direction(); |
| 460 } | 460 } |
| 461 | 461 |
| 462 void HTMLFormControlElement::updateVisibleValidationMessage() | 462 void HTMLFormControlElement::updateVisibleValidationMessage() |
| 463 { | 463 { |
| 464 Page* page = document().page(); | 464 Page* page = document().page(); |
| 465 if (!page) | 465 if (!page) |
| 466 return; | 466 return; |
| 467 String message; | 467 String message; |
| 468 if (renderer() && willValidate()) | 468 if (layoutObject() && willValidate()) |
| 469 message = validationMessage().stripWhiteSpace(); | 469 message = validationMessage().stripWhiteSpace(); |
| 470 | 470 |
| 471 m_hasValidationMessage = true; | 471 m_hasValidationMessage = true; |
| 472 ValidationMessageClient* client = &page->validationMessageClient(); | 472 ValidationMessageClient* client = &page->validationMessageClient(); |
| 473 TextDirection messageDir = LTR; | 473 TextDirection messageDir = LTR; |
| 474 TextDirection subMessageDir = LTR; | 474 TextDirection subMessageDir = LTR; |
| 475 String subMessage = String(); | 475 String subMessage = String(); |
| 476 if (message.isEmpty()) | 476 if (message.isEmpty()) |
| 477 client->hideValidationMessage(*this); | 477 client->hideValidationMessage(*this); |
| 478 else | 478 else |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 535 |
| 536 bool HTMLFormControlElement::reportValidity() | 536 bool HTMLFormControlElement::reportValidity() |
| 537 { | 537 { |
| 538 WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement> > unhandledInval
idControls; | 538 WillBeHeapVector<RefPtrWillBeMember<HTMLFormControlElement> > unhandledInval
idControls; |
| 539 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc
hInvalidEvent); | 539 bool isValid = checkValidity(&unhandledInvalidControls, CheckValidityDispatc
hInvalidEvent); |
| 540 if (isValid || unhandledInvalidControls.isEmpty()) | 540 if (isValid || unhandledInvalidControls.isEmpty()) |
| 541 return isValid; | 541 return isValid; |
| 542 ASSERT(unhandledInvalidControls.size() == 1); | 542 ASSERT(unhandledInvalidControls.size() == 1); |
| 543 ASSERT(unhandledInvalidControls[0].get() == this); | 543 ASSERT(unhandledInvalidControls[0].get() == this); |
| 544 // Update layout now before calling isFocusable(), which has | 544 // Update layout now before calling isFocusable(), which has |
| 545 // !renderer()->needsLayout() assertion. | 545 // !layoutObject()->needsLayout() assertion. |
| 546 document().updateLayoutIgnorePendingStylesheets(); | 546 document().updateLayoutIgnorePendingStylesheets(); |
| 547 if (isFocusable()) { | 547 if (isFocusable()) { |
| 548 showValidationMessage(); | 548 showValidationMessage(); |
| 549 return false; | 549 return false; |
| 550 } | 550 } |
| 551 if (document().frame()) { | 551 if (document().frame()) { |
| 552 String message("An invalid form control with name='%name' is not focusab
le."); | 552 String message("An invalid form control with name='%name' is not focusab
le."); |
| 553 message.replace("%name", name()); | 553 message.replace("%name", name()); |
| 554 document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSour
ce, ErrorMessageLevel, message)); | 554 document().addConsoleMessage(ConsoleMessage::create(RenderingMessageSour
ce, ErrorMessageLevel, message)); |
| 555 } | 555 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 dispatchFormControlChangeEvent(); | 640 dispatchFormControlChangeEvent(); |
| 641 } | 641 } |
| 642 | 642 |
| 643 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element
& source) | 643 void HTMLFormControlElement::copyNonAttributePropertiesFromElement(const Element
& source) |
| 644 { | 644 { |
| 645 HTMLElement::copyNonAttributePropertiesFromElement(source); | 645 HTMLElement::copyNonAttributePropertiesFromElement(source); |
| 646 setNeedsValidityCheck(); | 646 setNeedsValidityCheck(); |
| 647 } | 647 } |
| 648 | 648 |
| 649 } // namespace blink | 649 } // namespace blink |
| OLD | NEW |