aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-04-17 16:17:38 +0100
committerStephen Blott2016-04-17 16:19:08 +0100
commit4b564e8517dd3415cb8e2209ce019fa024e88770 (patch)
treebe4e76270a1b0fdffc58c1a706cc4983e57b23d9
parent5327d51946fa86ed494c7b5cd2ba39fb79d8e9e9 (diff)
downloadvimium-4b564e8517dd3415cb8e2209ce019fa024e88770.tar.bz2
Only Vomnibar.init() when the Vomnibar is needed.
The Vomnibar isn't needed on most tabs, so don't init it. I cannot detect any sluggishness as a result of this.
-rw-r--r--content_scripts/vimium_frontend.coffee12
-rw-r--r--content_scripts/vomnibar.coffee10
2 files changed, 6 insertions, 16 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 312c6bbe..a80093f9 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -141,9 +141,6 @@ installModes = ->
initializeOnEnabledStateKnown = Utils.makeIdempotent ->
installModes()
-initializeUIComponents = Utils.makeIdempotent -> DomUtils.documentReady ->
- Vomnibar.init() if DomUtils.isTopFrame()
-
#
# Complete initialization work that should be done prior to DOMReady.
#
@@ -455,13 +452,8 @@ checkIfEnabledForUrl = do ->
{isEnabledForUrl, passKeys, frameIsFocused} = response
initializeOnEnabledStateKnown()
normalMode.setPassKeys passKeys
- # Initialize UI components, if necessary. We only initialize these once we know that Vimium is enabled;
- # see #1838. We need to check this every time so that we can change state from disabled to enabled.
- if isEnabledForUrl
- initializeUIComponents() if frameIsFocused
- else
- # Hide the HUD if we're not enabled.
- HUD.hide true, false # Immediate, do not update indicator.
+ # Hide the HUD if we're not enabled.
+ HUD.hide true, false unless isEnabledForUrl
(frameIsFocused = windowIsFocused()) ->
Frame.postMessage "isEnabledForUrl", {frameIsFocused, url: window.location.toString()}
diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee
index 66494fc2..cbd2892c 100644
--- a/content_scripts/vomnibar.coffee
+++ b/content_scripts/vomnibar.coffee
@@ -48,8 +48,7 @@ Vomnibar =
}
init: ->
- unless @vomnibarUI?
- @vomnibarUI = new UIComponent "pages/vomnibar.html", "vomnibarFrame", ->
+ @vomnibarUI ?= new UIComponent "pages/vomnibar.html", "vomnibarFrame", ->
# This function opens the vomnibar. It accepts options, a map with the values:
# completer - The completer to fetch results from.
@@ -58,10 +57,9 @@ Vomnibar =
# newTab - Optional, boolean. Whether to open the result in a new tab.
open: (sourceFrameId, options) ->
@init()
- if @vomnibarUI?.uiComponentIsReady
- # The Vomnibar cannot coexist with the help dialog (it causes focus issues).
- HelpDialog.abort()
- @vomnibarUI.activate extend options, { name: "activate", sourceFrameId, focus: true }
+ # The Vomnibar cannot coexist with the help dialog (it causes focus issues).
+ HelpDialog.abort()
+ @vomnibarUI.activate extend options, { name: "activate", sourceFrameId, focus: true }
root = exports ? window
root.Vomnibar = Vomnibar