2010-11-08 Juha Savolainen <juha.savolainen@weego.fi>

        Reviewed by Andreas Kling.

        [Qt] Added new methods to QWKHistory and made QWKHistoryItemPrivate to shared object.
        https://bugs.webkit.org/show_bug.cgi?id=49063

        Added more functionality to the QWKHistory and changed QWKHistoryItemPrivate to shared object.
        This is needed because we cannot delete the QWKHistoryItemPrivate pointer in destructor of QWKHistoryItem,
        there may have other history instances which share same private implementation.

        * UIProcess/API/qt/qwkhistory.cpp:
        (QWKHistoryItemPrivate::~QWKHistoryItemPrivate):
        (QWKHistoryItem::QWKHistoryItem):
        (QWKHistoryItem::QWKHistoryItem::operator=):
        (QWKHistory::currentItem): Added
        (QWKHistory::backItem): Added
        (QWKHistory::forwardItem): Added
        (QWKHistory::itemAt): Added
        (QWKHistory::backItems): Added
        (QWKHistory::forwardItems): Added
        * UIProcess/API/qt/qwkhistory.h:
        * UIProcess/API/qt/qwkhistory_p.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71596 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e1c4a654
2010-11-08 Juha Savolainen <juha.savolainen@weego.fi>
Reviewed by Andreas Kling.
[Qt] Added new methods to QWKHistory and made QWKHistoryItemPrivate to shared object.
https://bugs.webkit.org/show_bug.cgi?id=49063
Added more functionality to the QWKHistory and changed QWKHistoryItemPrivate to shared object.
This is needed because we cannot delete the QWKHistoryItemPrivate pointer in destructor of QWKHistoryItem,
there may have other history instances which share same private implementation.
* UIProcess/API/qt/qwkhistory.cpp:
(QWKHistoryItemPrivate::~QWKHistoryItemPrivate):
(QWKHistoryItem::QWKHistoryItem):
(QWKHistoryItem::QWKHistoryItem::operator=):
(QWKHistory::currentItem): Added
(QWKHistory::backItem): Added
(QWKHistory::forwardItem): Added
(QWKHistory::itemAt): Added
(QWKHistory::backItems): Added
(QWKHistory::forwardItems): Added
* UIProcess/API/qt/qwkhistory.h:
* UIProcess/API/qt/qwkhistory_p.h:
2010-11-08 Anders Carlsson <andersca@apple.com>
Reviewed by Dan Bernstein.
......
......@@ -25,16 +25,17 @@
#include "config.h"
#include "qwkhistory.h"
#include <QSharedData>
#include <QString>
#include <QUrl>
#include "qwkhistory_p.h"
#include "WebBackForwardList.h"
#include <WebKit2/WKArray.h>
#include <WebKit2/WKRetainPtr.h>
#include "WKBackForwardList.h"
#include "WKBackForwardListItem.h"
#include "WKStringQt.h"
#include "WKURL.h"
#include "WKURLQt.h"
#include "WebBackForwardList.h"
#include "qwkhistory_p.h"
#include <QString>
#include <QUrl>
#include <WebKit2/WKRetainPtr.h>
using namespace WebKit;
......@@ -43,7 +44,23 @@ QWKHistoryItemPrivate::QWKHistoryItemPrivate(WKBackForwardListItemRef listItem)
{
}
QWKHistoryItem::QWKHistoryItem()
QWKHistoryItemPrivate::~QWKHistoryItemPrivate()
{
}
QWKHistoryItem::QWKHistoryItem(const QWKHistoryItem& other)
: d(other.d)
{
}
QWKHistoryItem& QWKHistoryItem::QWKHistoryItem::operator=(const QWKHistoryItem& other)
{
d = other.d;
return *this;
}
QWKHistoryItem::QWKHistoryItem(WKBackForwardListItemRef item)
: d(new QWKHistoryItemPrivate(item))
{
}
......@@ -115,3 +132,59 @@ int QWKHistory::count() const
return backListCount() + forwardListCount();
}
QWKHistoryItem QWKHistory::currentItem() const
{
WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetCurrentItem(toAPI(d->m_backForwardList));
QWKHistoryItem item(itemRef.get());
return item;
}
QWKHistoryItem QWKHistory::backItem() const
{
WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetBackItem(toAPI(d->m_backForwardList));
QWKHistoryItem item(itemRef.get());
return item;
}
QWKHistoryItem QWKHistory::forwardItem() const
{
WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetForwardItem(toAPI(d->m_backForwardList));
QWKHistoryItem item(itemRef.get());
return item;
}
QWKHistoryItem QWKHistory::itemAt(int index) const
{
WKRetainPtr<WKBackForwardListItemRef> itemRef = WKBackForwardListGetItemAtIndex(toAPI(d->m_backForwardList), index);
QWKHistoryItem item(itemRef.get());
return item;
}
QList<QWKHistoryItem> QWKHistory::backItems(int maxItems) const
{
WKArrayRef arrayRef = WKBackForwardListCopyBackListWithLimit(toAPI(d->m_backForwardList), maxItems);
int size = WKArrayGetSize(arrayRef);
QList<QWKHistoryItem> itemList;
for (int i = 0; i < size; ++i) {
WKTypeRef wkHistoryItem = WKArrayGetItemAtIndex(arrayRef, i);
WKBackForwardListItemRef itemRef = static_cast<WKBackForwardListItemRef>(wkHistoryItem);
QWKHistoryItem item(itemRef);
itemList.append(item);
}
return itemList;
}
QList<QWKHistoryItem> QWKHistory::forwardItems(int maxItems) const
{
WKArrayRef arrayRef = WKBackForwardListCopyForwardListWithLimit(toAPI(d->m_backForwardList), maxItems);
int size = WKArrayGetSize(arrayRef);
QList<QWKHistoryItem> itemList;
for (int i = 0; i < size; ++i) {
WKTypeRef wkHistoryItem = WKArrayGetItemAtIndex(arrayRef, i);
WKBackForwardListItemRef itemRef = static_cast<WKBackForwardListItemRef>(wkHistoryItem);
QWKHistoryItem item(itemRef);
itemList.append(item);
}
return itemList;
}
......@@ -27,6 +27,8 @@
#include "qwebkitglobal.h"
#include <QObject>
#include <QSharedData>
#include "WKBackForwardListItem.h"
class QWKHistoryPrivate;
class QWKHistoryItemPrivate;
......@@ -39,15 +41,18 @@ class WebBackForwardList;
class QWEBKIT_EXPORT QWKHistoryItem {
public:
QWKHistoryItem(const QWKHistoryItem& other);
QWKHistoryItem &operator=(const QWKHistoryItem& other);
~QWKHistoryItem();
QString title() const;
QUrl url() const;
QUrl originalUrl() const;
private:
QWKHistoryItem();
QWKHistoryItem(WKBackForwardListItemRef item);
QWKHistoryItemPrivate* d;
QExplicitlySharedDataPointer<QWKHistoryItemPrivate> d;
friend class QWKHistory;
friend class QWKHistoryItemPrivate;
......@@ -59,6 +64,12 @@ public:
int backListCount() const;
int forwardListCount() const;
int count() const;
QWKHistoryItem currentItem() const;
QWKHistoryItem backItem() const;
QWKHistoryItem forwardItem() const;
QWKHistoryItem itemAt(int index) const;
QList<QWKHistoryItem> backItems(int maxItems) const;
QList<QWKHistoryItem> forwardItems(int maxItems) const;
private:
QWKHistory();
......@@ -68,5 +79,4 @@ private:
friend class QWKHistoryPrivate;
friend class QWKPagePrivate;
};
#endif /* qwkhistory_h */
......@@ -25,6 +25,7 @@
#ifndef qwkhistory_p_h
#define qwkhistory_p_h
#include <QSharedData>
#include "qwebkitglobal.h"
#include <WebKit2/WKBase.h>
#include <WebKit2/WKRetainPtr.h>
......@@ -36,10 +37,11 @@ class WebBackForwardList;
class QWKHistory;
class QWEBKIT_EXPORT QWKHistoryItemPrivate {
class QWEBKIT_EXPORT QWKHistoryItemPrivate : public QSharedData {
public:
~QWKHistoryItemPrivate();
private:
QWKHistoryItemPrivate(WKBackForwardListItemRef listItem);
WKRetainPtr<WKBackForwardListItemRef> m_backForwardListItem;
friend class QWKHistory;
......
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