diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 530138c23..1b23f157a 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -350,7 +350,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'), @@ -376,15 +376,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)) @@ -437,7 +433,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)] @@ -481,11 +477,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" diff --git a/tests/end2end/features/hints.feature b/tests/end2end/features/hints.feature index 9d4470ebe..5bccf7ab4 100644 --- a/tests/end2end/features/hints.feature +++ b/tests/end2end/features/hints.feature @@ -113,8 +113,6 @@ Feature: Using hints @xfail_norun 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