diff options
| author | Stephen Blott | 2015-06-04 16:07:57 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-06-04 16:07:59 +0100 |
| commit | 9600d258cbadd80568e37637974172e7755ca28c (patch) | |
| tree | 2ab011a242a93294ffe901cd253df6e9a093e623 | |
| parent | bc4f3ecac81fd8f174b8c3ad92a0998ada8f7992 (diff) | |
| download | vimium-9600d258cbadd80568e37637974172e7755ca28c.tar.bz2 | |
Global marks; only handle messages in main frame.
On sites with several frames (e.g. Facebook), if we allow all of the
frames to handle the setScrollPosition and showHudForDuration messages,
then the focus ends up in an arbitrary frame. And, on Facebook, say,
Vimium ends up broken until the focus is returned to the main frame.
So, we only handle these messages in the main frame.
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index dc083e6c..033bb2b3 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -142,7 +142,7 @@ initializePreDomReady = -> window.removeEventListener "focus", onFocus requestHandlers = - showHUDforDuration: (request) -> HUD.showForDuration request.text, request.duration + showHUDforDuration: handleShowHUDforDuration toggleHelpDialog: (request) -> toggleHelpDialog(request.dialogHtml, request.frameId) focusFrame: (request) -> if (frameId == request.frameId) then focusThisFrame request refreshCompletionKeys: refreshCompletionKeys @@ -264,13 +264,16 @@ executePageCommand = (request) -> refreshCompletionKeys(request) -# Set the scroll position (but only in the main frame). Some pages (like Facebook) get confused if you set -# the scroll position in all frames. +handleShowHUDforDuration = ({ text, duration }) -> + if DomUtils.isTopFrame() + DomUtils.documentReady -> HUD.showForDuration text, duration + setScrollPosition = ({ scrollX, scrollY }) -> if DomUtils.isTopFrame() - if scrollX > 0 or scrollY > 0 - DomUtils.documentReady -> - window.focus() + DomUtils.documentReady -> + window.focus() + document.body.focus() + if 0 < scrollX or 0 < scrollY Marks.setPreviousPosition() window.scrollTo scrollX, scrollY |
