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

QWebEnginePage::contentsSize() reports widget size instead of page content size

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • 5.13.0 Beta3
    • 5.13.0
    • WebEngine
    • None
    • d29125ea49a6a7c86ea20a90a1f3fddb9b13d9f4 (qt/qtwebengine/dev)

      I tested this on Qt5.13.0 from kde-unstable on arch.

      The docs for QWebEnginePage::contentsSize() say that it returns "The size of the page contents.". Previously it returned the size of the whole page content, even the stuff outside the viewport. On 5.13 it appears to always return the same as the widget size.

      Here is a reproducer:

      #include <iostream>
      #include <QApplication>
      #include <QWebEngineView>
      
      QWebEngineView *view;
      
      void onScroll(QPointF pos) {
          std::cout << "size: " << view->page()->contentsSize().width() << "x" << view->page()->contentsSize().height() << std::endl;
      }
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QWebEngineView myview;
          view = &myview;
          QObject::connect(myview.page(), &QWebEnginePage::scrollPositionChanged, onScroll);
          myview.setHtml("<html><body style=\"width: 1600px; height: 1200px;\"><p>hi</p></body></html>");
          myview.show();
          return app.exec();
      }
      

      If you run that with -geometry 800x600 args and scroll the page then on previous Qt versions (I tested on 5.11 but I am confident 5.7 and 5.12 would be the same) it'll print out size: 1608x1216 or something close to that (I think the extra is the scroll bars) but on 5.13 it'll print size: 800x600.

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

            mibrunin Michael Bruning
            toofar toofar
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes