diff options
| -rw-r--r-- | content_scripts/link_hints.coffee | 8 | ||||
| -rw-r--r-- | content_scripts/mode_normal.coffee | 19 | ||||
| -rw-r--r-- | content_scripts/scroller.coffee | 9 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 2 | ||||
| -rw-r--r-- | lib/dom_utils.coffee | 8 | ||||
| -rw-r--r-- | lib/keyboard_utils.coffee | 5 | ||||
| -rw-r--r-- | manifest.json | 1 | ||||
| -rw-r--r-- | pages/options.html | 7 |
8 files changed, 45 insertions, 14 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index efb9239f..546d5914 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -245,17 +245,13 @@ class LinkHintsMode when "Control" @setOpenLinkMode(if @mode is OPEN_IN_NEW_FG_TAB then OPEN_IN_NEW_BG_TAB else OPEN_IN_NEW_FG_TAB) - handlerId = handlerStack.push + handlerId = @hintMode.push keyup: (event) => if event.key == key handlerStack.remove() @setOpenLinkMode previousMode true # Continue bubbling the event. - # For some (unknown) reason, we don't always receive the keyup event needed to remove this handler. - # Therefore, we ensure that it's always removed when hint mode exits. See #1911 and #1926. - @hintMode.onExit -> handlerStack.remove handlerId - else if KeyboardUtils.isBackspace event if @markerMatcher.popKeyChar() @tabCount = 0 @@ -290,7 +286,7 @@ class LinkHintsMode @markerMatcher.pushKeyChar keyChar @updateVisibleMarkers() else - return + return handlerStack.suppressPropagation handlerStack.suppressEvent diff --git a/content_scripts/mode_normal.coffee b/content_scripts/mode_normal.coffee index ee05f4b0..027ad22f 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) @@ -153,7 +169,6 @@ NormalModeCommands = # This is a hack to improve usability on the Vimium options page. We prime the recently-focused input # to be the key-mappings input. Arguably, this is the input that the user is most likely to use. recentlyFocusedElement = lastFocusedInput() - recentlyFocusedElement ?= document.getElementById "keyMappings" if window.isVimiumOptionsPage selectedInputIndex = if count == 1 diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee index 4a6c7edf..f65062e4 100644 --- a/content_scripts/scroller.coffee +++ b/content_scripts/scroller.coffee @@ -95,7 +95,14 @@ findScrollableElement = (element, direction, amount, factor) -> # On some pages, the scrolling element is not actually scrollable. Here, we search the document for the # largest visible element which does scroll vertically. This is used to initialize activatedElement. See # #1358. -firstScrollableElement = (element=getScrollingElement()) -> +firstScrollableElement = (element = null) -> + unless element + scrollingElement = getScrollingElement() + if doesScroll(scrollingElement, "y", 1, 1) or doesScroll(scrollingElement, "y", -1, 1) + return scrollingElement + else + element = document.body ? getScrollingElement() + if doesScroll(element, "y", 1, 1) or doesScroll(element, "y", -1, 1) element else diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 492a82e5..432fa7a2 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -157,6 +157,7 @@ initializePreDomReady = -> # Wrapper to install event listeners. Syntactic sugar. installListener = (element, event, callback) -> element.addEventListener(event, forTrusted(-> + root.extend window, root unless extend? # See #2800. if isEnabledForUrl then callback.apply(this, arguments) else true ), true) @@ -220,6 +221,7 @@ Frame = @port = chrome.runtime.connect name: "frames" @port.onMessage.addListener (request) => + root.extend window, root unless extend? # See #2800 and #2831. (@listeners[request.handler] ? this[request.handler]) request # We disable the content scripts when we lose contact with the background page, or on unload. diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 95b9f4b3..67d5a44c 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -363,8 +363,12 @@ DomUtils = @remove() if event.target == window handlerStack.continueBubbling callback?() - @suppressEvent event - handlerStack.suppressEvent + if suppressPropagation + DomUtils.suppressPropagation event + handlerStack.suppressPropagation + else + DomUtils.suppressEvent event + handlerStack.suppressEvent # Polyfill for selection.type (which is not available in Firefox). getSelectionType: (selection = document.getSelection()) -> diff --git a/lib/keyboard_utils.coffee b/lib/keyboard_utils.coffee index 70aa5a95..09623e50 100644 --- a/lib/keyboard_utils.coffee +++ b/lib/keyboard_utils.coffee @@ -36,6 +36,8 @@ KeyboardUtils = "" else if key of @keyNames @keyNames[key] + else if @isModifier event + "" # Don't resolve modifier keys. else if key.length == 1 key else @@ -70,6 +72,9 @@ KeyboardUtils = isPrintable: (event) -> @getKeyCharString(event)?.length == 1 + isModifier: (event) -> + event.key in ["Control", "Shift", "Alt", "OS", "AltGraph", "Meta"] + enUsTranslations: "Backquote": ["`", "~"] "Minus": ["-", "_"] diff --git a/manifest.json b/manifest.json index 71d7caba..353582d1 100644 --- a/manifest.json +++ b/manifest.json @@ -6,6 +6,7 @@ "icons": { "16": "icons/icon16.png", "48": "icons/icon48.png", "128": "icons/icon128.png" }, + "minimum_chrome_version": "51.0", "background": { "scripts": [ "lib/utils.js", diff --git a/pages/options.html b/pages/options.html index ec940cb2..b118bbd9 100644 --- a/pages/options.html +++ b/pages/options.html @@ -67,7 +67,7 @@ unmapAll <a href="#" id="showCommands">Show available commands</a>. </div> </div> - <textarea id="keyMappings" type="text"></textarea> + <textarea id="keyMappings" type="text" tabIndex="1"></textarea> </td> </tr> <tr> @@ -272,11 +272,12 @@ b: http://b.com/?q=%s description </td> </tr> <tr> - <td class="caption">CSS for link hints</td> + <td class="caption">CSS for Vimium UI</td> <td verticalAlign="top"> <div class="help"> <div class="example"> - The CSS used to style the characters next to each link hint.<br/><br/> + These styles are applied to link hints, the Vomnibar, the help dialog, the exclusions pop-up and the HUD.<br /> + By default, this CSS is used to style the characters next to each link hint.<br/><br/> These styles are used in addition to and take precedence over Vimium's default styles. </div> |
