diff options
| author | mrmr1993 | 2015-04-28 03:05:36 +0100 |
|---|---|---|
| committer | mrmr1993 | 2015-04-28 03:05:36 +0100 |
| commit | a61c63eed04a9a9a149d8607f2ad67c396ee8c18 (patch) | |
| tree | 68bc074ba1126ab295de4ec9b7f150353f101816 /background_scripts | |
| parent | 2de9bf879792b4be50efc09ee26d16008bb73ae7 (diff) | |
| download | vimium-a61c63eed04a9a9a149d8607f2ad67c396ee8c18.tar.bz2 | |
Don't re-order frameIds in the background page when manually focusing
Diffstat (limited to 'background_scripts')
| -rw-r--r-- | background_scripts/main.coffee | 18 |
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 |
