From 8a2f7bf9db05342bab2442f6b761f855fb0ca209 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 15 Dec 2014 19:12:41 +0000 Subject: Skip over tiny frames when calling focusThisFrame GMail and Google Inbox both use a large number of small (typically 0x0 or 1x1 frames) which we have to pass over with nextFrame to get to the frames we want. We avoid this issue by ignoring all frames with height or width < 3, since these will be essentially invisible to the user anyway. --- background_scripts/main.coffee | 1 + content_scripts/vimium_frontend.coffee | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 3ec618c9..647923c0 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -633,6 +633,7 @@ sendRequestHandlers = registerFrame: registerFrame, unregisterFrame: unregisterFrame, frameFocused: handleFrameFocused, + nextFrame: (request) -> BackgroundCommands.nextFrame 1, request.frameId upgradeNotificationClosed: upgradeNotificationClosed, updateScrollPosition: handleUpdateScrollPosition, copyToClipboard: copyToClipboard, diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 31f0eab5..cd7a7605 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -225,6 +225,10 @@ setScrollPosition = (scrollX, scrollY) -> # Called from the backend in order to change frame focus. # window.focusThisFrame = (shouldHighlight) -> + 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. + chrome.runtime.sendMessage({ handler: "nextFrame", frameId: frameId }) + return window.focus() if (document.body && shouldHighlight) borderWas = document.body.style.border -- cgit v1.2.3 From a36a735fca856bb59dd62b6bc77c56431cc9b9fd Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Tue, 16 Dec 2014 15:40:04 +0000 Subject: Add comments to nextFrame logic. --- content_scripts/vimium_frontend.coffee | 2 ++ 1 file changed, 2 insertions(+) diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 4ab6556f..491f5750 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -227,6 +227,8 @@ setScrollPosition = (scrollX, scrollY) -> window.focusThisFrame = (shouldHighlight) -> 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. + # NOTE(smblott) We assume that there is at least one frame large enough to focus. + # See #1317. chrome.runtime.sendMessage({ handler: "nextFrame", frameId: frameId }) return window.focus() -- cgit v1.2.3