aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/main.coffee
diff options
context:
space:
mode:
authorStephen Blott2016-03-17 12:35:33 +0000
committerStephen Blott2016-03-17 12:35:33 +0000
commit16b150c108f72cc7b3e33c6fa46bd5c2d06c71c8 (patch)
treea0af536d219e1728d6f483cb0b39f6ca1a89e524 /background_scripts/main.coffee
parentd6f8e7301ed43a64df77e9bfa0ef9dd7a263faeb (diff)
downloadvimium-16b150c108f72cc7b3e33c6fa46bd5c2d06c71c8.tar.bz2
Tweaks for #2053.
Diffstat (limited to 'background_scripts/main.coffee')
-rw-r--r--background_scripts/main.coffee10
1 files changed, 3 insertions, 7 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 25aaef7b..42e9b344 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -354,9 +354,8 @@ openOptionsPageInNewTab = ->
Frames =
onConnect: (sender, port) ->
[tabId, frameId] = [sender.tab.id, sender.frameId]
- # We always add frameId 0, the top frame, automatically, and never unregister it.
- frameIdsForTab[tabId] ?= [0]
- frameIdsForTab[tabId].push frameId unless frameId == 0
+ frameIdsForTab[tabId] ?= []
+ frameIdsForTab[tabId].push frameId unless frameId in frameIdsForTab[tabId]
port.postMessage handler: "registerFrameId", chromeFrameId: frameId
port.onDisconnect.addListener listener = ->
@@ -386,16 +385,13 @@ Frames =
handleFrameFocused = (request, sender) ->
[tabId, frameId] = [sender.tab.id, sender.frameId]
- # This might be the first time we've heard from this tab.
- frameIdsForTab[tabId] ?= [0]
- # Cycle frameIdsForTab to the focused frame.
+ frameIdsForTab[tabId] ?= []
frameIdsForTab[tabId] = cycleToFrame frameIdsForTab[tabId], frameId
# Inform all frames that a frame has received the focus.
chrome.tabs.sendMessage tabId, name: "frameFocused", focusFrameId: frameId
# Rotate through frames to the frame count places after frameId.
cycleToFrame = (frames, frameId, count = 0) ->
- frames ||= []
# 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