diff options
| author | mrmr1993 | 2015-05-29 04:28:58 +0100 | 
|---|---|---|
| committer | mrmr1993 | 2015-06-10 17:21:22 +0100 | 
| commit | dcc8d6ee0dadf4f7a473ab97bd8e20c282a3c445 (patch) | |
| tree | 1a61d6de3fc5eb20f960c5871f40efba32b51b69 /content_scripts/hud.coffee | |
| parent | 4f0cd5ba260f9b23d70bfd816efae43dc64d1e0a (diff) | |
| download | vimium-dcc8d6ee0dadf4f7a473ab97bd8e20c282a3c445.tar.bz2 | |
Accept input in the HUD iframe
Diffstat (limited to 'content_scripts/hud.coffee')
| -rw-r--r-- | content_scripts/hud.coffee | 24 | 
1 files changed, 16 insertions, 8 deletions
diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index 64ebd8e3..787be6a9 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -28,10 +28,6 @@ HUD =    showFindMode: (text = "") ->      return unless @enabled() -    # NOTE(mrmr1993): We set findModeQuery.rawQuery here rather in search while we still handle keys in the -    # main frame. When key handling is moved to the HUD iframe, this line should be deleted, and the -    # equivalent in search should be uncommented. -    findModeQuery.rawQuery = text      @hudUI.show {name: "showFindMode", text}      @tween.fade 1.0, 150 @@ -39,10 +35,7 @@ HUD =      @hudUI.postMessage {name: "updateMatchesCount", matchCount, showMatchText}    search: (data) -> -    # NOTE(mrmr1993): The following line is disabled as it is currently vulnerable to a race condition when a -    # user types quickly. When all of the key handling is done in the HUD iframe, this should be uncommented, -    # and the equivalent line in showFindMode should be deleted. -    #findModeQuery.rawQuery = data.query +    findModeQuery.rawQuery = data.query      updateFindModeQuery()      performFindInPlace()      showFindModeHUDForQuery() @@ -63,6 +56,21 @@ HUD =      else        @tween.fade 0, 150, => @hide true, updateIndicator +  hideFindMode: (data) -> +    # An element element won't receive a focus event if the search landed on it while we were in the HUD +    # iframe. To end up with the correct modes active, we create a focus/blur event manually after refocusing +    # this window. +    window.focus() +    focusNode = window.getSelection().focusNode +    focusNode = focusNode.parentElement if focusNode? and focusNode.nodeType != focusNode.ELEMENT_NODE +    if focusNode? and DomUtils.isFocusable focusNode +      focusNode.focus() +    else +      document.activeElement?.blur() + +    findModeQuery.rawQuery = data.query +    handlerStack.bubbleEvent "keydown", data.event +    isReady: do ->      ready = false      DomUtils.documentReady -> ready = true  | 
