[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

ariya at webkit.org ariya at webkit.org
Fri Feb 26 22:21:52 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 4f20108cb27db254a57518d9f28ca6bf39989f86
Author: ariya at webkit.org <ariya at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Feb 17 02:29:57 2010 +0000

    2010-02-16  Ariya Hidayat  <ariya.hidayat at gmail.com>
    
            Reviewed by Simon Hausmann.
    
            [Qt] Allow scrolling to an anchor programmatically.
            https://bugs.webkit.org/show_bug.cgi?id=29856
    
            * Api/qwebframe.cpp:
            (QWebFrame::scrollToAnchor): New API function.
            * Api/qwebframe.h:
            * tests/qwebframe/tst_qwebframe.cpp: New tests for scrollToAnchor().
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54857 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/qt/Api/qwebframe.cpp b/WebKit/qt/Api/qwebframe.cpp
index 4c1f318..d372290 100644
--- a/WebKit/qt/Api/qwebframe.cpp
+++ b/WebKit/qt/Api/qwebframe.cpp
@@ -1140,6 +1140,17 @@ void QWebFrame::setScrollPosition(const QPoint &pos)
 }
 
 /*!
+  \since 4.7
+  Scrolls the frame to the given \a anchor name.
+*/
+void QWebFrame::scrollToAnchor(const QString& anchor)
+{
+    FrameView *view = d->frame->view();
+    if (view)
+        view->scrollToAnchor(anchor);
+}
+
+/*!
   \since 4.6
   Render the \a layer of the frame using \a painter clipping to \a clip.
 
diff --git a/WebKit/qt/Api/qwebframe.h b/WebKit/qt/Api/qwebframe.h
index 25f6c9b..541b055 100644
--- a/WebKit/qt/Api/qwebframe.h
+++ b/WebKit/qt/Api/qwebframe.h
@@ -160,6 +160,8 @@ public:
     QPoint scrollPosition() const;
     void setScrollPosition(const QPoint &pos);
 
+    void scrollToAnchor(const QString& anchor);
+
     enum RenderLayer {
         ContentsLayer = 0x10,
         ScrollBarLayer = 0x20,
diff --git a/WebKit/qt/ChangeLog b/WebKit/qt/ChangeLog
index 4d4f651..99dbaa4 100644
--- a/WebKit/qt/ChangeLog
+++ b/WebKit/qt/ChangeLog
@@ -1,5 +1,17 @@
 2010-02-16  Ariya Hidayat  <ariya.hidayat at gmail.com>
 
+        Reviewed by Simon Hausmann.
+
+        [Qt] Allow scrolling to an anchor programmatically.
+        https://bugs.webkit.org/show_bug.cgi?id=29856
+
+        * Api/qwebframe.cpp:
+        (QWebFrame::scrollToAnchor): New API function.
+        * Api/qwebframe.h:
+        * tests/qwebframe/tst_qwebframe.cpp: New tests for scrollToAnchor().
+
+2010-02-16  Ariya Hidayat  <ariya.hidayat at gmail.com>
+
         Reviewed by Laszlo Gombos.
 
         Fix building with Qt < 4.6.
diff --git a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
index f5c0efb..5ac3769 100644
--- a/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
+++ b/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp
@@ -584,6 +584,7 @@ private slots:
     void hasSetFocus();
     void render();
     void scrollPosition();
+    void scrollToAnchor();
     void evaluateWillCauseRepaint();
     void qObjectWrapperWithSameIdentity();
     void scrollRecursively();
@@ -2764,6 +2765,38 @@ void tst_QWebFrame::scrollPosition()
     QCOMPARE(y, 29);
 }
 
+void tst_QWebFrame::scrollToAnchor()
+{
+    QWebPage page;
+    page.setViewportSize(QSize(480, 800));
+    QWebFrame* frame = page.mainFrame();
+
+    QString html("<html><body><p style=\"margin-bottom: 1500px;\">Hello.</p>"
+                 "<p><a id=\"foo\">This</a> is an anchor</p>"
+                 "<p style=\"margin-bottom: 1500px;\"><a id=\"bar\">This</a> is another anchor</p>"
+                 "</body></html>");
+    frame->setHtml(html);
+    frame->setScrollPosition(QPoint(0, 0));
+    QCOMPARE(frame->scrollPosition().x(), 0);
+    QCOMPARE(frame->scrollPosition().y(), 0);
+
+    QWebElement fooAnchor = frame->findFirstElement("a[id=foo]");
+
+    frame->scrollToAnchor("foo");
+    QCOMPARE(frame->scrollPosition().y(), fooAnchor.geometry().top());
+
+    frame->scrollToAnchor("bar");
+    frame->scrollToAnchor("foo");
+    QCOMPARE(frame->scrollPosition().y(), fooAnchor.geometry().top());
+
+    frame->scrollToAnchor("top");
+    QCOMPARE(frame->scrollPosition().y(), 0);
+
+    frame->scrollToAnchor("bar");
+    frame->scrollToAnchor("notexist");
+    QVERIFY(frame->scrollPosition().y() != 0);
+}
+
 void tst_QWebFrame::evaluateWillCauseRepaint()
 {
     QWebView view;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list