Commit b8b5aa1d authored by hausmann@webkit.org's avatar hausmann@webkit.org
Browse files

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)

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@38097 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ec67500a
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.
* history/HistoryItem.h:
2008-11-01 Alexey Proskuryakov <ap@webkit.org>
 
Reviewed by Darin Adler.
......
......@@ -37,6 +37,10 @@
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
#if PLATFORM(QT)
#include <QVariant>
#endif
#if PLATFORM(MAC)
#import <wtf/RetainPtr.h>
typedef struct objc_object* id;
......@@ -148,6 +152,11 @@ public:
void setTransientProperty(const String&, id);
#endif
#if PLATFORM(QT)
QVariant userData() const { return m_userData; }
void setUserData(const QVariant& userData) { m_userData = userData; }
#endif
#ifndef NDEBUG
int showTree() const;
int showTreeWithIndent(unsigned indentLevel) const;
......@@ -196,6 +205,9 @@ private:
RetainPtr<id> m_viewState;
OwnPtr<HashMap<String, RetainPtr<id> > > m_transientProperties;
#endif
#if PLATFORM(QT)
QVariant m_userData;
#endif
}; //class HistoryItem
} //namespace WebCore
......
......@@ -959,6 +959,17 @@ QWebFrame* QWebFramePrivate::kit(WebCore::Frame* coreFrame)
\sa icon()
*/
/*!
\since 4.5
\fn void QWebFrame::aboutToUpdateHistory(QWebHistoryItem* item);
This signal is emitted shortly before the history of navigated pages
is changed, for example when navigating back in the history.
A potential use-case for this signal is to store custom data in
the QWebHistoryItem associated to the frame, using QWebHistoryItem::setUserData().
*/
/*!
\class QWebHitTestResult
\since 4.4
......
......@@ -46,6 +46,7 @@ class QWebNetworkRequest;
class QWebFramePrivate;
class QWebPage;
class QWebHitTestResult;
class QWebHistoryItem;
namespace WebCore {
class WidgetPrivate;
......@@ -184,6 +185,8 @@ Q_SIGNALS:
void iconChanged();
void aboutToUpdateHistory(QWebHistoryItem* item);
private:
friend class QWebPage;
friend class QWebPagePrivate;
......
......@@ -47,6 +47,7 @@
\row \o originalUrl() \o The URL used to access the page.
\row \o lastVisited() \o The date and time of the user's last visit to the page.
\row \o icon() \o The icon associated with the page that was provided by the server.
\row \o userData() \o The user specific data that was stored with the history item.
\endtable
\note QWebHistoryItem objects are value based and \l{explicitly shared}.
......@@ -144,6 +145,32 @@ QIcon QWebHistoryItem::icon() const
}
/*!
\since 4.5
Returns the user specific data that was stored with the history item.
\sa setUserData()
*/
QVariant QWebHistoryItem::userData() const
{
if (d->item)
return d->item->userData();
return QVariant();
}
/*!
\since 4.5
Stores user specific data with the history item.
\sa userData()
*/
void QWebHistoryItem::setUserData(const QVariant& userData)
{
if (d->item)
d->item->setUserData(userData);
}
/*!*
\internal
*/
QWebHistoryItem::QWebHistoryItem(QWebHistoryItemPrivate *priv)
......@@ -363,6 +390,15 @@ QWebHistoryItem QWebHistory::forwardItem() const
return QWebHistoryItem(priv);
}
/*!
\since 4.5
Returns the index of the current item in history.
*/
int QWebHistory::currentItemIndex() const
{
return d->lst->backListCount();
}
/*!
Returns the item at index \a i in the history.
*/
......@@ -382,3 +418,25 @@ int QWebHistory::count() const
return d->lst->entries().size();
}
/*!
\since 4.5
Returns the maximum number of items in the history.
\sa setMaximumItemCount()
*/
int QWebHistory::maximumItemCount() const
{
return d->lst->capacity();
}
/*!
\since 4.5
Sets the maximum number of items in the history.
\sa maximumItemCount()
*/
void QWebHistory::setMaximumItemCount(int count)
{
d->lst->setCapacity(count);
}
......@@ -30,6 +30,10 @@
class QWebPage;
namespace WebCore {
class FrameLoaderClientQt;
};
class QWebHistoryItemPrivate;
class QWEBKIT_EXPORT QWebHistoryItem
{
......@@ -46,12 +50,16 @@ public:
QIcon icon() const;
QVariant userData() const;
void setUserData(const QVariant& userData);
bool isValid() const;
private:
QWebHistoryItem(QWebHistoryItemPrivate *priv);
friend class QWebHistory;
friend class QWebPage;
friend class WebCore::FrameLoaderClientQt;
QExplicitlySharedDataPointer<QWebHistoryItemPrivate> d;
};
......@@ -77,8 +85,13 @@ public:
QWebHistoryItem forwardItem() const;
QWebHistoryItem itemAt(int i) const;
int currentItemIndex() const;
int count() const;
int maximumItemCount() const;
void setMaximumItemCount(int count);
private:
QWebHistory();
~QWebHistory();
......
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)
* Api/qwebframe.h:
* Api/qwebhistory.cpp:
(QWebHistoryItem::userData):
(QWebHistoryItem::setUserData):
(QWebHistory::currentItemIndex):
(QWebHistory::maximumItemCount):
(QWebHistory::setMaximumItemCount):
* Api/qwebhistory.h:
* WebCoreSupport/FrameLoaderClientQt.cpp:
(WebCore::FrameLoaderClientQt::saveViewStateToItem):
* tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::modified):
2008-11-03 Cameron Zwarich <zwarich@apple.com>
Rubber-stamped by Maciej Stachowiak.
......
......@@ -66,6 +66,7 @@
#else
#include "qwebnetworkinterface_p.h"
#endif
#include "qwebhistory_p.h"
static bool dumpFrameLoaderCallbacks = false;
static bool dumpResourceLoadCallbacks = false;
......@@ -632,8 +633,10 @@ bool FrameLoaderClientQt::shouldGoToHistoryItem(WebCore::HistoryItem *item) cons
return true;
}
void FrameLoaderClientQt::saveViewStateToItem(WebCore::HistoryItem*)
void FrameLoaderClientQt::saveViewStateToItem(WebCore::HistoryItem* item)
{
QWebHistoryItem historyItem(new QWebHistoryItemPrivate(item));
emit m_webFrame->aboutToUpdateHistory(&historyItem);
}
bool FrameLoaderClientQt::canCachePage() const
......
......@@ -304,6 +304,23 @@ void tst_QWebPage::modified()
QVERIFY(m_page->history()->canGoForward());
QVERIFY(!m_page->isModified());
QVERIFY(m_page->history()->currentItemIndex() == 0);
m_page->history()->setMaximumItemCount(3);
QVERIFY(m_page->history()->maximumItemCount() == 3);
QVariant variant("string test");
m_page->history()->currentItem().setUserData(variant);
QVERIFY(m_page->history()->currentItem().userData().toString() == "string test");
m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is second page"));
m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is third page"));
QVERIFY(m_page->history()->count() == 2);
m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fourth page"));
QVERIFY(m_page->history()->count() == 2);
m_page->mainFrame()->setUrl(QUrl("data:text/html,<body>This is fifth page"));
QVERIFY(::waitForSignal(m_page->mainFrame(), SIGNAL(aboutToUpdateHistory(QWebHistoryItem*))));
}
void tst_QWebPage::contextMenuCrash()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment