Changeset 54857 in webkit


Ignore:
Timestamp:
Feb 16, 2010, 6:29:57 PM (16 years ago)
Author:
ariya@webkit.org
Message:

2010-02-16 Ariya Hidayat <ariya.hidayat@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().
Location:
trunk/WebKit/qt
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/Api/qwebframe.cpp

    r54612 r54857  
    11411141
    11421142/*!
     1143  \since 4.7
     1144  Scrolls the frame to the given \a anchor name.
     1145*/
     1146void QWebFrame::scrollToAnchor(const QString& anchor)
     1147{
     1148    FrameView *view = d->frame->view();
     1149    if (view)
     1150        view->scrollToAnchor(anchor);
     1151}
     1152
     1153/*!
    11431154  \since 4.6
    11441155  Render the \a layer of the frame using \a painter clipping to \a clip.
  • trunk/WebKit/qt/Api/qwebframe.h

    r52311 r54857  
    161161    void setScrollPosition(const QPoint &pos);
    162162
     163    void scrollToAnchor(const QString& anchor);
     164
    163165    enum RenderLayer {
    164166        ContentsLayer = 0x10,
  • trunk/WebKit/qt/ChangeLog

    r54854 r54857  
     12010-02-16  Ariya Hidayat  <ariya.hidayat@gmail.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Allow scrolling to an anchor programmatically.
     6        https://bugs.webkit.org/show_bug.cgi?id=29856
     7
     8        * Api/qwebframe.cpp:
     9        (QWebFrame::scrollToAnchor): New API function.
     10        * Api/qwebframe.h:
     11        * tests/qwebframe/tst_qwebframe.cpp: New tests for scrollToAnchor().
     12
    1132010-02-16  Ariya Hidayat  <ariya.hidayat@gmail.com>
    214
  • trunk/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp

    r54775 r54857  
    585585    void render();
    586586    void scrollPosition();
     587    void scrollToAnchor();
    587588    void evaluateWillCauseRepaint();
    588589    void qObjectWrapperWithSameIdentity();
     
    27652766}
    27662767
     2768void tst_QWebFrame::scrollToAnchor()
     2769{
     2770    QWebPage page;
     2771    page.setViewportSize(QSize(480, 800));
     2772    QWebFrame* frame = page.mainFrame();
     2773
     2774    QString html("<html><body><p style=\"margin-bottom: 1500px;\">Hello.</p>"
     2775                 "<p><a id=\"foo\">This</a> is an anchor</p>"
     2776                 "<p style=\"margin-bottom: 1500px;\"><a id=\"bar\">This</a> is another anchor</p>"
     2777                 "</body></html>");
     2778    frame->setHtml(html);
     2779    frame->setScrollPosition(QPoint(0, 0));
     2780    QCOMPARE(frame->scrollPosition().x(), 0);
     2781    QCOMPARE(frame->scrollPosition().y(), 0);
     2782
     2783    QWebElement fooAnchor = frame->findFirstElement("a[id=foo]");
     2784
     2785    frame->scrollToAnchor("foo");
     2786    QCOMPARE(frame->scrollPosition().y(), fooAnchor.geometry().top());
     2787
     2788    frame->scrollToAnchor("bar");
     2789    frame->scrollToAnchor("foo");
     2790    QCOMPARE(frame->scrollPosition().y(), fooAnchor.geometry().top());
     2791
     2792    frame->scrollToAnchor("top");
     2793    QCOMPARE(frame->scrollPosition().y(), 0);
     2794
     2795    frame->scrollToAnchor("bar");
     2796    frame->scrollToAnchor("notexist");
     2797    QVERIFY(frame->scrollPosition().y() != 0);
     2798}
     2799
    27672800void tst_QWebFrame::evaluateWillCauseRepaint()
    27682801{
Note: See TracChangeset for help on using the changeset viewer.