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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 { | 326 { |
327 // Skip tabIndex check in a parent class. | 327 // Skip tabIndex check in a parent class. |
328 return isFocusable(); | 328 return isFocusable(); |
329 } | 329 } |
330 | 330 |
331 bool HTMLFormControlElement::shouldShowFocusRingOnMouseFocus() const | 331 bool HTMLFormControlElement::shouldShowFocusRingOnMouseFocus() const |
332 { | 332 { |
333 return false; | 333 return false; |
334 } | 334 } |
335 | 335 |
336 void HTMLFormControlElement::dispatchFocusEvent(Element* oldFocusedElement, Focu
sType type) | |
337 { | |
338 if (type != FocusTypePage) | |
339 m_wasFocusedByMouse = type == FocusTypeMouse; | |
340 HTMLElement::dispatchFocusEvent(oldFocusedElement, type); | |
341 } | |
342 | |
343 bool HTMLFormControlElement::shouldHaveFocusAppearance() const | 336 bool HTMLFormControlElement::shouldHaveFocusAppearance() const |
344 { | 337 { |
345 ASSERT(focused()); | 338 return !m_wasFocusedByMouse || shouldShowFocusRingOnMouseFocus(); |
346 return shouldShowFocusRingOnMouseFocus() || !m_wasFocusedByMouse; | |
347 } | 339 } |
348 | 340 |
349 void HTMLFormControlElement::willCallDefaultEventHandler(const Event& event) | 341 bool HTMLFormControlElement::wasFocusedByMouse() const |
350 { | 342 { |
351 if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) | 343 return m_wasFocusedByMouse; |
352 return; | |
353 if (!m_wasFocusedByMouse) | |
354 return; | |
355 m_wasFocusedByMouse = false; | |
356 if (renderer()) | |
357 renderer()->setShouldDoFullPaintInvalidation(true); | |
358 } | 344 } |
359 | 345 |
| 346 void HTMLFormControlElement::setWasFocusedByMouse(bool wasFocusedByMouse) |
| 347 { |
| 348 m_wasFocusedByMouse = wasFocusedByMouse; |
| 349 } |
360 | 350 |
361 short HTMLFormControlElement::tabIndex() const | 351 short HTMLFormControlElement::tabIndex() const |
362 { | 352 { |
363 // Skip the supportsFocus check in HTMLElement. | 353 // Skip the supportsFocus check in HTMLElement. |
364 return Element::tabIndex(); | 354 return Element::tabIndex(); |
365 } | 355 } |
366 | 356 |
367 bool HTMLFormControlElement::recalcWillValidate() const | 357 bool HTMLFormControlElement::recalcWillValidate() const |
368 { | 358 { |
369 if (m_dataListAncestorState == Unknown) { | 359 if (m_dataListAncestorState == Unknown) { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 | 537 |
548 void HTMLFormControlElement::setFocus(bool flag) | 538 void HTMLFormControlElement::setFocus(bool flag) |
549 { | 539 { |
550 LabelableElement::setFocus(flag); | 540 LabelableElement::setFocus(flag); |
551 | 541 |
552 if (!flag && wasChangedSinceLastFormControlChangeEvent()) | 542 if (!flag && wasChangedSinceLastFormControlChangeEvent()) |
553 dispatchFormControlChangeEvent(); | 543 dispatchFormControlChangeEvent(); |
554 } | 544 } |
555 | 545 |
556 } // namespace Webcore | 546 } // namespace Webcore |
OLD | NEW |