diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-12-17 18:05:15 -0800 |
commit | 1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353 (patch) | |
tree | 4457a7306ea5acb43fe05bfe0973b1f7faf97ba2 /WebCore/history | |
parent | 9364f22aed35e1a1e9d07c121510f80be3ab0502 (diff) | |
download | external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.zip external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.gz external_webkit-1cbdecfa9fc428ac2d8aca0fa91c9580b3d57353.tar.bz2 |
Code drop from //branches/cupcake/...@124589
Diffstat (limited to 'WebCore/history')
-rw-r--r-- | WebCore/history/BackForwardList.h | 6 | ||||
-rw-r--r-- | WebCore/history/CachedPage.cpp | 95 | ||||
-rw-r--r-- | WebCore/history/CachedPage.h | 13 | ||||
-rw-r--r-- | WebCore/history/HistoryItem.cpp | 56 | ||||
-rw-r--r-- | WebCore/history/HistoryItem.h | 52 |
5 files changed, 85 insertions, 137 deletions
diff --git a/WebCore/history/BackForwardList.h b/WebCore/history/BackForwardList.h index 61a0ada..048778b 100644 --- a/WebCore/history/BackForwardList.h +++ b/WebCore/history/BackForwardList.h @@ -27,7 +27,7 @@ #define BackForwardList_h #include <wtf/RefCounted.h> -#include <wtf/Forward.h> +#include <wtf/PassRefPtr.h> #include <wtf/HashSet.h> #include <wtf/Vector.h> @@ -41,7 +41,7 @@ typedef HashSet<RefPtr<HistoryItem> > HistoryItemHashSet; class BackForwardList : public RefCounted<BackForwardList> { public: - BackForwardList(Page*); + static PassRefPtr<BackForwardList> create(Page* page) { return adoptRef(new BackForwardList(page)); } ~BackForwardList(); Page* page() { return m_page; } @@ -74,6 +74,8 @@ public: HistoryItemVector& entries(); private: + BackForwardList(Page*); + Page* m_page; HistoryItemVector m_entries; HistoryItemHashSet m_entryHash; diff --git a/WebCore/history/CachedPage.cpp b/WebCore/history/CachedPage.cpp index 008f2d6..2381f52 100644 --- a/WebCore/history/CachedPage.cpp +++ b/WebCore/history/CachedPage.cpp @@ -37,43 +37,32 @@ #include "FrameLoader.h" #include "FrameView.h" #include "GCController.h" -#include "JSLocation.h" +#include "JSDOMWindow.h" +#include "JSDOMWindowShell.h" #include "Logging.h" #include "Page.h" +#include "PageGroup.h" #include "PausedTimeouts.h" #include "SystemTime.h" +#include "ScriptController.h" +#include <runtime/JSLock.h> +#include <wtf/RefCountedLeakCounter.h> + #if ENABLE(SVG) #include "SVGDocumentExtensions.h" #endif -#include "kjs_proxy.h" -#include "kjs_window.h" -#include <kjs/JSLock.h> -#include <kjs/SavedBuiltins.h> -#include <kjs/property_map.h> - -using namespace KJS; +using namespace JSC; namespace WebCore { #ifndef NDEBUG -WTFLogChannel LogWebCoreCachedPageLeaks = { 0x00000000, "", WTFLogChannelOn }; - -struct CachedPageCounter { - static int count; - ~CachedPageCounter() - { - if (count) - LOG(WebCoreCachedPageLeaks, "LEAK: %d CachedPage\n", count); - } -}; -int CachedPageCounter::count = 0; -static CachedPageCounter cachedPageCounter; +static WTF::RefCountedLeakCounter cachedPageCounter("CachedPage"); #endif PassRefPtr<CachedPage> CachedPage::create(Page* page) { - return new CachedPage(page); + return adoptRef(new CachedPage(page)); } CachedPage::CachedPage(Page* page) @@ -82,44 +71,31 @@ CachedPage::CachedPage(Page* page) , m_view(page->mainFrame()->view()) , m_mousePressNode(page->mainFrame()->eventHandler()->mousePressNode()) , m_URL(page->mainFrame()->loader()->url()) - , m_windowProperties(new SavedProperties) - , m_locationProperties(new SavedProperties) - , m_windowLocalStorage(new SavedProperties) - , m_windowBuiltins(new SavedBuiltins) { #ifndef NDEBUG - ++CachedPageCounter::count; + cachedPageCounter.increment(); #endif - m_document->willSaveToCache(); + m_document->documentWillBecomeInactive(); Frame* mainFrame = page->mainFrame(); - Window* window = Window::retrieveWindow(mainFrame); - mainFrame->clearTimers(); - JSLock lock; + JSLock lock(false); - if (window) { - window->saveBuiltins(*m_windowBuiltins.get()); - window->saveProperties(*m_windowProperties.get()); - window->saveLocalStorage(*m_windowLocalStorage.get()); - window->location()->saveProperties(*m_locationProperties.get()); - m_pausedTimeouts.set(window->pauseTimeouts()); + ScriptController* proxy = mainFrame->script(); + if (proxy->haveWindowShell()) { + m_window = proxy->windowShell()->window(); + m_window->pauseTimeouts(m_pausedTimeouts); } m_document->setInPageCache(true); - -#if ENABLE(SVG) - if (m_document && m_document->svgExtensions()) - m_document->accessSVGExtensions()->pauseAnimations(); -#endif } CachedPage::~CachedPage() { #ifndef NDEBUG - --CachedPageCounter::count; + cachedPageCounter.decrement(); #endif clear(); @@ -130,16 +106,20 @@ void CachedPage::restore(Page* page) ASSERT(m_document->view() == m_view); Frame* mainFrame = page->mainFrame(); - Window* window = Window::retrieveWindow(mainFrame); - - JSLock lock; - if (window) { - window->restoreBuiltins(*m_windowBuiltins.get()); - window->restoreProperties(*m_windowProperties.get()); - window->restoreLocalStorage(*m_windowLocalStorage.get()); - window->location()->restoreProperties(*m_locationProperties.get()); - window->resumeTimeouts(m_pausedTimeouts.get()); + JSLock lock(false); + + ScriptController* proxy = mainFrame->script(); + if (proxy->haveWindowShell()) { + JSDOMWindowShell* windowShell = proxy->windowShell(); + if (m_window) { + windowShell->setWindow(m_window.get()); + windowShell->window()->resumeTimeouts(m_pausedTimeouts); + } else { + windowShell->setWindow(mainFrame->domWindow()); + proxy->attachDebugger(page->debugger()); + windowShell->window()->setProfileGroup(page->group().identifier()); + } } #if ENABLE(SVG) @@ -147,7 +127,7 @@ void CachedPage::restore(Page* page) m_document->accessSVGExtensions()->unpauseAnimations(); #endif - mainFrame->animationController()->resumeAnimations(); + mainFrame->animation()->resumeAnimations(m_document.get()); mainFrame->eventHandler()->setMousePressNode(mousePressNode()); @@ -172,7 +152,7 @@ void CachedPage::clear() ASSERT(m_document->frame() == m_view->frame()); if (m_document->inPageCache()) { - Frame::clearTimers(m_view.get()); + Frame::clearTimers(m_view.get(), m_document.get()); m_document->setInPageCache(false); // FIXME: We don't call willRemove here. Why is that OK? @@ -189,14 +169,11 @@ void CachedPage::clear() m_mousePressNode = 0; m_URL = KURL(); - JSLock lock; - - m_windowProperties.clear(); - m_locationProperties.clear(); - m_windowBuiltins.clear(); + JSLock lock(false); m_pausedTimeouts.clear(); + m_window = 0; + m_cachedPagePlatformData.clear(); - m_windowLocalStorage.clear(); gcController().garbageCollectSoon(); } diff --git a/WebCore/history/CachedPage.h b/WebCore/history/CachedPage.h index 9157b0b..842cb03 100644 --- a/WebCore/history/CachedPage.h +++ b/WebCore/history/CachedPage.h @@ -28,11 +28,8 @@ #include "KURL.h" #include <wtf/OwnPtr.h> - -namespace KJS { - class SavedBuiltins; - struct SavedProperties; -} +#include "PausedTimeouts.h" +#include <kjs/protect.h> namespace WebCore { @@ -40,6 +37,7 @@ namespace WebCore { class Document; class DocumentLoader; class FrameView; + class JSDOMWindow; class Node; class Page; class PausedTimeouts; @@ -74,10 +72,7 @@ private: RefPtr<FrameView> m_view; RefPtr<Node> m_mousePressNode; KURL m_URL; - OwnPtr<KJS::SavedProperties> m_windowProperties; - OwnPtr<KJS::SavedProperties> m_locationProperties; - OwnPtr<KJS::SavedProperties> m_windowLocalStorage; - OwnPtr<KJS::SavedBuiltins> m_windowBuiltins; + JSC::ProtectedPtr<JSDOMWindow> m_window; OwnPtr<PausedTimeouts> m_pausedTimeouts; OwnPtr<CachedPagePlatformData> m_cachedPagePlatformData; }; diff --git a/WebCore/history/HistoryItem.cpp b/WebCore/history/HistoryItem.cpp index ffc5744..d7cc311 100644 --- a/WebCore/history/HistoryItem.cpp +++ b/WebCore/history/HistoryItem.cpp @@ -34,13 +34,17 @@ #include "Logging.h" #include "PageCache.h" #include "ResourceRequest.h" +#include <stdio.h> namespace WebCore { #ifdef ANDROID_HISTORY_CLIENT void (*notifyHistoryItemChanged)(HistoryItem*); #else -static void defaultNotifyHistoryItemChanged() {} +static void defaultNotifyHistoryItemChanged() +{ +} + void (*notifyHistoryItemChanged)() = defaultNotifyHistoryItemChanged; #endif @@ -77,18 +81,6 @@ HistoryItem::HistoryItem(const String& urlString, const String& title, const Str iconDatabase()->retainIconForPageURL(m_urlString); } -HistoryItem::HistoryItem(const KURL& url, const String& title) - : m_urlString(url.string()) - , m_originalURLString(url.string()) - , m_title(title) - , m_lastVisitedTime(0) - , m_isInPageCache(false) - , m_isTargetItem(false) - , m_visitCount(0) -{ - iconDatabase()->retainIconForPageURL(m_urlString); -} - HistoryItem::HistoryItem(const KURL& url, const String& target, const String& parent, const String& title) : m_urlString(url.string()) , m_originalURLString(url.string()) @@ -109,7 +101,7 @@ HistoryItem::~HistoryItem() iconDatabase()->releaseIconForPageURL(m_urlString); } -HistoryItem::HistoryItem(const HistoryItem& item) +inline HistoryItem::HistoryItem(const HistoryItem& item) : RefCounted<HistoryItem>() , m_urlString(item.m_urlString) , m_originalURLString(item.m_originalURLString) @@ -124,18 +116,10 @@ HistoryItem::HistoryItem(const HistoryItem& item) , m_visitCount(item.m_visitCount) , m_formContentType(item.m_formContentType) , m_formReferrer(item.m_formReferrer) -#ifdef ANDROID_FIX - , m_originalFormContentType(item.m_originalFormContentType) - , m_originalFormReferrer(item.m_originalFormReferrer) -#endif , m_rssFeedReferrer(item.m_rssFeedReferrer) { if (item.m_formData) m_formData = item.m_formData->copy(); -#ifdef ANDROID_FIX - if (item.m_originalFormData) - m_originalFormData = item.m_originalFormData->copy(); -#endif unsigned size = item.m_subItems.size(); m_subItems.reserveCapacity(size); @@ -145,7 +129,7 @@ HistoryItem::HistoryItem(const HistoryItem& item) PassRefPtr<HistoryItem> HistoryItem::copy() const { - return new HistoryItem(*this); + return adoptRef(new HistoryItem(*this)); } const String& HistoryItem::urlString() const @@ -183,12 +167,12 @@ double HistoryItem::lastVisitedTime() const KURL HistoryItem::url() const { - return KURL(m_urlString.deprecatedString()); + return KURL(m_urlString); } KURL HistoryItem::originalURL() const { - return KURL(m_originalURLString.deprecatedString()); + return KURL(m_originalURLString); } const String& HistoryItem::target() const @@ -435,28 +419,6 @@ const FormData* HistoryItem::formData() const { return m_formData.get(); } - -FormData* HistoryItem::originalFormData() const -{ - return m_originalFormData.get(); -} - -String HistoryItem::originalFormContentType() const -{ - return m_originalFormContentType; -} - -String HistoryItem::originalFormReferrer() const -{ - return m_originalFormReferrer; -} - -void HistoryItem::setOriginalFormInfo(PassRefPtr<FormData> formdata, const String& contentType, const String& referrer) -{ - m_originalFormData = formdata; - m_originalFormContentType = contentType; - m_originalFormReferrer = referrer; -} #endif bool HistoryItem::isCurrentDocument(Document* doc) const diff --git a/WebCore/history/HistoryItem.h b/WebCore/history/HistoryItem.h index 5920635..cc131dd 100644 --- a/WebCore/history/HistoryItem.h +++ b/WebCore/history/HistoryItem.h @@ -29,7 +29,6 @@ #include "CachedPage.h" #include "FormData.h" #include "IntPoint.h" -#include "KURL.h" #include "PlatformString.h" #include <wtf/RefCounted.h> #include "StringHash.h" @@ -38,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; @@ -67,11 +70,19 @@ class HistoryItem : public RefCounted<HistoryItem> { friend class PageCache; public: - 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& title); - HistoryItem(const KURL& url, const String& target, const String& parent, const String& title); + static PassRefPtr<HistoryItem> create() { return adoptRef(new HistoryItem); } + static PassRefPtr<HistoryItem> create(const String& urlString, const String& title, double lastVisited) + { + return adoptRef(new HistoryItem(urlString, title, lastVisited)); + } + static PassRefPtr<HistoryItem> create(const String& urlString, const String& title, const String& alternateTitle, double lastVisited) + { + return adoptRef(new HistoryItem(urlString, title, alternateTitle, lastVisited)); + } + static PassRefPtr<HistoryItem> create(const KURL& url, const String& target, const String& parent, const String& title) + { + return adoptRef(new HistoryItem(url, target, parent, title)); + } ~HistoryItem(); @@ -100,12 +111,6 @@ public: FormData* formData(); #ifdef ANDROID_FIX const FormData* formData() const; - - FormData* originalFormData() const; - String originalFormContentType() const; - String originalFormReferrer() const; - - void setOriginalFormInfo(PassRefPtr<FormData>, const String&, const String&); #endif String formContentType() const; String formReferrer() const; @@ -158,17 +163,27 @@ 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; #endif #ifdef ANDROID_HISTORY_CLIENT - void setBridge(android::WebHistoryItem* bridge) { m_bridge = bridge; } + void setBridge(android::WebHistoryItem* bridge) { m_bridge = adoptRef(bridge); } android::WebHistoryItem* bridge() const { return m_bridge.get(); } #endif 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 HistoryItem&); String m_urlString; @@ -194,13 +209,6 @@ private: String m_formContentType; String m_formReferrer; -#ifdef ANDROID_FIX - // info used to repost form data for the original request - RefPtr<FormData> m_originalFormData; - String m_originalFormContentType; - String m_originalFormReferrer; -#endif - // info used to support RSS feeds String m_rssFeedReferrer; @@ -217,6 +225,10 @@ private: #ifdef ANDROID_HISTORY_CLIENT RefPtr<android::WebHistoryItem> m_bridge; #endif + +#if PLATFORM(QT) + QVariant m_userData; +#endif }; //class HistoryItem } //namespace WebCore |