From d630f966e7a3e680018dc362f67ebc53e8bc8c90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Tue, 23 Feb 2016 20:23:11 +0100 Subject: [PATCH] hints: ignore too small rectangles returned by getClientRects() Apparently we can have a '1px x 1px' rectangle at some zoom levels and '0px x 0px' at others. We can't reliably click these, so let's ignore them. --- qutebrowser/browser/hints.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index b5695badc..ef2f37f6c 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -424,12 +424,12 @@ class HintManager(QObject): """Return the element's first client rectangle with positive size. Uses the getClientRects() JavaScript method to obtain the collection of - rectangles containing the element and returns the first with positive - dimensions. Falls back to elem.rect_on_view() in case all rectangles - returned by getClientRects() have zero dimensions. + rectangles containing the element and returns the first rectangle which + is large enough (larger than 1px times 1px). If all rectangles returned + by getClientRects() are too small, falls back to elem.rect_on_view(). - Skipping of rectangles with zero dimensions is due to elements - containing other elements with "display:block" style, see + Skipping of small rectangles is due to elements containing other + elements with "display:block" style, see https://github.com/The-Compiler/qutebrowser/issues/1298 Args: @@ -442,7 +442,7 @@ class HintManager(QObject): rect = rects[str(i)] width = rect.get("width", 0) height = rect.get("height", 0) - if width > 0 and height > 0: + if width > 1 and height > 1: # fix coordinates according to zoom level zoom = elem.webFrame().zoomFactor() if not config.get('ui', 'zoom-text-only'):