Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
4.6.0, 4.7.2
-
None
Description
If style or content changes have recently been made to the HTML element represented by a QWebElement or its children then WebKit may have scheduled an asynchronous layout which has not happened yet, so the geometry returned by QWebElement::geometry() may not match what the developer is expecting.
The problem can be worked around by fetching a CSS style property which depends on the element's size before calling geometry():
// fetch a CSS property which depends on the size of the elemement
// to force WebKit to process any scheduled re-layout events for this element
QString widthProperty = element.styleProperty("width",QWebElement::ComputedStyle);
A solution would be for QWebElement::geometry() to force a layout before returning a result, but that may not always be desirable given the performance impact. An alternative would be to simply document this gotcha.