hints: position according to getClientRects()

This commit is contained in:
Jakub Klinkovský 2016-02-16 00:21:46 +01:00
parent 4c06e34074
commit c919fcba35

View File

@ -351,7 +351,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'),
@ -377,15 +377,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))
@ -438,7 +434,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)]