aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorStephen Blott2015-04-28 13:31:01 +0100
committerStephen Blott2015-04-28 13:31:01 +0100
commit8975229fd637ca1a91d7c52beb5969fe2b5e4d27 (patch)
tree74ace9150a4fa0de121b576f692982407a0bcd8b /content_scripts
parentc102821e37d1c1cec99580bfdba13bff9bd58de1 (diff)
downloadvimium-8975229fd637ca1a91d7c52beb5969fe2b5e4d27.tar.bz2
Activate grab-back-focus only if enabled.
This turned out to be trickier than expected. It turns out there's a period after document.body is defined but before the DOM is ready when we can't use the HUD (but previously thought we could, ie. HUD.isReady returned true).
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/mode.coffee3
-rw-r--r--content_scripts/vimium_frontend.coffee7
2 files changed, 7 insertions, 3 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index a2ac5b8c..f631b4cd 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -57,7 +57,8 @@ class Mode
# undefined, then the request propagates to the next mode.
# The active indicator can also be changed with @setIndicator().
if @options.indicator?
- if @options.indicator then HUD?.show @options.indicator else HUD?.hide true, false
+ if HUD?.isReady()
+ if @options.indicator then HUD.show @options.indicator else HUD.hide true, false
@stopBubblingAndTrue
else @continueBubbling
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index bc1f7687..c9410f90 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -13,6 +13,7 @@ isShowingHelpDialog = false
keyPort = null
isEnabledForUrl = true
isIncognitoMode = chrome.extension.inIncognitoContext
+isDomReady = false
passKeys = null
keyQueue = null
# The user's operating system.
@@ -149,7 +150,6 @@ window.initializeModes = ->
new NormalMode
new PassKeysMode
new InsertMode permanent: true
- new GrabBackFocus
Scroller.init settings
#
@@ -229,7 +229,9 @@ window.installListeners = ->
do (type) -> installListener window, type, (event) -> handlerStack.bubbleEvent type, event
installListener document, "DOMActivate", (event) -> handlerStack.bubbleEvent 'DOMActivate', event
installedListeners = true
+ # Other once-only initialisation.
FindModeHistory.init()
+ new GrabBackFocus if isEnabledForUrl
#
# Whenever we get the focus:
@@ -252,6 +254,7 @@ window.addEventListener "hashchange", onFocus
# Initialization tasks that must wait for the document to be ready.
#
initializeOnDomReady = ->
+ isDomReady = true
# Tell the background page we're in the dom ready state.
chrome.runtime.connect({ name: "domReady" })
CursorHider.init()
@@ -1153,7 +1156,7 @@ HUD =
else
HUD._tweenId = Tween.fade HUD.displayElement(), 0, 150, -> HUD.hide true, updateIndicator
- isReady: -> document.body != null
+ isReady: -> document.body != null and isDomReady
# A preference which can be toggled in the Options page. */
enabled: -> !settings.get("hideHud")