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 923712914c47a0a149f0df898ff8ed6b9b38b66a..1bf182919b58ff948cda151d0913ebd62b1632e7 100644 |
--- a/third_party/WebKit/Source/core/page/FocusController.cpp |
+++ b/third_party/WebKit/Source/core/page/FocusController.cpp |
@@ -426,15 +426,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; |
@@ -533,8 +534,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); |
} |