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

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

Issue 1561573004: Fix bug where scroll position was being restored after navigation completes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore to previous type Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fb740684346ca8425b8860db0f06f577492eb3aa..f458d0c0933e38a94fb6caa9f563976241811dd8 100644
--- a/third_party/WebKit/Source/core/loader/FrameLoader.cpp
+++ b/third_party/WebKit/Source/core/loader/FrameLoader.cpp
@@ -684,10 +684,10 @@ void FrameLoader::detachDocumentLoader(RefPtrWillBeMember<DocumentLoader>& loade
loader = nullptr;
}
-void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScriptValue> stateObject, FrameLoadType type, ClientRedirectPolicy clientRedirect)
+void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScriptValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadType, ClientRedirectPolicy clientRedirect)
{
// If we have a state object, we cannot also be a new navigation.
- ASSERT(!stateObject || type == FrameLoadTypeBackForward);
+ ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward);
// If we have a provisional request for a different document, a fragment scroll should cancel it.
if (m_provisionalDocumentLoader) {
@@ -696,24 +696,31 @@ void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
if (!m_frame->host())
return;
}
- m_loadType = type;
+ TemporaryChange<FrameLoadType> loadTypeChange(m_loadType, frameLoadType);
saveScrollState();
KURL oldURL = m_frame->document()->url();
- // If we were in the autoscroll/panScroll mode we want to stop it before following the link to the anchor
bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragmentIdentifier() != oldURL.fragmentIdentifier();
if (hashChange) {
+ // If we were in the autoscroll/panScroll mode we want to stop it before following the link to the anchor
m_frame->eventHandler().stopAutoscroll();
m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url);
}
m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect);
- updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, ScrollRestorationAuto, type);
+ updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, ScrollRestorationAuto, frameLoadType);
m_documentLoader->initialScrollState().wasScrolledByUser = false;
checkCompleted();
m_frame->localDOMWindow()->statePopped(stateObject ? stateObject : SerializedScriptValue::nullValue());
+
+ if (historyLoadType == HistorySameDocumentLoad)
+ restoreScrollPositionAndViewState();
+
+ // 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);
}
void FrameLoader::setReferrerForFrameRequest(ResourceRequest& request, ShouldSendReferrer shouldSendReferrer, Document* originDocument)
@@ -933,14 +940,7 @@ void FrameLoader::load(const FrameLoadRequest& passedRequest, FrameLoadType fram
newLoadType = FrameLoadTypeReplaceCurrentItem;
}
- loadInSameDocument(url, stateObject, newLoadType, request.clientRedirect());
-
- if (sameDocumentHistoryNavigation)
- restoreScrollPositionAndViewState();
-
- // 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);
+ loadInSameDocument(url, stateObject, newLoadType, historyLoadType, request.clientRedirect());
return;
}
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698