Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-18034

QWebElement::geometry() may return an unexpected value if there is a re-layout pending

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P2: Important
    • None
    • 4.6.0, 4.7.2
    • Documentation
    • 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.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            docteam Qt Documentation Team
            robertknight Robert Knight
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes