Chromium Code Reviews| Index: Source/core/loader/FrameLoader.cpp |
| diff --git a/Source/core/loader/FrameLoader.cpp b/Source/core/loader/FrameLoader.cpp |
| index fbf6d9da03013f45873bb4fdc35a980b843ac465..a7033da6620a026a5cb296aa21a9d55ccd7b9d47 100644 |
| --- a/Source/core/loader/FrameLoader.cpp |
| +++ b/Source/core/loader/FrameLoader.cpp |
| @@ -70,6 +70,7 @@ |
| #include "core/loader/ProgressTracker.h" |
| #include "core/loader/UniqueIdentifier.h" |
| #include "core/loader/appcache/ApplicationCacheHost.h" |
| +#include "core/page/BackForwardClient.h" |
| #include "core/page/Chrome.h" |
| #include "core/page/ChromeClient.h" |
| #include "core/page/EventHandler.h" |
| @@ -153,7 +154,7 @@ private: |
| FrameLoader::FrameLoader(Frame* frame, FrameLoaderClient* client) |
| : m_frame(frame) |
| , m_client(client) |
| - , m_history(frame) |
| + , m_history(frame->page()->history()) |
|
abarth-chromium
2013/10/29 20:36:58
Don't we need to clear out m_history when the Fram
|
| , m_icon(adoptPtr(new IconController(frame))) |
| , m_fetchContext(FrameFetchContext::create(frame)) |
| , m_mixedContentChecker(frame) |
| @@ -235,7 +236,7 @@ void FrameLoader::stopLoading() |
| bool FrameLoader::closeURL() |
| { |
| - history()->saveDocumentAndScrollState(); |
| + history()->saveDocumentAndScrollState(m_frame); |
| // Should only send the pagehide event here if the current document exists. |
| if (m_frame->document()) |
| @@ -328,8 +329,9 @@ void FrameLoader::didBeginDocument(bool dispatch) |
| m_isComplete = false; |
| m_frame->document()->setReadyState(Document::Loading); |
| - if (history()->currentItem() && m_loadType == FrameLoadTypeBackForward) |
| - m_frame->document()->statePopped(history()->currentItem()->stateObject()); |
| + if (history()->currentItem(m_frame) && m_loadType == FrameLoadTypeBackForward) { |
| + m_frame->document()->statePopped(history()->currentItem(m_frame)->stateObject()); |
| + } |
| if (dispatch) |
| dispatchDidClearWindowObjectsInAllWorlds(); |
| @@ -357,7 +359,7 @@ void FrameLoader::didBeginDocument(bool dispatch) |
| } |
| } |
| - history()->restoreDocumentState(); |
| + history()->restoreDocumentState(m_frame); |
| } |
| void FrameLoader::finishedParsing() |
| @@ -537,14 +539,14 @@ void FrameLoader::updateForSameDocumentNavigation(const KURL& newURL, SameDocume |
| // replaceRequestURLForSameDocumentNavigation(), since we add based on |
| // the current request. |
| if (updateBackForwardList == UpdateBackForwardList) |
| - history()->updateBackForwardListForFragmentScroll(); |
| + history()->updateBackForwardListForFragmentScroll(m_frame); |
| if (sameDocumentNavigationSource == SameDocumentNavigationDefault) |
| - history()->updateForSameDocumentNavigation(); |
| + history()->updateForSameDocumentNavigation(m_frame); |
| else if (sameDocumentNavigationSource == SameDocumentNavigationPushState) |
| - history()->pushState(data, newURL.string()); |
| + history()->pushState(m_frame, data, newURL.string()); |
| else if (sameDocumentNavigationSource == SameDocumentNavigationReplaceState) |
| - history()->replaceState(data, newURL.string()); |
| + history()->replaceState(m_frame, data, newURL.string()); |
| else |
| ASSERT_NOT_REACHED(); |
| @@ -622,16 +624,6 @@ void FrameLoader::started() |
| void FrameLoader::prepareForHistoryNavigation() |
| { |
| - // If there is no currentItem, but we still want to engage in |
| - // history navigation we need to manufacture one, and update |
| - // the state machine of this frame to impersonate having |
| - // loaded it. |
| - RefPtr<HistoryItem> currentItem = history()->currentItem(); |
| - if (!currentItem) { |
| - insertDummyHistoryItem(); |
| - ASSERT(stateMachine()->isDisplayingInitialEmptyDocument()); |
| - stateMachine()->advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad); |
| - } |
| } |
| void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSendReferrer shouldSendReferrer) |
| @@ -665,7 +657,7 @@ FrameLoadType FrameLoader::determineFrameLoadType(const FrameLoadRequest& reques |
| { |
| if (m_frame->tree().parent() && !m_stateMachine.startedFirstRealLoad()) |
| return FrameLoadTypeInitialInChildFrame; |
| - if (!m_frame->tree().parent() && !history()->currentItem()) |
| + if (!m_frame->tree().parent() && !m_frame->page()->backForward().backForwardListCount()) |
| return FrameLoadTypeStandard; |
| if (request.resourceRequest().cachePolicy() == ReloadIgnoringCacheData) |
| return FrameLoadTypeReload; |
| @@ -786,9 +778,6 @@ void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con |
| if (!documentLoader) |
| return; |
| - if (m_state == FrameStateProvisional) |
| - insertDummyHistoryItem(); |
| - |
| ResourceRequest request = documentLoader->request(); |
| // FIXME: We need to reset cache policy to prevent it from being incorrectly propagted to the reload. |
| // Do we need to propagate anything other than the url? |
| @@ -907,7 +896,7 @@ void FrameLoader::commitProvisionalLoad() |
| if (isLoadingMainFrame()) |
| m_frame->page()->chrome().client().needTouchEvents(false); |
| - history()->updateForCommit(); |
| + history()->updateForCommit(m_frame); |
| m_client->transitionToCommittedForNewPage(); |
| m_frame->navigationScheduler().cancel(); |
| @@ -1023,7 +1012,7 @@ void FrameLoader::checkLoadCompleteForThisFrame() |
| // If the user had a scroll point, scroll to it, overriding the anchor point if any. |
| if (m_frame->page()) { |
| if (isBackForwardLoadType(m_loadType) || m_loadType == FrameLoadTypeReload || m_loadType == FrameLoadTypeReloadFromOrigin) |
| - history()->restoreScrollPositionAndViewState(); |
| + history()->restoreScrollPositionAndViewState(m_frame); |
| } |
| if (!m_stateMachine.committedFirstRealDocumentLoad()) |
| @@ -1042,7 +1031,7 @@ void FrameLoader::checkLoadCompleteForThisFrame() |
| void FrameLoader::didFirstLayout() |
| { |
| if (m_frame->page() && isBackForwardLoadType(m_loadType)) |
| - history()->restoreScrollPositionAndViewState(); |
| + history()->restoreScrollPositionAndViewState(m_frame); |
| } |
| void FrameLoader::detachChildren() |
| @@ -1249,7 +1238,7 @@ void FrameLoader::checkNavigationPolicyAndContinueFragmentScroll(const Navigatio |
| m_provisionalDocumentLoader->detachFromFrame(); |
| m_provisionalDocumentLoader = 0; |
| } |
| - history()->setProvisionalItem(0); |
| + history()->clearProvisionalEntry(); |
| loadInSameDocument(request.url(), 0, isNewNavigation); |
| } |
| @@ -1489,9 +1478,7 @@ bool FrameLoader::shouldInterruptLoadForXFrameOptions(const String& content, con |
| bool FrameLoader::shouldTreatURLAsSameAsCurrent(const KURL& url) const |
| { |
| - if (!history()->currentItem()) |
| - return false; |
| - return url == history()->currentItem()->url() || url == history()->currentItem()->originalURL(); |
| + return url == m_frame->document()->url() || url == m_documentLoader->originalURL(); |
| } |
| bool FrameLoader::shouldTreatURLAsSrcdocDocument(const KURL& url) const |
| @@ -1535,19 +1522,13 @@ Frame* FrameLoader::findFrameForNavigation(const AtomicString& name, Document* a |
| return frame; |
| } |
| -void FrameLoader::loadHistoryItem(HistoryItem* item) |
| +void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoadType) |
| { |
| - HistoryItem* currentItem = history()->currentItem(); |
| - |
| - if (currentItem && item->shouldDoSameDocumentNavigationTo(currentItem)) { |
| - history()->setCurrentItem(item); |
| + if (historyLoadType == HistorySameDocumentLoad) { |
| loadInSameDocument(item->url(), item->stateObject(), false); |
| return; |
| } |
| - // Remember this item so we can traverse any child items as child frames load |
| - history()->setProvisionalItem(item); |
| - |
| RefPtr<FormData> formData = item->formData(); |
| ResourceRequest request(item->url()); |
| request.setHTTPReferrer(item->referrer()); |
| @@ -1564,8 +1545,6 @@ void FrameLoader::loadHistoryItem(HistoryItem* item) |
| void FrameLoader::insertDummyHistoryItem() |
| { |
| - RefPtr<HistoryItem> currentItem = HistoryItem::create(); |
| - history()->setCurrentItem(currentItem.get()); |
| } |
| void FrameLoader::dispatchDocumentElementAvailable() |