| Index: Source/core/input/EventHandler.cpp
|
| diff --git a/Source/core/input/EventHandler.cpp b/Source/core/input/EventHandler.cpp
|
| index 6de87e31af73df1a1f2000de30e5dc1701f63e33..41003478ecf59c73c7289fca2080a26f331f6996 100644
|
| --- a/Source/core/input/EventHandler.cpp
|
| +++ b/Source/core/input/EventHandler.cpp
|
| @@ -2071,6 +2071,8 @@ bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted
|
| // clear swallowEvent if the page already set it (e.g., by canceling
|
| // default behavior).
|
| if (element) {
|
| + if (slideFocusOnShadowHostIfNecessary(*element))
|
| + return true;
|
| if (!page->focusController().setFocusedElement(element, m_frame, WebFocusTypeMouse))
|
| return true;
|
| } else {
|
| @@ -2086,6 +2088,28 @@ bool EventHandler::handleMouseFocus(const MouseEventWithHitTestResults& targeted
|
| return false;
|
| }
|
|
|
| +bool EventHandler::slideFocusOnShadowHostIfNecessary(const Element& element)
|
| +{
|
| + if (element.shadowRoot() && element.shadowRoot()->delegatesFocus()) {
|
| + Document* doc = m_frame->document();
|
| + if (element.containsIncludingShadowDOM(doc->focusedElement())) {
|
| + // If the inner element is already focused, do nothing.
|
| + return true;
|
| + }
|
| +
|
| + // If the host has a focusable inner element, focus it. Otherwise, the host takes focus.
|
| + Page* page = m_frame->page();
|
| + ASSERT(page);
|
| + Node* next = page->focusController().findFocusableNode(WebFocusTypeForward, *element.shadowRoot());
|
| + if (next && next->isElementNode() && element.containsIncludingShadowDOM(next)) {
|
| + // Use WebFocusTypeForward instead of WebFocusTypeMouse here to mean the focus has slided.
|
| + toElement(next)->focus(false, WebFocusTypeForward);
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| +}
|
| +
|
| bool EventHandler::handleWheelEvent(const PlatformWheelEvent& event)
|
| {
|
| #define RETURN_WHEEL_EVENT_HANDLED() \
|
|
|