| 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 15 matching lines...) Expand all Loading... |
| 26 #include "core/html/HTMLFormControlElement.h" | 26 #include "core/html/HTMLFormControlElement.h" |
| 27 | 27 |
| 28 #include "core/events/Event.h" | 28 #include "core/events/Event.h" |
| 29 #include "core/html/HTMLDataListElement.h" | 29 #include "core/html/HTMLDataListElement.h" |
| 30 #include "core/html/HTMLFieldSetElement.h" | 30 #include "core/html/HTMLFieldSetElement.h" |
| 31 #include "core/html/HTMLFormElement.h" | 31 #include "core/html/HTMLFormElement.h" |
| 32 #include "core/html/HTMLInputElement.h" | 32 #include "core/html/HTMLInputElement.h" |
| 33 #include "core/html/HTMLLegendElement.h" | 33 #include "core/html/HTMLLegendElement.h" |
| 34 #include "core/html/ValidityState.h" | 34 #include "core/html/ValidityState.h" |
| 35 #include "core/frame/UseCounter.h" | 35 #include "core/frame/UseCounter.h" |
| 36 #include "core/page/FocusController.h" |
| 36 #include "core/page/Page.h" | 37 #include "core/page/Page.h" |
| 37 #include "core/page/ValidationMessageClient.h" | 38 #include "core/page/ValidationMessageClient.h" |
| 38 #include "core/rendering/RenderBox.h" | 39 #include "core/rendering/RenderBox.h" |
| 39 #include "core/rendering/RenderTheme.h" | 40 #include "core/rendering/RenderTheme.h" |
| 40 #include "wtf/Vector.h" | 41 #include "wtf/Vector.h" |
| 41 | 42 |
| 42 namespace blink { | 43 namespace blink { |
| 43 | 44 |
| 44 using namespace HTMLNames; | 45 using namespace HTMLNames; |
| 45 | 46 |
| 46 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc
ument& document, HTMLFormElement* form) | 47 HTMLFormControlElement::HTMLFormControlElement(const QualifiedName& tagName, Doc
ument& document, HTMLFormElement* form) |
| 47 : LabelableElement(tagName, document) | 48 : LabelableElement(tagName, document) |
| 48 , m_disabled(false) | 49 , m_disabled(false) |
| 49 , m_isAutofilled(false) | 50 , m_isAutofilled(false) |
| 50 , m_isReadOnly(false) | 51 , m_isReadOnly(false) |
| 51 , m_isRequired(false) | 52 , m_isRequired(false) |
| 52 , m_hasValidationMessage(false) | 53 , m_hasValidationMessage(false) |
| 53 , m_ancestorDisabledState(AncestorDisabledStateUnknown) | 54 , m_ancestorDisabledState(AncestorDisabledStateUnknown) |
| 54 , m_dataListAncestorState(Unknown) | 55 , m_dataListAncestorState(Unknown) |
| 55 , m_willValidateInitialized(false) | 56 , m_willValidateInitialized(false) |
| 56 , m_willValidate(true) | 57 , m_willValidate(true) |
| 57 , m_isValid(true) | 58 , m_isValid(true) |
| 58 , m_wasChangedSinceLastFormControlChangeEvent(false) | 59 , m_wasChangedSinceLastFormControlChangeEvent(false) |
| 59 , m_wasFocusedByMouse(false) | |
| 60 { | 60 { |
| 61 setHasCustomStyleCallbacks(); | 61 setHasCustomStyleCallbacks(); |
| 62 associateByParser(form); | 62 associateByParser(form); |
| 63 } | 63 } |
| 64 | 64 |
| 65 HTMLFormControlElement::~HTMLFormControlElement() | 65 HTMLFormControlElement::~HTMLFormControlElement() |
| 66 { | 66 { |
| 67 #if !ENABLE(OILPAN) | 67 #if !ENABLE(OILPAN) |
| 68 setForm(0); | 68 setForm(0); |
| 69 #endif | 69 #endif |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 { | 324 { |
| 325 // Skip tabIndex check in a parent class. | 325 // Skip tabIndex check in a parent class. |
| 326 return isFocusable(); | 326 return isFocusable(); |
| 327 } | 327 } |
| 328 | 328 |
| 329 bool HTMLFormControlElement::shouldShowFocusRingOnMouseFocus() const | 329 bool HTMLFormControlElement::shouldShowFocusRingOnMouseFocus() const |
| 330 { | 330 { |
| 331 return false; | 331 return false; |
| 332 } | 332 } |
| 333 | 333 |
| 334 void HTMLFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, Focu
sType type) | |
| 335 { | |
| 336 if (type != FocusTypePage) | |
| 337 m_wasFocusedByMouse = type == FocusTypeMouse; | |
| 338 HTMLElement::dispatchFocusEvent(oldFocusedElement, type); | |
| 339 } | |
| 340 | |
| 341 bool HTMLFormControlElement::shouldHaveFocusAppearance() const | 334 bool HTMLFormControlElement::shouldHaveFocusAppearance() const |
| 342 { | 335 { |
| 343 ASSERT(focused()); | 336 ASSERT(focused()); |
| 344 return shouldShowFocusRingOnMouseFocus() || !m_wasFocusedByMouse; | 337 return shouldShowFocusRingOnMouseFocus() || !document().page()->focusControl
ler().wasFocusedByMouse(); |
| 345 } | 338 } |
| 346 | 339 |
| 347 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event) | |
| 348 { | |
| 349 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) | |
| 350 return; | |
| 351 if (!m_wasFocusedByMouse) | |
| 352 return; | |
| 353 m_wasFocusedByMouse = false; | |
| 354 if (renderer()) | |
| 355 renderer()->paintInvalidationForWholeRenderer(); | |
| 356 } | |
| 357 | |
| 358 | |
| 359 short HTMLFormControlElement::tabIndex() const | 340 short HTMLFormControlElement::tabIndex() const |
| 360 { | 341 { |
| 361 // Skip the supportsFocus check in HTMLElement. | 342 // Skip the supportsFocus check in HTMLElement. |
| 362 return Element::tabIndex(); | 343 return Element::tabIndex(); |
| 363 } | 344 } |
| 364 | 345 |
| 365 bool HTMLFormControlElement::recalcWillValidate() const | 346 bool HTMLFormControlElement::recalcWillValidate() const |
| 366 { | 347 { |
| 367 if (m_dataListAncestorState == Unknown) { | 348 if (m_dataListAncestorState == Unknown) { |
| 368 if (Traversal<HTMLDataListElement>::firstAncestor(*this)) | 349 if (Traversal<HTMLDataListElement>::firstAncestor(*this)) |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 | 513 |
| 533 void HTMLFormControlElement::setFocus(bool flag) | 514 void HTMLFormControlElement::setFocus(bool flag) |
| 534 { | 515 { |
| 535 LabelableElement::setFocus(flag); | 516 LabelableElement::setFocus(flag); |
| 536 | 517 |
| 537 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 518 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
| 538 dispatchFormControlChangeEvent(); | 519 dispatchFormControlChangeEvent(); |
| 539 } | 520 } |
| 540 | 521 |
| 541 } // namespace Webcore | 522 } // namespace Webcore |
| OLD | NEW |