Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 Nuanti Ltd. | 3 * Copyright (C) 2008 Nuanti Ltd. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 547 findFocusableElementRecursivelyBackward(scope, start); | 547 findFocusableElementRecursivelyBackward(scope, start); |
| 548 } | 548 } |
| 549 | 549 |
| 550 Element* FocusController::findFocusableElementRecursivelyForward(const FocusNavi gationScope& scope, Node* start) | 550 Element* FocusController::findFocusableElementRecursivelyForward(const FocusNavi gationScope& scope, Node* start) |
| 551 { | 551 { |
| 552 // Starting node is exclusive. | 552 // Starting node is exclusive. |
| 553 Element* found = findFocusableElement(WebFocusTypeForward, scope, start); | 553 Element* found = findFocusableElement(WebFocusTypeForward, scope, start); |
| 554 if (!found) | 554 if (!found) |
| 555 return nullptr; | 555 return nullptr; |
| 556 if (isShadowHostDelegatesFocus(*found)) { | 556 if (isShadowHostDelegatesFocus(*found)) { |
| 557 if (isShadowHostWithoutCustomFocusLogic(*found)) { | 557 // If tabindex is positive, find focusable node inside its shadow tree. |
| 558 if (found->tabIndex() >= 0 && isShadowHostWithoutCustomFocusLogic(*found )) { | |
| 558 FocusNavigationScope innerScope = FocusNavigationScope::ownedByShado wHost(*found); | 559 FocusNavigationScope innerScope = FocusNavigationScope::ownedByShado wHost(*found); |
| 559 Element* foundInInnerFocusScope = findFocusableElementRecursivelyFor ward(innerScope, nullptr); | 560 if (Element* foundInInnerFocusScope = findFocusableElementRecursivel yForward(innerScope, nullptr)) |
| 560 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusab leElementRecursivelyForward(scope, found); | 561 return foundInInnerFocusScope; |
| 561 } | 562 } |
| 562 // Skip to the next node. | 563 // Skip to the next node in the same scope. |
| 563 if (!isNonFocusableFocusScopeOwner(*found)) | 564 found = findFocusableElementRecursivelyForward(scope, found); |
|
kochi
2015/06/17 07:11:49
In the previous CL[1], I added this line (563) but
| |
| 564 found = findFocusableElementRecursivelyForward(scope, found); | |
| 565 } | 565 } |
| 566 if (!found || !isNonFocusableFocusScopeOwner(*found)) | 566 if (!found || !isNonFocusableFocusScopeOwner(*found)) |
| 567 return found; | 567 return found; |
| 568 | 568 |
| 569 // Now |found| is on a focusable scope owner (either shadow host or <shadow> ) | 569 // Now |found| is on a non focusable scope owner (either shadow host or <sha dow>) |
|
kochi
2015/06/17 07:11:49
The comment was wrong ;(
| |
| 570 // Find inside the inward scope and return it if found. Otherwise continue s earching in the same | 570 // Find inside the inward scope and return it if found. Otherwise continue s earching in the same |
| 571 // scope. | 571 // scope. |
| 572 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusableF ocusScopeOwner(*found); | 572 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusableF ocusScopeOwner(*found); |
| 573 Element* foundInInnerFocusScope = findFocusableElementRecursivelyForward(inn erScope, nullptr); | 573 if (Element* foundInInnerFocusScope = findFocusableElementRecursivelyForward (innerScope, nullptr)) |
| 574 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableElemen tRecursivelyForward(scope, found); | 574 return foundInInnerFocusScope; |
| 575 return findFocusableElementRecursivelyForward(scope, found); | |
|
kochi
2015/06/17 07:11:50
This chunk does not change the logic, but aligned
| |
| 575 } | 576 } |
| 576 | 577 |
| 577 Element* FocusController::findFocusableElementRecursivelyBackward(const FocusNav igationScope& scope, Node* start) | 578 Element* FocusController::findFocusableElementRecursivelyBackward(const FocusNav igationScope& scope, Node* start) |
| 578 { | 579 { |
| 579 // Starting node is exclusive. | 580 // Starting node is exclusive. |
| 580 Element* found = findFocusableElement(WebFocusTypeBackward, scope, start); | 581 Element* found = findFocusableElement(WebFocusTypeBackward, scope, start); |
| 581 if (!found) | 582 if (!found) |
| 582 return nullptr; | 583 return nullptr; |
| 583 | 584 |
| 584 // Now |found| is on a focusable shadow host. | 585 // Now |found| is on a focusable shadow host. |
| 585 // Find inside shadow backwards. If any focusable element is found, return i t, otherwise return | 586 // Find inside shadow backwards. If any focusable element is found, return i t, otherwise return |
| 586 // the host itself. | 587 // the host itself. |
| 587 if (isKeyboardFocusableShadowHost(*found)) { | 588 if (isKeyboardFocusableShadowHost(*found)) { |
| 588 FocusNavigationScope innerScope = FocusNavigationScope::ownedByShadowHos t(*found); | 589 FocusNavigationScope innerScope = FocusNavigationScope::ownedByShadowHos t(*found); |
| 589 Element* foundInInnerFocusScope = findFocusableElementRecursivelyBackwar d(innerScope, nullptr); | 590 Element* foundInInnerFocusScope = findFocusableElementRecursivelyBackwar d(innerScope, nullptr); |
| 590 if (foundInInnerFocusScope) | 591 if (foundInInnerFocusScope) |
| 591 return foundInInnerFocusScope; | 592 return foundInInnerFocusScope; |
| 592 if (isShadowHostDelegatesFocus(*found)) | 593 if (isShadowHostDelegatesFocus(*found)) |
| 593 found = findFocusableElementRecursivelyBackward(scope, found); | 594 found = findFocusableElementRecursivelyBackward(scope, found); |
| 594 return found; | 595 return found; |
| 595 } | 596 } |
| 596 | 597 |
| 598 // If delegatesFocus is true and tabindex is negative, skip the whole shadow tree under the | |
| 599 // shadow host. | |
| 600 if (isShadowHostDelegatesFocus(*found) && found->tabIndex() < 0) | |
| 601 return findFocusableElementRecursivelyBackward(scope, found); | |
| 602 | |
| 597 // Now |found| is on a non focusable scope owner (either shadow host or <sha dow>). | 603 // Now |found| is on a non focusable scope owner (either shadow host or <sha dow>). |
| 598 // Find focusable node in decendant scope. If not found, find next focusable node within the | 604 // Find focusable node in decendant scope. If not found, find next focusable node within the |
| 599 // current scope. | 605 // current scope. |
| 600 if (isNonFocusableFocusScopeOwner(*found)) { | 606 if (isNonFocusableFocusScopeOwner(*found)) { |
| 601 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusa bleFocusScopeOwner(*found); | 607 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusa bleFocusScopeOwner(*found); |
| 602 Element* foundInInnerFocusScope = findFocusableElementRecursivelyBackwar d(innerScope, nullptr); | 608 Element* foundInInnerFocusScope = findFocusableElementRecursivelyBackwar d(innerScope, nullptr); |
| 603 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableEl ementRecursivelyBackward(scope, found); | 609 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableEl ementRecursivelyBackward(scope, found); |
| 604 } | 610 } |
| 605 | 611 |
| 606 return !isShadowHostDelegatesFocus(*found) ? found : findFocusableElementRec ursivelyBackward(scope, found); | 612 return !isShadowHostDelegatesFocus(*found) ? found : findFocusableElementRec ursivelyBackward(scope, found); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1019 return consumed; | 1025 return consumed; |
| 1020 } | 1026 } |
| 1021 | 1027 |
| 1022 DEFINE_TRACE(FocusController) | 1028 DEFINE_TRACE(FocusController) |
| 1023 { | 1029 { |
| 1024 visitor->trace(m_page); | 1030 visitor->trace(m_page); |
| 1025 visitor->trace(m_focusedFrame); | 1031 visitor->trace(m_focusedFrame); |
| 1026 } | 1032 } |
| 1027 | 1033 |
| 1028 } // namespace blink | 1034 } // namespace blink |
| OLD | NEW |