Merge branch 'hints_positioning' of https://github.com/lahwaacz/qutebrowser into lahwaacz-hints_positioning
This commit is contained in:
commit
0e4dbd646c
@ -350,7 +350,7 @@ class HintManager(QObject):
|
|||||||
('display', 'inline !important'),
|
('display', 'inline !important'),
|
||||||
('z-index', '{} !important'.format(int(2 ** 32 / 2 - 1))),
|
('z-index', '{} !important'.format(int(2 ** 32 / 2 - 1))),
|
||||||
('pointer-events', 'none !important'),
|
('pointer-events', 'none !important'),
|
||||||
('position', 'absolute !important'),
|
('position', 'fixed !important'),
|
||||||
('color', config.get('colors', 'hints.fg') + ' !important'),
|
('color', config.get('colors', 'hints.fg') + ' !important'),
|
||||||
('background', config.get('colors', 'hints.bg') + ' !important'),
|
('background', config.get('colors', 'hints.bg') + ' !important'),
|
||||||
('font', config.get('fonts', 'hints') + ' !important'),
|
('font', config.get('fonts', 'hints') + ' !important'),
|
||||||
@ -376,15 +376,11 @@ class HintManager(QObject):
|
|||||||
elem: The QWebElement to set the style attributes for.
|
elem: The QWebElement to set the style attributes for.
|
||||||
label: The label QWebElement.
|
label: The label QWebElement.
|
||||||
"""
|
"""
|
||||||
rect = elem.geometry()
|
rect = self._get_first_rectangle(elem)
|
||||||
left = rect.x()
|
left = rect.x()
|
||||||
top = rect.y()
|
top = rect.y()
|
||||||
zoom = elem.webFrame().zoomFactor()
|
log.hints.vdebug("Drawing label '{!r}' at {}/{} for element '{!r}'"
|
||||||
if not config.get('ui', 'zoom-text-only'):
|
.format(label, left, top, elem))
|
||||||
left /= zoom
|
|
||||||
top /= zoom
|
|
||||||
log.hints.vdebug("Drawing label '{!r}' at {}/{} for element '{!r}', "
|
|
||||||
"zoom level {}".format(label, left, top, elem, zoom))
|
|
||||||
label.setStyleProperty('left', '{}px !important'.format(left))
|
label.setStyleProperty('left', '{}px !important'.format(left))
|
||||||
label.setStyleProperty('top', '{}px !important'.format(top))
|
label.setStyleProperty('top', '{}px !important'.format(top))
|
||||||
|
|
||||||
@ -437,7 +433,7 @@ class HintManager(QObject):
|
|||||||
elem: The QWebElement of interest.
|
elem: The QWebElement of interest.
|
||||||
"""
|
"""
|
||||||
rects = elem.evaluateJavaScript("this.getClientRects()")
|
rects = elem.evaluateJavaScript("this.getClientRects()")
|
||||||
log.hints.debug("Client rectangles of element '{}': {}"
|
log.hints.vdebug("Client rectangles of element '{}': {}"
|
||||||
.format(elem.debug_text(), rects))
|
.format(elem.debug_text(), rects))
|
||||||
for i in range(int(rects.get("length", 0))):
|
for i in range(int(rects.get("length", 0))):
|
||||||
rect = rects[str(i)]
|
rect = rects[str(i)]
|
||||||
@ -481,11 +477,15 @@ class HintManager(QObject):
|
|||||||
else:
|
else:
|
||||||
target_mapping[Target.tab] = usertypes.ClickTarget.tab
|
target_mapping[Target.tab] = usertypes.ClickTarget.tab
|
||||||
|
|
||||||
# FIXME Instead of clicking the center, we could have nicer heuristics.
|
# Click the center of the largest square fitting into the top/left
|
||||||
# e.g. parse (-webkit-)border-radius correctly and click text fields at
|
# corner of the rectangle, this will help if part of the <a> element
|
||||||
# the bottom right, and everything else on the top left or so.
|
# is hidden behind other elements
|
||||||
# https://github.com/The-Compiler/qutebrowser/issues/70
|
# https://github.com/The-Compiler/qutebrowser/issues/1005
|
||||||
rect = self._get_first_rectangle(elem)
|
rect = self._get_first_rectangle(elem)
|
||||||
|
if rect.width() > rect.height():
|
||||||
|
rect.setWidth(rect.height())
|
||||||
|
else:
|
||||||
|
rect.setHeight(rect.width())
|
||||||
pos = rect.center()
|
pos = rect.center()
|
||||||
|
|
||||||
action = "Hovering" if context.target == Target.hover else "Clicking"
|
action = "Hovering" if context.target == Target.hover else "Clicking"
|
||||||
|
@ -113,8 +113,6 @@ Feature: Using hints
|
|||||||
@xfail_norun
|
@xfail_norun
|
||||||
Scenario: Using :follow-hint inside an iframe
|
Scenario: Using :follow-hint inside an iframe
|
||||||
When I open data/hints/iframe.html
|
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 :hint links normal
|
||||||
And I run :follow-hint a
|
And I run :follow-hint a
|
||||||
Then "acceptNavigationRequest, url http://localhost:*/data/hello.txt, type NavigationTypeLinkClicked, *" should be logged
|
Then "acceptNavigationRequest, url http://localhost:*/data/hello.txt, type NavigationTypeLinkClicked, *" should be logged
|
||||||
|
Loading…
Reference in New Issue
Block a user