[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373
eric at webkit.org
eric at webkit.org
Thu Apr 8 00:42:06 UTC 2010
The following commit has been merged in the webkit-1.2 branch:
commit ca331d2430aa035ac38718fbf1bab73070a2f018
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Fri Dec 18 15:04:00 2009 +0000
2009-12-18 Joe Ligman <joseph.ligman at nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Qt] Add new API to QWebFrame to scrollRecursively starting with any css overflow
then checking current frame and then ancestors
https://bugs.webkit.org/show_bug.cgi?id=32668
* Api/qwebframe.cpp:
(QWebFramePrivate::scrollOverflow):
(QWebFrame::scrollRecursively):
* Api/qwebframe.h:
* Api/qwebframe_p.h:
* tests/qwebframe/qwebframe.qrc:
* tests/qwebframe/testiframe.html: Added.
* tests/qwebframe/testiframe2.html: Added.
* tests/qwebframe/tst_qwebframe.cpp:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52311 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp
index ef97c3b..1a3bf7f 100644
--- a/WebKit/qt/Api/qwebframe.cpp
+++ b/WebKit/qt/Api/qwebframe.cpp
@@ -361,6 +361,45 @@ void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame:
}
}
+bool QWebFramePrivate::scrollOverflow(int dx, int dy)
+{
+ if (!frame || !frame->document() || !frame->eventHandler())
+ return false;
+
+ Node* node = frame->document()->focusedNode();
+ if (!node)
+ node = frame->document()->elementFromPoint(frame->eventHandler()->currentMousePosition().x(),
+ frame->eventHandler()->currentMousePosition().y());
+ if (!node)
+ return false;
+
+ RenderObject* renderer = node->renderer();
+ if (!renderer)
+ return false;
+
+ if (renderer->isListBox())
+ return false;
+
+ RenderLayer* renderLayer = renderer->enclosingLayer();
+ if (!renderLayer)
+ return false;
+
+ bool scrolledHorizontal = false;
+ bool scrolledVertical = false;
+
+ if (dx > 0)
+ scrolledHorizontal = renderLayer->scroll(ScrollRight, ScrollByPixel, dx);
+ else if (dx < 0)
+ scrolledHorizontal = renderLayer->scroll(ScrollLeft, ScrollByPixel, qAbs(dx));
+
+ if (dy > 0)
+ scrolledVertical = renderLayer->scroll(ScrollDown, ScrollByPixel, dy);
+ else if (dy < 0)
+ scrolledVertical = renderLayer->scroll(ScrollUp, ScrollByPixel, qAbs(dy));
+
+ return (scrolledHorizontal || scrolledVertical);
+}
+
/*!
\class QWebFrame
\since 4.4
@@ -1000,6 +1039,50 @@ void QWebFrame::scroll(int dx, int dy)
}
/*!
+ \since 4.7
+ Scrolls nested frames starting at this frame, \a dx pixels to the right
+ and \a dy pixels downward. Both \a dx and \a dy may be negative. First attempts
+ to scroll elements with CSS overflow followed by this frame. If this
+ frame doesn't scroll, attempts to scroll the parent
+
+ \sa QWebFrame::scroll
+*/
+bool QWebFrame::scrollRecursively(int dx, int dy)
+{
+ bool scrolledHorizontal = false;
+ bool scrolledVertical = false;
+ bool scrolledOverflow = d->scrollOverflow(dx, dy);
+
+ if (!scrolledOverflow) {
+ Frame* frame = d->frame;
+ if (!frame || !frame->view())
+ return false;
+
+ do {
+ IntSize scrollOffset = frame->view()->scrollOffset();
+ IntPoint maxScrollOffset = frame->view()->maximumScrollPosition();
+
+ if (dx > 0) // scroll right
+ scrolledHorizontal = scrollOffset.width() < maxScrollOffset.x();
+ else if (dx < 0) // scroll left
+ scrolledHorizontal = scrollOffset.width() > 0;
+
+ if (dy > 0) // scroll down
+ scrolledVertical = scrollOffset.height() < maxScrollOffset.y();
+ else if (dy < 0) //scroll up
+ scrolledVertical = scrollOffset.height() > 0;
+
+ if (scrolledHorizontal || scrolledVertical) {
+ frame->view()->scrollBy(IntSize(dx, dy));
+ return true;
+ }
+ frame = frame->tree()->parent();
+ } while (frame && frame->view());
+ }
+ return (scrolledHorizontal || scrolledVertical || scrolledOverflow);
+}
+
+/*!
\property QWebFrame::scrollPosition
\since 4.5
\brief the position the frame is currently scrolled to.
diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h
index c2a6e9b..25f6c9b 100644
--- a/WebKit/qt/Api/qwebframe.h
+++ b/WebKit/qt/Api/qwebframe.h
@@ -156,6 +156,7 @@ public:
QRect scrollBarGeometry(Qt::Orientation orientation) const;
void scroll(int, int);
+ bool scrollRecursively(int, int);
QPoint scrollPosition() const;
void setScrollPosition(const QPoint &pos);
diff --git a/WebKit/qt/Api/qwebframe_p.h b/WebKit/qt/Api/qwebframe_p.h
index 045c70e..ee978be 100644
--- a/WebKit/qt/Api/qwebframe_p.h
+++ b/WebKit/qt/Api/qwebframe_p.h
@@ -85,6 +85,8 @@ public:
void renderRelativeCoords(WebCore::GraphicsContext*, QWebFrame::RenderLayer, const QRegion& clip);
void renderContentsLayerAbsoluteCoords(WebCore::GraphicsContext*, const QRegion& clip);
+ bool scrollOverflow(int dx, int dy);
+
QWebFrame *q;
Qt::ScrollBarPolicy horizontalScrollBarPolicy;
Qt::ScrollBarPolicy verticalScrollBarPolicy;
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 15eb7b4..1d806dd 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,3 +1,21 @@
+2009-12-18 Joe Ligman <joseph.ligman at nokia.com>
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ [Qt] Add new API to QWebFrame to scrollRecursively starting with any css overflow
+ then checking current frame and then ancestors
+ https://bugs.webkit.org/show_bug.cgi?id=32668
+
+ * Api/qwebframe.cpp:
+ (QWebFramePrivate::scrollOverflow):
+ (QWebFrame::scrollRecursively):
+ * Api/qwebframe.h:
+ * Api/qwebframe_p.h:
+ * tests/qwebframe/qwebframe.qrc:
+ * tests/qwebframe/testiframe.html: Added.
+ * tests/qwebframe/testiframe2.html: Added.
+ * tests/qwebframe/tst_qwebframe.cpp:
+
2009-12-18 Simon Hausmann <simon.hausmann at nokia.com>
Reviewed by Tor Arne Vestbø.
diff --git a/WebKit/qt/tests/qwebframe/qwebframe.qrc b/WebKit/qt/tests/qwebframe/qwebframe.qrc
index 9615e27..8afa0c1 100644
--- a/WebKit/qt/tests/qwebframe/qwebframe.qrc
+++ b/WebKit/qt/tests/qwebframe/qwebframe.qrc
@@ -4,5 +4,7 @@
<file>style.css</file>
<file>test1.html</file>
<file>test2.html</file>
+<file>testiframe.html</file>
+<file>testiframe2.html</file>
</qresource>
</RCC>
diff --git a/WebKit/qt/tests/qwebframe/testiframe.html b/WebKit/qt/tests/qwebframe/testiframe.html
new file mode 100644
index 0000000..203d3d3
--- /dev/null
+++ b/WebKit/qt/tests/qwebframe/testiframe.html
@@ -0,0 +1,54 @@
+</html>
+<html>
+<head>
+<title></title>
+<style type="text/css">
+<!--
+#header {
+ background: #0f0;
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ width: 800px;
+ height: 100px;
+}
+#content1 {
+ background: #ff0;
+ position: absolute;
+ top: 101px;
+ left: 0px;
+ width: 400px;
+ height: 400px;
+ overflow: scroll;
+}
+#content2 {
+ background: #ff7;
+ position: absolute;
+ top: 101px;
+ left: 401px;
+ width: 400px;
+ height: 400px;
+}
+#footer {
+ background: #0f0;
+ position: absolute;
+ top: 502px;
+ left: 0px;
+ width: 800px;
+ height: 200px;
+}
+-->
+</style>
+</head>
+<body>
+<div id="header"></div>
+<div id="content1">You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.
+You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.
+You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.
+You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.
+You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.
+You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, auto, or inherit and see what happens. The default value is visible.</div>
+<iframe id="content2" name="control" src="testiframe2.html"> </iframe>
+<div id="footer"></div>
+</body>
+</html>
\ No newline at end of file
diff --git a/WebKit/qt/tests/qwebframe/testiframe2.html b/WebKit/qt/tests/qwebframe/testiframe2.html
new file mode 100644
index 0000000..0d3a22f
--- /dev/null
+++ b/WebKit/qt/tests/qwebframe/testiframe2.html
@@ -0,0 +1,21 @@
+</html>
+<html>
+<head>
+<title></title>
+<style type="text/css">
+<!--
+#content {
+ background: #fff;
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ width: 800px;
+ height: 800px;
+}
+-->
+</style>
+</head>
+<body>
+<div id="content"> </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index 6e3a56c..c6292ff 100644
--- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -576,6 +576,7 @@ private slots:
void scrollPosition();
void evaluateWillCauseRepaint();
void qObjectWrapperWithSameIdentity();
+ void scrollRecursively();
private:
QString evalJS(const QString&s) {
@@ -2795,5 +2796,69 @@ void tst_QWebFrame::qObjectWrapperWithSameIdentity()
QCOMPARE(mainFrame->toPlainText(), QString("test2"));
}
+void tst_QWebFrame::scrollRecursively()
+{
+ // The test content is
+ // a nested frame set
+ // The main frame scrolls
+ // and has two children
+ // an iframe and a div overflow
+ // both scroll
+ QWebView webView;
+ QWebPage* webPage = webView.page();
+ QSignalSpy loadSpy(webPage, SIGNAL(loadFinished(bool)));
+ QUrl url = QUrl("qrc:///testiframe.html");
+ webPage->mainFrame()->load(url);
+ QTRY_COMPARE(loadSpy.count(), 1);
+
+ QList<QWebFrame*> children = webPage->mainFrame()->childFrames();
+ QVERIFY(children.count() == 1);
+
+ // 1st test
+ // call scrollRecursively over mainframe
+ // verify scrolled
+ // verify scroll postion changed
+ QPoint scrollPosition(webPage->mainFrame()->scrollPosition());
+ QVERIFY(webPage->mainFrame()->scrollRecursively(10, 10));
+ QVERIFY(scrollPosition != webPage->mainFrame()->scrollPosition());
+
+ // 2nd test
+ // call scrollRecursively over child iframe
+ // verify scrolled
+ // verify child scroll position changed
+ // verify parent's scroll position did not change
+ scrollPosition = webPage->mainFrame()->scrollPosition();
+ QPoint childScrollPosition = children.at(0)->scrollPosition();
+ QVERIFY(children.at(0)->scrollRecursively(10, 10));
+ QVERIFY(scrollPosition == webPage->mainFrame()->scrollPosition());
+ QVERIFY(childScrollPosition != children.at(0)->scrollPosition());
+
+ // 3rd test
+ // call scrollRecursively over div overflow
+ // verify scrolled == true
+ // verify parent and child frame's scroll postion did not change
+ QWebElement div = webPage->mainFrame()->documentElement().findFirst("#content1");
+ QMouseEvent evpres(QEvent::MouseMove, div.geometry().center(), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+ webPage->event(&evpres);
+ scrollPosition = webPage->mainFrame()->scrollPosition();
+ childScrollPosition = children.at(0)->scrollPosition();
+ QVERIFY(webPage->mainFrame()->scrollRecursively(5, 5));
+ QVERIFY(childScrollPosition == children.at(0)->scrollPosition());
+ QVERIFY(scrollPosition == webPage->mainFrame()->scrollPosition());
+
+ // 4th test
+ // call scrollRecursively twice over childs iframe
+ // verify scrolled == true first time
+ // verify parent's scroll == true second time
+ // verify parent and childs scroll position changed
+ childScrollPosition = children.at(0)->scrollPosition();
+ QVERIFY(children.at(0)->scrollRecursively(-10, -10));
+ QVERIFY(childScrollPosition != children.at(0)->scrollPosition());
+ scrollPosition = webPage->mainFrame()->scrollPosition();
+ QVERIFY(children.at(0)->scrollRecursively(-10, -10));
+ QVERIFY(scrollPosition != webPage->mainFrame()->scrollPosition());
+
+}
+
QTEST_MAIN(tst_QWebFrame)
#include "tst_qwebframe.moc"
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list