diff options
| author | Stephen Blott | 2016-04-17 16:11:57 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2016-04-17 16:11:57 +0100 | 
| commit | 5327d51946fa86ed494c7b5cd2ba39fb79d8e9e9 (patch) | |
| tree | ae04f84ab4ef959e9b403af9aa1c0b0da1d13c7c | |
| parent | 12350784fc45998819ef92d6b5badf03e99128ae (diff) | |
| download | vimium-5327d51946fa86ed494c7b5cd2ba39fb79d8e9e9.tar.bz2 | |
Do not init() the HUD until it's needed.
This avoids initializing around 15 (almost all unused) HUDs on sites
like GMail and Google inbox.
Because the HUD is small, there is not noticable flicker.
| -rw-r--r-- | content_scripts/hud.coffee | 8 | ||||
| -rw-r--r-- | content_scripts/mode.coffee | 3 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 3 | 
3 files changed, 5 insertions, 9 deletions
| diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index 0bd1df3e..62bcf03f 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -23,13 +23,13 @@ HUD =      @_showForDurationTimerId = setTimeout((=> @hide()), duration)    show: (text) -> -    return unless @isReady() +    @init()      clearTimeout(@_showForDurationTimerId)      @hudUI.activate {name: "show", text}      @tween.fade 1.0, 150    showFindMode: (@findMode = null) -> -    return unless @isReady() +    @init()      @hudUI.activate name: "showFindMode"      @tween.fade 1.0, 150 @@ -46,7 +46,7 @@ HUD =    # If :updateIndicator is truthy, then we also refresh the mode indicator.  The only time we don't update the    # mode indicator, is when hide() is called for the mode indicator itself.    hide: (immediate = false, updateIndicator = true) -> -    return unless @tween? and @isReady() +    return unless @hudUI?.uiComponentIsReady      clearTimeout(@_showForDurationTimerId)      @tween.stop()      if immediate @@ -80,8 +80,6 @@ HUD =      @findMode.exit()      postExit?() -  isReady: -> @hudUI?.uiComponentIsReady -  class Tween    opacity: 0    intervalId: -1 diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index 37321660..6508627e 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -69,8 +69,7 @@ class Mode          # undefined, then the request propagates to the next mode.          # The active indicator can also be changed with @setIndicator().          if @options.indicator? -          if HUD?.isReady() -            if @options.indicator then HUD.show @options.indicator else HUD.hide true, false +          if @options.indicator then HUD.show @options.indicator else HUD.hide true, false            @passEventToPage          else @continueBubbling diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index f20bba7e..312c6bbe 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -142,7 +142,6 @@ initializeOnEnabledStateKnown = Utils.makeIdempotent ->    installModes()  initializeUIComponents = Utils.makeIdempotent -> DomUtils.documentReady -> - HUD.init()   Vomnibar.init() if DomUtils.isTopFrame()  # @@ -462,7 +461,7 @@ checkIfEnabledForUrl = do ->        initializeUIComponents() if frameIsFocused      else        # Hide the HUD if we're not enabled. -      HUD.hide() if HUD.isReady() +      HUD.hide true, false # Immediate, do not update indicator.    (frameIsFocused = windowIsFocused()) ->      Frame.postMessage "isEnabledForUrl", {frameIsFocused, url: window.location.toString()} | 
