COMMIT_MESSAGE

 1[Qt] resizeToContent seems to trigger infinite resize on some pages
 2https://bugs.webkit.org/show_bug.cgi?id=43852
 3
 4Reviewed by NOBODY (OOPS!).
 5
 6Source/WebCore:
 7
 8New methods logicalWidth and logicalHeight of class ScrollView return m_actualVisibleContentRect
 9sizes if m_actualVisibleContentRect is not empty. Otherwise they return ScrollView's width() and
 10height() respectivelly.
 11
 12Methods innerWidth and innerHeight of class DOMWindow now return ScrollView's logicalWidth and
 13logicalHeight respectivelly.
 14
 15* page/DOMWindow.cpp:
 16(WebCore::DOMWindow::innerHeight):
 17(WebCore::DOMWindow::innerWidth):
 18* platform/ScrollView.h:
 19(WebCore::ScrollView::logicalWidth):
 20(WebCore::ScrollView::logicalHeight):
 21
 22Source/WebKit/qt:
 23
 24Checking the innerHeight and innerWidth of object window seen by the javascript.
 25Some known bugs related to the window resize event in javascript are documented in the test.
 26
 27* tests/qgraphicswebview/tst_qgraphicswebview.cpp:
 28(ResizeSpy::receiveResize):
 29(ResizeSpy::size):
 30(tst_QGraphicsWebView::windowResizeEvent):
 31
 32Tools:
 33
 34Calling QWebPage::setActualVisibleContentRect on view's resize and scroll event
 35if resizeToContents is true.
 36
 37* QtTestBrowser/webview.cpp:
 38(WebViewGraphicsBased::setResizesToContents):
 39(WebViewGraphicsBased::resizeEvent):
 40(WebViewGraphicsBased::scrollContentsBy):
 41(GraphicsWebView::visibleContentRect):
 42(GraphicsWebView::updateActualVisibleContentRect):
 43(GraphicsWebView::timerEvent):
 44* QtTestBrowser/webview.h:

Source/WebCore/ChangeLog

 12011-07-12 Luiz Agostini <luiz.agostini@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 NOBODY (OOPS!).
 7
 8 New methods logicalWidth and logicalHeight of class ScrollView return m_actualVisibleContentRect
 9 sizes if m_actualVisibleContentRect is not empty. Otherwise they return ScrollView's width() and
 10 height() respectivelly.
 11
 12 Methods innerWidth and innerHeight of class DOMWindow now return ScrollView's logicalWidth and
 13 logicalHeight respectivelly.
 14
 15 * page/DOMWindow.cpp:
 16 (WebCore::DOMWindow::innerHeight):
 17 (WebCore::DOMWindow::innerWidth):
 18 * platform/ScrollView.h:
 19 (WebCore::ScrollView::logicalWidth):
 20 (WebCore::ScrollView::logicalHeight):
 21
1222011-07-13 John Knottenbelt <jknotten@chromium.org>
223
324 Reference Geolocation object from GeoNotifier and Geolocation::setIsAllowed.

Source/WebCore/page/DOMWindow.cpp

@@int DOMWindow::innerHeight() const
10921092 if (!view)
10931093 return 0;
10941094
1095  return static_cast<int>(view->height() / m_frame->pageZoomFactor());
 1095 return static_cast<int>(view->logicalHeight() / m_frame->pageZoomFactor());
10961096}
10971097
10981098int DOMWindow::innerWidth() const

@@int DOMWindow::innerWidth() const
11041104 if (!view)
11051105 return 0;
11061106
1107  return static_cast<int>(view->width() / m_frame->pageZoomFactor());
 1107 return static_cast<int>(view->logicalWidth() / m_frame->pageZoomFactor());
11081108}
11091109
11101110int DOMWindow::screenX() const

Source/WebCore/platform/ScrollView.h

@@public:
147147 LayoutUnit visibleWidth() const { return visibleContentRect().width(); }
148148 LayoutUnit visibleHeight() const { return visibleContentRect().height(); }
149149
 150 LayoutUnit logicalWidth() const { return m_actualVisibleContentRect.isEmpty() ? width() : m_actualVisibleContentRect.width(); }
 151 LayoutUnit logicalHeight() const { return m_actualVisibleContentRect.isEmpty() ? height() : m_actualVisibleContentRect.height(); }
 152
150153 // Functions for getting/setting the size webkit should use to layout the contents. By default this is the same as the visible
151154 // content size. Explicitly setting a layout size value will cause webkit to layout the contents using this size instead.
152155 int layoutWidth() const;

Source/WebKit/qt/ChangeLog

 12011-07-12 Luiz Agostini <luiz.agostini@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 NOBODY (OOPS!).
 7
 8 Checking the innerHeight and innerWidth of object window seen by the javascript.
 9 Some known bugs related to the window resize event in javascript are documented in the test.
 10
 11 * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
 12 (ResizeSpy::receiveResize):
 13 (ResizeSpy::size):
 14 (tst_QGraphicsWebView::windowResizeEvent):
 15
1162011-07-12 Joseph Pecoraro <joepeck@webkit.org>
217
318 ApplicationCache update should not immediately fail when reaching per-origin quota

Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp

@@private slots:
4141 void focusInputTypes();
4242 void crashOnSetScaleBeforeSetUrl();
4343 void widgetsRenderingThroughCache();
 44
 45 void windowResizeEvent();
 46
4447#if !(defined(WTF_USE_QT_MOBILE_THEME) && WTF_USE_QT_MOBILE_THEME)
4548 void setPalette_data();
4649 void setPalette();

@@void tst_QGraphicsWebView::compareCanvasToImage(const QUrl& url, const QImage& r
607610}
608611#endif
609612
 613class ResizeSpy : public QObject {
 614 Q_OBJECT
 615public slots:
 616 void receiveResize(int width, int height)
 617 {
 618 m_size = QSize(width, height);
 619 emit resized();
 620 }
 621 QSize size() const { return m_size; }
 622
 623signals:
 624 void resized();
 625
 626private:
 627 QSize m_size;
 628};
 629
 630void tst_QGraphicsWebView::windowResizeEvent()
 631{
 632 QGraphicsWebView* webView = new QGraphicsWebView();
 633 ResizeSpy resizeSpy;
 634 resizeSpy.setProperty("resizeCount", 0);
 635
 636 QString html = "<html><body><script>" \
 637 " function onResize() { window.resizeSpy.receiveResize(window.innerWidth, window.innerHeight); }" \
 638 " window.addEventListener('resize', onResize , false);" \
 639 "</script></body></html>";
 640
 641 webView->page()->mainFrame()->setHtml(html);
 642 webView->page()->mainFrame()->addToJavaScriptWindowObject("resizeSpy", &resizeSpy);
 643
 644 webView->setGeometry(QRect(0, 0, 1, 1));
 645 QVERIFY(::waitForSignal(&resizeSpy, SIGNAL(resized()), 1000));
 646 QVERIFY(resizeSpy.size() == QSize(1, 1));
 647
 648 // FIXME:
 649 // The following issues are known and were left intentionally because it was decided that we should wait until
 650 // the upstreaming work of the browser's branch is concluded before making any changes to the related code.
 651
 652 // This is where the properties innerWidth and innerHeight of the window object are actually changing.
 653 webView->page()->setActualVisibleContentRect(QRect(10, 10, 10, 10));
 654 QEXPECT_FAIL("", "setActualVisibleContentRect should trigger the resize event.", Continue);
 655 QVERIFY(::waitForSignal(&resizeSpy, SIGNAL(resized()), 1000));
 656
 657 webView->setGeometry(QRect(0, 0, 100, 100));
 658 QEXPECT_FAIL("", "QGraphicsWebView::setGeometry should not trigger the resize event if setActualVisibleContentRect was used.", Continue);
 659 QVERIFY(!::waitForSignal(&resizeSpy, SIGNAL(resized()), 1000));
 660
 661 QVERIFY(resizeSpy.size() == QSize(10, 10));
 662}
 663
610664QTEST_MAIN(tst_QGraphicsWebView)
611665
612666#include "tst_qgraphicswebview.moc"

Tools/ChangeLog

 12011-07-12 Luiz Agostini <luiz.agostini@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 NOBODY (OOPS!).
 7
 8 Calling QWebPage::setActualVisibleContentRect on view's resize and scroll event
 9 if resizeToContents is true.
 10
 11 * QtTestBrowser/webview.cpp:
 12 (WebViewGraphicsBased::setResizesToContents):
 13 (WebViewGraphicsBased::resizeEvent):
 14 (WebViewGraphicsBased::scrollContentsBy):
 15 (GraphicsWebView::visibleContentRect):
 16 (GraphicsWebView::updateActualVisibleContentRect):
 17 (GraphicsWebView::timerEvent):
 18 * QtTestBrowser/webview.h:
 19
1202011-07-13 Xan Lopez <xlopez@igalia.com>
221
322 [GTK] Do not grab focus too early in DRT.

Tools/QtTestBrowser/webview.cpp

@@void WebViewGraphicsBased::setResizesToContents(bool b)
9393
9494 m_resizesToContents = b;
9595 graphicsWebView()->setResizesToContents(m_resizesToContents);
 96 graphicsWebView()->updateActualVisibleContentRect();
9697
9798 // When setting resizesToContents ON, our web view widget will always size as big as the
9899 // web content being displayed, and so will the QWebPage's viewport. It implies that internally

@@void WebViewGraphicsBased::resizeEvent(QResizeEvent* event)
134135
135136 if (m_resizesToContents) {
136137 graphicsWebView()->page()->setPreferredContentsSize(size);
 138 graphicsWebView()->updateActualVisibleContentRect();
137139 return;
138140 }
139141

@@void WebViewGraphicsBased::animatedYFlip()
223225#endif
224226}
225227
 228void WebViewGraphicsBased::scrollContentsBy(int dx, int dy)
 229{
 230 QGraphicsView::scrollContentsBy(dx, dy);
 231 if (m_resizesToContents)
 232 m_item->updateActualVisibleContentRect();
 233}
 234
226235void WebViewGraphicsBased::paintEvent(QPaintEvent* event)
227236{
228237 QGraphicsView::paintEvent(event);

@@void GraphicsWebView::contextMenuEvent(QGraphicsSceneContextMenuEvent* event)
268277 delete menu;
269278}
270279
 280QRect GraphicsWebView::visibleContentRect() const
 281{
 282 if (!scene())
 283 return boundingRect().toRect();
 284
 285 QList<QGraphicsView*> viewList = scene()->views();
 286 if (viewList.isEmpty())
 287 return boundingRect().toRect();
 288
 289 QGraphicsView* view = viewList[0];
 290
 291 QRect rect = view->geometry();
 292 rect.moveTo(view->horizontalScrollBar()->value(), view->verticalScrollBar()->value());
 293
 294 return rect;
 295}
 296
 297void GraphicsWebView::updateActualVisibleContentRect()
 298{
 299 if (!m_timer.isActive())
 300 m_timer.start(0, this);
 301}
 302
 303void GraphicsWebView::timerEvent(QTimerEvent* event)
 304{
 305 if (event->timerId() == m_timer.timerId()) {
 306 m_timer.stop();
 307 page()->setActualVisibleContentRect(resizesToContents() ? visibleContentRect() : QRect());
 308 }
 309}
 310
271311void WebViewTraditional::contextMenuEvent(QContextMenuEvent* event)
272312{
273313 QMenu* menu = createContextMenu(page(), event->pos());

Tools/QtTestBrowser/webview.h

3535
3636#include "fpstimer.h"
3737#include "webpage.h"
38 #include <qwebview.h>
39 #include <qgraphicswebview.h>
 38#include <QBasicTimer>
4039#include <QGraphicsView>
4140#include <QGraphicsWidget>
4241#include <QTime>
 42#include <qgraphicswebview.h>
 43#include <qwebview.h>
4344
4445QT_BEGIN_NAMESPACE
4546class QStateMachine;

@@class GraphicsWebView : public QGraphicsWebView {
6263
6364public:
6465 GraphicsWebView(QGraphicsItem* parent = 0) : QGraphicsWebView(parent) {};
 66 void updateActualVisibleContentRect();
 67 QRect visibleContentRect() const;
6568
6669protected:
6770 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent*);
6871 virtual void mousePressEvent(QGraphicsSceneMouseEvent*);
 72 virtual void timerEvent(QTimerEvent*);
 73
 74private:
 75 QBasicTimer m_timer;
6976};
7077
7178

@@public:
8592
8693 virtual void resizeEvent(QResizeEvent*);
8794 virtual void paintEvent(QPaintEvent* event);
 95 virtual void scrollContentsBy(int, int);
8896
8997 void setResizesToContents(bool b);
9098 bool resizesToContents() const { return m_resizesToContents; }