summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael.bruning <michael.bruning@digia.com>2013-01-07 10:09:16 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-16 18:00:11 +0100
commit3fdf1c130e7e108f26bb64ec5749c0283103f134 (patch)
tree55dbcdabbcf93623821905bb43dff2816db20ddb
parent0ab6ee16c3bb723fe6827864b5b645d5a6f1babe (diff)
downloadqtwebkit-3fdf1c130e7e108f26bb64ec5749c0283103f134.tar.gz
[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 <jocelyn.turcotte@digia.com>
-rw-r--r--Source/WebKit/qt/ChangeLog29
-rw-r--r--Source/WebKit/qt/WidgetSupport/QStyleFacadeImp.cpp3
-rw-r--r--Source/WebKit/qt/tests/qgraphicswebview/resources/scrolltest_page.html6
-rw-r--r--Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp39
-rw-r--r--Source/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.qrc1
-rw-r--r--Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html6
-rw-r--r--Source/WebKit/qt/tests/qwebview/tst_qwebview.cpp27
-rw-r--r--Source/WebKit/qt/tests/qwebview/tst_qwebview.qrc1
8 files changed, 111 insertions, 1 deletions
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 <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-06 Pierre Rossi <pierre.rossi@gmail.com>
[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 @@
+<html>
+<head><title>Scrolling test</title></head>
+<body>
+ <div style="width: 1000px; height: 1000px; background-color: green"/>
+</body>
+</html>
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 @@
<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
index 000000000..18fcbbebe
--- /dev/null
+++ b/Source/WebKit/qt/tests/qwebview/resources/scrolltest_page.html
@@ -0,0 +1,6 @@
+<html>
+<head><title>Scrolling test</title></head>
+<body>
+ <div style="width: 1000px; height: 1000px; background-color: green"/>
+</body>
+</html>
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 @@
<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>