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

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

Issue 679863002: Revert "Prepare blink to unify definitions of load completion" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « Source/core/loader/FrameFetchContext.cpp ('k') | Source/core/loader/NavigationScheduler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 4 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 7 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
8 * Copyright (C) 2011 Google Inc. All rights reserved. 8 * Copyright (C) 2011 Google Inc. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 stopLoading(); 236 stopLoading();
237 237
238 if (Page* page = m_frame->page()) 238 if (Page* page = m_frame->page())
239 page->undoStack().didUnloadFrame(*m_frame); 239 page->undoStack().didUnloadFrame(*m_frame);
240 return true; 240 return true;
241 } 241 }
242 242
243 void FrameLoader::didExplicitOpen() 243 void FrameLoader::didExplicitOpen()
244 { 244 {
245 // Calling document.open counts as committing the first real document load. 245 // Calling document.open counts as committing the first real document load.
246 if (!m_stateMachine.committedFirstRealDocumentLoad()) { 246 if (!m_stateMachine.committedFirstRealDocumentLoad())
247 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); 247 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad );
248 m_progressTracker->progressStarted();
249 }
250 248
251 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results 249 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results
252 // from a subsequent window.document.open / window.document.write call. 250 // from a subsequent window.document.open / window.document.write call.
253 // Canceling redirection here works for all cases because document.open 251 // Canceling redirection here works for all cases because document.open
254 // implicitly precedes document.write. 252 // implicitly precedes document.write.
255 m_frame->navigationScheduler().cancel(); 253 m_frame->navigationScheduler().cancel();
256 } 254 }
257 255
258 void FrameLoader::clear() 256 void FrameLoader::clear()
259 { 257 {
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 bool FrameLoader::isLoadingMainFrame() const 954 bool FrameLoader::isLoadingMainFrame() const
957 { 955 {
958 return m_frame->isMainFrame(); 956 return m_frame->isMainFrame();
959 } 957 }
960 958
961 FrameLoadType FrameLoader::loadType() const 959 FrameLoadType FrameLoader::loadType() const
962 { 960 {
963 return m_loadType; 961 return m_loadType;
964 } 962 }
965 963
966 #if defined(ENABLE_LOAD_COMPLETION_HACKS)
967 // This function is an incomprehensible mess and is only used in checkLoadComple teForThisFrame. 964 // This function is an incomprehensible mess and is only used in checkLoadComple teForThisFrame.
968 // If you're thinking of using it elsewhere, stop right now and reconsider your life. 965 // If you're thinking of using it elsewhere, stop right now and reconsider your life.
969 static bool isDocumentDoneLoading(Document* document) 966 static bool isDocumentDoneLoading(Document* document)
970 { 967 {
971 if (!document->loader()) 968 if (!document->loader())
972 return true; 969 return true;
973 if (document->loader()->isLoadingMainResource()) 970 if (document->loader()->isLoadingMainResource())
974 return false; 971 return false;
975 if (!document->loadEventFinished()) 972 if (!document->loadEventFinished()) {
976 return false; 973 if (document->loader()->isLoading() || document->isDelayingLoadEvent())
974 return false;
975 }
977 if (document->fetcher()->requestCount()) 976 if (document->fetcher()->requestCount())
978 return false; 977 return false;
979 if (document->processingLoadEvent()) 978 if (document->processingLoadEvent())
980 return false; 979 return false;
980 if (document->hasActiveParser())
981 return false;
981 return true; 982 return true;
982 } 983 }
983 #endif
984 984
985 bool FrameLoader::checkLoadCompleteForThisFrame() 985 bool FrameLoader::checkLoadCompleteForThisFrame()
986 { 986 {
987 ASSERT(client()->hasWebView()); 987 ASSERT(client()->hasWebView());
988 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 988 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
989 989
990 bool allChildrenAreDoneLoading = true; 990 bool allChildrenAreDoneLoading = true;
991 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) { 991 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
992 if (child->isLocalFrame()) 992 if (child->isLocalFrame())
993 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame(); 993 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame();
(...skipping 15 matching lines...) Expand all
1009 return true; 1009 return true;
1010 } 1010 }
1011 1011
1012 if (!allChildrenAreDoneLoading) 1012 if (!allChildrenAreDoneLoading)
1013 return false; 1013 return false;
1014 1014
1015 if (m_state == FrameStateComplete) 1015 if (m_state == FrameStateComplete)
1016 return true; 1016 return true;
1017 if (m_provisionalDocumentLoader || !m_documentLoader) 1017 if (m_provisionalDocumentLoader || !m_documentLoader)
1018 return false; 1018 return false;
1019
1020 #if defined(ENABLE_LOAD_COMPLETION_HACKS)
1021 if (!isDocumentDoneLoading(m_frame->document()) && !m_inStopAllLoaders) 1019 if (!isDocumentDoneLoading(m_frame->document()) && !m_inStopAllLoaders)
1022 return false; 1020 return false;
1023 #else
1024 if (m_inStopAllLoaders)
1025 m_frame->document()->suppressLoadEvent();
1026 if (!m_frame->document()->loadEventFinished())
1027 return false;
1028 #endif
1029 1021
1030 m_state = FrameStateComplete; 1022 m_state = FrameStateComplete;
1031 1023
1032 // FIXME: Is this subsequent work important if we already navigated away? 1024 // FIXME: Is this subsequent work important if we already navigated away?
1033 // Maybe there are bugs because of that, or extra work we can skip because 1025 // Maybe there are bugs because of that, or extra work we can skip because
1034 // the new page is ready. 1026 // the new page is ready.
1035 1027
1036 // Retry restoring scroll offset since FrameStateComplete disables content 1028 // Retry restoring scroll offset since FrameStateComplete disables content
1037 // size clamping. 1029 // size clamping.
1038 restoreScrollPositionAndViewState(); 1030 restoreScrollPositionAndViewState();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1277 1269
1278 bool isTransitionNavigation = false; 1270 bool isTransitionNavigation = false;
1279 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame) 1271 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame)
1280 isTransitionNavigation = dispatchNavigationTransitionData(); 1272 isTransitionNavigation = dispatchNavigationTransitionData();
1281 1273
1282 // stopAllLoaders can detach the LocalFrame, so protect it. 1274 // stopAllLoaders can detach the LocalFrame, so protect it.
1283 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 1275 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1284 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) { 1276 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) {
1285 m_policyDocumentLoader->detachFromFrame(); 1277 m_policyDocumentLoader->detachFromFrame();
1286 m_policyDocumentLoader = nullptr; 1278 m_policyDocumentLoader = nullptr;
1287 if (!m_stateMachine.committedFirstRealDocumentLoad())
1288 m_state = FrameStateComplete;
1289 checkCompleted(); 1279 checkCompleted();
1290 return; 1280 return;
1291 } 1281 }
1292 1282
1293 if (m_provisionalDocumentLoader) { 1283 if (m_provisionalDocumentLoader) {
1294 m_provisionalDocumentLoader->stopLoading(); 1284 m_provisionalDocumentLoader->stopLoading();
1295 if (m_provisionalDocumentLoader) 1285 if (m_provisionalDocumentLoader)
1296 m_provisionalDocumentLoader->detachFromFrame(); 1286 m_provisionalDocumentLoader->detachFromFrame();
1297 m_provisionalDocumentLoader = nullptr; 1287 m_provisionalDocumentLoader = nullptr;
1298 } 1288 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. 1445 // FIXME: We need a way to propagate sandbox flags to out-of-process frames.
1456 Frame* parentFrame = m_frame->tree().parent(); 1446 Frame* parentFrame = m_frame->tree().parent();
1457 if (parentFrame && parentFrame->isLocalFrame()) 1447 if (parentFrame && parentFrame->isLocalFrame())
1458 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); 1448 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags();
1459 if (FrameOwner* frameOwner = m_frame->owner()) 1449 if (FrameOwner* frameOwner = m_frame->owner())
1460 flags |= frameOwner->sandboxFlags(); 1450 flags |= frameOwner->sandboxFlags();
1461 return flags; 1451 return flags;
1462 } 1452 }
1463 1453
1464 } // namespace blink 1454 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/loader/FrameFetchContext.cpp ('k') | Source/core/loader/NavigationScheduler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698