summaryrefslogtreecommitdiffstats
path: root/WebCore/history
diff options
context:
space:
mode:
authorFeng Qian <fqian@google.com>2009-06-17 12:12:20 -0700
committerFeng Qian <fqian@google.com>2009-06-17 12:12:20 -0700
commit5f1ab04193ad0130ca8204aadaceae083aca9881 (patch)
tree5a92cd389e2cfe7fb67197ce14b38469462379f8 /WebCore/history
parent194315e5a908cc8ed67d597010544803eef1ac59 (diff)
downloadexternal_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.zip
external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.gz
external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.bz2
Get WebKit r44544.
Diffstat (limited to 'WebCore/history')
-rw-r--r--WebCore/history/CachedFrame.cpp6
-rw-r--r--WebCore/history/CachedPage.cpp3
-rw-r--r--WebCore/history/HistoryItem.cpp65
-rw-r--r--WebCore/history/HistoryItem.h13
-rw-r--r--WebCore/history/cf/HistoryPropertyList.cpp156
-rw-r--r--WebCore/history/cf/HistoryPropertyList.h69
6 files changed, 274 insertions, 38 deletions
diff --git a/WebCore/history/CachedFrame.cpp b/WebCore/history/CachedFrame.cpp
index db18903..9a43b9d 100644
--- a/WebCore/history/CachedFrame.cpp
+++ b/WebCore/history/CachedFrame.cpp
@@ -123,11 +123,13 @@ void CachedFrame::clear()
if (m_document->inPageCache()) {
Frame::clearTimers(m_view.get(), m_document.get());
+ // FIXME: Why do we need to call removeAllEventListeners here? When the document is in page cache, this method won't work
+ // fully anyway, because the document won't be able to access its DOMWindow object (due to being frameless).
+ m_document->removeAllEventListeners();
+
m_document->setInPageCache(false);
// FIXME: We don't call willRemove here. Why is that OK?
m_document->detach();
- m_document->removeAllEventListenersFromAllNodes();
-
m_view->clearFrame();
}
diff --git a/WebCore/history/CachedPage.cpp b/WebCore/history/CachedPage.cpp
index d6b66db..8898ce2 100644
--- a/WebCore/history/CachedPage.cpp
+++ b/WebCore/history/CachedPage.cpp
@@ -26,12 +26,9 @@
#include "config.h"
#include "CachedPage.h"
-#include "CachedFrame.h"
#include "FocusController.h"
#include "Frame.h"
-#ifndef NDEBUG
#include "FrameView.h"
-#endif
#include "Page.h"
#include <wtf/CurrentTime.h>
#include <wtf/RefCountedLeakCounter.h>
diff --git a/WebCore/history/HistoryItem.cpp b/WebCore/history/HistoryItem.cpp
index 1d05042f..7826eb8 100644
--- a/WebCore/history/HistoryItem.cpp
+++ b/WebCore/history/HistoryItem.cpp
@@ -127,10 +127,10 @@ inline HistoryItem::HistoryItem(const HistoryItem& item)
if (item.m_formData)
m_formData = item.m_formData->copy();
- unsigned size = item.m_subItems.size();
- m_subItems.reserveInitialCapacity(size);
+ unsigned size = item.m_children.size();
+ m_children.reserveInitialCapacity(size);
for (unsigned i = 0; i < size; ++i)
- m_subItems.append(item.m_subItems[i]->copy());
+ m_children.uncheckedAppend(item.m_children[i]->copy());
if (item.m_redirectURLs)
m_redirectURLs.set(new Vector<String>(*item.m_redirectURLs));
@@ -413,55 +413,64 @@ void HistoryItem::setIsTargetItem(bool flag)
void HistoryItem::addChildItem(PassRefPtr<HistoryItem> child)
{
- m_subItems.append(child);
+ ASSERT(!childItemWithTarget(child->target()));
+ m_children.append(child);
#ifdef ANDROID_HISTORY_CLIENT
notifyHistoryItemChanged(this);
#endif
}
-HistoryItem* HistoryItem::childItemWithName(const String& name) const
+void HistoryItem::setChildItem(PassRefPtr<HistoryItem> child)
{
- unsigned size = m_subItems.size();
- for (unsigned i = 0; i < size; ++i)
- if (m_subItems[i]->target() == name)
- return m_subItems[i].get();
+ ASSERT(!child->isTargetItem());
+ unsigned size = m_children.size();
+ for (unsigned i = 0; i < size; ++i) {
+ if (m_children[i]->target() == child->target()) {
+ child->setIsTargetItem(m_children[i]->isTargetItem());
+ m_children[i] = child;
+ return;
+ }
+ }
+ m_children.append(child);
+}
+
+HistoryItem* HistoryItem::childItemWithTarget(const String& target) const
+{
+ unsigned size = m_children.size();
+ for (unsigned i = 0; i < size; ++i) {
+ if (m_children[i]->target() == target)
+ return m_children[i].get();
+ }
return 0;
}
-// <rdar://problem/4895849> HistoryItem::recurseToFindTargetItem() should be replace with a non-recursive method
-HistoryItem* HistoryItem::recurseToFindTargetItem()
+// <rdar://problem/4895849> HistoryItem::findTargetItem() should be replaced with a non-recursive method.
+HistoryItem* HistoryItem::findTargetItem()
{
if (m_isTargetItem)
return this;
- if (!m_subItems.size())
- return 0;
-
- HistoryItem* match;
- unsigned size = m_subItems.size();
+ unsigned size = m_children.size();
for (unsigned i = 0; i < size; ++i) {
- match = m_subItems[i]->recurseToFindTargetItem();
- if (match)
+ if (HistoryItem* match = m_children[i]->targetItem())
return match;
}
-
return 0;
}
HistoryItem* HistoryItem::targetItem()
{
- if (!m_subItems.size())
- return this;
- return recurseToFindTargetItem();
+ HistoryItem* foundItem = findTargetItem();
+ return foundItem ? foundItem : this;
}
const HistoryItemVector& HistoryItem::children() const
{
- return m_subItems;
+ return m_children;
}
bool HistoryItem::hasChildren() const
{
- return m_subItems.size();
+ return !m_children.isEmpty();
}
String HistoryItem::formContentType() const
@@ -524,9 +533,9 @@ Vector<String>* HistoryItem::redirectURLs() const
return m_redirectURLs.get();
}
-void HistoryItem::setRedirectURLs(std::auto_ptr<Vector<String> > redirectURLs)
+void HistoryItem::setRedirectURLs(PassOwnPtr<Vector<String> > redirectURLs)
{
- m_redirectURLs.adopt(redirectURLs);
+ m_redirectURLs = redirectURLs;
}
#ifndef NDEBUG
@@ -546,8 +555,8 @@ int HistoryItem::showTreeWithIndent(unsigned indentLevel) const
fprintf(stderr, "%s+-%s (%p)\n", prefix.data(), m_urlString.utf8().data(), this);
int totalSubItems = 0;
- for (unsigned i = 0; i < m_subItems.size(); ++i)
- totalSubItems += m_subItems[i]->showTreeWithIndent(indentLevel + 1);
+ for (unsigned i = 0; i < m_children.size(); ++i)
+ totalSubItems += m_children[i]->showTreeWithIndent(indentLevel + 1);
return totalSubItems + 1;
}
diff --git a/WebCore/history/HistoryItem.h b/WebCore/history/HistoryItem.h
index d35352e..2d8528c 100644
--- a/WebCore/history/HistoryItem.h
+++ b/WebCore/history/HistoryItem.h
@@ -29,6 +29,7 @@
#include "IntPoint.h"
#include "PlatformString.h"
#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
#if PLATFORM(MAC)
#import <wtf/RetainPtr.h>
@@ -137,9 +138,9 @@ public:
void setLastVisitWasHTTPNonGet(bool wasNotGet) { m_lastVisitWasHTTPNonGet = wasNotGet; }
void addChildItem(PassRefPtr<HistoryItem>);
- HistoryItem* childItemWithName(const String&) const;
+ void setChildItem(PassRefPtr<HistoryItem>);
+ HistoryItem* childItemWithTarget(const String&) const;
HistoryItem* targetItem();
- HistoryItem* recurseToFindTargetItem();
const HistoryItemVector& children() const;
bool hasChildren() const;
@@ -150,7 +151,7 @@ public:
void addRedirectURL(const String&);
Vector<String>* redirectURLs() const;
- void setRedirectURLs(std::auto_ptr<Vector<String> >);
+ void setRedirectURLs(PassOwnPtr<Vector<String> >);
bool isCurrentDocument(Document*) const;
@@ -187,7 +188,7 @@ private:
HistoryItem();
HistoryItem(const String& urlString, const String& title, double lastVisited);
HistoryItem(const String& urlString, const String& title, const String& alternateTitle, double lastVisited);
- HistoryItem(const KURL& url, const String& target, const String& parent, const String& title);
+ HistoryItem(const KURL& url, const String& frameName, const String& parent, const String& title);
HistoryItem(const HistoryItem&);
@@ -195,6 +196,8 @@ private:
void collapseDailyVisitsToWeekly();
void recordVisitAtTime(double);
+ HistoryItem* findTargetItem();
+
String m_urlString;
String m_originalURLString;
String m_referrer;
@@ -209,7 +212,7 @@ private:
IntPoint m_scrollPoint;
Vector<String> m_documentState;
- HistoryItemVector m_subItems;
+ HistoryItemVector m_children;
bool m_lastVisitWasFailure;
bool m_isTargetItem;
diff --git a/WebCore/history/cf/HistoryPropertyList.cpp b/WebCore/history/cf/HistoryPropertyList.cpp
new file mode 100644
index 0000000..fd28237
--- /dev/null
+++ b/WebCore/history/cf/HistoryPropertyList.cpp
@@ -0,0 +1,156 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "HistoryPropertyList.h"
+
+#include "HistoryItem.h"
+#include <wtf/StringExtras.h>
+
+namespace WebCore {
+
+static const int currentFileVersion = 1;
+
+HistoryPropertyListWriter::HistoryPropertyListWriter()
+ : m_dailyVisitCountsKey("D")
+ , m_displayTitleKey("displayTitle")
+ , m_lastVisitWasFailureKey("lastVisitWasFailure")
+ , m_lastVisitWasHTTPNonGetKey("lastVisitWasHTTPNonGet")
+ , m_lastVisitedDateKey("lastVisitedDate")
+ , m_redirectURLsKey("redirectURLs")
+ , m_titleKey("title")
+ , m_urlKey("")
+ , m_visitCountKey("visitCount")
+ , m_weeklyVisitCountsKey("W")
+ , m_buffer(0)
+{
+}
+
+UInt8* HistoryPropertyListWriter::buffer(size_t size)
+{
+ ASSERT(!m_buffer);
+ m_buffer = static_cast<UInt8*>(CFAllocatorAllocate(0, size, 0));
+ m_bufferSize = size;
+ return m_buffer;
+}
+
+RetainPtr<CFDataRef> HistoryPropertyListWriter::releaseData()
+{
+ UInt8* buffer = m_buffer;
+ if (!buffer)
+ return 0;
+ m_buffer = 0;
+ RetainPtr<CFDataRef> data(AdoptCF, CFDataCreateWithBytesNoCopy(0, buffer, m_bufferSize, 0));
+ if (!data) {
+ CFAllocatorDeallocate(0, buffer);
+ return 0;
+ }
+ return data;
+}
+
+void HistoryPropertyListWriter::writeObjects(BinaryPropertyListObjectStream& stream)
+{
+ size_t outerDictionaryStart = stream.writeDictionaryStart();
+
+ stream.writeString("WebHistoryFileVersion");
+ stream.writeString("WebHistoryDates");
+
+ stream.writeInteger(currentFileVersion);
+ size_t outerDateArrayStart = stream.writeArrayStart();
+ writeHistoryItems(stream);
+ stream.writeArrayEnd(outerDateArrayStart);
+
+ stream.writeDictionaryEnd(outerDictionaryStart);
+}
+
+void HistoryPropertyListWriter::writeHistoryItem(BinaryPropertyListObjectStream& stream, HistoryItem* item)
+{
+ size_t itemDictionaryStart = stream.writeDictionaryStart();
+
+ const String& title = item->title();
+ const String& displayTitle = item->alternateTitle();
+ double lastVisitedDate = item->lastVisitedTime();
+ int visitCount = item->visitCount();
+ Vector<String>* redirectURLs = item->redirectURLs();
+ const Vector<int>& dailyVisitCounts = item->dailyVisitCounts();
+ const Vector<int>& weeklyVisitCounts = item->weeklyVisitCounts();
+
+ // keys
+ stream.writeString(m_urlKey);
+ if (!title.isEmpty())
+ stream.writeString(m_titleKey);
+ if (!displayTitle.isEmpty())
+ stream.writeString(m_displayTitleKey);
+ if (lastVisitedDate)
+ stream.writeString(m_lastVisitedDateKey);
+ if (visitCount)
+ stream.writeString(m_visitCountKey);
+ if (item->lastVisitWasFailure())
+ stream.writeString(m_lastVisitWasFailureKey);
+ if (item->lastVisitWasHTTPNonGet())
+ stream.writeString(m_lastVisitWasHTTPNonGetKey);
+ if (redirectURLs)
+ stream.writeString(m_redirectURLsKey);
+ if (!dailyVisitCounts.isEmpty())
+ stream.writeString(m_dailyVisitCountsKey);
+ if (!weeklyVisitCounts.isEmpty())
+ stream.writeString(m_weeklyVisitCountsKey);
+
+ // values
+ stream.writeUniqueString(item->urlString());
+ if (!title.isEmpty())
+ stream.writeString(title);
+ if (!displayTitle.isEmpty())
+ stream.writeString(displayTitle);
+ if (lastVisitedDate) {
+ char buffer[32];
+ snprintf(buffer, sizeof(buffer), "%.1lf", lastVisitedDate);
+ stream.writeUniqueString(buffer);
+ }
+ if (visitCount)
+ stream.writeInteger(visitCount);
+ if (item->lastVisitWasFailure())
+ stream.writeBooleanTrue();
+ if (item->lastVisitWasHTTPNonGet()) {
+ ASSERT(item->urlString().startsWith("http:", false) || item->urlString().startsWith("https:", false));
+ stream.writeBooleanTrue();
+ }
+ if (redirectURLs) {
+ size_t redirectArrayStart = stream.writeArrayStart();
+ size_t size = redirectURLs->size();
+ ASSERT(size);
+ for (size_t i = 0; i < size; ++i)
+ stream.writeUniqueString(redirectURLs->at(i));
+ stream.writeArrayEnd(redirectArrayStart);
+ }
+ if (size_t size = dailyVisitCounts.size())
+ stream.writeIntegerArray(dailyVisitCounts.data(), size);
+ if (size_t size = weeklyVisitCounts.size())
+ stream.writeIntegerArray(weeklyVisitCounts.data(), size);
+
+ stream.writeDictionaryEnd(itemDictionaryStart);
+}
+
+}
diff --git a/WebCore/history/cf/HistoryPropertyList.h b/WebCore/history/cf/HistoryPropertyList.h
new file mode 100644
index 0000000..fcb8c47
--- /dev/null
+++ b/WebCore/history/cf/HistoryPropertyList.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HistoryPropertyList_h
+#define HistoryPropertyList_h
+
+#include "BinaryPropertyList.h"
+#include "PlatformString.h"
+#include <wtf/RetainPtr.h>
+
+namespace WebCore {
+
+class HistoryItem;
+
+class HistoryPropertyListWriter : public BinaryPropertyListWriter {
+public:
+ RetainPtr<CFDataRef> releaseData();
+
+protected:
+ HistoryPropertyListWriter();
+
+ void writeHistoryItem(BinaryPropertyListObjectStream&, HistoryItem*);
+
+private:
+ virtual void writeHistoryItems(BinaryPropertyListObjectStream&) = 0;
+
+ virtual void writeObjects(BinaryPropertyListObjectStream&);
+ virtual UInt8* buffer(size_t);
+
+ const String m_dailyVisitCountsKey;
+ const String m_displayTitleKey;
+ const String m_lastVisitWasFailureKey;
+ const String m_lastVisitWasHTTPNonGetKey;
+ const String m_lastVisitedDateKey;
+ const String m_redirectURLsKey;
+ const String m_titleKey;
+ const String m_urlKey;
+ const String m_visitCountKey;
+ const String m_weeklyVisitCountsKey;
+
+ UInt8* m_buffer;
+ size_t m_bufferSize;
+};
+
+}
+
+#endif