From 3fdf1c130e7e108f26bb64ec5749c0283103f134 Mon Sep 17 00:00:00 2001 From: "michael.bruning" Date: Mon, 7 Jan 2013 10:09:16 +0000 Subject: [Qt] Horizontal scrollbars events are offseted making them difficult to use https://bugs.webkit.org/show_bug.cgi?id=105014 Reviewed by Allan Sandfeld Jensen. Patch co-authored by Simon Hausmann. Only copy the layout direction from the facade options if the current option is Qt::LayoutDirectionAuto in order to prevent misinterpretations as different layout direction when hit testing. Tests added to tst_qwebview and tst_qgraphicswebview to verify that the view actually is scrolled in the right direction. * WidgetSupport/QStyleFacadeImp.cpp: (WebKit::initGenericStyleOption): * tests/qgraphicswebview/resources/scrolltest_page.html: Added. * tests/qgraphicswebview/tst_qgraphicswebview.cpp: (tst_QGraphicsWebView): (tst_QGraphicsWebView::horizontalScrollbarTest): * tests/qgraphicswebview/tst_qgraphicswebview.qrc: * tests/qwebview/resources/scrolltest_page.html: Added. * tests/qwebview/tst_qwebview.cpp: (tst_QWebView): (tst_QWebView::horizontalScrollbarTest): * tests/qwebview/tst_qwebview.qrc: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@138933 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: I3c8190858f4a0fcd0bf394056771f775677ba30e Reviewed-by: Jocelyn Turcotte --- Source/WebKit/qt/ChangeLog | 29 ++++++++++++++++ Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp | 3 +- .../resources/scrolltest_page.html | 6 ++++ .../qgraphicswebview/tst_qgraphicswebview.cpp | 39 ++++++++++++++++++++++ .../qgraphicswebview/tst_qgraphicswebview.qrc | 1 + .../tests/qwebview/resources/scrolltest_page.html | 6 ++++ Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp | 27 +++++++++++++++ Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc | 1 + 8 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html create mode 100644 Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html diff --git a/Source/WebKit/qt/ChangeLog b/Source/WebKit/qt/ChangeLog index 94441de35..2d6981e5b 100644 --- a/Source/WebKit/qt/ChangeLog +++ b/Source/WebKit/qt/ChangeLog @@ -1,3 +1,32 @@ +2013-01-07 Michael BrĂ¼ning + + [Qt] Horizontal scrollbars events are offseted making them difficult to use + https://bugs.webkit.org/show_bug.cgi?id=105014 + + Reviewed by Allan Sandfeld Jensen. + + Patch co-authored by Simon Hausmann. + + Only copy the layout direction from the facade options if the + current option is Qt::LayoutDirectionAuto in order to prevent + misinterpretations as different layout direction when hit testing. + + Tests added to tst_qwebview and tst_qgraphicswebview to verify + that the view actually is scrolled in the right direction. + + * WidgetSupport/QStyleFacadeImp.cpp: + (WebKit::initGenericStyleOption): + * tests/qgraphicswebview/resources/scrolltest_page.html: Added. + * tests/qgraphicswebview/tst_qgraphicswebview.cpp: + (tst_QGraphicsWebView): + (tst_QGraphicsWebView::horizontalScrollbarTest): + * tests/qgraphicswebview/tst_qgraphicswebview.qrc: + * tests/qwebview/resources/scrolltest_page.html: Added. + * tests/qwebview/tst_qwebview.cpp: + (tst_QWebView): + (tst_QWebView::horizontalScrollbarTest): + * tests/qwebview/tst_qwebview.qrc: + 2012-12-06 Pierre Rossi [Qt] QWebView uses the mobile style and doesn't follow Qt's style diff --git a/Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp b/Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp index 7e2b8cab7..6628d8339 100644 --- a/Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp +++ b/Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp @@ -77,7 +77,8 @@ static void initGenericStyleOption(QStyleOption* option, QWidget* widget, const option->rect = facadeOption.rect; option->state = convertToQStyleState(facadeOption.state); - option->direction = facadeOption.direction; + if (option->direction == Qt::LayoutDirectionAuto) + option->direction = facadeOption.direction; option->palette = facadeOption.palette; } diff --git a/Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html b/Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html new file mode 100644 index 000000000..18fcbbebe --- /dev/null +++ b/Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html @@ -0,0 +1,6 @@ + +Scrolling test + +
+ + diff --git a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp b/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp index 9ae960b9c..af70e59b2 100644 --- a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp +++ b/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp @@ -42,6 +42,7 @@ private Q_SLOTS: void crashOnSetScaleBeforeSetUrl(); void widgetsRenderingThroughCache(); void windowResizeEvent(); + void horizontalScrollbarTest(); #if !(defined(WTF_USE_QT_MOBILE_THEME) && WTF_USE_QT_MOBILE_THEME) void setPalette_data(); @@ -680,6 +681,44 @@ void tst_QGraphicsWebView::windowResizeEvent() QCOMPARE(resizeSpy.size(), QSize(60, 60)); } +void tst_QGraphicsWebView::horizontalScrollbarTest() +{ + QWebPage* page = new QWebPage; + GraphicsWebView* webView = new GraphicsWebView; + webView->setPage(page); + webView->setGeometry(QRect(0, 0, 600, 600)); + QGraphicsView* view = new QGraphicsView; + QGraphicsScene* scene = new QGraphicsScene(view); + view->setScene(scene); + scene->addItem(webView); + + // Turn off scrolling on the containing QGraphicsView, let the + // QGraphicsWebView handle the scrolling by itself. + view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + view->show(); + QCoreApplication::processEvents(); + + QUrl url("qrc:///resources/scrolltest_page.html"); + page->mainFrame()->load(url); + page->mainFrame()->setFocus(); + + QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); + + QVERIFY(webView->page()->mainFrame()->scrollPosition() == QPoint(0, 0)); + + // Note: The test below assumes that the layout direction is Qt::LeftToRight. + webView->fireMouseClick(QPointF(550.0, 590.0)); + QVERIFY(page->mainFrame()->scrollPosition().x() > 0); + + // Note: The test below assumes that the layout direction is Qt::LeftToRight. + webView->fireMouseClick(QPointF(20.0, 590.0)); + QVERIFY(page->mainFrame()->scrollPosition() == QPoint(0, 0)); + + delete webView; + delete view; +} + QTEST_MAIN(tst_QGraphicsWebView) #include "tst_qgraphicswebview.moc" diff --git a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc b/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc index 97726ba73..ff06bd8c4 100644 --- a/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc +++ b/Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc @@ -4,5 +4,6 @@ resources/pointing_right.html resources/pointing_up.html resources/greendiv.html + resources/scrolltest_page.html diff --git a/Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html b/Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html new file mode 100644 index 000000000..18fcbbebe --- /dev/null +++ b/Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html @@ -0,0 +1,6 @@ + +Scrolling test + +
+ + diff --git a/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp b/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp index 6ff2d1ff5..a990ad0f2 100644 --- a/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp +++ b/Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp @@ -52,6 +52,7 @@ private Q_SLOTS: void reusePage(); void microFocusCoordinates(); void focusInputTypes(); + void horizontalScrollbarTest(); void crashTests(); #if !(defined(WTF_USE_QT_MOBILE_THEME) && WTF_USE_QT_MOBILE_THEME) @@ -303,6 +304,32 @@ void tst_QWebView::focusInputTypes() QVERIFY(webView.testAttribute(Qt::WA_InputMethodEnabled)); } +void tst_QWebView::horizontalScrollbarTest() +{ + QWebView webView; + webView.resize(600, 600); + webView.show(); + QTest::qWaitForWindowExposed(&webView); + + QUrl url("qrc:///resources/scrolltest_page.html"); + QWebFrame* const mainFrame = webView.page()->mainFrame(); + mainFrame->load(url); + mainFrame->setFocus(); + + QVERIFY(waitForSignal(&webView, SIGNAL(loadFinished(bool)))); + + QVERIFY(webView.page()->mainFrame()->scrollPosition() == QPoint(0, 0)); + + // Note: The test below assumes that the layout direction is Qt::LeftToRight. + QTest::mouseClick(&webView, Qt::LeftButton, 0, QPoint(550, 595)); + QVERIFY(webView.page()->mainFrame()->scrollPosition().x() > 0); + + // Note: The test below assumes that the layout direction is Qt::LeftToRight. + QTest::mouseClick(&webView, Qt::LeftButton, 0, QPoint(20, 595)); + QVERIFY(webView.page()->mainFrame()->scrollPosition() == QPoint(0, 0)); +} + + #if !(defined(WTF_USE_QT_MOBILE_THEME) && WTF_USE_QT_MOBILE_THEME) void tst_QWebView::setPalette_data() { diff --git a/Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc b/Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc index 8710a9a17..e4b9ad776 100644 --- a/Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc +++ b/Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc @@ -3,6 +3,7 @@ resources/index.html resources/frame_a.html resources/input_types.html + resources/scrolltest_page.html -- cgit v1.2.1