summaryrefslogtreecommitdiffstats
path: root/WebCore/history
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/history')
-rw-r--r--WebCore/history/BackForwardListChromium.cpp4
-rw-r--r--WebCore/history/CachedFrame.cpp35
-rw-r--r--WebCore/history/CachedFrame.h23
-rw-r--r--WebCore/history/CachedPage.cpp9
-rw-r--r--WebCore/history/CachedPage.h16
-rw-r--r--WebCore/history/HistoryItem.cpp11
-rw-r--r--WebCore/history/HistoryItem.h7
7 files changed, 67 insertions, 38 deletions
diff --git a/WebCore/history/BackForwardListChromium.cpp b/WebCore/history/BackForwardListChromium.cpp
index 011f987..34f294c 100644
--- a/WebCore/history/BackForwardListChromium.cpp
+++ b/WebCore/history/BackForwardListChromium.cpp
@@ -38,6 +38,7 @@ static const unsigned NoCurrentItemIndex = UINT_MAX;
BackForwardList::BackForwardList(Page* page)
: m_page(page)
+ , m_client(0)
, m_capacity(DefaultCapacity)
, m_closed(true)
, m_enabled(true)
@@ -128,7 +129,8 @@ HistoryItemVector& BackForwardList::entries()
void BackForwardList::close()
{
- m_client->close();
+ if (m_client)
+ m_client->close();
m_page = 0;
m_closed = true;
}
diff --git a/WebCore/history/CachedFrame.cpp b/WebCore/history/CachedFrame.cpp
index ed7e9eb..db18903 100644
--- a/WebCore/history/CachedFrame.cpp
+++ b/WebCore/history/CachedFrame.cpp
@@ -27,9 +27,12 @@
#include "CachedPage.h"
#include "CachedFramePlatformData.h"
+#include "CString.h"
#include "DocumentLoader.h"
#include "Frame.h"
+#include "FrameLoaderClient.h"
#include "FrameView.h"
+#include "Logging.h"
#include <wtf/RefCountedLeakCounter.h>
#if ENABLE(SVG)
@@ -51,15 +54,29 @@ CachedFrame::CachedFrame(Frame* frame)
, m_documentLoader(frame->loader()->documentLoader())
, m_view(frame->view())
, m_mousePressNode(frame->eventHandler()->mousePressNode())
- , m_URL(frame->loader()->url())
- , m_cachedFrameScriptData(frame)
+ , m_url(frame->loader()->url())
{
#ifndef NDEBUG
cachedFrameCounter().increment();
#endif
+ ASSERT(m_document);
+ ASSERT(m_documentLoader);
+ ASSERT(m_view);
+
+ // Active DOM objects must be suspended before we cached the frame script data
+ m_document->suspendActiveDOMObjects();
+ m_cachedFrameScriptData.set(new ScriptCachedFrameData(frame));
+
m_document->documentWillBecomeInactive();
frame->clearTimers();
m_document->setInPageCache(true);
+
+ frame->loader()->client()->savePlatformDataToCachedFrame(this);
+
+ for (Frame* child = frame->tree()->firstChild(); child; child = child->tree()->nextSibling())
+ m_childFrames.append(CachedFrame::create(child));
+
+ LOG(PageCache, "Finished creating CachedFrame with url %s and documentloader %p\n", m_url.string().utf8().data(), m_documentLoader.get());
}
CachedFrame::~CachedFrame()
@@ -71,19 +88,25 @@ CachedFrame::~CachedFrame()
clear();
}
-void CachedFrame::restore(Frame* frame)
+void CachedFrame::restore()
{
ASSERT(m_document->view() == m_view);
- m_cachedFrameScriptData.restore(frame);
+ Frame* frame = m_view->frame();
+ m_cachedFrameScriptData->restore(frame);
#if ENABLE(SVG)
- if (m_document && m_document->svgExtensions())
+ if (m_document->svgExtensions())
m_document->accessSVGExtensions()->unpauseAnimations();
#endif
frame->animation()->resumeAnimations(m_document.get());
frame->eventHandler()->setMousePressNode(mousePressNode());
+ m_document->resumeActiveDOMObjects();
+
+ // It is necessary to update any platform script objects after restoring the
+ // cached page.
+ frame->script()->updatePlatformScriptObjects();
}
void CachedFrame::clear()
@@ -113,7 +136,7 @@ void CachedFrame::clear()
m_document = 0;
m_view = 0;
m_mousePressNode = 0;
- m_URL = KURL();
+ m_url = KURL();
m_cachedFramePlatformData.clear();
diff --git a/WebCore/history/CachedFrame.h b/WebCore/history/CachedFrame.h
index c7beb15..83c3c3c 100644
--- a/WebCore/history/CachedFrame.h
+++ b/WebCore/history/CachedFrame.h
@@ -28,10 +28,11 @@
#include "KURL.h"
#include "ScriptCachedFrameData.h"
-#include <wtf/Noncopyable.h>
+#include <wtf/RefPtr.h>
namespace WebCore {
+ class CachedFrame;
class CachedFramePlatformData;
class DOMWindow;
class Document;
@@ -40,32 +41,38 @@ namespace WebCore {
class FrameView;
class Node;
-class CachedFrame : public Noncopyable {
+typedef Vector<RefPtr<CachedFrame> > CachedFrameVector;
+
+class CachedFrame : public RefCounted<CachedFrame> {
public:
- CachedFrame(Frame*);
+ static PassRefPtr<CachedFrame> create(Frame* frame) { return adoptRef(new CachedFrame(frame)); }
~CachedFrame();
- void restore(Frame*);
+ void restore();
void clear();
Document* document() const { return m_document.get(); }
DocumentLoader* documentLoader() const { return m_documentLoader.get(); }
FrameView* view() const { return m_view.get(); }
Node* mousePressNode() const { return m_mousePressNode.get(); }
- const KURL& url() const { return m_URL; }
- DOMWindow* domWindow() const { return m_cachedFrameScriptData.domWindow(); }
+ const KURL& url() const { return m_url; }
+ DOMWindow* domWindow() const { return m_cachedFrameScriptData->domWindow(); }
void setCachedFramePlatformData(CachedFramePlatformData*);
CachedFramePlatformData* cachedFramePlatformData();
private:
+ CachedFrame(Frame*);
+
RefPtr<Document> m_document;
RefPtr<DocumentLoader> m_documentLoader;
RefPtr<FrameView> m_view;
RefPtr<Node> m_mousePressNode;
- KURL m_URL;
- ScriptCachedFrameData m_cachedFrameScriptData;
+ KURL m_url;
+ OwnPtr<ScriptCachedFrameData> m_cachedFrameScriptData;
OwnPtr<CachedFramePlatformData> m_cachedFramePlatformData;
+
+ CachedFrameVector m_childFrames;
};
} // namespace WebCore
diff --git a/WebCore/history/CachedPage.cpp b/WebCore/history/CachedPage.cpp
index 7167275..d6b66db 100644
--- a/WebCore/history/CachedPage.cpp
+++ b/WebCore/history/CachedPage.cpp
@@ -29,6 +29,9 @@
#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>
@@ -48,7 +51,7 @@ PassRefPtr<CachedPage> CachedPage::create(Page* page)
CachedPage::CachedPage(Page* page)
: m_timeStamp(currentTime())
- , m_cachedMainFrame(page->mainFrame())
+ , m_cachedMainFrame(CachedFrame::create(page->mainFrame()))
{
#ifndef NDEBUG
cachedPageCounter.increment();
@@ -66,8 +69,8 @@ CachedPage::~CachedPage()
void CachedPage::restore(Page* page)
{
- ASSERT(page && page->mainFrame());
- m_cachedMainFrame.restore(page->mainFrame());
+ ASSERT(page && page->mainFrame() && page->mainFrame() == m_cachedMainFrame->view()->frame());
+ m_cachedMainFrame->restore();
// Restore the focus appearance for the focused element.
// FIXME: Right now we don't support pages w/ frames in the b/f cache. This may need to be tweaked when we add support for that.
diff --git a/WebCore/history/CachedPage.h b/WebCore/history/CachedPage.h
index a9cf71c..430cf3a 100644
--- a/WebCore/history/CachedPage.h
+++ b/WebCore/history/CachedPage.h
@@ -30,7 +30,6 @@
namespace WebCore {
- class CachedFrame;
class CachedFramePlatformData;
class DOMWindow;
class Document;
@@ -48,22 +47,21 @@ public:
void restore(Page*);
void clear();
- Document* document() const { return m_cachedMainFrame.document(); }
- DocumentLoader* documentLoader() const { return m_cachedMainFrame.documentLoader(); }
- FrameView* view() const { return m_cachedMainFrame.view(); }
- Node* mousePressNode() const { return m_cachedMainFrame.mousePressNode(); }
- const KURL& url() const { return m_cachedMainFrame.url(); }
- DOMWindow* domWindow() const { return m_cachedMainFrame.domWindow(); }
+ Document* document() const { return m_cachedMainFrame->document(); }
+ DocumentLoader* documentLoader() const { return m_cachedMainFrame->documentLoader(); }
+ FrameView* mainFrameView() const { return m_cachedMainFrame->view(); }
+ const KURL& url() const { return m_cachedMainFrame->url(); }
+ DOMWindow* domWindow() const { return m_cachedMainFrame->domWindow(); }
double timeStamp() const { return m_timeStamp; }
- CachedFrame* cachedMainFrame() { return &m_cachedMainFrame; }
+ CachedFrame* cachedMainFrame() { return m_cachedMainFrame.get(); }
private:
CachedPage(Page*);
double m_timeStamp;
- CachedFrame m_cachedMainFrame;
+ RefPtr<CachedFrame> m_cachedMainFrame;
};
} // namespace WebCore
diff --git a/WebCore/history/HistoryItem.cpp b/WebCore/history/HistoryItem.cpp
index 5a059b2..1d05042f 100644
--- a/WebCore/history/HistoryItem.cpp
+++ b/WebCore/history/HistoryItem.cpp
@@ -50,7 +50,6 @@ HistoryItem::HistoryItem()
: m_lastVisitedTime(0)
, m_lastVisitWasHTTPNonGet(false)
, m_lastVisitWasFailure(false)
- , m_isInPageCache(false)
, m_isTargetItem(false)
, m_visitCount(0)
{
@@ -63,7 +62,6 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, double ti
, m_lastVisitedTime(time)
, m_lastVisitWasHTTPNonGet(false)
, m_lastVisitWasFailure(false)
- , m_isInPageCache(false)
, m_isTargetItem(false)
, m_visitCount(0)
{
@@ -78,7 +76,6 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, const Str
, m_lastVisitedTime(time)
, m_lastVisitWasHTTPNonGet(false)
, m_lastVisitWasFailure(false)
- , m_isInPageCache(false)
, m_isTargetItem(false)
, m_visitCount(0)
{
@@ -94,7 +91,6 @@ HistoryItem::HistoryItem(const KURL& url, const String& target, const String& pa
, m_lastVisitedTime(0)
, m_lastVisitWasHTTPNonGet(false)
, m_lastVisitWasFailure(false)
- , m_isInPageCache(false)
, m_isTargetItem(false)
, m_visitCount(0)
{
@@ -103,7 +99,7 @@ HistoryItem::HistoryItem(const KURL& url, const String& target, const String& pa
HistoryItem::~HistoryItem()
{
- ASSERT(!m_isInPageCache);
+ ASSERT(!m_cachedPage);
iconDatabase()->releaseIconForPageURL(m_urlString);
}
@@ -120,18 +116,19 @@ inline HistoryItem::HistoryItem(const HistoryItem& item)
, m_lastVisitWasHTTPNonGet(item.m_lastVisitWasHTTPNonGet)
, m_scrollPoint(item.m_scrollPoint)
, m_lastVisitWasFailure(item.m_lastVisitWasFailure)
- , m_isInPageCache(item.m_isInPageCache)
, m_isTargetItem(item.m_isTargetItem)
, m_visitCount(item.m_visitCount)
, m_dailyVisitCounts(item.m_dailyVisitCounts)
, m_weeklyVisitCounts(item.m_weeklyVisitCounts)
, m_formContentType(item.m_formContentType)
{
+ ASSERT(!item.m_cachedPage);
+
if (item.m_formData)
m_formData = item.m_formData->copy();
unsigned size = item.m_subItems.size();
- m_subItems.reserveCapacity(size);
+ m_subItems.reserveInitialCapacity(size);
for (unsigned i = 0; i < size; ++i)
m_subItems.append(item.m_subItems[i]->copy());
diff --git a/WebCore/history/HistoryItem.h b/WebCore/history/HistoryItem.h
index cd23c9e..d35352e 100644
--- a/WebCore/history/HistoryItem.h
+++ b/WebCore/history/HistoryItem.h
@@ -28,6 +28,7 @@
#include "IntPoint.h"
#include "PlatformString.h"
+#include <wtf/OwnPtr.h>
#if PLATFORM(MAC)
#import <wtf/RetainPtr.h>
@@ -50,7 +51,7 @@ class FormData;
class HistoryItem;
class Image;
class KURL;
-class ResourceRequest;
+struct ResourceRequest;
typedef Vector<RefPtr<HistoryItem> > HistoryItemVector;
@@ -86,8 +87,7 @@ public:
const String& urlString() const;
const String& title() const;
- void setInPageCache(bool inPageCache) { m_isInPageCache = inPageCache; }
- bool isInPageCache() const { return m_isInPageCache; }
+ bool isInPageCache() const { return m_cachedPage; }
double lastVisitedTime() const;
@@ -212,7 +212,6 @@ private:
HistoryItemVector m_subItems;
bool m_lastVisitWasFailure;
- bool m_isInPageCache;
bool m_isTargetItem;
int m_visitCount;
Vector<int> m_dailyVisitCounts;