aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2016-03-26 16:00:15 +0000
committerStephen Blott2016-03-26 16:04:04 +0000
commitb09a7524502e7df993bd1d5eb906553348130591 (patch)
treeaf0a7414a2d19368c66e36021ef6404bfb17e427 /background_scripts
parente2ea471eff20504b53da36a791769d246fff9593 (diff)
downloadvimium-b09a7524502e7df993bd1d5eb906553348130591.tar.bz2
Rework global mark activation.
There were two problems, both stemming from the fact that the notification was being displayed in the top frame, even if the mark was triggered in another frame: 1. That looks odd, because we close the HUD in one frame then open it in another. 2. As a side effect, we were moving the focus to the top frame. Here, we work out what's going to happen before sending the message to the background page. This allows us to display the message in the HUD in the frame which generated it.
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/marks.coffee22
1 files changed, 5 insertions, 17 deletions
diff --git a/background_scripts/marks.coffee b/background_scripts/marks.coffee
index 7cdbbf74..8fe30b2f 100644
--- a/background_scripts/marks.coffee
+++ b/background_scripts/marks.coffee
@@ -23,9 +23,8 @@ Marks =
@saveMark markInfo
else
# The front-end frame hasn't provided the scroll position (because it's not the top frame within its
- # tab). We need to ask the top frame what its scroll position is. (With the frame Id set to 0, below,
- # the request will only be handled by the top frame within the tab.)
- chrome.tabs.sendMessage sender.tab.id, name: "getScrollPosition", frameId: 0, (response) =>
+ # tab). We need to ask the top frame what its scroll position is.
+ chrome.tabs.sendMessage sender.tab.id, name: "getScrollPosition", (response) =>
@saveMark extend markInfo, scrollX: response.scrollX, scrollY: response.scrollY
saveMark: (markInfo) ->
@@ -42,13 +41,7 @@ Marks =
key = @getLocationKey req.markName
chrome.storage.sync.get key, (items) =>
markInfo = items[key]
- if not markInfo
- # The mark is not defined.
- chrome.tabs.sendMessage sender.tab.id,
- name: "showHUDforDuration",
- text: "Global mark not set: '#{req.markName}'."
- duration: 1000
- else if markInfo.vimiumSecret != vimiumSecret
+ if markInfo.vimiumSecret != vimiumSecret
# This is a different Vimium instantiation, so markInfo.tabId is definitely out of date.
@focusOrLaunch markInfo, req
else
@@ -64,13 +57,8 @@ Marks =
# Focus an existing tab and scroll to the given position within it.
gotoPositionInTab: ({ tabId, scrollX, scrollY, markName }) ->
- chrome.tabs.update tabId, { selected: true }, ->
- chrome.tabs.sendMessage tabId,
- { name: "setScrollPosition", scrollX: scrollX, scrollY: scrollY }, ->
- chrome.tabs.sendMessage tabId,
- name: "showHUDforDuration",
- text: "Jumped to global mark '#{markName}'."
- duration: 1000
+ chrome.tabs.update tabId, {selected: true}, ->
+ chrome.tabs.sendMessage tabId, {name: "setScrollPosition", scrollX, scrollY}
# The tab we're trying to find no longer exists. We either find another tab with a matching URL and use it,
# or we create a new tab.