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

Unified Diff: third_party/WebKit/Source/core/page/FocusController.cpp

Issue 2362223002: Stop clamping tabIndex to short range (Closed)
Patch Set: Fix test expectation Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/page/FocusController.cpp
diff --git a/third_party/WebKit/Source/core/page/FocusController.cpp b/third_party/WebKit/Source/core/page/FocusController.cpp
index f13385c9fd2253b38c169aa69011f1ae4c49ec79..9438e9be717ab0f510b5b59c501380f46734d2d1 100644
--- a/third_party/WebKit/Source/core/page/FocusController.cpp
+++ b/third_party/WebKit/Source/core/page/FocusController.cpp
@@ -440,15 +440,16 @@ Element* findElementWithExactTabIndex(ScopedFocusNavigation& scope,
Element* nextElementWithGreaterTabIndex(ScopedFocusNavigation& scope,
int tabIndex) {
// Search is inclusive of start
- int winningTabIndex = std::numeric_limits<short>::max() + 1;
+ int winningTabIndex = std::numeric_limits<int>::max();
Element* winner = nullptr;
for (; scope.currentElement(); scope.moveToNext()) {
Element* current = scope.currentElement();
int currentTabIndex = adjustedTabIndex(*current);
- if (shouldVisit(*current) && currentTabIndex > tabIndex &&
- currentTabIndex < winningTabIndex) {
- winner = current;
- winningTabIndex = currentTabIndex;
+ if (shouldVisit(*current) && currentTabIndex > tabIndex) {
+ if (!winner || currentTabIndex < winningTabIndex) {
+ winner = current;
+ winningTabIndex = currentTabIndex;
+ }
}
}
return winner;
@@ -547,8 +548,7 @@ Element* previousFocusableElement(ScopedFocusNavigation& scope) {
// 1) has the highest non-zero tabindex (that is less than start's tabindex),
// and
// 2) comes last in the scope, if there's a tie.
- tabIndex =
- (current && tabIndex) ? tabIndex : std::numeric_limits<short>::max();
+ tabIndex = (current && tabIndex) ? tabIndex : std::numeric_limits<int>::max();
scope.moveToLast();
return previousElementWithLowerTabIndex(scope, tabIndex);
}

Powered by Google App Engine
This is Rietveld 408576698