aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-03-07 16:05:27 +0000
committerStephen Blott2015-03-07 16:05:27 +0000
commitae60abb94665446200db8a750bbc1362895d04d2 (patch)
tree60b9ae15af8206e1cf040eafcc9891e153df17a6
parent3e0d5f0538a5db5a170eb35f6ef44f11d4923d42 (diff)
parent3c988a07a64a5bf4cab9ec98fe4d377c2af2208e (diff)
downloadvimium-ae60abb94665446200db8a750bbc1362895d04d2.tar.bz2
Merge branch 'fix-vomnibar-visibility'
-rw-r--r--content_scripts/vomnibar.coffee5
-rw-r--r--pages/vomnibar.coffee28
2 files changed, 24 insertions, 9 deletions
diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee
index 6381fd7f..c4cfc8b9 100644
--- a/content_scripts/vomnibar.coffee
+++ b/content_scripts/vomnibar.coffee
@@ -38,7 +38,10 @@ Vomnibar =
init: ->
unless @vomnibarUI?
@vomnibarUI = new UIComponent "pages/vomnibar.html", "vomnibarFrame", (event) =>
- @vomnibarUI.hide() if event.data == "hide"
+ if event.data == "hide"
+ @vomnibarUI.hide()
+ @vomnibarUI.postMessage "hidden"
+
# This function opens the vomnibar. It accepts options, a map with the values:
# completer - The completer to fetch results from.
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee
index d0b7a7dd..906aa0f3 100644
--- a/pages/vomnibar.coffee
+++ b/pages/vomnibar.coffee
@@ -39,10 +39,12 @@ Vomnibar =
@vomnibarUI.update()
hide: -> @vomnibarUI?.hide()
+ onHidden: -> @vomnibarUI?.onHidden()
class VomnibarUI
constructor: ->
@refreshInterval = 0
+ @postHideCallback = null
@initDom()
setQuery: (query) -> @input.value = query
@@ -59,9 +61,10 @@ class VomnibarUI
setForceNewTab: (forceNewTab) -> @forceNewTab = forceNewTab
- hide: ->
+ hide: (callback = null) ->
UIComponentServer.postMessage "hide"
@reset()
+ @postHideCallback = callback
reset: ->
@completionList.style.display = ""
@@ -70,6 +73,12 @@ class VomnibarUI
@completions = []
@selection = @initialSelectionValue
+ # Called after the vomnibar has been hidden. We wait until after the vomnibar has been hidden to avoid
+ # vomnibar flicker (see #1485).
+ onHidden: ->
+ @postHideCallback?()
+ @postHideCallback = null
+
updateSelection: ->
# We retain global state here (previousAutoSelect) to tell if a search item (for which autoSelect is set)
# has just appeared or disappeared. If that happens, we set @selection to 0 or -1.
@@ -123,15 +132,15 @@ class VomnibarUI
query = @input.value.trim()
# <Enter> on an empty vomnibar is a no-op.
return unless 0 < query.length
- @hide()
- chrome.runtime.sendMessage({
- handler: if openInNewTab then "openUrlInNewTab" else "openUrlInCurrentTab"
- url: query })
+ @hide ->
+ chrome.runtime.sendMessage
+ handler: if openInNewTab then "openUrlInNewTab" else "openUrlInCurrentTab"
+ url: query
else
@update true, =>
# Shift+Enter will open the result in a new tab instead of the current tab.
- @completions[@selection].performAction(openInNewTab)
- @hide()
+ completion = @completions[@selection]
+ @hide -> completion.performAction openInNewTab
# It seems like we have to manually suppress the event here and still return true.
event.stopImmediatePropagation()
@@ -234,7 +243,10 @@ extend BackgroundCompleter,
switchToTab: (tabId) -> chrome.runtime.sendMessage({ handler: "selectSpecificTab", id: tabId })
UIComponentServer.registerHandler (event) ->
- if event.data == "hide" then Vomnibar.hide() else Vomnibar.activate event.data
+ switch event.data
+ when "hide" then Vomnibar.hide()
+ when "hidden" then Vomnibar.onHidden()
+ else Vomnibar.activate event.data
root = exports ? window
root.Vomnibar = Vomnibar