Add initial hinting implementation
This commit is contained in:
parent
1b3d693a5e
commit
58d2d30e9a
@ -132,7 +132,33 @@ class WebEngineElement(webelem.AbstractWebElement):
|
||||
we want to avoid doing it twice.
|
||||
no_js: Fall back to the Python implementation
|
||||
"""
|
||||
log.stub()
|
||||
rects = self._js_dict['rects']
|
||||
for rect in rects:
|
||||
# FIXME:qtwebengine
|
||||
# width = rect.get("width", 0)
|
||||
# height = rect.get("height", 0)
|
||||
width = rect['width']
|
||||
height = rect['height']
|
||||
if width > 1 and height > 1:
|
||||
# fix coordinates according to zoom level
|
||||
# FIXME:qtwebengine
|
||||
# zoom = self._elem.webFrame().zoomFactor()
|
||||
# if not config.get('ui', 'zoom-text-only'):
|
||||
# rect["left"] *= zoom
|
||||
# rect["top"] *= zoom
|
||||
# width *= zoom
|
||||
# height *= zoom
|
||||
rect = QRect(rect["left"], rect["top"], width, height)
|
||||
# FIXME:qtwebengine
|
||||
# frame = self._elem.webFrame()
|
||||
# while frame is not None:
|
||||
# # Translate to parent frames' position (scroll position
|
||||
# # is taken care of inside getClientRects)
|
||||
# rect.translate(frame.geometry().topLeft())
|
||||
# frame = frame.parentFrame()
|
||||
return rect
|
||||
log.webview.debug("Couldn't find rectangle for {!r} ({})".format(
|
||||
self, rects))
|
||||
return QRect()
|
||||
|
||||
def is_visible(self, mainframe):
|
||||
|
@ -23,7 +23,7 @@ rules:
|
||||
init-declarations: "off"
|
||||
no-plusplus: "off"
|
||||
no-extra-parens: off
|
||||
id-length: ["error", {"exceptions": ["i", "x", "y"]}]
|
||||
id-length: ["error", {"exceptions": ["i", "k", "x", "y"]}]
|
||||
object-shorthand: "off"
|
||||
max-statements: ["error", {"max": 30}]
|
||||
quotes: ["error", "double", {"avoidEscape": true}]
|
||||
|
@ -29,6 +29,7 @@ window._qutebrowser.webelem = (function() {
|
||||
"text": elem.text,
|
||||
"tag_name": elem.tagName,
|
||||
"outer_xml": elem.outerHTML,
|
||||
"rects": [], // Gets filled up later
|
||||
};
|
||||
|
||||
var attributes = {};
|
||||
@ -38,6 +39,19 @@ window._qutebrowser.webelem = (function() {
|
||||
}
|
||||
out.attributes = attributes;
|
||||
|
||||
var client_rects = elem.getClientRects();
|
||||
for (var k = 0; k < client_rects.length; ++k) {
|
||||
var rect = client_rects[k];
|
||||
out.rects.push({
|
||||
"top": rect.top,
|
||||
"right": rect.right,
|
||||
"bottom": rect.bottom,
|
||||
"left": rect.left,
|
||||
"height": rect.height,
|
||||
"width": rect.width,
|
||||
});
|
||||
}
|
||||
|
||||
// console.log(JSON.stringify(out));
|
||||
|
||||
return out;
|
||||
|
Loading…
Reference in New Issue
Block a user