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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2628683003: Add DidSaveScrollOrScaleState flag to prevent restoreScrollPositionAndViewState restore from default (Closed)
Patch Set: remove checkComplete call in loadInSameDocument Created 3 years, 10 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 client()->dispatchDidFinishLoad(); 736 client()->dispatchDidFinishLoad();
737 // Finishing the load can detach the frame when running layout tests. 737 // Finishing the load can detach the frame when running layout tests.
738 if (!m_frame->client()) 738 if (!m_frame->client())
739 return; 739 return;
740 } 740 }
741 741
742 if (shouldSendCompleteNotification(m_frame, m_isNavigationHandledByClient)) { 742 if (shouldSendCompleteNotification(m_frame, m_isNavigationHandledByClient)) {
743 m_progressTracker->progressCompleted(); 743 m_progressTracker->progressCompleted();
744 // Retry restoring scroll offset since finishing loading disables content 744 // Retry restoring scroll offset since finishing loading disables content
745 // size clamping. 745 // size clamping.
746 restoreScrollPositionAndViewState(); 746 setScrollFromNavigation(NavigationToDifferentDocument);
747 747
748 m_loadType = FrameLoadTypeStandard; 748 m_loadType = FrameLoadTypeStandard;
749 m_frame->domWindow()->finishedLoading(); 749 m_frame->domWindow()->finishedLoading();
750 } 750 }
751 751
752 Frame* parent = m_frame->tree().parent(); 752 Frame* parent = m_frame->tree().parent();
753 if (parent && parent->isLocalFrame()) 753 if (parent && parent->isLocalFrame())
754 toLocalFrame(parent)->loader().checkCompleted(); 754 toLocalFrame(parent)->loader().checkCompleted();
755 } 755 }
756 756
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
873 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); 873 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url);
874 } 874 }
875 m_documentLoader->setIsClientRedirect(clientRedirect == 875 m_documentLoader->setIsClientRedirect(clientRedirect ==
876 ClientRedirectPolicy::ClientRedirect); 876 ClientRedirectPolicy::ClientRedirect);
877 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, 877 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr,
878 ScrollRestorationAuto, frameLoadType, 878 ScrollRestorationAuto, frameLoadType,
879 initiatingDocument); 879 initiatingDocument);
880 880
881 m_documentLoader->initialScrollState().wasScrolledByUser = false; 881 m_documentLoader->initialScrollState().wasScrolledByUser = false;
882 882
883 checkCompleted();
Nate Chapin 2017/01/26 21:25:35 Context: I suggested removing this, because update
majidvp 2017/01/26 21:49:50 Interesting. That works. Should we add a DCHECK in
884
885 m_frame->domWindow()->statePopped(stateObject 883 m_frame->domWindow()->statePopped(stateObject
886 ? std::move(stateObject) 884 ? std::move(stateObject)
887 : SerializedScriptValue::nullValue()); 885 : SerializedScriptValue::nullValue());
888 886
889 if (historyLoadType == HistorySameDocumentLoad) 887 if (historyLoadType == HistorySameDocumentLoad)
890 restoreScrollPositionAndViewState(); 888 setScrollFromNavigation(NavigationWithinSameDocument);
891 889
892 // We need to scroll to the fragment whether or not a hash change occurred, 890 // We need to scroll to the fragment whether or not a hash change occurred,
893 // since the user might have scrolled since the previous navigation. 891 // since the user might have scrolled since the previous navigation.
894 processFragment(url, NavigationWithinSameDocument); 892 processFragment(url, NavigationWithinSameDocument);
895 takeObjectSnapshot(); 893 takeObjectSnapshot();
896 } 894 }
897 895
898 // static 896 // static
899 void FrameLoader::setReferrerForFrameRequest(FrameLoadRequest& frameRequest) { 897 void FrameLoader::setReferrerForFrameRequest(FrameLoadRequest& frameRequest) {
900 ResourceRequest& request = frameRequest.resourceRequest(); 898 ResourceRequest& request = frameRequest.resourceRequest();
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 } 1367 }
1370 1368
1371 bool FrameLoader::isLoadingMainFrame() const { 1369 bool FrameLoader::isLoadingMainFrame() const {
1372 return m_frame->isMainFrame(); 1370 return m_frame->isMainFrame();
1373 } 1371 }
1374 1372
1375 FrameLoadType FrameLoader::loadType() const { 1373 FrameLoadType FrameLoader::loadType() const {
1376 return m_loadType; 1374 return m_loadType;
1377 } 1375 }
1378 1376
1377 void FrameLoader::setScrollFromNavigation(LoadStartType loadStartType) {
1378 processFragment(m_frame->document()->url(), loadStartType);
1379 restoreScrollPositionAndViewState();
1380 }
1381
1379 void FrameLoader::restoreScrollPositionAndViewState() { 1382 void FrameLoader::restoreScrollPositionAndViewState() {
1380 FrameView* view = m_frame->view(); 1383 FrameView* view = m_frame->view();
1381 if (!m_frame->page() || !view || !view->layoutViewportScrollableArea() || 1384 if (!m_frame->page() || !view || !view->layoutViewportScrollableArea() ||
1382 !m_currentItem || !m_stateMachine.committedFirstRealDocumentLoad() || 1385 !m_currentItem || !m_stateMachine.committedFirstRealDocumentLoad() ||
1383 !documentLoader()) { 1386 !documentLoader()) {
1384 return; 1387 return;
1385 } 1388 }
1386 1389
1387 if (!needsHistoryItemRestore(m_loadType)) 1390 if (!needsHistoryItemRestore(m_loadType))
1388 return; 1391 return;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 m_documentLoader ? m_documentLoader->url() : String()); 1908 m_documentLoader ? m_documentLoader->url() : String());
1906 return tracedValue; 1909 return tracedValue;
1907 } 1910 }
1908 1911
1909 inline void FrameLoader::takeObjectSnapshot() const { 1912 inline void FrameLoader::takeObjectSnapshot() const {
1910 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, 1913 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this,
1911 toTracedValue()); 1914 toTracedValue());
1912 } 1915 }
1913 1916
1914 } // namespace blink 1917 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/loader/FrameLoader.h ('k') | third_party/WebKit/Source/web/tests/ProgrammaticScrollTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698