Changeset 38097 in webkit


Ignore:
Timestamp:
Nov 4, 2008 8:22:05 AM (16 years ago)
Author:
Simon Hausmann
Message:

WebCore:

2008-11-03 Yael Aharon <yael.aharon@nokia.com>

Reviewed by Simon Hausmann.

Add methods for getting and setting user data on History Item.
This change is limited to QT port only. Tests were added in
the patch for https://bugs.webkit.org/show_bug.cgi?id=21864.

Minor change by Simon: made the functions inline and added a missing
const.

WebKit/qt:

2008-10-24 Yael Aharon <yael.aharon@nokia.com>

Reviewed by Simon Hausmann.

Add userData() and setUserData() to QWebHistoryItem.
Add setMaximumItemCount() and maximumItemCount() to QWebHistory.
Add currentItemIndex() to QWebHistory.

See also https://bugs.webkit.org/show_bug.cgi?id=21864

Small cleanup by Simon (docs and forward declaration of QWebHistoryItem in qwebframe.h)

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r38094 r38097  
     12008-11-03  Yael Aharon  <yael.aharon@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        Add methods for getting and setting user data on History Item.
     6        This change is limited to QT port only. Tests were added in
     7        the patch for https://bugs.webkit.org/show_bug.cgi?id=21864.
     8
     9        Minor change by Simon: made the functions inline and added a missing
     10        const.
     11
     12        * history/HistoryItem.h:
     13
    1142008-11-01  Alexey Proskuryakov  <ap@webkit.org>
    215
  • trunk/WebCore/history/HistoryItem.h

    r34432 r38097  
    3838#include <wtf/Vector.h>
    3939
     40#if PLATFORM(QT)
     41#include <QVariant>
     42#endif
     43
    4044#if PLATFORM(MAC)
    4145#import <wtf/RetainPtr.h>
     
    149153#endif
    150154
     155#if PLATFORM(QT)
     156    QVariant userData() const { return m_userData; }
     157    void setUserData(const QVariant& userData) { m_userData = userData; }
     158#endif
     159
    151160#ifndef NDEBUG
    152161    int showTree() const;
     
    197206    OwnPtr<HashMap<String, RetainPtr<id> > > m_transientProperties;
    198207#endif
     208#if PLATFORM(QT)
     209    QVariant m_userData;
     210#endif
    199211}; //class HistoryItem
    200212
  • trunk/WebKit/qt/Api/qwebframe.cpp

    r37845 r38097  
    961961
    962962/*!
     963  \since 4.5
     964  \fn void QWebFrame::aboutToUpdateHistory(QWebHistoryItem* item);
     965
     966  This signal is emitted shortly before the history of navigated pages
     967  is changed, for example when navigating back in the history.
     968
     969  A potential use-case for this signal is to store custom data in
     970  the QWebHistoryItem associated to the frame, using QWebHistoryItem::setUserData().
     971*/
     972
     973/*!
    963974    \class QWebHitTestResult
    964975    \since 4.4
  • trunk/WebKit/qt/Api/qwebframe.h

    r37787 r38097  
    4747class QWebPage;
    4848class QWebHitTestResult;
     49class QWebHistoryItem;
    4950
    5051namespace WebCore {
     
    185186    void iconChanged();
    186187
     188    void aboutToUpdateHistory(QWebHistoryItem* item);
     189
    187190private:
    188191    friend class QWebPage;
  • trunk/WebKit/qt/Api/qwebhistory.cpp

    r37843 r38097  
    4848  \row    \o lastVisited() \o The date and time of the user's last visit to the page.
    4949  \row    \o icon()        \o The icon associated with the page that was provided by the server.
     50  \row    \o userData()    \o The user specific data that was stored with the history item.
    5051  \endtable
    5152
     
    145146
    146147/*!
     148  \since 4.5
     149  Returns the user specific data that was stored with the history item.
     150
     151  \sa setUserData()
     152*/
     153QVariant QWebHistoryItem::userData() const
     154{
     155    if (d->item)
     156        return d->item->userData();
     157    return QVariant();
     158}
     159
     160/*!
     161  \since 4.5
     162
     163 Stores user specific data with the history item.
     164
     165 \sa userData()
     166*/
     167void QWebHistoryItem::setUserData(const QVariant& userData)
     168{
     169    if (d->item)
     170        d->item->setUserData(userData);
     171}
     172
     173/*!*
    147174  \internal
    148175*/
     
    365392
    366393/*!
     394  \since 4.5
     395  Returns the index of the current item in history.
     396*/
     397int QWebHistory::currentItemIndex() const
     398{
     399    return d->lst->backListCount();
     400}
     401
     402/*!
    367403  Returns the item at index \a i in the history.
    368404*/
     
    383419}
    384420
     421/*!
     422  \since 4.5
     423  Returns the maximum number of items in the history.
     424
     425  \sa setMaximumItemCount()
     426*/
     427int QWebHistory::maximumItemCount() const
     428{
     429    return d->lst->capacity();
     430}
     431
     432/*!
     433  \since 4.5
     434  Sets the maximum number of items in the history.
     435
     436  \sa maximumItemCount()
     437*/
     438void QWebHistory::setMaximumItemCount(int count)
     439{
     440    d->lst->setCapacity(count);
     441}
     442
  • trunk/WebKit/qt/Api/qwebhistory.h

    r37843 r38097  
    3131class QWebPage;
    3232
     33namespace WebCore {
     34    class FrameLoaderClientQt;
     35};
     36
    3337class QWebHistoryItemPrivate;
    3438class QWEBKIT_EXPORT QWebHistoryItem
     
    4751    QIcon icon() const;
    4852
     53    QVariant userData() const;
     54    void setUserData(const QVariant& userData);
     55
    4956    bool isValid() const;
    5057
     
    5360    friend class QWebHistory;
    5461    friend class QWebPage;
     62    friend class WebCore::FrameLoaderClientQt;
    5563    QExplicitlySharedDataPointer<QWebHistoryItemPrivate> d;
    5664};
     
    7886    QWebHistoryItem itemAt(int i) const;
    7987
     88    int currentItemIndex() const;
     89
    8090    int count() const;
     91
     92    int maximumItemCount() const;
     93    void setMaximumItemCount(int count);
    8194
    8295private:
  • trunk/WebKit/qt/ChangeLog

    r38087 r38097  
     12008-10-24  Yael Aharon <yael.aharon@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        Add userData() and setUserData() to QWebHistoryItem.
     6        Add setMaximumItemCount() and maximumItemCount() to QWebHistory.
     7        Add currentItemIndex() to QWebHistory.
     8
     9        See also https://bugs.webkit.org/show_bug.cgi?id=21864
     10
     11        Small cleanup by Simon (docs and forward declaration of QWebHistoryItem in qwebframe.h)
     12
     13        * Api/qwebframe.h:
     14        * Api/qwebhistory.cpp:
     15        (QWebHistoryItem::userData):
     16        (QWebHistoryItem::setUserData):
     17        (QWebHistory::currentItemIndex):
     18        (QWebHistory::maximumItemCount):
     19        (QWebHistory::setMaximumItemCount):
     20        * Api/qwebhistory.h:
     21        * WebCoreSupport/FrameLoaderClientQt.cpp:
     22        (WebCore::FrameLoaderClientQt::saveViewStateToItem):
     23        * tests/qwebpage/tst_qwebpage.cpp:
     24        (tst_QWebPage::modified):
     25
    1262008-11-03  Cameron Zwarich  <zwarich@apple.com>
    227
  • trunk/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp

    r37754 r38097  
    6767#include "qwebnetworkinterface_p.h"
    6868#endif
     69#include "qwebhistory_p.h"
    6970
    7071static bool dumpFrameLoaderCallbacks = false;
     
    633634}
    634635
    635 void FrameLoaderClientQt::saveViewStateToItem(WebCore::HistoryItem*)
    636 {
     636void FrameLoaderClientQt::saveViewStateToItem(WebCore::HistoryItem* item)
     637{
     638    QWebHistoryItem historyItem(new QWebHistoryItemPrivate(item));
     639    emit m_webFrame->aboutToUpdateHistory(&historyItem);
    637640}
    638641
  • trunk/WebKit/qt/tests/qwebpage/tst_qwebpage.cpp

    r37843 r38097  
    305305
    306306    QVERIFY(!m_page->isModified());
     307
     308    QVERIFY(m_page->history()->currentItemIndex() == 0);
     309
     310    m_page->history()->setMaximumItemCount(3);
     311    QVERIFY(m_page->history()->maximumItemCount() == 3);
     312
     313    QVariant variant("string test");
     314    m_page->history()->currentItem().setUserData(variant);
     315    QVERIFY(m_page->history()->currentItem().userData().toString() == "string test");
     316
     317    m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is second page"));
     318    m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is third page"));
     319    QVERIFY(m_page->history()->count() == 2);
     320    m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fourth page"));
     321    QVERIFY(m_page->history()->count() == 2);
     322    m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fifth page"));
     323    QVERIFY(::waitForSignal(m_page->mainFrame(), SIGNAL(aboutToUpdateHistory(QWebHistoryItem*))));
    307324}
    308325
Note: See TracChangeset for help on using the changeset viewer.