Changeset 95525 in webkit


Ignore:
Timestamp:
Sep 20, 2011 3:41:11 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt] resizeToContent seems to trigger infinite resize on some pages
https://bugs.webkit.org/show_bug.cgi?id=43852

Patch by Adenilson Cavalcanti <adenilson.silva@openbossa.org> on 2011-09-20
Reviewed by Kenneth Rohde Christiansen.

Source/WebCore:

InnerHeight and InnerWidth are now calculated using ScrollView::visibleContentRect
including the scrollbars (if any) instead of using ScrollView::frameRect as before.

This makes no behavior change while not using the tiled backing
store and is compliant with the W3C definition stated in the CSSOM
View Module.

Plus it will return the correct values for tiled backing store,
thus fixing the original bug report by avoiding infinite resize
events caused by wrong innerHeight and innerWidth values.

Test: innerWidth/Height are covered by existing tests. The
non-infinite resizing is covered by a new Qt autotest at
test_qgraphicswebview::windowResizeEvent()

  • page/DOMWindow.cpp:

(WebCore::DOMWindow::innerHeight): using ScrollView::visibleContentRect.
(WebCore::DOMWindow::innerWidth): using ScrollView::visibleContentRect.

Source/WebKit/qt:

Test by Luiz Agostini.

  • tests/qgraphicswebview/tst_qgraphicswebview.cpp:

(ResizeSpy::receiveResize):
(ResizeSpy::size):
(tst_QGraphicsWebView::windowResizeEvent):

Location:
trunk/Source
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r95524 r95525  
     12011-09-20  Adenilson Cavalcanti  <adenilson.silva@openbossa.org>
     2
     3        [Qt] resizeToContent seems to trigger infinite resize on some pages
     4        https://bugs.webkit.org/show_bug.cgi?id=43852
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        InnerHeight and InnerWidth are now calculated using ScrollView::visibleContentRect
     9        including the scrollbars (if any) instead of using ScrollView::frameRect as before.
     10
     11        This makes no behavior change while not using the tiled backing
     12        store and is compliant with the W3C definition stated in the CSSOM
     13        View Module.
     14
     15        Plus it will return the correct values for tiled backing store,
     16        thus fixing the original bug report by avoiding infinite resize
     17        events caused by wrong innerHeight and innerWidth values.
     18
     19        Test: innerWidth/Height are covered by existing tests. The
     20        non-infinite resizing is covered by a new Qt autotest at
     21        test_qgraphicswebview::windowResizeEvent()
     22
     23        * page/DOMWindow.cpp:
     24        (WebCore::DOMWindow::innerHeight): using ScrollView::visibleContentRect.
     25        (WebCore::DOMWindow::innerWidth): using ScrollView::visibleContentRect.
     26
    1272011-09-09  Pavel Podivilov  <podivilov@chromium.org>
    228
  • trunk/Source/WebCore/page/DOMWindow.cpp

    r95271 r95525  
    10941094        return 0;
    10951095   
    1096     return static_cast<int>(view->height() / m_frame->pageZoomFactor());
     1096    return static_cast<int>(view->visibleContentRect(/* includeScrollbars */ true).height() / m_frame->pageZoomFactor());
    10971097}
    10981098
     
    11061106        return 0;
    11071107
    1108     return static_cast<int>(view->width() / m_frame->pageZoomFactor());
     1108    return static_cast<int>(view->visibleContentRect(/* includeScrollbars */ true).width() / m_frame->pageZoomFactor());
    11091109}
    11101110
  • trunk/Source/WebKit/qt/ChangeLog

    r95387 r95525  
     12011-09-20  Adenilson Cavalcanti  <adenilson.silva@openbossa.org>
     2
     3        [Qt] resizeToContent seems to trigger infinite resize on some pages
     4        https://bugs.webkit.org/show_bug.cgi?id=43852
     5
     6        Reviewed by Kenneth Rohde Christiansen.
     7
     8        Test by Luiz Agostini.
     9
     10        * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
     11        (ResizeSpy::receiveResize):
     12        (ResizeSpy::size):
     13        (tst_QGraphicsWebView::windowResizeEvent):
     14
    1152011-09-17  Mihai Parparita  <mihaip@chromium.org>
    216
  • trunk/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp

    r87514 r95525  
    4242    void crashOnSetScaleBeforeSetUrl();
    4343    void widgetsRenderingThroughCache();
     44    void windowResizeEvent();
     45
    4446#if !(defined(WTF_USE_QT_MOBILE_THEME) && WTF_USE_QT_MOBILE_THEME)
    4547    void setPalette_data();
     
    608610#endif
    609611
     612class ResizeSpy : public QObject {
     613    Q_OBJECT
     614public slots:
     615    void receiveResize(int width, int height)
     616    {
     617        m_size = QSize(width, height);
     618        emit resized();
     619    }
     620
     621    QSize size() const
     622    {
     623        return m_size;
     624    }
     625
     626signals:
     627    void resized();
     628
     629private:
     630    QSize m_size;
     631};
     632
     633void tst_QGraphicsWebView::windowResizeEvent()
     634{
     635    QGraphicsWebView webView;
     636    ResizeSpy resizeSpy;
     637    resizeSpy.setProperty("resizeCount", 0);
     638
     639    QString html = "<html><body><script>"
     640                   "function onResize() { window.resizeSpy.receiveResize(window.innerWidth, window.innerHeight); }"
     641                   "window.addEventListener('resize', onResize , false);"
     642                   "</script></body></html>";
     643
     644    webView.page()->mainFrame()->setHtml(html);
     645    webView.page()->mainFrame()->addToJavaScriptWindowObject("resizeSpy",
     646                                                             &resizeSpy);
     647    webView.setGeometry(QRect(0, 0, 50, 50));
     648    QVERIFY(::waitForSignal(&resizeSpy, SIGNAL(resized()), 1000));
     649    QCOMPARE(resizeSpy.size(), QSize(50, 50));
     650
     651    webView.page()->setActualVisibleContentRect(QRect(10, 10, 60, 60));
     652    webView.setGeometry(QRect(0, 0, 100, 100));
     653    waitForSignal(&resizeSpy, SIGNAL(resized()), 1000);
     654
     655    // This will be triggered without the fix on DOMWindow::innerHeight/Width
     656    QCOMPARE(resizeSpy.size(), QSize(60, 60));
     657}
     658
    610659QTEST_MAIN(tst_QGraphicsWebView)
    611660
Note: See TracChangeset for help on using the changeset viewer.