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

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: majidvp comment#33 addressed 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);
majidvp 2017/01/25 20:31:59 Are you sure this is the correct navigation type?
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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 880
881 m_documentLoader->initialScrollState().wasScrolledByUser = false; 881 m_documentLoader->initialScrollState().wasScrolledByUser = false;
882 882
883 checkCompleted(); 883 checkCompleted();
884 884
885 m_frame->domWindow()->statePopped(stateObject 885 m_frame->domWindow()->statePopped(stateObject
886 ? std::move(stateObject) 886 ? std::move(stateObject)
887 : SerializedScriptValue::nullValue()); 887 : SerializedScriptValue::nullValue());
888 888
889 if (historyLoadType == HistorySameDocumentLoad) 889 if (historyLoadType == HistorySameDocumentLoad)
890 restoreScrollPositionAndViewState(); 890 setScrollFromNavigation(NavigationWithinSameDocument);
891 891
892 // We need to scroll to the fragment whether or not a hash change occurred, 892 // 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. 893 // since the user might have scrolled since the previous navigation.
894 processFragment(url, NavigationWithinSameDocument); 894 processFragment(url, NavigationWithinSameDocument);
895 takeObjectSnapshot(); 895 takeObjectSnapshot();
896 } 896 }
897 897
898 // static 898 // static
899 void FrameLoader::setReferrerForFrameRequest(FrameLoadRequest& frameRequest) { 899 void FrameLoader::setReferrerForFrameRequest(FrameLoadRequest& frameRequest) {
900 ResourceRequest& request = frameRequest.resourceRequest(); 900 ResourceRequest& request = frameRequest.resourceRequest();
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1369 } 1369 }
1370 1370
1371 bool FrameLoader::isLoadingMainFrame() const { 1371 bool FrameLoader::isLoadingMainFrame() const {
1372 return m_frame->isMainFrame(); 1372 return m_frame->isMainFrame();
1373 } 1373 }
1374 1374
1375 FrameLoadType FrameLoader::loadType() const { 1375 FrameLoadType FrameLoader::loadType() const {
1376 return m_loadType; 1376 return m_loadType;
1377 } 1377 }
1378 1378
1379 void FrameLoader::setScrollFromNavigation(LoadStartType loadStartType) {
1380 processFragment(m_frame->document()->url(), loadStartType);
1381 restoreScrollPositionAndViewState();
1382 }
1383
1379 void FrameLoader::restoreScrollPositionAndViewState() { 1384 void FrameLoader::restoreScrollPositionAndViewState() {
1380 FrameView* view = m_frame->view(); 1385 FrameView* view = m_frame->view();
1381 if (!m_frame->page() || !view || !view->layoutViewportScrollableArea() || 1386 if (!m_frame->page() || !view || !view->layoutViewportScrollableArea() ||
1382 !m_currentItem || !m_stateMachine.committedFirstRealDocumentLoad() || 1387 !m_currentItem || !m_stateMachine.committedFirstRealDocumentLoad() ||
1383 !documentLoader()) { 1388 !documentLoader()) {
1384 return; 1389 return;
1385 } 1390 }
1386 1391
1387 if (!needsHistoryItemRestore(m_loadType)) 1392 if (!needsHistoryItemRestore(m_loadType))
1388 return; 1393 return;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1905 m_documentLoader ? m_documentLoader->url() : String()); 1910 m_documentLoader ? m_documentLoader->url() : String());
1906 return tracedValue; 1911 return tracedValue;
1907 } 1912 }
1908 1913
1909 inline void FrameLoader::takeObjectSnapshot() const { 1914 inline void FrameLoader::takeObjectSnapshot() const {
1910 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, 1915 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this,
1911 toTracedValue()); 1916 toTracedValue());
1912 } 1917 }
1913 1918
1914 } // namespace blink 1919 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698