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

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

Issue 2362223002: Stop clamping tabIndex to short range (Closed)
Patch Set: Fix tabindex-clamp.html Created 4 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 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 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);
}
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLSlotElement.cpp ('k') | third_party/WebKit/Source/core/svg/SVGAElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698