aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormrmr19932017-11-12 15:08:52 +0000
committermrmr19932017-11-12 15:18:10 +0000
commit305a9275de0bd2f8e3578467a2fa33ba82747959 (patch)
tree0fde53b1bd98531f755242ba8340ffaebfc486dc
parent959379d46c18671551d819eb7eb2199da3ac43e2 (diff)
downloadvimium-305a9275de0bd2f8e3578467a2fa33ba82747959.tar.bz2
Make focusInput visit inputs according to tabIndex order
-rw-r--r--content_scripts/mode_normal.coffee18
1 files changed, 17 insertions, 1 deletions
diff --git a/content_scripts/mode_normal.coffee b/content_scripts/mode_normal.coffee
index ee05f4b0..788042f0 100644
--- a/content_scripts/mode_normal.coffee
+++ b/content_scripts/mode_normal.coffee
@@ -144,7 +144,23 @@ NormalModeCommands =
for i in [0...resultSet.snapshotLength] by 1
element = resultSet.snapshotItem i
continue unless DomUtils.getVisibleClientRect element, true
- { element, rect: Rect.copy element.getBoundingClientRect() }
+ { element, index: i, rect: Rect.copy element.getBoundingClientRect() }
+
+ visibleInputs.sort ({element: element1, index: i1}, {element: element2, index: i2}) ->
+ # Put elements with a lower positive tabIndex first, keeping elements in DOM order.
+ if element1.tabIndex > 0
+ if element2.tabIndex > 0
+ tabDifference = element1.tabIndex - element2.tabIndex
+ if tabDifference != 0
+ tabDifference
+ else
+ i1 - i2
+ else
+ -1
+ else if element2.tabIndex > 0
+ 1
+ else
+ i1 - i2
if visibleInputs.length == 0
HUD.showForDuration("There are no inputs to focus.", 1000)