aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts
diff options
context:
space:
mode:
authorStephen Blott2015-04-28 09:44:21 +0100
committerStephen Blott2015-04-28 09:44:21 +0100
commitc6a01401f31ffdac3ae639c48abf6d408227243e (patch)
treebd5494ec71eab79858913b4717fe8f920a5eb0d2 /background_scripts
parent36df218436e0a873272367f11727207a7530c371 (diff)
parenta61c63eed04a9a9a149d8607f2ad67c396ee8c18 (diff)
downloadvimium-c6a01401f31ffdac3ae639c48abf6d408227243e.tar.bz2
Merge branch 'no-reorder-frameIds' of https://github.com/mrmr1993/vimium into mrmr1993-no-reorder-frameIds
Diffstat (limited to 'background_scripts')
-rw-r--r--background_scripts/main.coffee18
1 files changed, 10 insertions, 8 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index e782a217..c9e3a118 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -303,11 +303,7 @@ BackgroundCommands =
moveTabRight: (count) -> moveTab(null, count)
nextFrame: (count,frameId) ->
chrome.tabs.getSelected(null, (tab) ->
- frames = frameIdsForTab[tab.id]
- # We can't always track which frame chrome has focussed, but here we learn that it's frameId; so add an
- # additional offset such that we do indeed start from frameId.
- count = (count + Math.max 0, frameIdsForTab[tab.id].indexOf frameId) % frames.length
- frames = frameIdsForTab[tab.id] = [frames[count..]..., frames[0...count]...]
+ frameIdsForTab[tab.id] = cycleToFrame frameIdsForTab[tab.id], frameId, count
chrome.tabs.sendMessage(tab.id, { name: "focusFrame", frameId: frames[0], highlight: true }))
mainFrame: ->
chrome.tabs.getSelected null, (tab) ->
@@ -613,14 +609,20 @@ handleFrameFocused = (request, sender) ->
tabId = sender.tab.id
# Cycle frameIdsForTab to the focused frame. However, also ensure that we don't inadvertently register a
# frame which wasn't previously registered (such as a frameset).
- if frameIdsForTab[tabId]? and request.frameId in frameIdsForTab[tabId]
- frameIdsForTab[tabId] =
- [request.frameId, (frameIdsForTab[tabId].filter (id) -> id != request.frameId)...]
+ if frameIdsForTab[tabId]?
+ frameIdsForTab[tabId] = cycleToFrame frameIdsForTab[tabId], request.frameId
# Inform all frames that a frame has received the focus.
chrome.tabs.sendMessage sender.tab.id,
name: "frameFocused"
focusFrameId: request.frameId
+# Rotate through frames to the frame count places after frameId.
+cycleToFrame = (frames, frameId, count = 0) ->
+ # We can't always track which frame chrome has focussed, but here we learn that it's frameId; so add an
+ # additional offset such that we do indeed start from frameId.
+ count = (count + Math.max 0, frames.indexOf frameId) % frames.length
+ [frames[count..]..., frames[0...count]...]
+
# Send a message to all frames in the current tab.
sendMessageToFrames = (request, sender) ->
chrome.tabs.sendMessage sender.tab.id, request.message