diff options
| -rw-r--r-- | background_scripts/main.coffee | 20 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 17 |
2 files changed, 17 insertions, 20 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 722091a4..10e6121f 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -600,23 +600,21 @@ openOptionsPageInNewTab = -> chrome.tabs.create({ url: chrome.runtime.getURL("pages/options.html"), index: tab.index + 1 })) registerFrame = (request, sender) -> - frameIdsForTab[sender.tab.id] ?= [] - # Don't store frameset containers; focusing them is no use. - frameIdsForTab[sender.tab.id].push request.frameId unless request.is_frameset + (frameIdsForTab[sender.tab.id] ?= []).push request.frameId unregisterFrame = (request, sender) -> tabId = sender.tab.id - return unless frameIdsForTab[tabId]? - - if request.is_top # The whole tab is closing, so we can drop the frames list. - updateOpenTabs sender.tab - else - frameIdsForTab[tabId] = frameIdsForTab[tabId].filter (id) -> id != request.frameId + if frameIdsForTab[tabId]? + if request.tab_is_closing + updateOpenTabs sender.tab + else + frameIdsForTab[tabId] = frameIdsForTab[tabId].filter (id) -> id != request.frameId handleFrameFocused = (request, sender) -> tabId = sender.tab.id - frameIdsForTab[tabId] = - [request.frameId, (frameIdsForTab[tabId].filter (id) -> id != request.frameId)...] + if frameIdsForTab[tabId]? + frameIdsForTab[tabId] = + [request.frameId, (frameIdsForTab[tabId].filter (id) -> id != request.frameId)...] # Port handler mapping portHandlers = diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 62b1132b..0c88be84 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -185,19 +185,18 @@ initializeOnDomReady = -> chrome.runtime.connect({ name: "domReady" }) registerFrame = -> - chrome.runtime.sendMessage( - handler: "registerFrame" - frameId: frameId - is_top: window.top == window.self - is_frameset: document.body.tagName == "FRAMESET") + # Don't register frameset containers; focusing them is no use. + if document.body.tagName != "FRAMESET" + chrome.runtime.sendMessage + handler: "registerFrame" + frameId: frameId # Unregister the frame if we're going to exit. unregisterFrame = -> - chrome.runtime.sendMessage( + chrome.runtime.sendMessage handler: "unregisterFrame" frameId: frameId - is_top: window.top == window.self - is_frameset: document.body.tagName == "FRAMESET") + tab_is_closing: window.top == window.self # # Enters insert mode if the currently focused element in the DOM is focusable. @@ -1062,8 +1061,8 @@ Tween = initializePreDomReady() window.addEventListener("DOMContentLoaded", registerFrame) -window.addEventListener("DOMContentLoaded", initializeOnDomReady) window.addEventListener("unload", unregisterFrame) +window.addEventListener("DOMContentLoaded", initializeOnDomReady) window.onbeforeunload = -> chrome.runtime.sendMessage( |
