aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--background_scripts/main.coffee10
-rw-r--r--content_scripts/vimium_frontend.coffee9
2 files changed, 13 insertions, 6 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index f17befa0..241c809b 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -290,10 +290,6 @@ for icon in [ENABLED_ICON, DISABLED_ICON, PARTIAL_ICON]
Frames =
onConnect: (sender, port) ->
[tabId, frameId] = [sender.tab.id, sender.frameId]
- frameIdsForTab[tabId] ?= []
- frameIdsForTab[tabId].push frameId unless frameId in frameIdsForTab[tabId]
- portsForTab[tabId] ?= {}
- portsForTab[tabId][frameId] = port
port.postMessage handler: "registerFrameId", chromeFrameId: frameId
port.onDisconnect.addListener listener = ->
@@ -310,6 +306,12 @@ Frames =
(request, port) =>
this[request.handler] {request, tabId, frameId, port}
+ registerFrame: ({tabId, frameId, port}) ->
+ frameIdsForTab[tabId] ?= []
+ frameIdsForTab[tabId].push frameId unless frameId in frameIdsForTab[tabId]
+ portsForTab[tabId] ?= {}
+ portsForTab[tabId][frameId] = port
+
isEnabledForUrl: ({request, tabId, port}) ->
urlForTab[tabId] = request.url if request.frameIsFocused
enabledState = Exclusions.isEnabledForUrl request.url
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 693c0c46..b1e82a75 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -138,12 +138,15 @@ installModes = ->
initializeOnEnabledStateKnown = Utils.makeIdempotent ->
installModes()
+registerFrame = ->
+ Frame.postMessage "registerFrame"
+
#
# Complete initialization work that sould be done prior to DOMReady.
#
initializePreDomReady = ->
installListeners()
- Frame.init()
+ Frame.init registerFrame
checkIfEnabledForUrl()
requestHandlers =
@@ -214,7 +217,7 @@ Frame =
registerFrameId: ({chromeFrameId}) -> frameId = window.frameId = chromeFrameId
linkHintsMessage: (request) -> HintCoordinator[request.messageType] request
- init: (callback) ->
+ init: (callback = null) ->
@port = chrome.runtime.connect name: "frames"
@port.onMessage.addListener (request) =>
@@ -225,6 +228,8 @@ Frame =
isEnabledForUrl = false
window.removeEventListener "focus", onFocus
+ callback?()
+
setScrollPosition = ({ scrollX, scrollY }) ->
if DomUtils.isTopFrame()
DomUtils.documentReady ->