From 4c06e3407438fc299618f8d2afbc99512b7bc608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Tue, 16 Feb 2016 00:19:22 +0100 Subject: [PATCH 1/3] hints: change click position to the center of the largest square fitting to the top/left corner of the rectangle --- qutebrowser/browser/hints.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 69252f106..b6f493162 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -482,11 +482,15 @@ class HintManager(QObject): else: target_mapping[Target.tab] = usertypes.ClickTarget.tab - # FIXME Instead of clicking the center, we could have nicer heuristics. - # e.g. parse (-webkit-)border-radius correctly and click text fields at - # the bottom right, and everything else on the top left or so. - # https://github.com/The-Compiler/qutebrowser/issues/70 + # Click the center of the largest square fitting into the top/left + # corner of the rectangle, this will help if part of the element + # is hidden behind other elements + # https://github.com/The-Compiler/qutebrowser/issues/1005 rect = self._get_first_rectangle(elem) + if rect.width() > rect.height(): + rect.setWidth(rect.height()) + else: + rect.setHeight(rect.width()) pos = rect.center() action = "Hovering" if context.target == Target.hover else "Clicking" From c919fcba3536b6415ba79a38cbc2c4e421b65577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Tue, 16 Feb 2016 00:21:46 +0100 Subject: [PATCH 2/3] hints: position according to getClientRects() --- qutebrowser/browser/hints.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index b6f493162..f89322898 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -351,7 +351,7 @@ class HintManager(QObject): ('display', 'inline !important'), ('z-index', '{} !important'.format(int(2 ** 32 / 2 - 1))), ('pointer-events', 'none !important'), - ('position', 'absolute !important'), + ('position', 'fixed !important'), ('color', config.get('colors', 'hints.fg') + ' !important'), ('background', config.get('colors', 'hints.bg') + ' !important'), ('font', config.get('fonts', 'hints') + ' !important'), @@ -377,15 +377,11 @@ class HintManager(QObject): elem: The QWebElement to set the style attributes for. label: The label QWebElement. """ - rect = elem.geometry() + rect = self._get_first_rectangle(elem) left = rect.x() top = rect.y() - zoom = elem.webFrame().zoomFactor() - if not config.get('ui', 'zoom-text-only'): - left /= zoom - top /= zoom - log.hints.vdebug("Drawing label '{!r}' at {}/{} for element '{!r}', " - "zoom level {}".format(label, left, top, elem, zoom)) + log.hints.vdebug("Drawing label '{!r}' at {}/{} for element '{!r}'" + .format(label, left, top, elem)) label.setStyleProperty('left', '{}px !important'.format(left)) label.setStyleProperty('top', '{}px !important'.format(top)) @@ -438,7 +434,7 @@ class HintManager(QObject): elem: The QWebElement of interest. """ rects = elem.evaluateJavaScript("this.getClientRects()") - log.hints.debug("Client rectangles of element '{}': {}" + log.hints.vdebug("Client rectangles of element '{}': {}" .format(elem.debug_text(), rects)) for i in range(int(rects.get("length", 0))): rect = rects[str(i)] From ee8247525e0a9894730fa5981bcdb3546b2d52a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= Date: Sun, 22 May 2016 15:19:00 +0200 Subject: [PATCH 3/3] simplify testcase for following a hint inside an iframe --- tests/integration/features/hints.feature | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/integration/features/hints.feature b/tests/integration/features/hints.feature index 4d4519fdd..9f9dab4a1 100644 --- a/tests/integration/features/hints.feature +++ b/tests/integration/features/hints.feature @@ -63,8 +63,6 @@ Feature: Using hints Scenario: Using :follow-hint inside an iframe When I open data/hints/iframe.html - And I run :hint all normal - And I run :follow-hint a And I run :hint links normal And I run :follow-hint a Then "acceptNavigationRequest, url http://localhost:*/data/hello.txt, type NavigationTypeLinkClicked, *" should be logged