[Qt] Horizontal scrollbars events are offseted making them difficult to use
authormichael.bruning@digia.com <michael.bruning@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2013 10:09:16 +0000 (10:09 +0000)
committermichael.bruning@digia.com <michael.bruning@digia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jan 2013 10:09:16 +0000 (10:09 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@138933 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp
Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html [new file with mode: 0644]
Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc
Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html [new file with mode: 0644]
Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp
Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc

index 284f5dd..c61ca33 100644 (file)
@@ -1,3 +1,32 @@
+2013-01-07  Michael BrĂ¼ning  <michael.bruning@digia.com>
+
+        [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-23  Alexey Proskuryakov  <ap@apple.com>
 
         <rdar://problem/12808377> Network process should respect cookie accept policy
index 7e2b8ca..6628d83 100644 (file)
@@ -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 (file)
index 0000000..18fcbbe
--- /dev/null
@@ -0,0 +1,6 @@
+<html>
+<head><title>Scrolling test</title></head>
+<body>
+  <div style="width: 1000px; height: 1000px; background-color: green"/>
+</body>
+</html>
index 9ae960b..af70e59 100644 (file)
@@ -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"
index 97726ba..ff06bd8 100644 (file)
@@ -4,5 +4,6 @@
         <file>resources/pointing_right.html</file>
         <file>resources/pointing_up.html</file>
         <file>resources/greendiv.html</file>
+        <file>resources/scrolltest_page.html</file>
     </qresource>
 </RCC>
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 (file)
index 0000000..18fcbbe
--- /dev/null
@@ -0,0 +1,6 @@
+<html>
+<head><title>Scrolling test</title></head>
+<body>
+  <div style="width: 1000px; height: 1000px; background-color: green"/>
+</body>
+</html>
index 6ff2d1f..a990ad0 100644 (file)
@@ -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()
 {
index 8710a9a..e4b9ad7 100644 (file)
@@ -3,6 +3,7 @@
     <file>resources/index.html</file>
     <file>resources/frame_a.html</file>
     <file>resources/input_types.html</file>
+    <file>resources/scrolltest_page.html</file>
 </qresource>
 </RCC>