Title: [95525] trunk/Source
Revision
95525
Author
commit-qu...@webkit.org
Date
2011-09-20 03:41:11 -0700 (Tue, 20 Sep 2011)

Log 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.si...@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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (95524 => 95525)


--- trunk/Source/WebCore/ChangeLog	2011-09-20 10:22:59 UTC (rev 95524)
+++ trunk/Source/WebCore/ChangeLog	2011-09-20 10:41:11 UTC (rev 95525)
@@ -1,3 +1,29 @@
+2011-09-20  Adenilson Cavalcanti  <adenilson.si...@openbossa.org>
+
+        [Qt] resizeToContent seems to trigger infinite resize on some pages
+        https://bugs.webkit.org/show_bug.cgi?id=43852
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        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.
+
 2011-09-09  Pavel Podivilov  <podivi...@chromium.org>
 
         Web Inspector: implement reverse mapping for compiler source maps.

Modified: trunk/Source/WebCore/page/DOMWindow.cpp (95524 => 95525)


--- trunk/Source/WebCore/page/DOMWindow.cpp	2011-09-20 10:22:59 UTC (rev 95524)
+++ trunk/Source/WebCore/page/DOMWindow.cpp	2011-09-20 10:41:11 UTC (rev 95525)
@@ -1093,7 +1093,7 @@
     if (!view)
         return 0;
     
-    return static_cast<int>(view->height() / m_frame->pageZoomFactor());
+    return static_cast<int>(view->visibleContentRect(/* includeScrollbars */ true).height() / m_frame->pageZoomFactor());
 }
 
 int DOMWindow::innerWidth() const
@@ -1105,7 +1105,7 @@
     if (!view)
         return 0;
 
-    return static_cast<int>(view->width() / m_frame->pageZoomFactor());
+    return static_cast<int>(view->visibleContentRect(/* includeScrollbars */ true).width() / m_frame->pageZoomFactor());
 }
 
 int DOMWindow::screenX() const

Modified: trunk/Source/WebKit/qt/ChangeLog (95524 => 95525)


--- trunk/Source/WebKit/qt/ChangeLog	2011-09-20 10:22:59 UTC (rev 95524)
+++ trunk/Source/WebKit/qt/ChangeLog	2011-09-20 10:41:11 UTC (rev 95525)
@@ -1,3 +1,17 @@
+2011-09-20  Adenilson Cavalcanti  <adenilson.si...@openbossa.org>
+
+        [Qt] resizeToContent seems to trigger infinite resize on some pages
+        https://bugs.webkit.org/show_bug.cgi?id=43852
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Test by Luiz Agostini.
+
+        * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
+        (ResizeSpy::receiveResize):
+        (ResizeSpy::size):
+        (tst_QGraphicsWebView::windowResizeEvent):
+
 2011-09-17  Mihai Parparita  <mih...@chromium.org>
 
         FrameLoaderClient BackForwardList-related methods are unsued

Modified: trunk/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp (95524 => 95525)


--- trunk/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp	2011-09-20 10:22:59 UTC (rev 95524)
+++ trunk/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp	2011-09-20 10:41:11 UTC (rev 95525)
@@ -41,6 +41,8 @@
     void focusInputTypes();
     void crashOnSetScaleBeforeSetUrl();
     void widgetsRenderingThroughCache();
+    void windowResizeEvent();
+
 #if !(defined(WTF_USE_QT_MOBILE_THEME) && WTF_USE_QT_MOBILE_THEME)
     void setPalette_data();
     void setPalette();
@@ -607,6 +609,53 @@
 }
 #endif
 
+class ResizeSpy : public QObject {
+    Q_OBJECT
+public slots:
+    void receiveResize(int width, int height)
+    {
+        m_size = QSize(width, height);
+        emit resized();
+    }
+
+    QSize size() const
+    {
+        return m_size;
+    }
+
+signals:
+    void resized();
+
+private:
+    QSize m_size;
+};
+
+void tst_QGraphicsWebView::windowResizeEvent()
+{
+    QGraphicsWebView webView;
+    ResizeSpy resizeSpy;
+    resizeSpy.setProperty("resizeCount", 0);
+
+    QString html = "<html><body><script>"
+                   "function onResize() { window.resizeSpy.receiveResize(window.innerWidth, window.innerHeight); }"
+                   "window.addEventListener('resize', onResize , false);"
+                   "</script></body></html>";
+
+    webView.page()->mainFrame()->setHtml(html);
+    webView.page()->mainFrame()->addToJavaScriptWindowObject("resizeSpy",
+                                                             &resizeSpy);
+    webView.setGeometry(QRect(0, 0, 50, 50));
+    QVERIFY(::waitForSignal(&resizeSpy, SIGNAL(resized()), 1000));
+    QCOMPARE(resizeSpy.size(), QSize(50, 50));
+
+    webView.page()->setActualVisibleContentRect(QRect(10, 10, 60, 60));
+    webView.setGeometry(QRect(0, 0, 100, 100));
+    waitForSignal(&resizeSpy, SIGNAL(resized()), 1000);
+
+    // This will be triggered without the fix on DOMWindow::innerHeight/Width
+    QCOMPARE(resizeSpy.size(), QSize(60, 60));
+}
+
 QTEST_MAIN(tst_QGraphicsWebView)
 
 #include "tst_qgraphicswebview.moc"
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to