Make copies of geometries before modifying them

This commit is contained in:
Florian Bruhin 2014-05-12 12:06:08 +02:00
parent 80d4068ad5
commit 6cd8fd407f

View File

@ -27,6 +27,7 @@ Module attributes:
import logging import logging
from PyQt5.QtCore import QRect
from PyQt5.QtWebKit import QWebElement from PyQt5.QtWebKit import QWebElement
import qutebrowser.utils.url as urlutils import qutebrowser.utils.url as urlutils
@ -95,7 +96,7 @@ def is_visible(elem, mainframe):
elem_frame = elem.webFrame() elem_frame = elem.webFrame()
elem_rect = elem.geometry() elem_rect = elem.geometry()
if elem_frame.parentFrame() is not None: if elem_frame.parentFrame() is not None:
framegeom = elem_frame.geometry() framegeom = QRect(elem_frame.geometry())
framegeom.moveTo(0, 0) framegeom.moveTo(0, 0)
framegeom.translate(elem_frame.scrollPosition()) framegeom.translate(elem_frame.scrollPosition())
if elem_rect.isValid(): if elem_rect.isValid():
@ -112,7 +113,7 @@ def is_visible(elem, mainframe):
def rect_on_view(elem): def rect_on_view(elem):
"""Get the geometry of the element relative to the webview.""" """Get the geometry of the element relative to the webview."""
frame = elem.webFrame() frame = elem.webFrame()
rect = elem.geometry() rect = QRect(elem.geometry())
while frame is not None: while frame is not None:
rect.translate(frame.geometry().topLeft()) rect.translate(frame.geometry().topLeft())
logging.debug("After adding frame pos: {}".format(rect)) logging.debug("After adding frame pos: {}".format(rect))