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

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

Issue 700313002: Improve consistency of nextNodeWithGreaterTabIndex() and previousNodeWithLowerTabIndex(). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | « no previous file | no next file » | 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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 542
543 static Node* nextNodeWithGreaterTabIndex(Node* start, int tabIndex) 543 static Node* nextNodeWithGreaterTabIndex(Node* start, int tabIndex)
544 { 544 {
545 // Search is inclusive of start 545 // Search is inclusive of start
546 int winningTabIndex = std::numeric_limits<short>::max() + 1; 546 int winningTabIndex = std::numeric_limits<short>::max() + 1;
547 Node* winner = nullptr; 547 Node* winner = nullptr;
548 for (Node& node : NodeTraversal::startsAt(start)) { 548 for (Node& node : NodeTraversal::startsAt(start)) {
549 int currentTabIndex = adjustedTabIndex(&node); 549 int currentTabIndex = adjustedTabIndex(&node);
550 if (shouldVisit(&node) && currentTabIndex > tabIndex && currentTabIndex < winningTabIndex) { 550 if (shouldVisit(&node) && currentTabIndex > tabIndex && currentTabIndex < winningTabIndex) {
551 winner = &node; 551 winner = &node;
552 winningTabIndex = node.tabIndex(); 552 winningTabIndex = currentTabIndex;
553 } 553 }
554 } 554 }
555 555
556 return winner; 556 return winner;
557 } 557 }
558 558
559 static Node* previousNodeWithLowerTabIndex(Node* start, int tabIndex) 559 static Node* previousNodeWithLowerTabIndex(Node* start, int tabIndex)
560 { 560 {
561 // Search is inclusive of start 561 // Search is inclusive of start
562 int winningTabIndex = 0; 562 int winningTabIndex = 0;
563 Node* winner = nullptr; 563 Node* winner = nullptr;
564 for (Node* node = start; node; node = NodeTraversal::previous(*node)) { 564 for (Node* node = start; node; node = NodeTraversal::previous(*node)) {
565 int currentTabIndex = adjustedTabIndex(node); 565 int currentTabIndex = adjustedTabIndex(node);
566 if ((shouldVisit(node) || isNonKeyboardFocusableShadowHost(node)) && cur rentTabIndex < tabIndex && currentTabIndex > winningTabIndex) { 566 if (shouldVisit(node) && currentTabIndex < tabIndex && currentTabIndex > winningTabIndex) {
567 winner = node; 567 winner = node;
568 winningTabIndex = currentTabIndex; 568 winningTabIndex = currentTabIndex;
569 } 569 }
570 } 570 }
571 return winner; 571 return winner;
572 } 572 }
573 573
574 Node* FocusController::nextFocusableNode(FocusNavigationScope scope, Node* start ) 574 Node* FocusController::nextFocusableNode(FocusNavigationScope scope, Node* start )
575 { 575 {
576 if (start) { 576 if (start) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 return consumed; 928 return consumed;
929 } 929 }
930 930
931 void FocusController::trace(Visitor* visitor) 931 void FocusController::trace(Visitor* visitor)
932 { 932 {
933 visitor->trace(m_page); 933 visitor->trace(m_page);
934 visitor->trace(m_focusedFrame); 934 visitor->trace(m_focusedFrame);
935 } 935 }
936 936
937 } // namespace blink 937 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698