Advertisement
Guest User

Source/core/dom/FocusableElement.cpp

a guest
Aug 22nd, 2014
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. // Copyright 2014 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4.  
  5. #include "config.h"
  6. #include "code/dom/FocusableElement.h"
  7.  
  8. namespace blink {
  9.  
  10. template <class ElementT>
  11. FocusableElement::FocusableElement()
  12.     : m_wasFocusedByMouse(false)
  13. {
  14. }
  15.  
  16. template <class ElementT>
  17. bool FocusableElement<ElementT>::shouldHaveFocusAppearance() const
  18. {
  19.     ASSERT(focused());
  20.     return shouldShowFocusRingOnMouseFocus() || !m_wasFocusedByMouse;
  21. }
  22.  
  23. template <class ElementT>
  24. void FocusableElement<ElementT>::dispatchFocusEvent(Element* oldFocusedElement, FocusType type)
  25. {
  26.     if (type != FocusTypePage)
  27.         m_wasFocusedByMouse = type == FocusTypeMouse;
  28.     ElementT::dispatchFocusEvent(oldFocusedElement, type);
  29. }
  30.  
  31. template <class ElementT>
  32. void FocusableElement<ElementT>::willCallDefaultEventHandler(const Event&)
  33. {
  34.     if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown)
  35.         return;
  36.     if (!m_wasFocusedByMouse)
  37.         return;
  38.     m_wasFocusedByMouse = false;
  39.     if (renderer())
  40.         renderer()->setShouldDoFullPaintInvalidation(true);
  41. }
  42.  
  43. } // namespace blink
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement