Chromium Code Reviews| Index: Source/core/page/FocusController.cpp |
| diff --git a/Source/core/page/FocusController.cpp b/Source/core/page/FocusController.cpp |
| index db3dc8cc5b048b47bc5494a8fb43bec9202693f0..ec016f6a5c0a909e81a6dc5b2e5870853f9a3349 100644 |
| --- a/Source/core/page/FocusController.cpp |
| +++ b/Source/core/page/FocusController.cpp |
| @@ -554,24 +554,25 @@ Element* FocusController::findFocusableElementRecursivelyForward(const FocusNavi |
| if (!found) |
| return nullptr; |
| if (isShadowHostDelegatesFocus(*found)) { |
| - if (isShadowHostWithoutCustomFocusLogic(*found)) { |
| + // If tabindex is positive, find focusable node inside its shadow tree. |
| + if (found->tabIndex() >= 0 && isShadowHostWithoutCustomFocusLogic(*found)) { |
| FocusNavigationScope innerScope = FocusNavigationScope::ownedByShadowHost(*found); |
| - Element* foundInInnerFocusScope = findFocusableElementRecursivelyForward(innerScope, nullptr); |
| - return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableElementRecursivelyForward(scope, found); |
| + if (Element* foundInInnerFocusScope = findFocusableElementRecursivelyForward(innerScope, nullptr)) |
| + return foundInInnerFocusScope; |
| } |
| - // Skip to the next node. |
| - if (!isNonFocusableFocusScopeOwner(*found)) |
|
kochi
2015/06/17 07:11:49
In the previous CL[1], I added this line (563) but
|
| - found = findFocusableElementRecursivelyForward(scope, found); |
| + // Skip to the next node in the same scope. |
| + found = findFocusableElementRecursivelyForward(scope, found); |
| } |
| if (!found || !isNonFocusableFocusScopeOwner(*found)) |
| return found; |
| - // Now |found| is on a focusable scope owner (either shadow host or <shadow>) |
| + // Now |found| is on a non focusable scope owner (either shadow host or <shadow>) |
|
kochi
2015/06/17 07:11:49
The comment was wrong ;(
|
| // Find inside the inward scope and return it if found. Otherwise continue searching in the same |
| // scope. |
| FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusableFocusScopeOwner(*found); |
| - Element* foundInInnerFocusScope = findFocusableElementRecursivelyForward(innerScope, nullptr); |
| - return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableElementRecursivelyForward(scope, found); |
| + if (Element* foundInInnerFocusScope = findFocusableElementRecursivelyForward(innerScope, nullptr)) |
| + return foundInInnerFocusScope; |
| + return findFocusableElementRecursivelyForward(scope, found); |
|
kochi
2015/06/17 07:11:50
This chunk does not change the logic, but aligned
|
| } |
| Element* FocusController::findFocusableElementRecursivelyBackward(const FocusNavigationScope& scope, Node* start) |
| @@ -594,6 +595,11 @@ Element* FocusController::findFocusableElementRecursivelyBackward(const FocusNav |
| return found; |
| } |
| + // If delegatesFocus is true and tabindex is negative, skip the whole shadow tree under the |
| + // shadow host. |
| + if (isShadowHostDelegatesFocus(*found) && found->tabIndex() < 0) |
| + return findFocusableElementRecursivelyBackward(scope, found); |
| + |
| // Now |found| is on a non focusable scope owner (either shadow host or <shadow>). |
| // Find focusable node in decendant scope. If not found, find next focusable node within the |
| // current scope. |