diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2010-11-10 15:31:59 -0800 |
---|---|---|
committer | Teng-Hui Zhu <ztenghui@google.com> | 2010-11-17 13:35:59 -0800 |
commit | 28040489d744e0c5d475a88663056c9040ed5320 (patch) | |
tree | c463676791e4a63e452a95f0a12b2a8519730693 /WebCore/loader | |
parent | eff9be92c41913c92fb1d3b7983c071f3e718678 (diff) | |
download | external_webkit-28040489d744e0c5d475a88663056c9040ed5320.zip external_webkit-28040489d744e0c5d475a88663056c9040ed5320.tar.gz external_webkit-28040489d744e0c5d475a88663056c9040ed5320.tar.bz2 |
Merge WebKit at r71558: Initial merge by git.
Change-Id: Ib345578fa29df7e4bc72b4f00e4a6fddcb754c4c
Diffstat (limited to 'WebCore/loader')
-rw-r--r-- | WebCore/loader/DocumentLoader.cpp | 2 | ||||
-rw-r--r-- | WebCore/loader/EmptyClients.h | 14 | ||||
-rw-r--r-- | WebCore/loader/FrameLoader.cpp | 93 | ||||
-rw-r--r-- | WebCore/loader/HistoryController.cpp | 25 | ||||
-rw-r--r-- | WebCore/loader/HistoryController.h | 2 | ||||
-rw-r--r-- | WebCore/loader/NavigationScheduler.cpp | 8 | ||||
-rw-r--r-- | WebCore/loader/PlaceholderDocument.cpp | 3 | ||||
-rw-r--r-- | WebCore/loader/ProgressTracker.cpp | 4 | ||||
-rw-r--r-- | WebCore/loader/Request.h | 8 | ||||
-rw-r--r-- | WebCore/loader/SubframeLoader.cpp | 4 | ||||
-rw-r--r-- | WebCore/loader/archive/cf/LegacyWebArchive.cpp | 6 | ||||
-rw-r--r-- | WebCore/loader/cache/CachePolicy.h (renamed from WebCore/loader/CachePolicy.h) | 0 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedCSSStyleSheet.cpp (renamed from WebCore/loader/CachedCSSStyleSheet.cpp) | 4 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedCSSStyleSheet.h (renamed from WebCore/loader/CachedCSSStyleSheet.h) | 1 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedFont.cpp (renamed from WebCore/loader/CachedFont.cpp) | 2 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedFont.h (renamed from WebCore/loader/CachedFont.h) | 4 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedImage.cpp (renamed from WebCore/loader/CachedImage.cpp) | 4 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedImage.h (renamed from WebCore/loader/CachedImage.h) | 5 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedResource.cpp (renamed from WebCore/loader/CachedResource.cpp) | 8 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedResource.h (renamed from WebCore/loader/CachedResource.h) | 10 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedResourceClient.h (renamed from WebCore/loader/CachedResourceClient.h) | 0 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedResourceClientWalker.cpp (renamed from WebCore/loader/CachedResourceClientWalker.cpp) | 0 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedResourceClientWalker.h (renamed from WebCore/loader/CachedResourceClientWalker.h) | 0 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedResourceHandle.cpp (renamed from WebCore/loader/CachedResourceHandle.cpp) | 0 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedResourceHandle.h (renamed from WebCore/loader/CachedResourceHandle.h) | 0 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedResourceLoader.cpp (renamed from WebCore/loader/CachedResourceLoader.cpp) | 34 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedResourceLoader.h (renamed from WebCore/loader/CachedResourceLoader.h) | 8 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedScript.cpp (renamed from WebCore/loader/CachedScript.cpp) | 4 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedScript.h (renamed from WebCore/loader/CachedScript.h) | 1 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedXSLStyleSheet.cpp (renamed from WebCore/loader/CachedXSLStyleSheet.cpp) | 0 | ||||
-rw-r--r-- | WebCore/loader/cache/CachedXSLStyleSheet.h (renamed from WebCore/loader/CachedXSLStyleSheet.h) | 0 | ||||
-rw-r--r-- | WebCore/loader/cache/MemoryCache.cpp (renamed from WebCore/loader/Cache.cpp) | 84 | ||||
-rw-r--r-- | WebCore/loader/cache/MemoryCache.h (renamed from WebCore/loader/Cache.h) | 12 | ||||
-rw-r--r-- | WebCore/loader/loader.cpp | 14 |
34 files changed, 190 insertions, 174 deletions
diff --git a/WebCore/loader/DocumentLoader.cpp b/WebCore/loader/DocumentLoader.cpp index 5707530..0836805 100644 --- a/WebCore/loader/DocumentLoader.cpp +++ b/WebCore/loader/DocumentLoader.cpp @@ -500,7 +500,7 @@ PassRefPtr<ArchiveResource> DocumentLoader::mainResource() const if (!mainResourceBuffer) mainResourceBuffer = SharedBuffer::create(); - return ArchiveResource::create(mainResourceBuffer, r.url(), r.mimeType(), r.textEncodingName(), frame()->tree()->name()); + return ArchiveResource::create(mainResourceBuffer, r.url(), r.mimeType(), r.textEncodingName(), frame()->tree()->uniqueName()); } PassRefPtr<ArchiveResource> DocumentLoader::subresource(const KURL& url) const diff --git a/WebCore/loader/EmptyClients.h b/WebCore/loader/EmptyClients.h index 59be8b1..3a5e0e9 100644 --- a/WebCore/loader/EmptyClients.h +++ b/WebCore/loader/EmptyClients.h @@ -106,6 +106,7 @@ public: virtual void takeFocus(FocusDirection) { } virtual void focusedNodeChanged(Node*) { } + virtual void focusedFrameChanged(Frame*) { } virtual Page* createWindow(Frame*, const FrameLoadRequest&, const WindowFeatures&, const NavigationAction&) { return 0; } virtual void show() { } @@ -143,6 +144,10 @@ public: virtual PassRefPtr<PopupMenu> createPopupMenu(PopupMenuClient*) const { return adoptRef(new EmptyPopupMenu()); } virtual PassRefPtr<SearchPopupMenu> createSearchPopupMenu(PopupMenuClient*) const { return adoptRef(new EmptySearchPopupMenu()); } +#if ENABLE(CONTEXT_MENUS) + virtual void showContextMenu() { } +#endif + virtual void setStatusbarText(const String&) { } virtual bool tabsToLinks() const { return false; } @@ -153,6 +158,9 @@ public: virtual void invalidateContentsAndWindow(const IntRect&, bool) { } virtual void invalidateContentsForSlowScroll(const IntRect&, bool) {}; virtual void scroll(const IntSize&, const IntRect&, const IntRect&) { } +#if ENABLE(TILED_BACKING_STORE) + virtual void delegatedScrollRequested(const IntSize&) { } +#endif virtual IntPoint screenToWindow(const IntPoint& p) const { return p; } virtual IntRect windowToScreen(const IntRect& r) const { return r; } @@ -479,9 +487,9 @@ public: #if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) virtual void checkTextOfParagraph(const UChar*, int, uint64_t, Vector<TextCheckingResult>&) { }; #endif -#if PLATFORM(MAC) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_SNOW_LEOPARD) - virtual void showCorrectionPanel(const FloatRect&, const String&, const String&, Editor*) { } - virtual void dismissCorrectionPanel(bool) { } +#if SUPPORT_AUTOCORRECTION_PANEL + virtual void showCorrectionPanel(CorrectionPanelInfo::PanelType, const FloatRect&, const String&, const String&, Editor*) { } + virtual void dismissCorrectionPanel(CorrectionWasRejectedOrNot) { } virtual bool isShowingCorrectionPanel() { return false; } #endif virtual void updateSpellingUIWithGrammarString(const String&, const GrammarDetail&) { } diff --git a/WebCore/loader/FrameLoader.cpp b/WebCore/loader/FrameLoader.cpp index 8a2adee..e4a6513 100644 --- a/WebCore/loader/FrameLoader.cpp +++ b/WebCore/loader/FrameLoader.cpp @@ -37,15 +37,19 @@ #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size #include "Archive.h" #include "ArchiveFactory.h" +<<<<<<< HEAD #endif #include "BackForwardList.h" +======= +#include "BackForwardController.h" +>>>>>>> webkit.org at r71558 #include "BeforeUnloadEvent.h" -#include "Cache.h" +#include "MemoryCache.h" #include "CachedPage.h" +#include "CachedResourceLoader.h" #include "Chrome.h" #include "DOMImplementation.h" #include "DOMWindow.h" -#include "CachedResourceLoader.h" #include "Document.h" #include "DocumentLoadTiming.h" #include "DocumentLoader.h" @@ -65,9 +69,6 @@ #include "FrameView.h" #include "HTMLAnchorElement.h" #include "HTMLFormElement.h" -#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) -#include "HTMLMediaElement.h" -#endif #include "HTMLNames.h" #include "HTMLObjectElement.h" #include "HTTPParsers.h" @@ -82,7 +83,6 @@ #include "PageCache.h" #include "PageGroup.h" #include "PageTransitionEvent.h" -#include "PlaceholderDocument.h" #include "PluginData.h" #include "PluginDatabase.h" #include "PluginDocument.h" @@ -104,6 +104,10 @@ #include <wtf/text/CString.h> #include <wtf/text/StringConcatenate.h> +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) +#include "HTMLMediaElement.h" +#endif + #if ENABLE(SHARED_WORKERS) #include "SharedWorkerRepository.h" #endif @@ -937,7 +941,7 @@ void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer, // If we're moving in the back/forward list, we might want to replace the content // of this child frame with whatever was there at that point. if (parentItem && parentItem->children().size() && isBackForwardLoadType(loadType)) { - HistoryItem* childItem = parentItem->childItemWithTarget(childFrame->tree()->name()); + HistoryItem* childItem = parentItem->childItemWithTarget(childFrame->tree()->uniqueName()); if (childItem) { // Use the original URL to ensure we get all the side-effects, such as // onLoad handlers, of any redirects that happened. An example of where @@ -948,8 +952,12 @@ void FrameLoader::loadURLIntoChildFrame(const KURL& url, const String& referer, } } +<<<<<<< HEAD #if ENABLE(ARCHIVE) // ANDROID extension: disabled to reduce code size RefPtr<Archive> subframeArchive = activeDocumentLoader()->popArchiveForSubframe(childFrame->tree()->name()); +======= + RefPtr<Archive> subframeArchive = activeDocumentLoader()->popArchiveForSubframe(childFrame->tree()->uniqueName()); +>>>>>>> webkit.org at r71558 if (subframeArchive) childFrame->loader()->loadArchive(subframeArchive.release()); @@ -1851,7 +1859,7 @@ void FrameLoader::commitProvisionalLoad() RefPtr<CachedPage> cachedPage = m_loadingFromCachedPage ? pageCache()->get(history()->provisionalItem()) : 0; RefPtr<DocumentLoader> pdl = m_provisionalDocumentLoader; - LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame->tree()->name().string().utf8().data(), m_URL.string().utf8().data(), + LOG(PageCache, "WebCoreLoading %s: About to commit provisional load from previous URL '%s' to new URL '%s'", m_frame->tree()->uniqueName().string().utf8().data(), m_URL.string().utf8().data(), pdl ? pdl->url().string().utf8().data() : "<no provisional DocumentLoader>"); // Check to see if we need to cache the page we are navigating away from into the back/forward cache. @@ -1899,7 +1907,7 @@ void FrameLoader::commitProvisionalLoad() didOpenURL(url); } - LOG(Loading, "WebCoreLoading %s: Finished committing provisional load to URL %s", m_frame->tree()->name().string().utf8().data(), m_URL.string().utf8().data()); + LOG(Loading, "WebCoreLoading %s: Finished committing provisional load to URL %s", m_frame->tree()->uniqueName().string().utf8().data(), m_URL.string().utf8().data()); if (m_loadType == FrameLoadTypeStandard && m_documentLoader->isClientRedirect()) history()->updateForClientRedirect(); @@ -1972,30 +1980,28 @@ void FrameLoader::transitionToCommitted(PassRefPtr<CachedPage> cachedPage) case FrameLoadTypeBack: case FrameLoadTypeBackWMLDeckNotAccessible: case FrameLoadTypeIndexedBackForward: - if (Page* page = m_frame->page()) { - if (page->backForwardList()) { - // If the first load within a frame is a navigation within a back/forward list that was attached - // without any of the items being loaded then we need to update the history in a similar manner as - // for a standard load with the exception of updating the back/forward list (<rdar://problem/8091103>). - if (!m_stateMachine.committedFirstRealDocumentLoad()) - history()->updateForStandardLoad(HistoryController::UpdateAllExceptBackForwardList); - - history()->updateForBackForwardNavigation(); - - // For cached pages, CachedFrame::restore will take care of firing the popstate event with the history item's state object - if (history()->currentItem() && !cachedPage) - m_pendingStateObject = history()->currentItem()->stateObject(); - - // Create a document view for this document, or used the cached view. - if (cachedPage) { - DocumentLoader* cachedDocumentLoader = cachedPage->documentLoader(); - ASSERT(cachedDocumentLoader); - cachedDocumentLoader->setFrame(m_frame); - m_client->transitionToCommittedFromCachedFrame(cachedPage->cachedMainFrame()); - - } else - m_client->transitionToCommittedForNewPage(); - } + if (m_frame->page()) { + // If the first load within a frame is a navigation within a back/forward list that was attached + // without any of the items being loaded then we need to update the history in a similar manner as + // for a standard load with the exception of updating the back/forward list (<rdar://problem/8091103>). + if (!m_stateMachine.committedFirstRealDocumentLoad()) + history()->updateForStandardLoad(HistoryController::UpdateAllExceptBackForwardList); + + history()->updateForBackForwardNavigation(); + + // For cached pages, CachedFrame::restore will take care of firing the popstate event with the history item's state object + if (history()->currentItem() && !cachedPage) + m_pendingStateObject = history()->currentItem()->stateObject(); + + // Create a document view for this document, or used the cached view. + if (cachedPage) { + DocumentLoader* cachedDocumentLoader = cachedPage->documentLoader(); + ASSERT(cachedDocumentLoader); + cachedDocumentLoader->setFrame(m_frame); + m_client->transitionToCommittedFromCachedFrame(cachedPage->cachedMainFrame()); + + } else + m_client->transitionToCommittedForNewPage(); } break; @@ -2405,7 +2411,7 @@ void FrameLoader::checkLoadCompleteForThisFrame() } if (shouldReset && item) if (Page* page = m_frame->page()) { - page->backForwardList()->goToItem(item.get()); + page->backForward()->setCurrentItem(item.get()); Settings* settings = m_frame->settings(); page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : item.get()); } @@ -2426,9 +2432,10 @@ void FrameLoader::checkLoadCompleteForThisFrame() m_client->forceLayoutForNonHTML(); // If the user had a scroll point, scroll to it, overriding the anchor point if any. - if (Page* page = m_frame->page()) - if ((isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload || m_loadType == FrameLoadTypeReloadFromOrigin) && page->backForwardList()) + if (m_frame->page()) { + if (isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload || m_loadType == FrameLoadTypeReloadFromOrigin) history()->restoreScrollPositionAndViewState(); + } if (m_stateMachine.creatingInitialEmptyDocument() || !m_stateMachine.committedFirstRealDocumentLoad()) return; @@ -2496,9 +2503,8 @@ void FrameLoader::continueLoadAfterWillSubmitForm() void FrameLoader::didFirstLayout() { - if (Page* page = m_frame->page()) - if (isBackForwardLoadType(m_loadType) && page->backForwardList()) - history()->restoreScrollPositionAndViewState(); + if (m_frame->page() && isBackForwardLoadType(m_loadType)) + history()->restoreScrollPositionAndViewState(); if (m_stateMachine.committedFirstRealDocumentLoad() && !m_stateMachine.isDisplayingInitialEmptyDocument() && !m_stateMachine.firstLayoutDone()) m_stateMachine.advanceTo(FrameLoaderStateMachine::FirstLayoutDone); @@ -2614,9 +2620,12 @@ void FrameLoader::detachFromParent() RefPtr<Frame> protect(m_frame); closeURL(); - stopAllLoaders(); history()->saveScrollPositionAndViewStateToItem(history()->currentItem()); detachChildren(); + // stopAllLoaders() needs to be called after detachChildren(), because detachedChildren() + // will trigger the unload event handlers of any child frames, and those event + // handlers might start a new subresource load in this frame. + stopAllLoaders(); #if ENABLE(INSPECTOR) if (Page* page = m_frame->page()) @@ -2963,7 +2972,7 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest&, Pass if (Page* page = m_frame->page()) { Frame* mainFrame = page->mainFrame(); if (HistoryItem* resetItem = mainFrame->loader()->history()->currentItem()) { - page->backForwardList()->goToItem(resetItem); + page->backForward()->setCurrentItem(resetItem); Settings* settings = m_frame->settings(); page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : resetItem); } @@ -3144,7 +3153,7 @@ void FrameLoader::checkDidPerformFirstNavigation() if (!page) return; - if (!m_didPerformFirstNavigation && page->backForwardList()->currentItem() && !page->backForwardList()->backItem() && !page->backForwardList()->forwardItem()) { + if (!m_didPerformFirstNavigation && page->backForward()->currentItem() && !page->backForward()->backItem() && !page->backForward()->forwardItem()) { m_didPerformFirstNavigation = true; m_client->didPerformFirstNavigation(); } diff --git a/WebCore/loader/HistoryController.cpp b/WebCore/loader/HistoryController.cpp index f06589e..07bece7 100644 --- a/WebCore/loader/HistoryController.cpp +++ b/WebCore/loader/HistoryController.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "HistoryController.h" -#include "BackForwardList.h" +#include "BackForwardController.h" #include "CachedPage.h" #include "DocumentLoader.h" #include "Frame.h" @@ -149,7 +149,7 @@ void HistoryController::saveDocumentState() ASSERT(document); if (item->isCurrentDocument(document)) { - LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree()->name().string().utf8().data(), item); + LOG(Loading, "WebCoreLoading %s: saving form state to %p", m_frame->tree()->uniqueName().string().utf8().data(), item); item->setDocumentState(document->formElementsState()); } } @@ -188,7 +188,7 @@ void HistoryController::restoreDocumentState() if (!itemToRestore) return; - LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame->tree()->name().string().utf8().data(), itemToRestore); + LOG(Loading, "WebCoreLoading %s: restoring form state from %p", m_frame->tree()->uniqueName().string().utf8().data(), itemToRestore); doc->setStateForNewFormElements(itemToRestore->documentState()); } @@ -230,9 +230,8 @@ void HistoryController::goToItem(HistoryItem* targetItem, FrameLoadType type) // Set the BF cursor before commit, which lets the user quickly click back/forward again. // - plus, it only makes sense for the top level of the operation through the frametree, // as opposed to happening for some/one of the page commits that might happen soon - BackForwardList* bfList = page->backForwardList(); - HistoryItem* currentItem = bfList->currentItem(); - bfList->goToItem(targetItem); + HistoryItem* currentItem = page->backForward()->currentItem(); + page->backForward()->setCurrentItem(targetItem); Settings* settings = m_frame->settings(); page->setGlobalHistoryItem((!settings || settings->privateBrowsingEnabled()) ? 0 : targetItem); recursiveGoToItem(targetItem, currentItem, type); @@ -295,7 +294,7 @@ void HistoryController::updateForStandardLoad(HistoryUpdateType updateType) frameLoader->client()->updateGlobalHistoryRedirectLinks(); } if (Page* page = m_frame->page()) - page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardList()->currentItem()); + page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForward()->currentItem()); } } else if (frameLoader->documentLoader()->unreachableURL().isEmpty() && m_currentItem) { m_currentItem->setURL(frameLoader->documentLoader()->url()); @@ -333,7 +332,7 @@ void HistoryController::updateForRedirectWithLockedBackForwardList() m_frame->loader()->client()->updateGlobalHistoryRedirectLinks(); } if (Page* page = m_frame->page()) - page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForwardList()->currentItem()); + page->setGlobalHistoryItem(needPrivacy ? 0 : page->backForward()->currentItem()); } } if (m_currentItem) { @@ -481,10 +480,10 @@ PassRefPtr<HistoryItem> HistoryController::createItem(bool useOriginal) originalURL = blankURL(); Frame* parentFrame = m_frame->tree()->parent(); - String parent = parentFrame ? parentFrame->tree()->name() : ""; + String parent = parentFrame ? parentFrame->tree()->uniqueName() : ""; String title = documentLoader ? documentLoader->title() : ""; - RefPtr<HistoryItem> item = HistoryItem::create(url, m_frame->tree()->name(), parent, title); + RefPtr<HistoryItem> item = HistoryItem::create(url, m_frame->tree()->uniqueName(), parent, title); item->setOriginalURLString(originalURL.string()); if (!unreachableURL.isEmpty() || !documentLoader || documentLoader->response().httpStatusCode() >= 400) @@ -599,7 +598,7 @@ void HistoryController::recursiveGoToItem(HistoryItem* item, HistoryItem* fromIt // Helper method that determines whether the current frame tree matches given history item's. bool HistoryController::currentFramesMatchItem(HistoryItem* item) const { - if ((!m_frame->tree()->name().isEmpty() || !item->target().isEmpty()) && m_frame->tree()->name() != item->target()) + if ((!m_frame->tree()->uniqueName().isEmpty() || !item->target().isEmpty()) && m_frame->tree()->uniqueName() != item->target()) return false; const HistoryItemVector& childItems = item->children(); @@ -637,7 +636,7 @@ void HistoryController::updateBackForwardListClippedAtTarget(bool doClip) RefPtr<HistoryItem> topItem = frameLoader->history()->createItemTree(m_frame, doClip); LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", topItem.get(), m_frame->loader()->documentLoader()->url().string().ascii().data()); - page->backForwardList()->addItem(topItem.release()); + page->backForward()->addItem(topItem.release()); } void HistoryController::pushState(PassRefPtr<SerializedScriptValue> stateObject, const String& title, const String& urlString) @@ -657,7 +656,7 @@ void HistoryController::pushState(PassRefPtr<SerializedScriptValue> stateObject, m_currentItem->setStateObject(stateObject); m_currentItem->setURLString(urlString); - page->backForwardList()->addItem(topItem.release()); + page->backForward()->addItem(topItem.release()); } void HistoryController::replaceState(PassRefPtr<SerializedScriptValue> stateObject, const String& title, const String& urlString) diff --git a/WebCore/loader/HistoryController.h b/WebCore/loader/HistoryController.h index 487fdc9..1002dbc 100644 --- a/WebCore/loader/HistoryController.h +++ b/WebCore/loader/HistoryController.h @@ -75,6 +75,8 @@ public: void setCurrentItemTitle(const String&); bool currentItemShouldBeReplaced() const; + HistoryItem* previousItem() const { return m_previousItem.get(); } + HistoryItem* provisionalItem() const { return m_provisionalItem.get(); } void setProvisionalItem(HistoryItem*); diff --git a/WebCore/loader/NavigationScheduler.cpp b/WebCore/loader/NavigationScheduler.cpp index 98f21fe..28fda9a 100644 --- a/WebCore/loader/NavigationScheduler.cpp +++ b/WebCore/loader/NavigationScheduler.cpp @@ -32,7 +32,7 @@ #include "config.h" #include "NavigationScheduler.h" -#include "BackForwardList.h" +#include "BackForwardController.h" #include "DOMWindow.h" #include "DocumentLoader.h" #include "Event.h" @@ -177,7 +177,7 @@ public: } // go(i!=0) from a frame navigates into the history of the frame only, // in both IE and NS (but not in Mozilla). We can't easily do that. - frame->page()->goBackOrForward(m_historySteps); + frame->page()->backForward()->goBackOrForward(m_historySteps); } private: @@ -352,8 +352,8 @@ void NavigationScheduler::scheduleHistoryNavigation(int steps) // Invalid history navigations (such as history.forward() during a new load) have the side effect of cancelling any scheduled // redirects. We also avoid the possibility of cancelling the current load by avoiding the scheduled redirection altogether. - HistoryItem* specifiedEntry = m_frame->page()->backForwardList()->itemAtIndex(steps); - if (!specifiedEntry) { + BackForwardController* backForward = m_frame->page()->backForward(); + if (steps > backForward->forwardCount() || -steps > backForward->backCount()) { cancel(); return; } diff --git a/WebCore/loader/PlaceholderDocument.cpp b/WebCore/loader/PlaceholderDocument.cpp index 81222b3..93a26db 100644 --- a/WebCore/loader/PlaceholderDocument.cpp +++ b/WebCore/loader/PlaceholderDocument.cpp @@ -26,9 +26,6 @@ #include "config.h" #include "PlaceholderDocument.h" -#include "CSSStyleSelector.h" -#include "StyleSheetList.h" - namespace WebCore { void PlaceholderDocument::attach() diff --git a/WebCore/loader/ProgressTracker.cpp b/WebCore/loader/ProgressTracker.cpp index 561e6bc..6bc2055 100644 --- a/WebCore/loader/ProgressTracker.cpp +++ b/WebCore/loader/ProgressTracker.cpp @@ -101,7 +101,7 @@ void ProgressTracker::reset() void ProgressTracker::progressStarted(Frame* frame) { - LOG(Progress, "Progress started (%p) - frame %p(\"%s\"), value %f, tracked frames %d, originating frame %p", this, frame, frame->tree()->name().string().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get()); + LOG(Progress, "Progress started (%p) - frame %p(\"%s\"), value %f, tracked frames %d, originating frame %p", this, frame, frame->tree()->uniqueName().string().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get()); frame->loader()->client()->willChangeEstimatedProgress(); @@ -119,7 +119,7 @@ void ProgressTracker::progressStarted(Frame* frame) void ProgressTracker::progressCompleted(Frame* frame) { - LOG(Progress, "Progress completed (%p) - frame %p(\"%s\"), value %f, tracked frames %d, originating frame %p", this, frame, frame->tree()->name().string().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get()); + LOG(Progress, "Progress completed (%p) - frame %p(\"%s\"), value %f, tracked frames %d, originating frame %p", this, frame, frame->tree()->uniqueName().string().utf8().data(), m_progressValue, m_numProgressTrackedFrames, m_originatingProgressFrame.get()); if (m_numProgressTrackedFrames <= 0) return; diff --git a/WebCore/loader/Request.h b/WebCore/loader/Request.h index 25bf31a..b6de312 100644 --- a/WebCore/loader/Request.h +++ b/WebCore/loader/Request.h @@ -36,13 +36,13 @@ namespace WebCore { Request(CachedResourceLoader*, CachedResource*, bool incremental, SecurityCheckPolicy, bool sendResourceLoadCallbacks); ~Request(); - CachedResource* cachedResource() { return m_object; } - CachedResourceLoader* cachedResourceLoader() { return m_cachedResourceLoader; } + CachedResource* cachedResource() const { return m_object; } + CachedResourceLoader* cachedResourceLoader() const { return m_cachedResourceLoader; } - bool isIncremental() { return m_incremental; } + bool isIncremental() const { return m_incremental; } void setIsIncremental(bool b = true) { m_incremental = b; } - bool isMultipart() { return m_multipart; } + bool isMultipart() const { return m_multipart; } void setIsMultipart(bool b = true) { m_multipart = b; } SecurityCheckPolicy shouldDoSecurityCheck() const { return m_shouldDoSecurityCheck; } diff --git a/WebCore/loader/SubframeLoader.cpp b/WebCore/loader/SubframeLoader.cpp index f73646b..d486de0 100644 --- a/WebCore/loader/SubframeLoader.cpp +++ b/WebCore/loader/SubframeLoader.cpp @@ -366,8 +366,8 @@ bool SubframeLoader::loadPlugin(HTMLPlugInImageElement* pluginElement, const KUR renderer->setWidget(widget); m_containsPlugins = true; - -#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) + +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) || ENABLE(3D_PLUGIN) pluginElement->setNeedsStyleRecalc(SyntheticStyleChange); #endif return true; diff --git a/WebCore/loader/archive/cf/LegacyWebArchive.cpp b/WebCore/loader/archive/cf/LegacyWebArchive.cpp index 061f4d9..ddd564e 100644 --- a/WebCore/loader/archive/cf/LegacyWebArchive.cpp +++ b/WebCore/loader/archive/cf/LegacyWebArchive.cpp @@ -29,7 +29,7 @@ #include "config.h" #include "LegacyWebArchive.h" -#include "Cache.h" +#include "MemoryCache.h" #include "Document.h" #include "DocumentLoader.h" #include "Frame.h" @@ -492,7 +492,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString if (responseURL.isNull()) responseURL = KURL(ParsedURLString, ""); - PassRefPtr<ArchiveResource> mainResource = ArchiveResource::create(utf8Buffer(markupString), responseURL, response.mimeType(), "UTF-8", frame->tree()->name()); + PassRefPtr<ArchiveResource> mainResource = ArchiveResource::create(utf8Buffer(markupString), responseURL, response.mimeType(), "UTF-8", frame->tree()->uniqueName()); Vector<PassRefPtr<LegacyWebArchive> > subframeArchives; Vector<PassRefPtr<ArchiveResource> > subresources; @@ -509,7 +509,7 @@ PassRefPtr<LegacyWebArchive> LegacyWebArchive::create(const String& markupString if (subframeArchive) subframeArchives.append(subframeArchive); else - LOG_ERROR("Unabled to archive subframe %s", childFrame->tree()->name().string().utf8().data()); + LOG_ERROR("Unabled to archive subframe %s", childFrame->tree()->uniqueName().string().utf8().data()); } else { ListHashSet<KURL> subresourceURLs; node->getSubresourceURLs(subresourceURLs); diff --git a/WebCore/loader/CachePolicy.h b/WebCore/loader/cache/CachePolicy.h index 2639caa..2639caa 100644 --- a/WebCore/loader/CachePolicy.h +++ b/WebCore/loader/cache/CachePolicy.h diff --git a/WebCore/loader/CachedCSSStyleSheet.cpp b/WebCore/loader/cache/CachedCSSStyleSheet.cpp index 877cd1d..f0016d1 100644 --- a/WebCore/loader/CachedCSSStyleSheet.cpp +++ b/WebCore/loader/cache/CachedCSSStyleSheet.cpp @@ -27,7 +27,7 @@ #include "config.h" #include "CachedCSSStyleSheet.h" -#include "Cache.h" +#include "MemoryCache.h" #include "CachedResourceClient.h" #include "CachedResourceClientWalker.h" #include "HTTPParsers.h" @@ -59,7 +59,7 @@ void CachedCSSStyleSheet::didAddClient(CachedResourceClient *c) void CachedCSSStyleSheet::allClientsRemoved() { - if (!Cache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable()) + if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable()) makePurgeable(true); } diff --git a/WebCore/loader/CachedCSSStyleSheet.h b/WebCore/loader/cache/CachedCSSStyleSheet.h index 03bde69..abcdb85 100644 --- a/WebCore/loader/CachedCSSStyleSheet.h +++ b/WebCore/loader/cache/CachedCSSStyleSheet.h @@ -55,6 +55,7 @@ namespace WebCore { private: bool canUseSheet(bool enforceMIMEType, bool* hasValidMIMEType) const; + virtual PurgePriority purgePriority() const { return PurgeLast; } protected: RefPtr<TextResourceDecoder> m_decoder; diff --git a/WebCore/loader/CachedFont.cpp b/WebCore/loader/cache/CachedFont.cpp index e8db6c6..6297ad1 100644 --- a/WebCore/loader/CachedFont.cpp +++ b/WebCore/loader/cache/CachedFont.cpp @@ -31,7 +31,7 @@ #define STORE_FONT_CUSTOM_PLATFORM_DATA #endif -#include "Cache.h" +#include "MemoryCache.h" #include "CachedResourceClient.h" #include "CachedResourceClientWalker.h" #include "FontPlatformData.h" diff --git a/WebCore/loader/CachedFont.h b/WebCore/loader/cache/CachedFont.h index 8dc8874..e1a34e8 100644 --- a/WebCore/loader/CachedFont.h +++ b/WebCore/loader/cache/CachedFont.h @@ -39,7 +39,7 @@ namespace WebCore { class CachedResourceLoader; -class Cache; +class MemoryCache; class FontPlatformData; class SVGFontElement; @@ -81,7 +81,7 @@ private: RefPtr<SVGDocument> m_externalSVGDocument; #endif - friend class Cache; + friend class MemoryCache; }; } diff --git a/WebCore/loader/CachedImage.cpp b/WebCore/loader/cache/CachedImage.cpp index 30eaf9d..ce1c9a3 100644 --- a/WebCore/loader/CachedImage.cpp +++ b/WebCore/loader/cache/CachedImage.cpp @@ -25,7 +25,7 @@ #include "CachedImage.h" #include "BitmapImage.h" -#include "Cache.h" +#include "MemoryCache.h" #include "CachedResourceClient.h" #include "CachedResourceClientWalker.h" #include "CachedResourceLoader.h" @@ -338,7 +338,7 @@ void CachedImage::destroyDecodedData() // Invoking addClient() will reconstruct the image object. m_image = 0; setDecodedSize(0); - if (!Cache::shouldMakeResourcePurgeableOnEviction()) + if (!MemoryCache::shouldMakeResourcePurgeableOnEviction()) makePurgeable(true); } else if (m_image && !errorOccurred()) m_image->destroyDecodedData(); diff --git a/WebCore/loader/CachedImage.h b/WebCore/loader/cache/CachedImage.h index 15f4238..313f3f3 100644 --- a/WebCore/loader/CachedImage.h +++ b/WebCore/loader/cache/CachedImage.h @@ -32,10 +32,10 @@ namespace WebCore { class CachedResourceLoader; -class Cache; +class MemoryCache; class CachedImage : public CachedResource, public ImageObserver { - friend class Cache; + friend class MemoryCache; public: CachedImage(const String& url); @@ -93,6 +93,7 @@ private: // If not null, changeRect is the changed part of the image. void notifyObservers(const IntRect* changeRect = 0); void decodedDataDeletionTimerFired(Timer<CachedImage>*); + virtual PurgePriority purgePriority() const { return PurgeFirst; } RefPtr<Image> m_image; Timer<CachedImage> m_decodedDataDeletionTimer; diff --git a/WebCore/loader/CachedResource.cpp b/WebCore/loader/cache/CachedResource.cpp index e519c29..c440ec9 100644 --- a/WebCore/loader/CachedResource.cpp +++ b/WebCore/loader/cache/CachedResource.cpp @@ -24,7 +24,7 @@ #include "config.h" #include "CachedResource.h" -#include "Cache.h" +#include "MemoryCache.h" #include "CachedMetadata.h" #include "CachedResourceClient.h" #include "CachedResourceClientWalker.h" @@ -517,17 +517,13 @@ bool CachedResource::makePurgeable(bool purgeable) if (!m_data->hasOneRef()) return false; - // Purgeable buffers are allocated in multiples of the page size (4KB in common CPUs) so it does not make sense for very small buffers. - const size_t purgeableThreshold = 4 * 4096; - if (m_data->size() < purgeableThreshold) - return false; - if (m_data->hasPurgeableBuffer()) { m_purgeableData = m_data->releasePurgeableBuffer(); } else { m_purgeableData = PurgeableBuffer::create(m_data->data(), m_data->size()); if (!m_purgeableData) return false; + m_purgeableData->setPurgePriority(purgePriority()); } m_purgeableData->makePurgeable(true); diff --git a/WebCore/loader/CachedResource.h b/WebCore/loader/cache/CachedResource.h index 078da57..ba02459 100644 --- a/WebCore/loader/CachedResource.h +++ b/WebCore/loader/cache/CachedResource.h @@ -26,6 +26,7 @@ #include "CachePolicy.h" #include "FrameLoaderTypes.h" #include "PlatformString.h" +#include "PurgePriority.h" #include "ResourceResponse.h" #include <wtf/HashCountedSet.h> #include <wtf/HashSet.h> @@ -35,21 +36,21 @@ namespace WebCore { -class Cache; +class MemoryCache; class CachedMetadata; class CachedResourceClient; class CachedResourceHandleBase; class CachedResourceLoader; class Frame; class InspectorResource; -class Request; class PurgeableBuffer; +class Request; // A resource that is held in the cache. Classes who want to use this object should derive // from CachedResourceClient, to get the function calls in case the requested data has arrived. // This class also does the actual communication with the loader to obtain the resource from the network. class CachedResource : public Noncopyable { - friend class Cache; + friend class MemoryCache; friend class InspectorResource; public: @@ -224,11 +225,12 @@ protected: private: void addClientToSet(CachedResourceClient*); - // These are called by the friendly Cache only + // These are called by the friendly MemoryCache only void setResourceToRevalidate(CachedResource*); void switchClientsToRevalidatedResource(); void clearResourceToRevalidate(); void updateResponseAfterRevalidation(const ResourceResponse& validatingResponse); + virtual PurgePriority purgePriority() const { return PurgeDefault; } double currentAge() const; double freshnessLifetime() const; diff --git a/WebCore/loader/CachedResourceClient.h b/WebCore/loader/cache/CachedResourceClient.h index 275d331..275d331 100644 --- a/WebCore/loader/CachedResourceClient.h +++ b/WebCore/loader/cache/CachedResourceClient.h diff --git a/WebCore/loader/CachedResourceClientWalker.cpp b/WebCore/loader/cache/CachedResourceClientWalker.cpp index 142a2a1..142a2a1 100644 --- a/WebCore/loader/CachedResourceClientWalker.cpp +++ b/WebCore/loader/cache/CachedResourceClientWalker.cpp diff --git a/WebCore/loader/CachedResourceClientWalker.h b/WebCore/loader/cache/CachedResourceClientWalker.h index d079584..d079584 100644 --- a/WebCore/loader/CachedResourceClientWalker.h +++ b/WebCore/loader/cache/CachedResourceClientWalker.h diff --git a/WebCore/loader/CachedResourceHandle.cpp b/WebCore/loader/cache/CachedResourceHandle.cpp index 871292c..871292c 100644 --- a/WebCore/loader/CachedResourceHandle.cpp +++ b/WebCore/loader/cache/CachedResourceHandle.cpp diff --git a/WebCore/loader/CachedResourceHandle.h b/WebCore/loader/cache/CachedResourceHandle.h index 7d485bf..7d485bf 100644 --- a/WebCore/loader/CachedResourceHandle.h +++ b/WebCore/loader/cache/CachedResourceHandle.h diff --git a/WebCore/loader/CachedResourceLoader.cpp b/WebCore/loader/cache/CachedResourceLoader.cpp index 5925f67..29d1204 100644 --- a/WebCore/loader/CachedResourceLoader.cpp +++ b/WebCore/loader/cache/CachedResourceLoader.cpp @@ -27,32 +27,32 @@ #include "config.h" #include "CachedResourceLoader.h" -#include "loader.h" -#include "Cache.h" #include "CachedCSSStyleSheet.h" #include "CachedFont.h" #include "CachedImage.h" #include "CachedScript.h" #include "CachedXSLStyleSheet.h" #include "Console.h" -#include "Document.h" #include "DOMWindow.h" -#include "HTMLElement.h" +#include "Document.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameLoaderClient.h" +#include "HTMLElement.h" +#include "MemoryCache.h" #include "PingLoader.h" #include "SecurityOrigin.h" #include "Settings.h" +#include "loader.h" #include <wtf/text/StringConcatenate.h> #define PRELOAD_DEBUG 0 namespace WebCore { -CachedResourceLoader::CachedResourceLoader(Document* doc) +CachedResourceLoader::CachedResourceLoader(Document* document) : m_cache(cache()) - , m_doc(doc) + , m_document(document) , m_requestCount(0) #ifdef ANDROID_BLOCK_NETWORK_IMAGE , m_blockNetworkImage(false) @@ -81,7 +81,7 @@ CachedResourceLoader::~CachedResourceLoader() Frame* CachedResourceLoader::frame() const { - return m_doc->frame(); + return m_document->frame(); } void CachedResourceLoader::checkForReload(const KURL& fullURL) @@ -131,7 +131,7 @@ CachedImage* CachedResourceLoader::requestImage(const String& url) return 0; if (f->loader()->pageDismissalEventBeingDispatched()) { - KURL completeURL = m_doc->completeURL(url); + KURL completeURL = m_document->completeURL(url); if (completeURL.isValid() && canRequest(CachedResource::ImageResource, completeURL)) PingLoader::loadImage(f, completeURL); return 0; @@ -203,7 +203,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url break; #if ENABLE(XSLT) case CachedResource::XSLStyleSheet: - if (!m_doc->securityOrigin()->canRequest(url)) { + if (!m_document->securityOrigin()->canRequest(url)) { printAccessDeniedMessage(url); return false; } @@ -228,7 +228,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url #endif // These resource can inject script into the current document. if (Frame* f = frame()) - f->loader()->checkIfRunInsecureContent(m_doc->securityOrigin(), url); + f->loader()->checkIfRunInsecureContent(m_document->securityOrigin(), url); break; case CachedResource::ImageResource: case CachedResource::CSSStyleSheet: @@ -255,7 +255,7 @@ bool CachedResourceLoader::canRequest(CachedResource::Type type, const KURL& url CachedResource* CachedResourceLoader::requestResource(CachedResource::Type type, const String& url, const String& charset, bool isPreload) { - KURL fullURL = m_doc->completeURL(url); + KURL fullURL = m_document->completeURL(url); if (!fullURL.isValid() || !canRequest(type, fullURL)) return 0; @@ -296,9 +296,9 @@ void CachedResourceLoader::printAccessDeniedMessage(const KURL& url) const if (!settings || settings->privateBrowsingEnabled()) return; - String message = m_doc->url().isNull() ? + String message = m_document->url().isNull() ? makeString("Unsafe attempt to load URL ", url.string(), '.') : - makeString("Unsafe attempt to load URL ", url.string(), " from frame with URL ", m_doc->url().string(), ". Domains, protocols and ports must match.\n"); + makeString("Unsafe attempt to load URL ", url.string(), " from frame with URL ", m_document->url().string(), ". Domains, protocols and ports must match.\n"); // FIXME: provide a real line number and source URL. frame()->domWindow()->console()->addMessage(OtherMessageSource, LogMessageType, ErrorMessageLevel, message, 1, String()); @@ -423,7 +423,7 @@ int CachedResourceLoader::requestCount() void CachedResourceLoader::preload(CachedResource::Type type, const String& url, const String& charset, bool referencedFromBody) { - bool hasRendering = m_doc->body() && m_doc->body()->renderer(); + bool hasRendering = m_document->body() && m_document->body()->renderer(); if (!hasRendering && (referencedFromBody || type == CachedResource::ImageResource)) { // Don't preload images or body resources before we have something to draw. This prevents // preloads from body delaying first display when bandwidth is limited. @@ -437,12 +437,12 @@ void CachedResourceLoader::preload(CachedResource::Type type, const String& url, void CachedResourceLoader::checkForPendingPreloads() { unsigned count = m_pendingPreloads.size(); - if (!count || !m_doc->body() || !m_doc->body()->renderer()) + if (!count || !m_document->body() || !m_document->body()->renderer()) return; for (unsigned i = 0; i < count; ++i) { PendingPreload& preload = m_pendingPreloads[i]; // Don't request preload if the resource already loaded normally (this will result in double load if the page is being reloaded with cached results ignored). - if (!cachedResource(m_doc->completeURL(preload.m_url))) + if (!cachedResource(m_document->completeURL(preload.m_url))) requestPreload(preload.m_type, preload.m_url, preload.m_charset); } m_pendingPreloads.clear(); @@ -452,7 +452,7 @@ void CachedResourceLoader::requestPreload(CachedResource::Type type, const Strin { String encoding; if (type == CachedResource::Script || type == CachedResource::CSSStyleSheet) - encoding = charset.isEmpty() ? m_doc->frame()->loader()->writer()->encoding() : charset; + encoding = charset.isEmpty() ? m_document->frame()->loader()->writer()->encoding() : charset; CachedResource* resource = requestResource(type, url, encoding, true); if (!resource || (m_preloads && m_preloads->contains(resource))) diff --git a/WebCore/loader/CachedResourceLoader.h b/WebCore/loader/cache/CachedResourceLoader.h index 16d73ad..eaed52e 100644 --- a/WebCore/loader/CachedResourceLoader.h +++ b/WebCore/loader/cache/CachedResourceLoader.h @@ -48,7 +48,7 @@ class KURL; // The CachedResourceLoader manages the loading of scripts/images/stylesheets for a single document. class CachedResourceLoader : public Noncopyable { -friend class Cache; +friend class MemoryCache; friend class ImageLoader; public: @@ -88,7 +88,7 @@ public: CachePolicy cachePolicy() const; Frame* frame() const; // Can be NULL - Document* doc() const { return m_doc; } + Document* document() const { return m_document; } void removeCachedResource(CachedResource*) const; @@ -115,10 +115,10 @@ private: void checkCacheObjectStatus(CachedResource*); bool canRequest(CachedResource::Type, const KURL&); - Cache* m_cache; + MemoryCache* m_cache; HashSet<String> m_reloadedURLs; mutable DocumentResourceMap m_documentResources; - Document* m_doc; + Document* m_document; int m_requestCount; diff --git a/WebCore/loader/CachedScript.cpp b/WebCore/loader/cache/CachedScript.cpp index 1898438..50a8c17 100644 --- a/WebCore/loader/CachedScript.cpp +++ b/WebCore/loader/cache/CachedScript.cpp @@ -27,7 +27,7 @@ #include "config.h" #include "CachedScript.h" -#include "Cache.h" +#include "MemoryCache.h" #include "CachedResourceClient.h" #include "CachedResourceClientWalker.h" #include "SharedBuffer.h" @@ -111,7 +111,7 @@ void CachedScript::destroyDecodedData() { m_script = String(); setDecodedSize(0); - if (!Cache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable()) + if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() && isSafeToMakePurgeable()) makePurgeable(true); } diff --git a/WebCore/loader/CachedScript.h b/WebCore/loader/cache/CachedScript.h index 1bc4e8c..7311f9b 100644 --- a/WebCore/loader/CachedScript.h +++ b/WebCore/loader/cache/CachedScript.h @@ -54,6 +54,7 @@ namespace WebCore { private: void decodedDataDeletionTimerFired(Timer<CachedScript>*); + virtual PurgePriority purgePriority() const { return PurgeLast; } String m_script; RefPtr<TextResourceDecoder> m_decoder; diff --git a/WebCore/loader/CachedXSLStyleSheet.cpp b/WebCore/loader/cache/CachedXSLStyleSheet.cpp index 5b30e30..5b30e30 100644 --- a/WebCore/loader/CachedXSLStyleSheet.cpp +++ b/WebCore/loader/cache/CachedXSLStyleSheet.cpp diff --git a/WebCore/loader/CachedXSLStyleSheet.h b/WebCore/loader/cache/CachedXSLStyleSheet.h index 8587b0b..8587b0b 100644 --- a/WebCore/loader/CachedXSLStyleSheet.h +++ b/WebCore/loader/cache/CachedXSLStyleSheet.h diff --git a/WebCore/loader/Cache.cpp b/WebCore/loader/cache/MemoryCache.cpp index 7dc8a32..25af774 100644 --- a/WebCore/loader/Cache.cpp +++ b/WebCore/loader/cache/MemoryCache.cpp @@ -21,7 +21,7 @@ */ #include "config.h" -#include "Cache.h" +#include "MemoryCache.h" #include "CachedCSSStyleSheet.h" #include "CachedFont.h" @@ -49,13 +49,13 @@ static const double cMinDelayBeforeLiveDecodedPrune = 1; // Seconds. static const float cTargetPrunePercentage = .95f; // Percentage of capacity toward which we prune, to avoid immediately pruning again. static const double cDefaultDecodedDataDeletionInterval = 0; -Cache* cache() +MemoryCache* cache() { - static Cache* staticCache = new Cache; + static MemoryCache* staticCache = new MemoryCache; return staticCache; } -Cache::Cache() +MemoryCache::MemoryCache() : m_disabled(false) , m_pruneEnabled(true) , m_inPruneDeadResources(false) @@ -94,9 +94,9 @@ static CachedResource* createResource(CachedResource::Type type, const KURL& url return 0; } -CachedResource* Cache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload) +CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload) { - LOG(ResourceLoading, "Cache::requestResource '%s', charset '%s', preload=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload); + LOG(ResourceLoading, "MemoryCache::requestResource '%s', charset '%s', preload=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload); // FIXME: Do we really need to special-case an empty URL? // Would it be better to just go on with the cache code and let it fail later? @@ -107,14 +107,14 @@ CachedResource* Cache::requestResource(CachedResourceLoader* cachedResourceLoade CachedResource* resource = resourceForURL(url.string()); if (resource && requestIsPreload && !resource->isPreloaded()) { - LOG(ResourceLoading, "Cache::requestResource already has a preload request for this request, and it hasn't been preloaded yet"); + LOG(ResourceLoading, "MemoryCache::requestResource already has a preload request for this request, and it hasn't been preloaded yet"); return 0; } - if (!cachedResourceLoader->doc()->securityOrigin()->canDisplay(url)) { + if (!cachedResourceLoader->document()->securityOrigin()->canDisplay(url)) { LOG(ResourceLoading, "...URL was not allowed by SecurityOrigin"); if (!requestIsPreload) - FrameLoader::reportLocalLoadFailed(cachedResourceLoader->doc()->frame(), url.string()); + FrameLoader::reportLocalLoadFailed(cachedResourceLoader->document()->frame(), url.string()); return 0; } @@ -149,7 +149,7 @@ CachedResource* Cache::requestResource(CachedResourceLoader* cachedResourceLoade } if (resource->type() != type) { - LOG(ResourceLoading, "Cache::requestResource cannot use cached resource for '%s' due to type mismatch", url.string().latin1().data()); + LOG(ResourceLoading, "MemoryCache::requestResource cannot use cached resource for '%s' due to type mismatch", url.string().latin1().data()); return 0; } @@ -158,12 +158,12 @@ CachedResource* Cache::requestResource(CachedResourceLoader* cachedResourceLoade resourceAccessed(resource); } - LOG(ResourceLoading, "Cache::requestResource for '%s' returning resource %p\n", url.string().latin1().data(), resource); + LOG(ResourceLoading, "MemoryCache::requestResource for '%s' returning resource %p\n", url.string().latin1().data(), resource); return resource; } -CachedCSSStyleSheet* Cache::requestUserCSSStyleSheet(CachedResourceLoader* cachedResourceLoader, const String& url, const String& charset) +CachedCSSStyleSheet* MemoryCache::requestUserCSSStyleSheet(CachedResourceLoader* cachedResourceLoader, const String& url, const String& charset) { CachedCSSStyleSheet* userSheet; if (CachedResource* existing = resourceForURL(url)) { @@ -192,7 +192,7 @@ CachedCSSStyleSheet* Cache::requestUserCSSStyleSheet(CachedResourceLoader* cache return userSheet; } -void Cache::revalidateResource(CachedResource* resource, CachedResourceLoader* cachedResourceLoader) +void MemoryCache::revalidateResource(CachedResource* resource, CachedResourceLoader* cachedResourceLoader) { ASSERT(resource); ASSERT(resource->inCache()); @@ -215,7 +215,7 @@ void Cache::revalidateResource(CachedResource* resource, CachedResourceLoader* c newResource->load(cachedResourceLoader); } -void Cache::revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse& response) +void MemoryCache::revalidationSucceeded(CachedResource* revalidatingResource, const ResourceResponse& response) { CachedResource* resource = revalidatingResource->resourceToRevalidate(); ASSERT(resource); @@ -241,17 +241,17 @@ void Cache::revalidationSucceeded(CachedResource* revalidatingResource, const Re revalidatingResource->clearResourceToRevalidate(); } -void Cache::revalidationFailed(CachedResource* revalidatingResource) +void MemoryCache::revalidationFailed(CachedResource* revalidatingResource) { LOG(ResourceLoading, "Revalidation failed for %p", revalidatingResource); ASSERT(revalidatingResource->resourceToRevalidate()); revalidatingResource->clearResourceToRevalidate(); } -CachedResource* Cache::resourceForURL(const String& url) +CachedResource* MemoryCache::resourceForURL(const String& url) { CachedResource* resource = m_resources.get(url); - bool wasPurgeable = Cache::shouldMakeResourcePurgeableOnEviction() && resource && resource->isPurgeable(); + bool wasPurgeable = MemoryCache::shouldMakeResourcePurgeableOnEviction() && resource && resource->isPurgeable(); if (resource && !resource->makePurgeable(false)) { ASSERT(!resource->hasClients()); evict(resource); @@ -263,7 +263,7 @@ CachedResource* Cache::resourceForURL(const String& url) return resource; } -unsigned Cache::deadCapacity() const +unsigned MemoryCache::deadCapacity() const { // Dead resource capacity is whatever space is not occupied by live resources, bounded by an independent minimum and maximum. unsigned capacity = m_capacity - min(m_liveSize, m_capacity); // Start with available capacity. @@ -272,13 +272,13 @@ unsigned Cache::deadCapacity() const return capacity; } -unsigned Cache::liveCapacity() const +unsigned MemoryCache::liveCapacity() const { // Live resource capacity is whatever is left over after calculating dead resource capacity. return m_capacity - deadCapacity(); } -void Cache::pruneLiveResources() +void MemoryCache::pruneLiveResources() { if (!m_pruneEnabled) return; @@ -322,7 +322,7 @@ void Cache::pruneLiveResources() } } -void Cache::pruneDeadResources() +void MemoryCache::pruneDeadResources() { if (!m_pruneEnabled) return; @@ -406,7 +406,7 @@ void Cache::pruneDeadResources() m_inPruneDeadResources = false; } -void Cache::setCapacities(unsigned minDeadBytes, unsigned maxDeadBytes, unsigned totalBytes) +void MemoryCache::setCapacities(unsigned minDeadBytes, unsigned maxDeadBytes, unsigned totalBytes) { ASSERT(minDeadBytes <= maxDeadBytes); ASSERT(maxDeadBytes <= totalBytes); @@ -416,9 +416,9 @@ void Cache::setCapacities(unsigned minDeadBytes, unsigned maxDeadBytes, unsigned prune(); } -bool Cache::makeResourcePurgeable(CachedResource* resource) +bool MemoryCache::makeResourcePurgeable(CachedResource* resource) { - if (!Cache::shouldMakeResourcePurgeableOnEviction()) + if (!MemoryCache::shouldMakeResourcePurgeableOnEviction()) return false; if (!resource->inCache()) @@ -438,7 +438,7 @@ bool Cache::makeResourcePurgeable(CachedResource* resource) return true; } -void Cache::evict(CachedResource* resource) +void MemoryCache::evict(CachedResource* resource) { LOG(ResourceLoading, "Evicting resource %p for '%s' from cache", resource, resource->url().latin1().data()); // The resource may have already been removed by someone other than our caller, @@ -455,7 +455,7 @@ void Cache::evict(CachedResource* resource) // If the resource was purged, it means we had already decremented the size when we made the // resource purgeable in makeResourcePurgeable(). So adjust the size if we are evicting a // resource that was not marked as purgeable. - if (!Cache::shouldMakeResourcePurgeableOnEviction() || !resource->isPurgeable()) + if (!MemoryCache::shouldMakeResourcePurgeableOnEviction() || !resource->isPurgeable()) adjustSize(resource->hasClients(), -static_cast<int>(resource->size())); } else ASSERT(m_resources.get(resource->url()) != resource); @@ -464,12 +464,12 @@ void Cache::evict(CachedResource* resource) delete resource; } -void Cache::addCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) +void MemoryCache::addCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) { m_cachedResourceLoaders.add(cachedResourceLoader); } -void Cache::removeCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) +void MemoryCache::removeCachedResourceLoader(CachedResourceLoader* cachedResourceLoader) { m_cachedResourceLoaders.remove(cachedResourceLoader); } @@ -492,7 +492,7 @@ static inline unsigned fastLog2(unsigned i) return log2; } -Cache::LRUList* Cache::lruListFor(CachedResource* resource) +MemoryCache::LRUList* MemoryCache::lruListFor(CachedResource* resource) { unsigned accessCount = max(resource->accessCount(), 1U); unsigned queueIndex = fastLog2(resource->size() / accessCount); @@ -504,7 +504,7 @@ Cache::LRUList* Cache::lruListFor(CachedResource* resource) return &m_allResources[queueIndex]; } -void Cache::removeFromLRUList(CachedResource* resource) +void MemoryCache::removeFromLRUList(CachedResource* resource) { // If we've never been accessed, then we're brand new and not in any list. if (resource->accessCount() == 0) @@ -551,7 +551,7 @@ void Cache::removeFromLRUList(CachedResource* resource) list->m_head = next; } -void Cache::insertInLRUList(CachedResource* resource) +void MemoryCache::insertInLRUList(CachedResource* resource) { // Make sure we aren't in some list already. ASSERT(!resource->m_nextInAllResourcesList && !resource->m_prevInAllResourcesList); @@ -583,7 +583,7 @@ void Cache::insertInLRUList(CachedResource* resource) } -void Cache::resourceAccessed(CachedResource* resource) +void MemoryCache::resourceAccessed(CachedResource* resource) { ASSERT(resource->inCache()); @@ -602,7 +602,7 @@ void Cache::resourceAccessed(CachedResource* resource) insertInLRUList(resource); } -void Cache::removeFromLiveDecodedResourcesList(CachedResource* resource) +void MemoryCache::removeFromLiveDecodedResourcesList(CachedResource* resource) { // If we've never been accessed, then we're brand new and not in any list. if (!resource->m_inLiveDecodedResourcesList) @@ -641,7 +641,7 @@ void Cache::removeFromLiveDecodedResourcesList(CachedResource* resource) m_liveDecodedResources.m_head = next; } -void Cache::insertInLiveDecodedResourcesList(CachedResource* resource) +void MemoryCache::insertInLiveDecodedResourcesList(CachedResource* resource) { // Make sure we aren't in the list already. ASSERT(!resource->m_nextInLiveResourcesList && !resource->m_prevInLiveResourcesList && !resource->m_inLiveDecodedResourcesList); @@ -669,19 +669,19 @@ void Cache::insertInLiveDecodedResourcesList(CachedResource* resource) } -void Cache::addToLiveResourcesSize(CachedResource* resource) +void MemoryCache::addToLiveResourcesSize(CachedResource* resource) { m_liveSize += resource->size(); m_deadSize -= resource->size(); } -void Cache::removeFromLiveResourcesSize(CachedResource* resource) +void MemoryCache::removeFromLiveResourcesSize(CachedResource* resource) { m_liveSize -= resource->size(); m_deadSize += resource->size(); } -void Cache::adjustSize(bool live, int delta) +void MemoryCache::adjustSize(bool live, int delta) { if (live) { ASSERT(delta >= 0 || ((int)m_liveSize + delta >= 0)); @@ -692,7 +692,7 @@ void Cache::adjustSize(bool live, int delta) } } -void Cache::TypeStatistic::addResource(CachedResource* o) +void MemoryCache::TypeStatistic::addResource(CachedResource* o) { bool purged = o->wasPurged(); bool purgeable = o->isPurgeable() && !purged; @@ -705,7 +705,7 @@ void Cache::TypeStatistic::addResource(CachedResource* o) purgedSize += purged ? pageSize : 0; } -Cache::Statistics Cache::getStatistics() +MemoryCache::Statistics MemoryCache::getStatistics() { Statistics stats; CachedResourceMap::iterator e = m_resources.end(); @@ -736,7 +736,7 @@ Cache::Statistics Cache::getStatistics() return stats; } -void Cache::setDisabled(bool disabled) +void MemoryCache::setDisabled(bool disabled) { m_disabled = disabled; if (!m_disabled) @@ -751,7 +751,7 @@ void Cache::setDisabled(bool disabled) } #ifndef NDEBUG -void Cache::dumpStats() +void MemoryCache::dumpStats() { Statistics s = getStatistics(); printf("%-13s %-13s %-13s %-13s %-13s %-13s %-13s\n", "", "Count", "Size", "LiveSize", "DecodedSize", "PurgeableSize", "PurgedSize"); @@ -766,7 +766,7 @@ void Cache::dumpStats() printf("%-13s %-13s %-13s %-13s %-13s %-13s %-13s\n\n", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------", "-------------"); } -void Cache::dumpLRULists(bool includeLive) const +void MemoryCache::dumpLRULists(bool includeLive) const { printf("LRU-SP lists in eviction order (Kilobytes decoded, Kilobytes encoded, Access count, Referenced, isPurgeable, wasPurged):\n"); diff --git a/WebCore/loader/Cache.h b/WebCore/loader/cache/MemoryCache.h index eb5b398..a40f85e 100644 --- a/WebCore/loader/Cache.h +++ b/WebCore/loader/cache/MemoryCache.h @@ -71,9 +71,9 @@ class KURL; // its member variables) are allocated in non-purgeable TC-malloc'd memory so we would see slightly // more memory use due to this. -class Cache : public Noncopyable { +class MemoryCache : public Noncopyable { public: - friend Cache* cache(); + friend MemoryCache* cache(); typedef HashMap<String, CachedResource*> CachedResourceMap; @@ -175,8 +175,8 @@ public: #endif private: - Cache(); - ~Cache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons. + MemoryCache(); + ~MemoryCache(); // Not implemented to make sure nobody accidentally calls delete -- WebCore does not delete singletons. LRUList* lruListFor(CachedResource*); void resourceAccessed(CachedResource*); @@ -223,7 +223,7 @@ private: HashMap<String, CachedResource*> m_resources; }; -inline bool Cache::shouldMakeResourcePurgeableOnEviction() +inline bool MemoryCache::shouldMakeResourcePurgeableOnEviction() { #if PLATFORM(IOS) return true; @@ -233,7 +233,7 @@ inline bool Cache::shouldMakeResourcePurgeableOnEviction() } // Function to obtain the global cache. -Cache* cache(); +MemoryCache* cache(); } diff --git a/WebCore/loader/loader.cpp b/WebCore/loader/loader.cpp index aa3f246..bd27312 100644 --- a/WebCore/loader/loader.cpp +++ b/WebCore/loader/loader.cpp @@ -24,7 +24,7 @@ #include "config.h" #include "loader.h" -#include "Cache.h" +#include "MemoryCache.h" #include "CachedImage.h" #include "CachedResource.h" #include "CachedResourceLoader.h" @@ -151,7 +151,7 @@ void Loader::load(CachedResourceLoader* cachedResourceLoader, CachedResource* re host->servePendingRequests(priority); } else { // Handle asynchronously so early low priority requests don't get scheduled before later high priority ones - InspectorInstrumentation::didScheduleResourceRequest(cachedResourceLoader->doc(), resource->url()); + InspectorInstrumentation::didScheduleResourceRequest(cachedResourceLoader->document(), resource->url()); scheduleServePendingRequests(); } } @@ -334,7 +334,7 @@ void Loader::Host::servePendingRequests(RequestQueue& requestsPending, bool& ser // For named hosts - which are only http(s) hosts - we should always enforce the connection limit. // For non-named hosts - everything but http(s) - we should only enforce the limit if the document isn't done parsing // and we don't know all stylesheets yet. - bool shouldLimitRequests = !m_name.isNull() || cachedResourceLoader->doc()->parsing() || !cachedResourceLoader->doc()->haveStylesheetsLoaded(); + bool shouldLimitRequests = !m_name.isNull() || cachedResourceLoader->document()->parsing() || !cachedResourceLoader->document()->haveStylesheetsLoaded(); if (shouldLimitRequests && m_requestsLoading.size() + m_nonCachedRequestsInFlight >= m_maxRequestsInFlight) { serveLowerPriority = false; return; @@ -368,10 +368,10 @@ void Loader::Host::servePendingRequests(RequestQueue& requestsPending, bool& ser #if ENABLE(LINK_PREFETCH) if (request->cachedResource()->type() == CachedResource::LinkPrefetch) - resourceRequest.setHTTPHeaderField("X-Purpose", "prefetch"); + resourceRequest.setHTTPHeaderField("Purpose", "prefetch"); #endif - RefPtr<SubresourceLoader> loader = SubresourceLoader::create(cachedResourceLoader->doc()->frame(), + RefPtr<SubresourceLoader> loader = SubresourceLoader::create(cachedResourceLoader->document()->frame(), this, resourceRequest, request->shouldDoSecurityCheck(), request->sendResourceLoadCallbacks()); if (loader) { m_requestsLoading.add(loader.release(), request); @@ -405,7 +405,7 @@ void Loader::Host::didFinishLoading(SubresourceLoader* loader) CachedResourceLoader* cachedResourceLoader = request->cachedResourceLoader(); // Prevent the document from being destroyed before we are done with // the cachedResourceLoader that it will delete when the document gets deleted. - RefPtr<Document> protector(cachedResourceLoader->doc()); + RefPtr<Document> protector(cachedResourceLoader->document()); if (!request->isMultipart()) cachedResourceLoader->decrementRequestCount(request->cachedResource()); @@ -451,7 +451,7 @@ void Loader::Host::didFail(SubresourceLoader* loader, bool cancelled) CachedResourceLoader* cachedResourceLoader = request->cachedResourceLoader(); // Prevent the document from being destroyed before we are done with // the cachedResourceLoader that it will delete when the document gets deleted. - RefPtr<Document> protector(cachedResourceLoader->doc()); + RefPtr<Document> protector(cachedResourceLoader->document()); if (!request->isMultipart()) cachedResourceLoader->decrementRequestCount(request->cachedResource()); |