Handle failing javascript in webelem.rect_on_view

Fixes #1641.
This commit is contained in:
Florian Bruhin 2016-07-28 17:09:17 +02:00
parent 5463e133ee
commit 56515321dd
2 changed files with 11 additions and 0 deletions

View File

@ -25,6 +25,11 @@ Changed
- `:bookmark-load` now has a `--delete` flag which deletes the bookmark after
loading it.
Fixed
-----
- Fixed crash when using hints with JS disabled in some rare circumstances.
v0.8.1
------

View File

@ -367,6 +367,12 @@ class WebElementWrapper(collections.abc.MutableMapping):
def _rect_on_view_js(self, adjust_zoom):
"""Javascript implementation for rect_on_view."""
rects = self._elem.evaluateJavaScript("this.getClientRects()")
if rects is None:
# Depending on unknown circumstances, this might not work with JS
# disabled in QWebSettings:
# https://github.com/The-Compiler/qutebrowser/issues/1641
return None
text = utils.compact_text(self._elem.toOuterXml(), 500)
log.hints.vdebug("Client rectangles of element '{}': {}".format(
text, rects))