| Index: third_party/WebKit/Source/core/page/FocusController.cpp
|
| diff --git a/third_party/WebKit/Source/core/page/FocusController.cpp b/third_party/WebKit/Source/core/page/FocusController.cpp
|
| index 180f66033404f3c61646f90656a2bfed7c524918..bcc8233a6c687914aba41f571c2009ed7d97c475 100644
|
| --- a/third_party/WebKit/Source/core/page/FocusController.cpp
|
| +++ b/third_party/WebKit/Source/core/page/FocusController.cpp
|
| @@ -71,6 +71,37 @@ inline bool isShadowInsertionPointFocusScopeOwner(Element& element) {
|
| toHTMLShadowElement(element).olderShadowRoot();
|
| }
|
|
|
| +inline bool hasCustomFocusLogic(const Element& element) {
|
| + return element.isHTMLElement() &&
|
| + toHTMLElement(element).hasCustomFocusLogic();
|
| +}
|
| +
|
| +inline bool isShadowHostWithoutCustomFocusLogic(const Element& element) {
|
| + return isShadowHost(element) && !hasCustomFocusLogic(element);
|
| +}
|
| +
|
| +inline bool isNonKeyboardFocusableShadowHost(const Element& element) {
|
| + return isShadowHostWithoutCustomFocusLogic(element) &&
|
| + !(element.shadowRootIfV1() ? element.isFocusable()
|
| + : element.isKeyboardFocusable());
|
| +}
|
| +
|
| +inline bool isKeyboardFocusableShadowHost(const Element& element) {
|
| + return isShadowHostWithoutCustomFocusLogic(element) &&
|
| + element.isKeyboardFocusable();
|
| +}
|
| +
|
| +inline bool isNonFocusableFocusScopeOwner(Element& element) {
|
| + return isNonKeyboardFocusableShadowHost(element) ||
|
| + isShadowInsertionPointFocusScopeOwner(element) ||
|
| + isHTMLSlotElement(element);
|
| +}
|
| +
|
| +inline bool isShadowHostDelegatesFocus(const Element& element) {
|
| + return element.authorShadowRoot() &&
|
| + element.authorShadowRoot()->delegatesFocus();
|
| +}
|
| +
|
| class ScopedFocusNavigation {
|
| STACK_ALLOCATED();
|
|
|
| @@ -203,11 +234,25 @@ void ScopedFocusNavigation::moveToLast() {
|
| HeapVector<Member<Node>> assignedNodes = m_rootSlot->assignedNodes();
|
| for (auto assignedNode = assignedNodes.rbegin();
|
| assignedNode != assignedNodes.rend(); ++assignedNode) {
|
| - if ((*assignedNode)->isElementNode()) {
|
| - m_current =
|
| - ElementTraversal::lastWithinOrSelf(*toElement(*assignedNode));
|
| - break;
|
| + if (!(*assignedNode)->isElementNode())
|
| + continue;
|
| +
|
| + Element* last = ElementTraversal::lastWithin(*toElement(*assignedNode));
|
| + if (!last) {
|
| + m_current = toElement(*assignedNode);
|
| + } else {
|
| + while (last) {
|
| + Element* ancestor =
|
| + SlotScopedTraversal::nearestAncestorAssignedToSlot(*last);
|
| + DCHECK(ancestor);
|
| + if (ancestor == *assignedNode)
|
| + break;
|
| + last = ancestor->parentElement();
|
| + }
|
| + DCHECK(last);
|
| + m_current = last;
|
| }
|
| + break;
|
| }
|
| } else {
|
| Element* last = ElementTraversal::lastWithin(*m_rootSlot);
|
| @@ -380,37 +425,6 @@ inline void dispatchEventsOnWindowAndFocusedElement(Document* document,
|
| }
|
| }
|
|
|
| -inline bool hasCustomFocusLogic(const Element& element) {
|
| - return element.isHTMLElement() &&
|
| - toHTMLElement(element).hasCustomFocusLogic();
|
| -}
|
| -
|
| -inline bool isShadowHostWithoutCustomFocusLogic(const Element& element) {
|
| - return isShadowHost(element) && !hasCustomFocusLogic(element);
|
| -}
|
| -
|
| -inline bool isNonKeyboardFocusableShadowHost(const Element& element) {
|
| - return isShadowHostWithoutCustomFocusLogic(element) &&
|
| - !(element.shadowRootIfV1() ? element.isFocusable()
|
| - : element.isKeyboardFocusable());
|
| -}
|
| -
|
| -inline bool isKeyboardFocusableShadowHost(const Element& element) {
|
| - return isShadowHostWithoutCustomFocusLogic(element) &&
|
| - element.isKeyboardFocusable();
|
| -}
|
| -
|
| -inline bool isNonFocusableFocusScopeOwner(Element& element) {
|
| - return isNonKeyboardFocusableShadowHost(element) ||
|
| - isShadowInsertionPointFocusScopeOwner(element) ||
|
| - isHTMLSlotElement(element);
|
| -}
|
| -
|
| -inline bool isShadowHostDelegatesFocus(const Element& element) {
|
| - return element.authorShadowRoot() &&
|
| - element.authorShadowRoot()->delegatesFocus();
|
| -}
|
| -
|
| inline int adjustedTabIndex(Element& element) {
|
| return (isNonKeyboardFocusableShadowHost(element) ||
|
| isShadowInsertionPointFocusScopeOwner(element))
|
|
|