aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-03-17 12:54:44 +0000
committerStephen Blott2016-03-17 12:54:44 +0000
commite1aee8b4867e3d315d799ba06ba46fa7d7077c0c (patch)
tree52753640d0661985d0ca33d74105d9b480fe71bb
parent16b150c108f72cc7b3e33c6fa46bd5c2d06c71c8 (diff)
downloadvimium-e1aee8b4867e3d315d799ba06ba46fa7d7077c0c.tar.bz2
More tweaks for #2053.
-rw-r--r--background_scripts/main.coffee7
-rw-r--r--content_scripts/vimium_frontend.coffee7
2 files changed, 6 insertions, 8 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index 42e9b344..1a67f2b2 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -360,10 +360,9 @@ Frames =
port.onDisconnect.addListener listener = ->
# Unregister the frame. However, we never unregister the main/top frame. If the tab is navigating to
- # another page, then there'll be a new top frame (with the same Id) along soon. If the tab is closing,
- # then we'll tidy up in the chrome.tabs.onRemoved listener, below. This approach avoids any dependency
- # on the order in which register and unregister events happens (e.g. on navigation, a new top frame
- # registering before the old one is deregistered).
+ # another page, then there'll be a new top frame with the same Id soon. If the tab is closing, then
+ # we tidy up in the chrome.tabs.onRemoved listener. This elides any dependency on the order in which
+ # events happen (e.g. on navigation, a new top frame registers before the old one unregisters).
if tabId of frameIdsForTab and frameId != 0
frameIdsForTab[tabId] = frameIdsForTab[tabId].filter (fId) -> fId != frameId
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index a538e46e..13d1377d 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -213,16 +213,15 @@ Frame =
port: null
listeners: {}
- addEventListener: (handler, callback) -> (@listeners[handler] ?= []).push callback
+ addEventListener: (handler, callback) -> @listeners[handler] = callback
postMessage: (handler, request = {}) -> @port.postMessage extend request, {handler}
registerFrameId: ({chromeFrameId}) -> frameId = window.frameId = chromeFrameId
init: (callback) ->
- @addEventListener "registerFrameId", Frame.registerFrameId
@port = chrome.runtime.connect name: "frames"
@port.onMessage.addListener (request) =>
- handler request for handler in @listeners[request.handler]
+ (@listeners[request.handler] ? this[request.handler]) request
@port.onDisconnect.addListener ->
# We disable the content scripts when we lose contact with the background page.
@@ -459,7 +458,7 @@ checkIfEnabledForUrl = do ->
HUD.hide()
normalMode?.setPassKeys passKeys
# Update the page icon, if necessary.
- if frameIsFocused
+ if windowIsFocused()
chrome.runtime.sendMessage
handler: "setIcon"
icon: