diff options
| author | Stephen Blott | 2017-04-18 05:47:15 +0100 |
|---|---|---|
| committer | GitHub | 2017-04-18 05:47:15 +0100 |
| commit | 8058a54fd5a6a2f0e1a62a3a66f837a07045396e (patch) | |
| tree | a7e0949cd41b8fa8d03fa27140f8b815ec1d64c4 /content_scripts | |
| parent | 84723d7561d0cc12f54a6d388dcd505ddd6105ac (diff) | |
| parent | b0fc681480da40ec0bdb43773275ef7181c78cf1 (diff) | |
| download | vimium-8058a54fd5a6a2f0e1a62a3a66f837a07045396e.tar.bz2 | |
Merge pull request #2476 from mrmr1993/firefox
Improve firefox support
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/hud.coffee | 4 | ||||
| -rw-r--r-- | content_scripts/marks.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/mode_find.coffee | 12 |
3 files changed, 13 insertions, 5 deletions
diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index 407b90e1..c2170914 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -35,7 +35,9 @@ HUD = @tween.fade 1.0, 150 search: (data) -> - @findMode.findInPlace data.query + # NOTE(mrmr1993): On Firefox, window.find moves the window focus away from the HUD. We use postFindFocus + # to put it back, so the user can continue typing. + @findMode.findInPlace data.query, {"postFindFocus": @hudUI.iframeElement.contentWindow} # Show the number of matches in the HUD UI. matchCount = if FindMode.query.parsedQuery.length > 0 then FindMode.query.matchCount else 0 diff --git a/content_scripts/marks.coffee b/content_scripts/marks.coffee index 808f0a1d..37b062ba 100644 --- a/content_scripts/marks.coffee +++ b/content_scripts/marks.coffee @@ -64,7 +64,7 @@ Marks = if @isGlobalMark event, markName # This key must match @getLocationKey() in the back end. key = "vimiumGlobalMark|#{markName}" - chrome.storage.sync.get key, (items) -> + Settings.storage.get key, (items) -> if key of items chrome.runtime.sendMessage handler: 'gotoMark', markName: markName HUD.showForDuration "Jumped to global mark '#{markName}'", 1000 diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 0178527b..63825600 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -87,7 +87,7 @@ class FindMode extends Mode selection.removeAllRanges() selection.addRange range - findInPlace: (query) -> + findInPlace: (query, options) -> # If requested, restore the scroll position (so that failed searches leave the scroll position unchanged). @checkReturnToViewPort() FindMode.updateQuery query @@ -95,7 +95,7 @@ class FindMode extends Mode # match as the user adds matching characters, or removes previously-matched characters. See #1434. @restoreSelection() query = if FindMode.query.isRegex then FindMode.getNextQueryFromRegexMatches(0) else FindMode.query.parsedQuery - FindMode.query.hasResults = FindMode.execute query + FindMode.query.hasResults = FindMode.execute query, options @updateQuery: (query) -> @query.rawQuery = query @@ -178,7 +178,13 @@ class FindMode extends Mode # ignore the selectionchange event generated by find() document.removeEventListener("selectionchange", @restoreDefaultSelectionHighlight, true) - result = window.find(query, options.caseSensitive, options.backwards, true, false, true, false) + try + result = window.find(query, options.caseSensitive, options.backwards, true, false, true, false) + catch # Failed searches throw on Firefox. + + # window.find focuses the |window| that it is called on. This gives us an opportunity to (re-)focus + # another element/window, if that isn't the behaviour we want. + options.postFindFocus?.focus() if options.colorSelection setTimeout( |
