From 1ae621489da091e6d9430da248d0e6eaab606f35 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 16 Mar 2015 09:35:24 +0000 Subject: Activate vomnibar in window.top. This changes vomnibar commands to activate not in the current frame, but in window.top. Consequently, the vomnibar always appears in the same position, and we don't get odd looking vomnibars in small frames. Apart from the better UX, this seems to be the right thing to do. Vomnibar commands apply to tabs (not frames). Currently incomplete: - On exit, the focus is not returned to the frame which originally had the focus. (It's returned to window.top). - The vomnibar can lose the focus and not hide itself for various frame/click combinations. --- content_scripts/vimium_frontend.coffee | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 429657fc..0aaee3db 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -241,7 +241,7 @@ initializeOnDomReady = -> # Tell the background page we're in the dom ready state. chrome.runtime.connect({ name: "domReady" }) CursorHider.init() - Vomnibar.init() + Vomnibar.init() if window.top == window registerFrame = -> # Don't register frameset containers; focusing them is no use. @@ -258,6 +258,14 @@ unregisterFrame = -> tab_is_closing: window.top == window.self executePageCommand = (request) -> + # Vomnibar commands are handled in the tab's main frame. + if request.command.split(".")[0] == "Vomnibar" + if window.top == window + Utils.invokeCommandString request.command + refreshCompletionKeys request + return + + # All other commands are handled in their frame. return unless frameId == request.frameId if (request.passCountToFunction) -- cgit v1.2.3 From efada88f419933c5bd1478faada3b4eff3082103 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 17 Mar 2015 09:18:52 +0000 Subject: Activate vomnibar in window.top; refocus original frame. --- content_scripts/vimium_frontend.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 0aaee3db..cdb47613 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -232,7 +232,9 @@ getActiveState = -> registerFocus = -> # settings may have changed since the frame last had focus settings.load() - chrome.runtime.sendMessage({ handler: "frameFocused", frameId: frameId }) + # Don't register frameset containers; focusing them is no use. + unless document.body?.tagName.toLowerCase() == "frameset" + chrome.runtime.sendMessage({ handler: "frameFocused", frameId: frameId }) # # Initialization tasks that must wait for the document to be ready. @@ -261,7 +263,9 @@ executePageCommand = (request) -> # Vomnibar commands are handled in the tab's main frame. if request.command.split(".")[0] == "Vomnibar" if window.top == window - Utils.invokeCommandString request.command + # We pass the frameId from request. That's the frame which originated the request, so that's the frame + # that needs to receive the focus when we're done. + Utils.invokeCommandString request.command, [ request.frameId ] refreshCompletionKeys request return @@ -283,6 +287,7 @@ setScrollPosition = (scrollX, scrollY) -> # Called from the backend in order to change frame focus. # window.focusThisFrame = (shouldHighlight) -> + console.log "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" if window.innerWidth < 3 or window.innerHeight < 3 # This frame is too small to focus. Cancel and tell the background frame to focus the next one instead. # This affects sites like Google Inbox, which have many tiny iframes. See #1317. -- cgit v1.2.3 From e65f4d4e8a498e34a18c64898cb7425caee9fdc0 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 17 Mar 2015 09:34:43 +0000 Subject: Activate vomnibar in window.top; minor clean up. --- content_scripts/vimium_frontend.coffee | 1 - 1 file changed, 1 deletion(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index cdb47613..eb951c33 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -287,7 +287,6 @@ setScrollPosition = (scrollX, scrollY) -> # Called from the backend in order to change frame focus. # window.focusThisFrame = (shouldHighlight) -> - console.log "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" if window.innerWidth < 3 or window.innerHeight < 3 # This frame is too small to focus. Cancel and tell the background frame to focus the next one instead. # This affects sites like Google Inbox, which have many tiny iframes. See #1317. -- cgit v1.2.3 From 9461d30b0d19fd65dc43e18bebec1fe0fd3ee818 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 17 Mar 2015 10:32:40 +0000 Subject: Activate vomnibar in window.top; hide on focus. --- content_scripts/vimium_frontend.coffee | 1 + 1 file changed, 1 insertion(+) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index eb951c33..941b2bc2 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -178,6 +178,7 @@ initializePreDomReady = -> currentKeyQueue: (request) -> keyQueue = request.keyQueue handlerStack.bubbleEvent "registerKeyQueue", { keyQueue: keyQueue } + frameFocused: -> # A frame has received the focus. We don't care, here. The Vomnibar/UI-component cares. chrome.runtime.onMessage.addListener (request, sender, sendResponse) -> # In the options page, we will receive requests from both content and background scripts. ignore those -- cgit v1.2.3 From 8bc811aae1118e28faa7c17e67b039c67f637274 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 17 Mar 2015 11:42:58 +0000 Subject: Activate vomnibar in window.top; hide on focus, fixed. --- content_scripts/vimium_frontend.coffee | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 941b2bc2..90b25a40 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -94,7 +94,12 @@ settings = # # Give this frame a unique id. # -frameId = Math.floor(Math.random()*999999999) +window.frameId = Math.floor(Math.random()*999999999) + +# For debugging only. This logs to the console on the background page. +window.bgLog = (args...) -> + args = (arg.toString() for arg in args) + chrome.runtime.sendMessage handler: "log", frameId: frameId, message: args.join " " # If an input grabs the focus before the user has interacted with the page, then grab it back (if the # grabBackFocus option is set). @@ -230,12 +235,13 @@ getActiveState = -> # # The backend needs to know which frame has focus. # -registerFocus = -> - # settings may have changed since the frame last had focus - settings.load() - # Don't register frameset containers; focusing them is no use. - unless document.body?.tagName.toLowerCase() == "frameset" - chrome.runtime.sendMessage({ handler: "frameFocused", frameId: frameId }) +registerFocus = (event) -> + if event.target == window + # settings may have changed since the frame last had focus + settings.load() + # Don't register frameset containers; focusing them is no use. + unless document.body?.tagName.toLowerCase() == "frameset" + chrome.runtime.sendMessage({ handler: "frameFocused", frameId: frameId }) # # Initialization tasks that must wait for the document to be ready. -- cgit v1.2.3 From 4399e2e4fffc4faba9f1505dfc0ad3150a948632 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 17 Mar 2015 12:06:15 +0000 Subject: Activate vomnibar in window.top; more clean up. --- content_scripts/vimium_frontend.coffee | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 90b25a40..072789a4 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -237,11 +237,11 @@ getActiveState = -> # registerFocus = (event) -> if event.target == window - # settings may have changed since the frame last had focus + # Settings may have changed since the frame last had focus. settings.load() # Don't register frameset containers; focusing them is no use. unless document.body?.tagName.toLowerCase() == "frameset" - chrome.runtime.sendMessage({ handler: "frameFocused", frameId: frameId }) + chrome.runtime.sendMessage handler: "frameFocused", frameId: frameId # # Initialization tasks that must wait for the document to be ready. @@ -250,7 +250,7 @@ initializeOnDomReady = -> # Tell the background page we're in the dom ready state. chrome.runtime.connect({ name: "domReady" }) CursorHider.init() - Vomnibar.init() if window.top == window + Vomnibar.init() if DomUtils.isTopFrame() registerFrame = -> # Don't register frameset containers; focusing them is no use. @@ -264,12 +264,12 @@ unregisterFrame = -> chrome.runtime.sendMessage handler: "unregisterFrame" frameId: frameId - tab_is_closing: window.top == window.self + tab_is_closing: DomUtils.isTopFrame() executePageCommand = (request) -> - # Vomnibar commands are handled in the tab's main frame. + # Vomnibar commands are handled in the tab's main/top frame. if request.command.split(".")[0] == "Vomnibar" - if window.top == window + if DomUtils.isTopFrame() # We pass the frameId from request. That's the frame which originated the request, so that's the frame # that needs to receive the focus when we're done. Utils.invokeCommandString request.command, [ request.frameId ] -- cgit v1.2.3 From 71d33fdeaa5c081de5041a6a0909d452e1564633 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 17 Mar 2015 13:21:02 +0000 Subject: Activate vomnibar in window.top; fix race condition on close. --- content_scripts/vimium_frontend.coffee | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 072789a4..dccdfe76 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -173,7 +173,7 @@ initializePreDomReady = -> showUpgradeNotification: (request) -> HUD.showUpgradeNotification(request.version) showHUDforDuration: (request) -> HUD.showForDuration request.text, request.duration toggleHelpDialog: (request) -> toggleHelpDialog(request.dialogHtml, request.frameId) - focusFrame: (request) -> if (frameId == request.frameId) then focusThisFrame(request.highlight) + focusFrame: (request) -> if (frameId == request.frameId) then focusThisFrame request refreshCompletionKeys: refreshCompletionKeys getScrollPosition: -> scrollX: window.scrollX, scrollY: window.scrollY setScrollPosition: (request) -> setScrollPosition request.scrollX, request.scrollY @@ -293,7 +293,7 @@ setScrollPosition = (scrollX, scrollY) -> # # Called from the backend in order to change frame focus. # -window.focusThisFrame = (shouldHighlight) -> +window.focusThisFrame = (request) -> if window.innerWidth < 3 or window.innerHeight < 3 # This frame is too small to focus. Cancel and tell the background frame to focus the next one instead. # This affects sites like Google Inbox, which have many tiny iframes. See #1317. @@ -301,7 +301,9 @@ window.focusThisFrame = (shouldHighlight) -> chrome.runtime.sendMessage({ handler: "nextFrame", frameId: frameId }) return window.focus() - if (document.body && shouldHighlight) + shouldHighlight = request.highlight + shouldHighlight ||= request.highlightOnlyIfNotTop and not DomUtils.isTopFrame() + if document.body and shouldHighlight borderWas = document.body.style.border document.body.style.border = '5px solid yellow' setTimeout((-> document.body.style.border = borderWas), 200) -- cgit v1.2.3 From b65f285aa65b2cfbdaefb4d7c445dbd5e684fbbf Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 17 Mar 2015 14:29:12 +0000 Subject: Activate vomnibar in window.top; more clean up. Clean up, and fixes following code review from @mrmr1993. --- content_scripts/vimium_frontend.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index dccdfe76..11ef30cc 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -94,10 +94,10 @@ settings = # # Give this frame a unique id. # -window.frameId = Math.floor(Math.random()*999999999) +frameId = Math.floor(Math.random()*999999999) # For debugging only. This logs to the console on the background page. -window.bgLog = (args...) -> +bgLog = (args...) -> args = (arg.toString() for arg in args) chrome.runtime.sendMessage handler: "log", frameId: frameId, message: args.join " " @@ -271,7 +271,7 @@ executePageCommand = (request) -> if request.command.split(".")[0] == "Vomnibar" if DomUtils.isTopFrame() # We pass the frameId from request. That's the frame which originated the request, so that's the frame - # that needs to receive the focus when we're done. + # which whould receive the focus when the vomnibar closes. Utils.invokeCommandString request.command, [ request.frameId ] refreshCompletionKeys request return @@ -1238,3 +1238,4 @@ root.settings = settings root.HUD = HUD root.handlerStack = handlerStack root.frameId = frameId +root.bgLog = bgLog -- cgit v1.2.3 From 8d09dc19c3e1afb629becef02d7d6cc58d13eaad Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 17 Mar 2015 15:08:21 +0000 Subject: Activate vomnibar in window.top; yet more clean up. --- content_scripts/vimium_frontend.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 11ef30cc..a057d654 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -192,6 +192,9 @@ initializePreDomReady = -> return unless isEnabledForUrl or request.name == 'getActiveState' or request.name == 'setState' # These requests are delivered to the options page, but there are no handlers there. return if request.handler in [ "registerFrame", "frameFocused", "unregisterFrame" ] + # We don't handle these here. They're handled elsewhere (e.g. in the vomnibar/UI component). + return if request.name in [ "frameFocused" ] + # Handle the request. sendResponse requestHandlers[request.name](request, sender) # Ensure the sendResponse callback is freed. false @@ -271,7 +274,7 @@ executePageCommand = (request) -> if request.command.split(".")[0] == "Vomnibar" if DomUtils.isTopFrame() # We pass the frameId from request. That's the frame which originated the request, so that's the frame - # which whould receive the focus when the vomnibar closes. + # which should receive the focus when the vomnibar closes. Utils.invokeCommandString request.command, [ request.frameId ] refreshCompletionKeys request return -- cgit v1.2.3 From 49c52049f8e54c7a8a4e4432bc147d781a481c1a Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 17 Mar 2015 15:43:48 +0000 Subject: Activate vomnibar in window.top; fix dropped line. --- content_scripts/vimium_frontend.coffee | 1 + 1 file changed, 1 insertion(+) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index a057d654..81e0e3b2 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -242,6 +242,7 @@ registerFocus = (event) -> if event.target == window # Settings may have changed since the frame last had focus. settings.load() + checkIfEnabledForUrl() # Don't register frameset containers; focusing them is no use. unless document.body?.tagName.toLowerCase() == "frameset" chrome.runtime.sendMessage handler: "frameFocused", frameId: frameId -- cgit v1.2.3 From a469e8265ab5121bdb83935e977c8a89777572b0 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 18 Apr 2015 15:47:38 +0100 Subject: Activate vomnibar in window.top; add "labs" option. --- content_scripts/vimium_frontend.coffee | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 81e0e3b2..95c508ef 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -44,7 +44,7 @@ settings = loadedValues: 0 valuesToLoad: [ "scrollStepSize", "linkHintCharacters", "linkHintNumbers", "filterLinkHints", "hideHud", "previousPatterns", "nextPatterns", "regexFindMode", "userDefinedLinkHintCss", - "helpDialog_showAdvancedCommands", "smoothScroll", "grabBackFocus" ] + "helpDialog_showAdvancedCommands", "smoothScroll", "grabBackFocus", "vomnibarInTopFrame" ] isLoaded: false eventListeners: {} @@ -254,7 +254,7 @@ initializeOnDomReady = -> # Tell the background page we're in the dom ready state. chrome.runtime.connect({ name: "domReady" }) CursorHider.init() - Vomnibar.init() if DomUtils.isTopFrame() + Vomnibar.init() # if DomUtils.isTopFrame() registerFrame = -> # Don't register frameset containers; focusing them is no use. @@ -273,11 +273,12 @@ unregisterFrame = -> executePageCommand = (request) -> # Vomnibar commands are handled in the tab's main/top frame. if request.command.split(".")[0] == "Vomnibar" - if DomUtils.isTopFrame() - # We pass the frameId from request. That's the frame which originated the request, so that's the frame - # which should receive the focus when the vomnibar closes. - Utils.invokeCommandString request.command, [ request.frameId ] - refreshCompletionKeys request + if (DomUtils.isTopFrame() and settings.get "vomnibarInTopFrame") or + (frameId == request.frameId and not settings.get "vomnibarInTopFrame") + # We pass the frameId from request. That's the frame which originated the request, so that's the frame + # which should receive the focus when the vomnibar closes. + Utils.invokeCommandString request.command, [ request.frameId ] + refreshCompletionKeys request return # All other commands are handled in their frame. -- cgit v1.2.3 From d67347461da5a0468547e4c807a54bb40746faf4 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 19 Apr 2015 07:40:59 +0100 Subject: Activate vomnibar in window.top; handle Vomnibar even if disabled. Vomnibar commands are handled in a frame even is isEnabledForUrl is false. --- content_scripts/vimium_frontend.coffee | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 95c508ef..a75f77e2 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -189,7 +189,8 @@ initializePreDomReady = -> # In the options page, we will receive requests from both content and background scripts. ignore those # from the former. return if sender.tab and not sender.tab.url.startsWith 'chrome-extension://' - return unless isEnabledForUrl or request.name == 'getActiveState' or request.name == 'setState' + # We handle the message if we're enabled, or if it's one of these listed message types. + return unless isEnabledForUrl or request.name in [ "getActiveState", "setState", "executePageCommand" ] # These requests are delivered to the options page, but there are no handlers there. return if request.handler in [ "registerFrame", "frameFocused", "unregisterFrame" ] # We don't handle these here. They're handled elsewhere (e.g. in the vomnibar/UI component). @@ -254,7 +255,8 @@ initializeOnDomReady = -> # Tell the background page we're in the dom ready state. chrome.runtime.connect({ name: "domReady" }) CursorHider.init() - Vomnibar.init() # if DomUtils.isTopFrame() + # We only initialize the vomnibar in the tab's main frame, because it's only ever opened there. + Vomnibar.init() if DomUtils.isTopFrame() registerFrame = -> # Don't register frameset containers; focusing them is no use. @@ -271,18 +273,17 @@ unregisterFrame = -> tab_is_closing: DomUtils.isTopFrame() executePageCommand = (request) -> - # Vomnibar commands are handled in the tab's main/top frame. - if request.command.split(".")[0] == "Vomnibar" - if (DomUtils.isTopFrame() and settings.get "vomnibarInTopFrame") or - (frameId == request.frameId and not settings.get "vomnibarInTopFrame") - # We pass the frameId from request. That's the frame which originated the request, so that's the frame - # which should receive the focus when the vomnibar closes. - Utils.invokeCommandString request.command, [ request.frameId ] - refreshCompletionKeys request + # Vomnibar commands are handled in the tab's main/top frame. They are handled even if Vimium is otherwise + # disabled in the frame. + if request.command.split(".")[0] == "Vomnibar" and DomUtils.isTopFrame() + # We pass the frameId from request. That's the frame which originated the request, so that's the frame + # which should receive the focus when the vomnibar closes. + Utils.invokeCommandString request.command, [ request.frameId ] + refreshCompletionKeys request return - # All other commands are handled in their frame. - return unless frameId == request.frameId + # All other commands are handled in their frame (but only if Vimium is enabled). + return unless frameId == request.frameId and isEnabledForUrl if (request.passCountToFunction) Utils.invokeCommandString(request.command, [request.count]) -- cgit v1.2.3 From 2ed990d02a4b2663d96acf8f81dfbde7eb19bd54 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sun, 19 Apr 2015 08:15:49 +0100 Subject: Activate vomnibar in window.top; fix logic error. --- content_scripts/vimium_frontend.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index a75f77e2..7ffb35f1 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -275,7 +275,9 @@ unregisterFrame = -> executePageCommand = (request) -> # Vomnibar commands are handled in the tab's main/top frame. They are handled even if Vimium is otherwise # disabled in the frame. - if request.command.split(".")[0] == "Vomnibar" and DomUtils.isTopFrame() + console.log frameId, request + if request.command.split(".")[0] == "Vomnibar" + if DomUtils.isTopFrame() # We pass the frameId from request. That's the frame which originated the request, so that's the frame # which should receive the focus when the vomnibar closes. Utils.invokeCommandString request.command, [ request.frameId ] -- cgit v1.2.3 From 9eaa7330b1e4952e171cf53db855cf447c8e1e49 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Wed, 22 Apr 2015 14:50:10 +0100 Subject: Tidy up. Remove reference to unused setting "vomnibarInTopFrame". --- content_scripts/vimium_frontend.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 7ffb35f1..c5bc185f 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -44,7 +44,7 @@ settings = loadedValues: 0 valuesToLoad: [ "scrollStepSize", "linkHintCharacters", "linkHintNumbers", "filterLinkHints", "hideHud", "previousPatterns", "nextPatterns", "regexFindMode", "userDefinedLinkHintCss", - "helpDialog_showAdvancedCommands", "smoothScroll", "grabBackFocus", "vomnibarInTopFrame" ] + "helpDialog_showAdvancedCommands", "smoothScroll", "grabBackFocus" ] isLoaded: false eventListeners: {} @@ -275,7 +275,6 @@ unregisterFrame = -> executePageCommand = (request) -> # Vomnibar commands are handled in the tab's main/top frame. They are handled even if Vimium is otherwise # disabled in the frame. - console.log frameId, request if request.command.split(".")[0] == "Vomnibar" if DomUtils.isTopFrame() # We pass the frameId from request. That's the frame which originated the request, so that's the frame -- cgit v1.2.3 From bfa6c88b41acac4c98d06f324f25f8bb7b328614 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 23 Apr 2015 11:07:36 +0100 Subject: Activate vomnibar in window.top; no flicker and tidy up. 1. Rework event handling to eliminate frame flicker (a la #1485). 2. Tidy up logic. Which should make this more robust. --- content_scripts/vimium_frontend.coffee | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'content_scripts/vimium_frontend.coffee') diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index c5bc185f..931b8edf 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -19,6 +19,13 @@ keyQueue = null currentCompletionKeys = "" validFirstKeys = "" +# We track whther the current window has the focus or not. +windowIsFocused = do -> + windowHasFocus = document.hasFocus() + window.addEventListener "focus", (event) -> windowHasFocus = true if event.target == window; true + window.addEventListener "blur", (event) -> windowHasFocus = false if event.target == window; true + -> windowHasFocus + # The types in that we consider for focusInput command. Right now this is recalculated in # each content script. Alternatively we could calculate it once in the background page and use a request to # fetch it each time. @@ -192,7 +199,7 @@ initializePreDomReady = -> # We handle the message if we're enabled, or if it's one of these listed message types. return unless isEnabledForUrl or request.name in [ "getActiveState", "setState", "executePageCommand" ] # These requests are delivered to the options page, but there are no handlers there. - return if request.handler in [ "registerFrame", "frameFocused", "unregisterFrame" ] + return if request.handler in [ "registerFrame", "unregisterFrame" ] # We don't handle these here. They're handled elsewhere (e.g. in the vomnibar/UI component). return if request.name in [ "frameFocused" ] # Handle the request. @@ -1245,4 +1252,5 @@ root.settings = settings root.HUD = HUD root.handlerStack = handlerStack root.frameId = frameId +root.windowIsFocused = windowIsFocused root.bgLog = bgLog -- cgit v1.2.3