Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(251)

Side by Side Diff: Source/core/page/FocusController.cpp

Issue 917613004: Add isTabStop attribute to Element (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: revert status to experimental Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ElementRareData.h ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 ASSERT(!currentNode || !isNonFocusableShadowHost(*currentNode)); 521 ASSERT(!currentNode || !isNonFocusableShadowHost(*currentNode));
522 Node* found = findFocusableNodeRecursivelyBackward(scope, currentNode); 522 Node* found = findFocusableNodeRecursivelyBackward(scope, currentNode);
523 523
524 // If there's no focusable node to advance to, move up the focus scopes unti l we find one. 524 // If there's no focusable node to advance to, move up the focus scopes unti l we find one.
525 FocusNavigationScope currentScope = scope; 525 FocusNavigationScope currentScope = scope;
526 while (!found) { 526 while (!found) {
527 Node* owner = currentScope.owner(); 527 Node* owner = currentScope.owner();
528 if (!owner) 528 if (!owner)
529 break; 529 break;
530 currentScope = FocusNavigationScope::focusNavigationScopeOf(*owner); 530 currentScope = FocusNavigationScope::focusNavigationScopeOf(*owner);
531 if (isKeyboardFocusableShadowHost(*owner)) { 531 if (isKeyboardFocusableShadowHost(*owner) && toElement(owner)->isTabStop ()) {
532 found = owner; 532 found = owner;
533 break; 533 break;
534 } 534 }
535 found = findFocusableNodeRecursivelyBackward(currentScope, owner); 535 found = findFocusableNodeRecursivelyBackward(currentScope, owner);
536 } 536 }
537 return findFocusableNodeDecendingDownIntoFrameDocument(WebFocusTypeBackward, found); 537 return findFocusableNodeDecendingDownIntoFrameDocument(WebFocusTypeBackward, found);
538 } 538 }
539 539
540 Node* FocusController::findFocusableNodeRecursively(WebFocusType type, const Foc usNavigationScope& scope, Node* start) 540 Node* FocusController::findFocusableNodeRecursively(WebFocusType type, const Foc usNavigationScope& scope, Node* start)
541 { 541 {
542 return (type == WebFocusTypeForward) ? 542 return (type == WebFocusTypeForward) ?
543 findFocusableNodeRecursivelyForward(scope, start) : 543 findFocusableNodeRecursivelyForward(scope, start) :
544 findFocusableNodeRecursivelyBackward(scope, start); 544 findFocusableNodeRecursivelyBackward(scope, start);
545 } 545 }
546 546
547 Node* FocusController::findFocusableNodeRecursivelyForward(const FocusNavigation Scope& scope, Node* start) 547 Node* FocusController::findFocusableNodeRecursivelyForward(const FocusNavigation Scope& scope, Node* start)
548 { 548 {
549 // Starting node is exclusive. 549 // Starting node is exclusive.
550 Node* foundOrNull = findFocusableNode(WebFocusTypeForward, scope, start); 550 Node* found = findFocusableNode(WebFocusTypeForward, scope, start);
551 if (!foundOrNull) 551 if (!found)
552 return nullptr; 552 return nullptr;
553 Node& found = *foundOrNull; 553 if (found->isElementNode() && !toElement(found)->isTabStop()) {
554 if (!isNonFocusableFocusScopeOwner(found)) 554 if (isShadowHostWithoutCustomFocusLogic(*found)) {
555 return &found; 555 FocusNavigationScope innerScope = FocusNavigationScope::ownedByShado wHost(*found);
556 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyForward(FocusNavi gationScope::ownedByNonFocusableFocusScopeOwner(found), nullptr); 556 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyForward(i nnerScope, nullptr);
557 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableNodeRe cursivelyForward(scope, &found); 557 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusab leNodeRecursivelyForward(scope, found);
558 }
559 if (!isNonFocusableFocusScopeOwner(*found))
560 found = findFocusableNodeRecursivelyForward(scope, found);
561 }
562 if (!isNonFocusableFocusScopeOwner(*found))
563 return found;
564
565 // Now |found| is on a focusable scope owner (either shadow host or <shadow> )
566 // Find inside the inward scope and return it if found. Otherwise continue s earching in the same
567 // scope.
568 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusableF ocusScopeOwner(*found);
569 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyForward(innerScop e, nullptr);
570 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableNodeRe cursivelyForward(scope, found);
558 } 571 }
559 572
560 Node* FocusController::findFocusableNodeRecursivelyBackward(const FocusNavigatio nScope& scope, Node* start) 573 Node* FocusController::findFocusableNodeRecursivelyBackward(const FocusNavigatio nScope& scope, Node* start)
561 { 574 {
562 // Starting node is exclusive. 575 // Starting node is exclusive.
563 Node* foundOrNull = findFocusableNode(WebFocusTypeBackward, scope, start); 576 Node* found = findFocusableNode(WebFocusTypeBackward, scope, start);
564 if (!foundOrNull) 577 if (!found)
565 return nullptr; 578 return nullptr;
566 Node& found = *foundOrNull; 579
567 if (isKeyboardFocusableShadowHost(found)) { 580 // Now |found| is on a focusable shadow host.
568 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyBackward(Focu sNavigationScope::ownedByShadowHost(found), nullptr); 581 // Find inside shadow backwards. If any focusable element is found, return i t, otherwise return
569 return foundInInnerFocusScope ? foundInInnerFocusScope : &found; 582 // the host itself.
583 if (isKeyboardFocusableShadowHost(*found)) {
584 FocusNavigationScope innerScope = FocusNavigationScope::ownedByShadowHos t(*found);
585 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyBackward(inne rScope, nullptr);
586 if (foundInInnerFocusScope)
587 return foundInInnerFocusScope;
588 if (found->isElementNode() && !toElement(found)->isTabStop())
589 found = findFocusableNodeRecursivelyBackward(scope, found);
590 return found;
570 } 591 }
571 if (isNonFocusableFocusScopeOwner(found)) { 592
572 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyBackward(Focu sNavigationScope::ownedByNonFocusableFocusScopeOwner(found), nullptr); 593 // Now |found| is on a non focusable scope owner (either shadow host or <sha dow>).
573 return foundInInnerFocusScope ? foundInInnerFocusScope :findFocusableNod eRecursivelyBackward(scope, &found); 594 // Find focusable node in decendant scope. If not found, find next focusable node within the
595 // current scope.
596 if (isNonFocusableFocusScopeOwner(*found)) {
597 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusa bleFocusScopeOwner(*found);
598 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyBackward(inne rScope, nullptr);
599 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableNo deRecursivelyBackward(scope, found);
574 } 600 }
575 return &found; 601
602 return found->isElementNode() && toElement(found)->isTabStop() ? found : fin dFocusableNodeRecursivelyBackward(scope, found);
576 } 603 }
577 604
578 static Node* findNodeWithExactTabIndex(Node* start, int tabIndex, WebFocusType t ype) 605 static Node* findNodeWithExactTabIndex(Node* start, int tabIndex, WebFocusType t ype)
579 { 606 {
580 // Search is inclusive of start 607 // Search is inclusive of start
581 for (Node* node = start; node; node = type == WebFocusTypeForward ? NodeTrav ersal::next(*node) : NodeTraversal::previous(*node)) { 608 for (Node* node = start; node; node = type == WebFocusTypeForward ? NodeTrav ersal::next(*node) : NodeTraversal::previous(*node)) {
582 if (shouldVisit(*node) && adjustedTabIndex(*node) == tabIndex) 609 if (shouldVisit(*node) && adjustedTabIndex(*node) == tabIndex)
583 return node; 610 return node;
584 } 611 }
585 return nullptr; 612 return nullptr;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 return consumed; 1004 return consumed;
978 } 1005 }
979 1006
980 void FocusController::trace(Visitor* visitor) 1007 void FocusController::trace(Visitor* visitor)
981 { 1008 {
982 visitor->trace(m_page); 1009 visitor->trace(m_page);
983 visitor->trace(m_focusedFrame); 1010 visitor->trace(m_focusedFrame);
984 } 1011 }
985 1012
986 } // namespace blink 1013 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/ElementRareData.h ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698