Index: Source/core/dom/Element.cpp |
diff --git a/Source/core/dom/Element.cpp b/Source/core/dom/Element.cpp |
index 0253525e3481a27a63fbedffb0bd68d3fdddb7af..4ddf601f274d422f5970fa857f7bb100efaa49b2 100644 |
--- a/Source/core/dom/Element.cpp |
+++ b/Source/core/dom/Element.cpp |
@@ -2126,6 +2126,12 @@ bool Element::supportsFocus() const |
|| supportsSpatialNavigationFocus(); |
} |
+bool Element::shouldHaveFocusAppearance() const |
+{ |
+ ASSERT(focused()); |
+ return shouldShowFocusRingOnMouseFocus() || !shouldHideFocusRingOnMouseFocus(); |
+} |
+ |
bool Element::supportsSpatialNavigationFocus() const |
{ |
// This function checks whether the element satisfies the extended criteria |
@@ -2164,8 +2170,24 @@ bool Element::isMouseFocusable() const |
return isFocusable(); |
} |
-void Element::dispatchFocusEvent(Element* oldFocusedElement, FocusType) |
+void Element::willCallDefaultEventHandler(const Event& event) |
+{ |
+ if (!event.isKeyboardEvent() || event.type() != EventTypeNames::keydown) |
+ return; |
+ if (!shouldHideFocusRingOnMouseFocus()) |
+ return; |
+ |
+ ensureUniqueElementData().m_shouldHideFocusRingOnMouseFocus = false; |
+ // Focus changes could affect the focus ring appearance if the focus ring is not shown by default on mouse focus. |
+ if (renderer()) |
+ renderer()->setShouldDoFullPaintInvalidation(true); |
+} |
+ |
+void Element::dispatchFocusEvent(Element* oldFocusedElement, FocusType type) |
{ |
+ if (type != FocusTypePage && !shouldShowFocusRingOnMouseFocus()) |
+ ensureUniqueElementData().m_shouldHideFocusRingOnMouseFocus = type == FocusTypeMouse; |
+ |
RefPtrWillBeRawPtr<FocusEvent> event = FocusEvent::create(EventTypeNames::focus, false, false, document().domWindow(), 0, oldFocusedElement); |
EventDispatcher::dispatchEvent(this, FocusEventDispatchMediator::create(event.release())); |
} |