diff options
| author | Stephen Blott | 2016-04-28 13:51:44 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2016-04-28 13:55:08 +0100 | 
| commit | f83e99fd42a4cf412c79fb15c58f59c105c25723 (patch) | |
| tree | 673e75c9d372fd70ae0742a05c76c581f0faff32 /content_scripts/vimium_frontend.coffee | |
| parent | ac340e2346247b5cd1878e1a814d4c151df3e892 (diff) | |
| download | vimium-f83e99fd42a4cf412c79fb15c58f59c105c25723.tar.bz2 | |
Fix UI-component initialization issues.
This fixes some UI component initialization issues.  It's a long
story...
The problem.
- Go to this page: http://www.thejournal.ie/seanad-election-results-2016-2737768-Apr2016/
- Click one of the links from the "Most Popular" box on the right.
- Navigate back (`H`) and, as the original page is loading, activate the Vomnibar.
In 1.54 this renders Vimium unusable.  In `master` this renders the
Vomnibar unsable, but the rest of Vimium usable.
It seems the source of the issue is that we're initializing UI
components too soon.  We need to wait until the `readyState` is
"complete".
With this PR:
- The Vomnibar is initialised when the `readyState` is "complete" (in
  the top frame only, and only if Vimium is enabled).  Requests arriving
  prior to then are silently discarded.
- The HUD is also initialized only when the `readyState` is "complete";
  however, requests arriving before then are queued.  So, if the user
  immediately enters insert mode, then the "Insert mode" indicator will
  eventually be displayed.
- The help dialog silently discards requests until the `readyState` is
  "complete.
I'm posting this as a PR because:
1. It needs some visibility.
2. With this, if the `readyState` *never* reaches "complete", then the
   Vomnibar would be unusable.  And that's pretty serious.
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 9 | 
1 files changed, 5 insertions, 4 deletions
| diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 4d081e90..7ff03ee5 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -143,7 +143,7 @@ initializeOnEnabledStateKnown = (isEnabledForUrl) ->    if isEnabledForUrl      # We only initialize (and activate) the Vomnibar in the top frame.  Also, we do not initialize the      # Vomnibar until we know that Vimium is enabled.  Thereafter, there's no more initialization to do. -    Vomnibar.init() if DomUtils.isTopFrame() +    DomUtils.documentComplete Vomnibar.init.bind Vomnibar if DomUtils.isTopFrame()      initializeOnEnabledStateKnown = ->  # @@ -635,10 +635,11 @@ window.HelpDialog ?=    abort: -> @helpUI.hide false if @isShowing()    toggle: (request) -> -    @helpUI ?= new UIComponent "pages/help_dialog.html", "vimiumHelpDialogFrame", -> -    if @isShowing() +    DomUtils.documentComplete => +      @helpUI ?= new UIComponent "pages/help_dialog.html", "vimiumHelpDialogFrame", -> +    if @helpUI? and @isShowing()        @helpUI.hide() -    else +    else if @helpUI?        @helpUI.activate extend request,          name: "activate", focus: true | 
