diff options
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/ui_component.coffee | 10 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 12 | ||||
| -rw-r--r-- | content_scripts/vomnibar.coffee | 18 |
3 files changed, 21 insertions, 19 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index 3d8cef29..185d525a 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -15,9 +15,11 @@ class UIComponent # Hide the iframe, but don't interfere with the focus. @hide false - # If any other frame in the current tab receives the focus, then we hide the vomnibar. + # If any other frame in the current tab receives the focus, then we hide the UI component. + # NOTE(smblott) This is correct for the vomnibar, but might be incorrect (and need to be revisited) for + # other UI components. chrome.runtime.onMessage.addListener (request) => - @hide false if @showing and request.name == "frameFocused" and request.frameId != frameId + @hide false if @showing and request.name == "frameFocused" and request.focusFrameId != frameId false # Free up response handler. # Open a port and pass it to the iframe via window.postMessage. @@ -57,12 +59,12 @@ class UIComponent @iframeElement.classList.add "vimiumUIComponentHidden" window.removeEventListener "focus", @onFocus if @onFocus @onFocus = null - if focusWindow and @options?.frameId? + if focusWindow and @options?.sourceFrameId? chrome.runtime.sendMessage handler: "sendMessageToFrames" message: name: "focusFrame" - frameId: @options.frameId + frameId: @options.sourceFrameId highlight: true # true for debugging; should be false when live. @options = null @showing = false 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 ] diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee index 823dcd01..3d54e643 100644 --- a/content_scripts/vomnibar.coffee +++ b/content_scripts/vomnibar.coffee @@ -4,33 +4,33 @@ Vomnibar = vomnibarUI: null - # frameId here (and below) is the ID of the frame from which this request originates, which may be different + # sourceFrameId here (and below) is the ID of the frame from which this request originates, which may be different # from the current frame. - activate: (frameId) -> @open frameId, {completer:"omni"} - activateInNewTab: (frameId) -> @open frameId, { + activate: (sourceFrameId) -> @open sourceFrameId, {completer:"omni"} + activateInNewTab: (sourceFrameId) -> @open sourceFrameId, { completer: "omni" selectFirst: false newTab: true } - activateTabSelection: (frameId) -> @open frameId, { + activateTabSelection: (sourceFrameId) -> @open sourceFrameId, { completer: "tabs" selectFirst: true } - activateBookmarks: (frameId) -> @open frameId, { + activateBookmarks: (sourceFrameId) -> @open sourceFrameId, { completer: "bookmarks" selectFirst: true } - activateBookmarksInNewTab: (frameId) -> @open frameId, { + activateBookmarksInNewTab: (sourceFrameId) -> @open sourceFrameId, { completer: "bookmarks" selectFirst: true newTab: true } - activateEditUrl: (frameId) -> @open frameId, { + activateEditUrl: (sourceFrameId) -> @open sourceFrameId, { completer: "omni" selectFirst: false query: window.location.href } - activateEditUrlInNewTab: (frameId) -> @open frameId, { + activateEditUrlInNewTab: (sourceFrameId) -> @open sourceFrameId, { completer: "omni" selectFirst: false query: window.location.href @@ -50,7 +50,7 @@ Vomnibar = # query - Optional. Text to prefill the Vomnibar with. # selectFirst - Optional, boolean. Whether to select the first entry. # newTab - Optional, boolean. Whether to open the result in a new tab. - open: (frameId, options) -> @vomnibarUI.activate extend options, { frameId } + open: (sourceFrameId, options) -> @vomnibarUI.activate extend options, { sourceFrameId } root = exports ? window root.Vomnibar = Vomnibar |
