aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorStephen Blott2016-03-18 08:46:50 +0000
committerStephen Blott2016-03-18 08:46:50 +0000
commit7a0f53a8dceb8ffb4f1080e84f1d875a4fa20b78 (patch)
tree18c4411a39db5e8a6fed21b83540775c125868db /content_scripts
parent009967b9ba7b7a14b9773f7ba18b8d9f5c85c747 (diff)
downloadvimium-7a0f53a8dceb8ffb4f1080e84f1d875a4fa20b78.tar.bz2
Reduce complexity for initialising the top frame.
In #2053, I omitted to notice that the top-frame (vomnibar) initialisation sequence also generates O(n^2) messages. This makes that sequence O(n).
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/vimium_frontend.coffee16
1 files changed, 5 insertions, 11 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index a1461622..1b823dbc 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -425,17 +425,11 @@ extend window,
indicator: false
# Initialize UI components which are only installed in the main/top frame.
-initializeTopFrameUIComponents = Utils.makeIdempotent (request = null) ->
- DomUtils.documentReady ->
- # We only initialize the vomnibar in the tab's top/main frame, because it's only ever opened there.
- if DomUtils.isTopFrame()
- Vomnibar.init()
- else
- # Ignore requests from other frames (because we're not the top frame).
- unless request?
- # Tell the top frame to initialize the Vomnibar. We already have "DOMContentLoaded". This ensures
- # that the listener in the main/top frame (which are installed pre-DomReady) is ready.
- chrome.runtime.sendMessage handler: "sendMessageToFrames", message: name: "initializeTopFrameUIComponents"
+initializeTopFrameUIComponents = do ->
+ Frame.addEventListener "initializeTopFrameUIComponents", Utils.makeIdempotent Vomnibar.init.bind Vomnibar
+
+ Utils.makeIdempotent ->
+ DomUtils.documentReady -> Frame.postMessage "initializeTopFrameUIComponents"
# Initialize UI components which are only installed in all frames (i.e., the HUD).
initializeAllFrameUIComponents = Utils.makeIdempotent ->