Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2653673006: Move loadType() to DocumentLoader (Closed)
Patch Set: Move loadType() to DocumentLoader Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/loader/FrameLoader.cpp
diff --git a/third_party/WebKit/Source/core/loader/FrameLoader.cpp b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
index 669c20af2972c42385ca57ad8af63ba7e57d3649..d0064eeb2214e66fda92657d53bc5471c909ad94 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -183,7 +183,6 @@ ResourceRequest FrameLoader::resourceRequestForReload(
FrameLoader::FrameLoader(LocalFrame* frame)
: m_frame(frame),
m_progressTracker(ProgressTracker::create(frame)),
- m_loadType(FrameLoadTypeStandard),
m_inStopAllLoaders(false),
m_checkTimer(TaskRunnerHelper::get(TaskType::Networking, frame),
this,
@@ -271,7 +270,8 @@ void FrameLoader::saveScrollState() {
return;
// Shouldn't clobber anything if we might still restore later.
- if (needsHistoryItemRestore(m_loadType) && m_documentLoader &&
+ if (m_documentLoader &&
+ needsHistoryItemRestore(m_documentLoader->loadType()) &&
!m_documentLoader->initialScrollState().wasScrolledByUser)
return;
@@ -310,7 +310,7 @@ void FrameLoader::didExplicitOpen() {
if ((parent->isLocalFrame() &&
toLocalFrame(parent)->document()->loadEventStillNeeded()) ||
(parent->isRemoteFrame() && parent->isLoading())) {
- m_progressTracker->progressStarted();
+ m_progressTracker->progressStarted(m_documentLoader->loadType());
}
}
@@ -458,17 +458,18 @@ void FrameLoader::receivedFirstData() {
if (m_stateMachine.creatingInitialEmptyDocument())
return;
- HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType);
+ FrameLoadType loadType = m_documentLoader->loadType();
+ HistoryCommitType historyCommitType = loadTypeToCommitType(loadType);
if (historyCommitType == StandardCommit &&
(m_documentLoader->urlForHistory().isEmpty() ||
(opener() && !m_currentItem &&
m_documentLoader->originalRequest().url().isEmpty())))
historyCommitType = HistoryInertCommit;
- setHistoryItemStateForCommit(m_loadType, historyCommitType,
+ setHistoryItemStateForCommit(loadType, historyCommitType,
HistoryNavigationType::DifferentDocument);
if (!m_stateMachine.committedMultipleRealLoads() &&
- m_loadType == FrameLoadTypeStandard) {
+ loadType == FrameLoadTypeStandard) {
m_stateMachine.advanceTo(
FrameLoaderStateMachine::CommittedMultipleRealLoads);
}
@@ -516,7 +517,8 @@ void FrameLoader::didInstallNewDocument(bool dispatchWindowObjectAvailable) {
m_documentLoader ? m_documentLoader->releaseContentSecurityPolicy()
: ContentSecurityPolicy::create());
- if (m_provisionalItem && isBackForwardLoadType(m_loadType)) {
+ if (m_provisionalItem &&
+ isBackForwardLoadType(m_documentLoader->loadType())) {
m_frame->document()->setStateForNewFormElements(
m_provisionalItem->getDocumentState());
}
@@ -642,7 +644,8 @@ void FrameLoader::finishedParsing() {
// Check if the scrollbars are really needed for the content. If not, remove
// them, relayout, and repaint.
m_frame->view()->restoreScrollbar();
- processFragment(m_frame->document()->url(), NavigationToDifferentDocument);
+ processFragment(m_frame->document()->url(), m_documentLoader->loadType(),
+ NavigationToDifferentDocument);
}
static bool allDescendantsAreComplete(Frame* frame) {
@@ -744,8 +747,8 @@ void FrameLoader::checkCompleted() {
// Retry restoring scroll offset since finishing loading disables content
// size clamping.
restoreScrollPositionAndViewState();
-
- m_loadType = FrameLoadTypeStandard;
+ if (m_documentLoader)
yhirano 2017/01/25 06:30:43 Can you tell me when |m_documentLoader| is null?
Nate Chapin 2017/01/25 17:25:29 m_documentLoader is null: * In a narrow window dur
+ m_documentLoader->setLoadType(FrameLoadTypeStandard);
m_frame->domWindow()->finishedLoading();
}
@@ -860,7 +863,6 @@ void FrameLoader::loadInSameDocument(
detachDocumentLoader(m_provisionalDocumentLoader);
if (!m_frame->host())
return;
- AutoReset<FrameLoadType> loadTypeChange(&m_loadType, frameLoadType);
saveScrollState();
KURL oldURL = m_frame->document()->url();
@@ -887,11 +889,11 @@ void FrameLoader::loadInSameDocument(
: SerializedScriptValue::nullValue());
if (historyLoadType == HistorySameDocumentLoad)
- restoreScrollPositionAndViewState();
+ restoreScrollPositionAndViewStateForLoadType(frameLoadType);
// We need to scroll to the fragment whether or not a hash change occurred,
// since the user might have scrolled since the previous navigation.
- processFragment(url, NavigationWithinSameDocument);
+ processFragment(url, frameLoadType, NavigationWithinSameDocument);
takeObjectSnapshot();
}
@@ -930,7 +932,7 @@ FrameLoadType FrameLoader::determineFrameLoadType(
if (m_provisionalDocumentLoader &&
request.substituteData().failingURL() ==
m_provisionalDocumentLoader->url() &&
- m_loadType == FrameLoadTypeBackForward)
+ m_provisionalDocumentLoader->loadType() == FrameLoadTypeBackForward)
return FrameLoadTypeBackForward;
if (request.resourceRequest().getCachePolicy() ==
WebCachePolicy::ValidatingCacheData)
@@ -957,7 +959,7 @@ FrameLoadType FrameLoader::determineFrameLoadType(
if (request.substituteData().failingURL() ==
m_documentLoader->urlForHistory() &&
- m_loadType == FrameLoadTypeReload)
+ m_documentLoader->loadType() == FrameLoadTypeReload)
return FrameLoadTypeReload;
if (m_frame->settings()->getHistoryEntryRequiresUserGesture() &&
@@ -1372,19 +1374,20 @@ bool FrameLoader::isLoadingMainFrame() const {
return m_frame->isMainFrame();
}
-FrameLoadType FrameLoader::loadType() const {
- return m_loadType;
+void FrameLoader::restoreScrollPositionAndViewState() {
+ if (!m_frame->page() || !documentLoader())
+ return;
+ restoreScrollPositionAndViewStateForLoadType(documentLoader()->loadType());
}
-void FrameLoader::restoreScrollPositionAndViewState() {
+void FrameLoader::restoreScrollPositionAndViewStateForLoadType(
+ FrameLoadType loadType) {
FrameView* view = m_frame->view();
- if (!m_frame->page() || !view || !view->layoutViewportScrollableArea() ||
- !m_currentItem || !m_stateMachine.committedFirstRealDocumentLoad() ||
- !documentLoader()) {
+ if (!view || !view->layoutViewportScrollableArea() || !m_currentItem ||
+ !m_stateMachine.committedFirstRealDocumentLoad()) {
return;
}
-
- if (!needsHistoryItemRestore(m_loadType))
+ if (!needsHistoryItemRestore(loadType))
return;
bool shouldRestoreScroll =
@@ -1476,7 +1479,8 @@ void FrameLoader::loadFailed(DocumentLoader* loader,
m_frame->deprecatedLocalOwner()->renderFallbackContent();
}
- HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType);
+ HistoryCommitType historyCommitType =
+ loadTypeToCommitType(loader->loadType());
if (loader == m_provisionalDocumentLoader) {
m_provisionalDocumentLoader->setSentDidFinishLoad();
client()->dispatchDidFailProvisionalLoad(error, historyCommitType);
@@ -1512,6 +1516,7 @@ bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission,
}
void FrameLoader::processFragment(const KURL& url,
+ FrameLoadType frameLoadType,
LoadStartType loadStartType) {
FrameView* view = m_frame->view();
if (!view)
@@ -1536,7 +1541,7 @@ void FrameLoader::processFragment(const KURL& url,
// is a same document reload.
bool shouldScrollToFragment =
(loadStartType == NavigationWithinSameDocument &&
- !isBackForwardLoadType(m_loadType)) ||
+ !isBackForwardLoadType(frameLoadType)) ||
(documentLoader() &&
!documentLoader()->initialScrollState().didRestoreFromHistory &&
!(m_currentItem &&
@@ -1595,7 +1600,7 @@ bool FrameLoader::shouldContinueForNavigationPolicy(
ContentSecurityPolicyDisposition shouldCheckMainWorldContentSecurityPolicy,
NavigationType type,
NavigationPolicy policy,
- bool replacesCurrentHistoryItem,
+ FrameLoadType frameLoadType,
bool isClientRedirect,
HTMLFormElement* form) {
m_isNavigationHandledByClient = false;
@@ -1632,6 +1637,8 @@ bool FrameLoader::shouldContinueForNavigationPolicy(
request.url()))
return false;
+ bool replacesCurrentHistoryItem =
+ frameLoadType == FrameLoadTypeReplaceCurrentItem;
policy = client()->decidePolicyForNavigation(request, loader, type, policy,
replacesCurrentHistoryItem,
isClientRedirect, form);
@@ -1642,7 +1649,7 @@ bool FrameLoader::shouldContinueForNavigationPolicy(
if (policy == NavigationPolicyHandledByClient) {
m_isNavigationHandledByClient = true;
// Mark the frame as loading since the embedder is handling the navigation.
- m_progressTracker->progressStarted();
+ m_progressTracker->progressStarted(frameLoadType);
m_frame->navigationScheduler().cancel();
@@ -1686,8 +1693,7 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest,
if (!shouldContinueForNavigationPolicy(
resourceRequest, frameLoadRequest.substituteData(), nullptr,
frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(),
- navigationType, navigationPolicy,
- type == FrameLoadTypeReplaceCurrentItem,
+ navigationType, navigationPolicy, type,
frameLoadRequest.clientRedirect() ==
ClientRedirectPolicy::ClientRedirect,
frameLoadRequest.form()))
@@ -1707,18 +1713,17 @@ void FrameLoader::startLoad(FrameLoadRequest& frameLoadRequest,
? frameLoadRequest.substituteData()
: defaultSubstituteDataForURL(resourceRequest.url()),
frameLoadRequest.clientRedirect());
+ m_provisionalDocumentLoader->setLoadType(type);
m_provisionalDocumentLoader->setNavigationType(navigationType);
m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(
type == FrameLoadTypeReplaceCurrentItem);
m_frame->navigationScheduler().cancel();
m_checkTimer.stop();
- m_loadType = type;
-
if (frameLoadRequest.form())
client()->dispatchWillSubmitForm(frameLoadRequest.form());
- m_progressTracker->progressStarted();
+ m_progressTracker->progressStarted(type);
m_provisionalDocumentLoader->appendRedirect(
m_provisionalDocumentLoader->getRequest().url());
client()->dispatchDidStartProvisionalLoad();

Powered by Google App Engine
This is Rietveld 408576698