diff options
Diffstat (limited to 'WebCore/history')
-rw-r--r-- | WebCore/history/BackForwardList.cpp | 10 | ||||
-rw-r--r-- | WebCore/history/BackForwardList.h | 2 | ||||
-rw-r--r-- | WebCore/history/CachedFrame.cpp | 9 | ||||
-rw-r--r-- | WebCore/history/CachedFrame.h | 2 | ||||
-rw-r--r-- | WebCore/history/HistoryItem.cpp | 41 | ||||
-rw-r--r-- | WebCore/history/HistoryItem.h | 25 | ||||
-rw-r--r-- | WebCore/history/PageCache.cpp | 17 | ||||
-rw-r--r-- | WebCore/history/PageCache.h | 6 | ||||
-rw-r--r-- | WebCore/history/qt/HistoryItemQt.cpp | 114 |
9 files changed, 205 insertions, 21 deletions
diff --git a/WebCore/history/BackForwardList.cpp b/WebCore/history/BackForwardList.cpp index e747a33..99827e3 100644 --- a/WebCore/history/BackForwardList.cpp +++ b/WebCore/history/BackForwardList.cpp @@ -306,16 +306,20 @@ bool BackForwardList::containsItem(HistoryItem* entry) } #if ENABLE(WML) -void BackForwardList::clearWmlPageHistory() +void BackForwardList::clearWMLPageHistory() { - PassRefPtr<HistoryItem> cur = currentItem(); + RefPtr<HistoryItem> currentItem = this->currentItem(); - for (unsigned i = 0; i < m_entries.size(); ++i) + int size = m_entries.size(); + for (int i = 0; i < size; ++i) pageCache()->remove(m_entries[i].get()); m_entries.clear(); m_entryHash.clear(); m_current = NoCurrentItemIndex; + + // Spec: The history stack may be reset to a state where it only contains the current card. + addItem(currentItem); } #endif diff --git a/WebCore/history/BackForwardList.h b/WebCore/history/BackForwardList.h index a99d387..fdc3360 100644 --- a/WebCore/history/BackForwardList.h +++ b/WebCore/history/BackForwardList.h @@ -97,7 +97,7 @@ public: HistoryItemVector& entries(); #if ENABLE(WML) - void clearWmlPageHistory(); + void clearWMLPageHistory(); #endif private: diff --git a/WebCore/history/CachedFrame.cpp b/WebCore/history/CachedFrame.cpp index 9a43b9d..5f4e746 100644 --- a/WebCore/history/CachedFrame.cpp +++ b/WebCore/history/CachedFrame.cpp @@ -155,4 +155,13 @@ CachedFramePlatformData* CachedFrame::cachedFramePlatformData() return m_cachedFramePlatformData.get(); } +int CachedFrame::descendantFrameCount() const +{ + int count = m_childFrames.size(); + for (size_t i = 0; i < m_childFrames.size(); ++i) + count += m_childFrames[i]->descendantFrameCount(); + + return count; +} + } // namespace WebCore diff --git a/WebCore/history/CachedFrame.h b/WebCore/history/CachedFrame.h index 83c3c3c..0302444 100644 --- a/WebCore/history/CachedFrame.h +++ b/WebCore/history/CachedFrame.h @@ -60,6 +60,8 @@ public: void setCachedFramePlatformData(CachedFramePlatformData*); CachedFramePlatformData* cachedFramePlatformData(); + + int descendantFrameCount() const; private: CachedFrame(Frame*); diff --git a/WebCore/history/HistoryItem.cpp b/WebCore/history/HistoryItem.cpp index 7826eb8..08143e8 100644 --- a/WebCore/history/HistoryItem.cpp +++ b/WebCore/history/HistoryItem.cpp @@ -165,8 +165,8 @@ const String& HistoryItem::alternateTitle() const Image* HistoryItem::icon() const { - Image* result = iconDatabase()->iconForPageURL(m_urlString, IntSize(16,16)); - return result ? result : iconDatabase()->defaultIcon(IntSize(16,16)); + Image* result = iconDatabase()->iconForPageURL(m_urlString, IntSize(16, 16)); + return result ? result : iconDatabase()->defaultIcon(IntSize(16, 16)); } double HistoryItem::lastVisitedTime() const @@ -313,14 +313,16 @@ void HistoryItem::collapseDailyVisitsToWeekly() m_weeklyVisitCounts.shrink(maxWeeklyCounts); } -void HistoryItem::recordVisitAtTime(double time) +void HistoryItem::recordVisitAtTime(double time, VisitCountBehavior visitCountBehavior) { padDailyCountsForNewVisit(time); m_lastVisitedTime = time; - m_visitCount++; - m_dailyVisitCounts[0]++; + if (visitCountBehavior == IncreaseVisitCount) { + ++m_visitCount; + ++m_dailyVisitCounts[0]; + } collapseDailyVisitsToWeekly(); } @@ -331,10 +333,10 @@ void HistoryItem::setLastVisitedTime(double time) recordVisitAtTime(time); } -void HistoryItem::visited(const String& title, double time) +void HistoryItem::visited(const String& title, double time, VisitCountBehavior visitCountBehavior) { m_title = title; - recordVisitAtTime(time); + recordVisitAtTime(time, visitCountBehavior); } int HistoryItem::visitCount() const @@ -355,10 +357,10 @@ void HistoryItem::setVisitCount(int count) void HistoryItem::adoptVisitCounts(Vector<int>& dailyCounts, Vector<int>& weeklyCounts) { - m_dailyVisitCounts.clear(); - m_dailyVisitCounts.swap(dailyCounts); - m_weeklyVisitCounts.clear(); - m_weeklyVisitCounts.swap(weeklyCounts); + m_dailyVisitCounts.clear(); + m_dailyVisitCounts.swap(dailyCounts); + m_weeklyVisitCounts.clear(); + m_weeklyVisitCounts.swap(weeklyCounts); } const IntPoint& HistoryItem::scrollPoint() const @@ -473,6 +475,11 @@ bool HistoryItem::hasChildren() const return !m_children.isEmpty(); } +void HistoryItem::clearChildren() +{ + m_children.clear(); +} + String HistoryItem::formContentType() const { return m_formContentType; @@ -496,6 +503,16 @@ void HistoryItem::setFormInfoFromRequest(const ResourceRequest& request) #endif } +void HistoryItem::setFormData(PassRefPtr<FormData> formData) +{ + m_formData = formData; +} + +void HistoryItem::setFormContentType(const String& formContentType) +{ + m_formContentType = formContentType; +} + FormData* HistoryItem::formData() { return m_formData.get(); @@ -504,7 +521,7 @@ FormData* HistoryItem::formData() bool HistoryItem::isCurrentDocument(Document* doc) const { // FIXME: We should find a better way to check if this is the current document. - return urlString() == doc->url(); + return equalIgnoringFragmentIdentifier(url(), doc->url()); } void HistoryItem::mergeAutoCompleteHints(HistoryItem* otherItem) diff --git a/WebCore/history/HistoryItem.h b/WebCore/history/HistoryItem.h index 2d8528c..21d2293 100644 --- a/WebCore/history/HistoryItem.h +++ b/WebCore/history/HistoryItem.h @@ -42,6 +42,8 @@ typedef struct objc_object* id; #if PLATFORM(QT) #include <QVariant> +#include <QByteArray> +#include <QDataStream> #endif namespace WebCore { @@ -62,6 +64,11 @@ extern void (*notifyHistoryItemChanged)(HistoryItem*); extern void (*notifyHistoryItemChanged)(); #endif +enum VisitCountBehavior { + IncreaseVisitCount, + DoNotIncreaseVisitCount +}; + class HistoryItem : public RefCounted<HistoryItem> { friend class PageCache; @@ -130,6 +137,8 @@ public: void setIsTargetItem(bool); void setFormInfoFromRequest(const ResourceRequest&); + void setFormData(PassRefPtr<FormData>); + void setFormContentType(const String&); void recordInitialVisit(); @@ -143,11 +152,12 @@ public: HistoryItem* targetItem(); const HistoryItemVector& children() const; bool hasChildren() const; + void clearChildren(); // This should not be called directly for HistoryItems that are already included // in GlobalHistory. The WebKit api for this is to use -[WebHistory setLastVisitedTimeInterval:forItem:] instead. void setLastVisitedTime(double); - void visited(const String& title, double time); + void visited(const String& title, double time, VisitCountBehavior); void addRedirectURL(const String&); Vector<String>* redirectURLs() const; @@ -168,6 +178,9 @@ public: #if PLATFORM(QT) QVariant userData() const { return m_userData; } void setUserData(const QVariant& userData) { m_userData = userData; } + + bool restoreState(QDataStream& buffer, int version); + QDataStream& saveState(QDataStream& out, int version) const; #endif #ifndef NDEBUG @@ -181,8 +194,8 @@ public: #endif void adoptVisitCounts(Vector<int>& dailyCounts, Vector<int>& weeklyCounts); - const Vector<int>& dailyVisitCounts() { return m_dailyVisitCounts; } - const Vector<int>& weeklyVisitCounts() { return m_weeklyVisitCounts; } + const Vector<int>& dailyVisitCounts() const { return m_dailyVisitCounts; } + const Vector<int>& weeklyVisitCounts() const { return m_weeklyVisitCounts; } private: HistoryItem(); @@ -194,10 +207,14 @@ private: void padDailyCountsForNewVisit(double time); void collapseDailyVisitsToWeekly(); - void recordVisitAtTime(double); + void recordVisitAtTime(double, VisitCountBehavior = IncreaseVisitCount); HistoryItem* findTargetItem(); + /* When adding new member variables to this class, please notify the Qt team. + * qt/HistoryItemQt.cpp contains code to serialize history items. + */ + String m_urlString; String m_originalURLString; String m_referrer; diff --git a/WebCore/history/PageCache.cpp b/WebCore/history/PageCache.cpp index 7c25701..8d04f6f 100644 --- a/WebCore/history/PageCache.cpp +++ b/WebCore/history/PageCache.cpp @@ -63,6 +63,23 @@ void PageCache::setCapacity(int capacity) prune(); } +int PageCache::frameCount() const +{ + int frameCount = 0; + for (HistoryItem* current = m_head; current; current = current->m_next) { + ++frameCount; + ASSERT(current->m_cachedPage); + frameCount += current->m_cachedPage ? current->m_cachedPage->cachedMainFrame()->descendantFrameCount() : 0; + } + + return frameCount; +} + +int PageCache::autoreleasedPageCount() const +{ + return m_autoreleaseSet.size(); +} + void PageCache::add(PassRefPtr<HistoryItem> prpItem, PassRefPtr<CachedPage> cachedPage) { ASSERT(prpItem); diff --git a/WebCore/history/PageCache.h b/WebCore/history/PageCache.h index ad15ab6..607a87d 100644 --- a/WebCore/history/PageCache.h +++ b/WebCore/history/PageCache.h @@ -37,7 +37,7 @@ namespace WebCore { class CachedPage; class HistoryItem; - class PageCache : Noncopyable { + class PageCache : public Noncopyable { public: friend PageCache* pageCache(); @@ -49,6 +49,10 @@ namespace WebCore { CachedPage* get(HistoryItem* item) { return item ? item->m_cachedPage.get() : 0; } void releaseAutoreleasedPagesNow(); + + int pageCount() const { return m_size; } + int frameCount() const; + int autoreleasedPageCount() const; private: typedef HashSet<RefPtr<CachedPage> > CachedPageSet; diff --git a/WebCore/history/qt/HistoryItemQt.cpp b/WebCore/history/qt/HistoryItemQt.cpp new file mode 100644 index 0000000..68fee87 --- /dev/null +++ b/WebCore/history/qt/HistoryItemQt.cpp @@ -0,0 +1,114 @@ +/* + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "config.h" +#include "HistoryItem.h" + +#include "CString.h" +#include "FormData.h" + +bool WebCore::HistoryItem::restoreState(QDataStream& in, int /*version*/) +{ + // there is no different version right now + // switch (version) { + WebCore::String url; + WebCore::String title; + WebCore::String altTitle; + WebCore::String orginalUrl; + WebCore::String referrer; + WebCore::String target; + WebCore::String parrent; + double lastVisitedTime; + bool validUserData; + WebCore::String parent; + bool lastVisitWasHTTPNonGet; + bool lastVisitWasFailure; + bool isTargetItem; + int visitCount; + WTF::Vector<WebCore::String> documentState; + WebCore::IntPoint scrollPoint; + WTF::Vector<int> weeklyVisitCounts; + WTF::Vector<int> dailyVisitCounts; + bool loadFormdata; + // WebCore::String formContentType; + // WTF::Vector<char> formData; + + in >> url >> title >> altTitle >> lastVisitedTime >> orginalUrl >> referrer >> target >> parent; + in >> lastVisitWasHTTPNonGet >> lastVisitWasFailure >> isTargetItem >> visitCount >> documentState; + in >> scrollPoint >> dailyVisitCounts >> weeklyVisitCounts; + /*in >> loadFormdata; + if (loadFormdata) { + in >> formContentType >> formData; + // direct assigned (!) + m_formContentType = formContentType; + m_formData = FormData::create(CString(formData)); + }*/ + // use setters + adoptVisitCounts(dailyVisitCounts, weeklyVisitCounts); + setScrollPoint(scrollPoint); + setDocumentState(documentState); + setVisitCount(visitCount); + setIsTargetItem(isTargetItem); + setLastVisitWasFailure(lastVisitWasFailure); + setLastVisitWasHTTPNonGet(lastVisitWasHTTPNonGet); + setParent(parent); + setTarget(target); + setReferrer(referrer); + setOriginalURLString(orginalUrl); + setURLString(url); + setLastVisitedTime(lastVisitedTime); + setTitle(title); + setAlternateTitle(altTitle); + + // at the end load userData + in >> validUserData; + if (validUserData) { + QVariant tmp; + in >> tmp; + setUserData(tmp); + } + + return in.status() == QDataStream::Ok; +} + +QDataStream& WebCore::HistoryItem::saveState(QDataStream& out, int /*version*/) const +{ + // there is no different version right now + // switch (version) { + out << urlString() << title() << alternateTitle() << lastVisitedTime(); + out << originalURLString() << referrer() << target() << parent(); + out << lastVisitWasHTTPNonGet() << lastVisitWasFailure() << isTargetItem(); + out << visitCount() << documentState() << scrollPoint(); + out << dailyVisitCounts() << weeklyVisitCounts(); + /*if (m_formData) { + out << true; + out << formContentType(); + out << m_formData->flatten(); + } else { + out << false; + }*/ + // save user data + if (userData().isValid()) + out << true << userData(); + else + out << false; + + return out; +} + |