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

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

Issue 1144953007: Remove tabStop feature (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 6 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/input/EventHandler.cpp ('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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 ASSERT(!currentNode || !isNonFocusableShadowHost(*currentNode)); 519 ASSERT(!currentNode || !isNonFocusableShadowHost(*currentNode));
520 Node* found = findFocusableNodeRecursivelyBackward(scope, currentNode); 520 Node* found = findFocusableNodeRecursivelyBackward(scope, currentNode);
521 521
522 // If there's no focusable node to advance to, move up the focus scopes unti l we find one. 522 // If there's no focusable node to advance to, move up the focus scopes unti l we find one.
523 FocusNavigationScope currentScope = scope; 523 FocusNavigationScope currentScope = scope;
524 while (!found) { 524 while (!found) {
525 Node* owner = currentScope.owner(); 525 Node* owner = currentScope.owner();
526 if (!owner) 526 if (!owner)
527 break; 527 break;
528 currentScope = FocusNavigationScope::focusNavigationScopeOf(*owner); 528 currentScope = FocusNavigationScope::focusNavigationScopeOf(*owner);
529 if (isKeyboardFocusableShadowHost(*owner) && toElement(owner)->tabStop() ) { 529 if (isKeyboardFocusableShadowHost(*owner)) {
530 found = owner; 530 found = owner;
531 break; 531 break;
532 } 532 }
533 found = findFocusableNodeRecursivelyBackward(currentScope, owner); 533 found = findFocusableNodeRecursivelyBackward(currentScope, owner);
534 } 534 }
535 return findFocusableNodeDecendingDownIntoFrameDocument(WebFocusTypeBackward, found); 535 return findFocusableNodeDecendingDownIntoFrameDocument(WebFocusTypeBackward, found);
536 } 536 }
537 537
538 Node* FocusController::findFocusableNodeRecursively(WebFocusType type, const Foc usNavigationScope& scope, Node* start) 538 Node* FocusController::findFocusableNodeRecursively(WebFocusType type, const Foc usNavigationScope& scope, Node* start)
539 { 539 {
540 return (type == WebFocusTypeForward) ? 540 return (type == WebFocusTypeForward) ?
541 findFocusableNodeRecursivelyForward(scope, start) : 541 findFocusableNodeRecursivelyForward(scope, start) :
542 findFocusableNodeRecursivelyBackward(scope, start); 542 findFocusableNodeRecursivelyBackward(scope, start);
543 } 543 }
544 544
545 Node* FocusController::findFocusableNodeRecursivelyForward(const FocusNavigation Scope& scope, Node* start) 545 Node* FocusController::findFocusableNodeRecursivelyForward(const FocusNavigation Scope& scope, Node* start)
546 { 546 {
547 // Starting node is exclusive. 547 // Starting node is exclusive.
548 Node* found = findFocusableNode(WebFocusTypeForward, scope, start); 548 Node* found = findFocusableNode(WebFocusTypeForward, scope, start);
549 if (!found) 549 if (!found)
550 return nullptr; 550 return nullptr;
551 if (found->isElementNode() && !toElement(found)->tabStop()) {
552 if (isShadowHostWithoutCustomFocusLogic(*found)) {
553 FocusNavigationScope innerScope = FocusNavigationScope::ownedByShado wHost(*found);
554 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyForward(i nnerScope, nullptr);
555 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusab leNodeRecursivelyForward(scope, found);
556 }
557 // Skip to the next node.
558 if (!isNonFocusableFocusScopeOwner(*found))
559 found = findFocusableNodeRecursivelyForward(scope, found);
560 }
561 if (!found || !isNonFocusableFocusScopeOwner(*found)) 551 if (!found || !isNonFocusableFocusScopeOwner(*found))
562 return found; 552 return found;
563 553
564 // Now |found| is on a focusable scope owner (either shadow host or <shadow> ) 554 // Now |found| is on a focusable scope owner (either shadow host or <shadow> )
565 // Find inside the inward scope and return it if found. Otherwise continue s earching in the same 555 // Find inside the inward scope and return it if found. Otherwise continue s earching in the same
566 // scope. 556 // scope.
567 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusableF ocusScopeOwner(*found); 557 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusableF ocusScopeOwner(*found);
568 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyForward(innerScop e, nullptr); 558 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyForward(innerScop e, nullptr);
569 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableNodeRe cursivelyForward(scope, found); 559 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableNodeRe cursivelyForward(scope, found);
570 } 560 }
571 561
572 Node* FocusController::findFocusableNodeRecursivelyBackward(const FocusNavigatio nScope& scope, Node* start) 562 Node* FocusController::findFocusableNodeRecursivelyBackward(const FocusNavigatio nScope& scope, Node* start)
573 { 563 {
574 // Starting node is exclusive. 564 // Starting node is exclusive.
575 Node* found = findFocusableNode(WebFocusTypeBackward, scope, start); 565 Node* found = findFocusableNode(WebFocusTypeBackward, scope, start);
576 if (!found) 566 if (!found)
577 return nullptr; 567 return nullptr;
578 568
579 // Now |found| is on a focusable shadow host. 569 // Now |found| is on a focusable shadow host.
580 // Find inside shadow backwards. If any focusable element is found, return i t, otherwise return 570 // Find inside shadow backwards. If any focusable element is found, return i t, otherwise return
581 // the host itself. 571 // the host itself.
582 if (isKeyboardFocusableShadowHost(*found)) { 572 if (isKeyboardFocusableShadowHost(*found)) {
583 FocusNavigationScope innerScope = FocusNavigationScope::ownedByShadowHos t(*found); 573 FocusNavigationScope innerScope = FocusNavigationScope::ownedByShadowHos t(*found);
584 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyBackward(inne rScope, nullptr); 574 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyBackward(inne rScope, nullptr);
585 if (foundInInnerFocusScope) 575 if (foundInInnerFocusScope)
586 return foundInInnerFocusScope; 576 return foundInInnerFocusScope;
587 if (found->isElementNode() && !toElement(found)->tabStop())
588 found = findFocusableNodeRecursivelyBackward(scope, found);
589 return found; 577 return found;
590 } 578 }
591 579
592 // Now |found| is on a non focusable scope owner (either shadow host or <sha dow>). 580 // Now |found| is on a non focusable scope owner (either shadow host or <sha dow>).
593 // Find focusable node in decendant scope. If not found, find next focusable node within the 581 // Find focusable node in decendant scope. If not found, find next focusable node within the
594 // current scope. 582 // current scope.
595 if (isNonFocusableFocusScopeOwner(*found)) { 583 if (isNonFocusableFocusScopeOwner(*found)) {
596 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusa bleFocusScopeOwner(*found); 584 FocusNavigationScope innerScope = FocusNavigationScope::ownedByNonFocusa bleFocusScopeOwner(*found);
597 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyBackward(inne rScope, nullptr); 585 Node* foundInInnerFocusScope = findFocusableNodeRecursivelyBackward(inne rScope, nullptr);
598 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableNo deRecursivelyBackward(scope, found); 586 return foundInInnerFocusScope ? foundInInnerFocusScope : findFocusableNo deRecursivelyBackward(scope, found);
599 } 587 }
600 588
601 return found->isElementNode() && toElement(found)->tabStop() ? found : findF ocusableNodeRecursivelyBackward(scope, found); 589 return found;
602 } 590 }
603 591
604 static Node* findNodeWithExactTabIndex(Node* start, int tabIndex, WebFocusType t ype) 592 static Node* findNodeWithExactTabIndex(Node* start, int tabIndex, WebFocusType t ype)
605 { 593 {
606 // Search is inclusive of start 594 // Search is inclusive of start
607 for (Node* node = start; node; node = type == WebFocusTypeForward ? NodeTrav ersal::next(*node) : NodeTraversal::previous(*node)) { 595 for (Node* node = start; node; node = type == WebFocusTypeForward ? NodeTrav ersal::next(*node) : NodeTraversal::previous(*node)) {
608 if (shouldVisit(*node) && adjustedTabIndex(*node) == tabIndex) 596 if (shouldVisit(*node) && adjustedTabIndex(*node) == tabIndex)
609 return node; 597 return node;
610 } 598 }
611 return nullptr; 599 return nullptr;
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 return consumed; 998 return consumed;
1011 } 999 }
1012 1000
1013 DEFINE_TRACE(FocusController) 1001 DEFINE_TRACE(FocusController)
1014 { 1002 {
1015 visitor->trace(m_page); 1003 visitor->trace(m_page);
1016 visitor->trace(m_focusedFrame); 1004 visitor->trace(m_focusedFrame);
1017 } 1005 }
1018 1006
1019 } // namespace blink 1007 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/input/EventHandler.cpp ('k') | Source/platform/RuntimeEnabledFeatures.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698