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

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

Issue 561813003: Prepare blink to unify definitions of load completion (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 | Annotate | Revision Log
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 stopLoading(); 233 stopLoading();
234 234
235 if (Page* page = m_frame->page()) 235 if (Page* page = m_frame->page())
236 page->undoStack().didUnloadFrame(*m_frame); 236 page->undoStack().didUnloadFrame(*m_frame);
237 return true; 237 return true;
238 } 238 }
239 239
240 void FrameLoader::didExplicitOpen() 240 void FrameLoader::didExplicitOpen()
241 { 241 {
242 // Calling document.open counts as committing the first real document load. 242 // Calling document.open counts as committing the first real document load.
243 if (!m_stateMachine.committedFirstRealDocumentLoad()) 243 if (!m_stateMachine.committedFirstRealDocumentLoad()) {
244 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); 244 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad );
245 m_progressTracker->progressStarted();
246 }
245 247
246 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results 248 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results
247 // from a subsequent window.document.open / window.document.write call. 249 // from a subsequent window.document.open / window.document.write call.
248 // Canceling redirection here works for all cases because document.open 250 // Canceling redirection here works for all cases because document.open
249 // implicitly precedes document.write. 251 // implicitly precedes document.write.
250 m_frame->navigationScheduler().cancel(); 252 m_frame->navigationScheduler().cancel();
251 } 253 }
252 254
253 void FrameLoader::clear() 255 void FrameLoader::clear()
254 { 256 {
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 bool FrameLoader::isLoadingMainFrame() const 953 bool FrameLoader::isLoadingMainFrame() const
952 { 954 {
953 return m_frame->isMainFrame(); 955 return m_frame->isMainFrame();
954 } 956 }
955 957
956 FrameLoadType FrameLoader::loadType() const 958 FrameLoadType FrameLoader::loadType() const
957 { 959 {
958 return m_loadType; 960 return m_loadType;
959 } 961 }
960 962
963 #if defined(ENABLE_LOAD_COMPLETION_HACKS)
961 // 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.
962 // 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.
963 static bool isDocumentDoneLoading(Document* document) 966 static bool isDocumentDoneLoading(Document* document)
964 { 967 {
965 if (!document->loader()) 968 if (!document->loader())
966 return true; 969 return true;
967 if (document->loader()->isLoadingMainResource()) 970 if (document->loader()->isLoadingMainResource())
968 return false; 971 return false;
969 if (!document->loadEventFinished()) { 972 if (!document->loadEventFinished())
970 if (document->loader()->isLoading() || document->isDelayingLoadEvent()) 973 return false;
971 return false;
972 }
973 if (document->fetcher()->requestCount()) 974 if (document->fetcher()->requestCount())
974 return false; 975 return false;
975 if (document->processingLoadEvent()) 976 if (document->processingLoadEvent())
976 return false; 977 return false;
977 if (document->hasActiveParser())
978 return false;
979 return true; 978 return true;
980 } 979 }
980 #endif
981 981
982 bool FrameLoader::checkLoadCompleteForThisFrame() 982 bool FrameLoader::checkLoadCompleteForThisFrame()
983 { 983 {
984 ASSERT(client()->hasWebView()); 984 ASSERT(client()->hasWebView());
985 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 985 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
986 986
987 bool allChildrenAreDoneLoading = true; 987 bool allChildrenAreDoneLoading = true;
988 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) { 988 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
989 if (child->isLocalFrame()) 989 if (child->isLocalFrame())
990 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame(); 990 allChildrenAreDoneLoading &= toLocalFrame(child.get())->loader().che ckLoadCompleteForThisFrame();
(...skipping 15 matching lines...) Expand all
1006 return true; 1006 return true;
1007 } 1007 }
1008 1008
1009 if (!allChildrenAreDoneLoading) 1009 if (!allChildrenAreDoneLoading)
1010 return false; 1010 return false;
1011 1011
1012 if (m_state == FrameStateComplete) 1012 if (m_state == FrameStateComplete)
1013 return true; 1013 return true;
1014 if (m_provisionalDocumentLoader || !m_documentLoader) 1014 if (m_provisionalDocumentLoader || !m_documentLoader)
1015 return false; 1015 return false;
1016
1017 #if defined(ENABLE_LOAD_COMPLETION_HACKS)
dcheng 2014/10/20 18:35:14 o.O
1016 if (!isDocumentDoneLoading(m_frame->document()) && !m_inStopAllLoaders) 1018 if (!isDocumentDoneLoading(m_frame->document()) && !m_inStopAllLoaders)
1017 return false; 1019 return false;
1020 #else
1021 if (m_inStopAllLoaders)
1022 m_frame->document()->suppressLoadEvent();
1023 if (!m_frame->document()->loadEventFinished())
1024 return false;
1025 #endif
1018 1026
1019 m_state = FrameStateComplete; 1027 m_state = FrameStateComplete;
1020 1028
1021 // FIXME: Is this subsequent work important if we already navigated away? 1029 // FIXME: Is this subsequent work important if we already navigated away?
1022 // Maybe there are bugs because of that, or extra work we can skip because 1030 // Maybe there are bugs because of that, or extra work we can skip because
1023 // the new page is ready. 1031 // the new page is ready.
1024 1032
1025 // Retry restoring scroll offset since FrameStateComplete disables content 1033 // Retry restoring scroll offset since FrameStateComplete disables content
1026 // size clamping. 1034 // size clamping.
1027 restoreScrollPositionAndViewState(); 1035 restoreScrollPositionAndViewState();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 1274
1267 bool isTransitionNavigation = false; 1275 bool isTransitionNavigation = false;
1268 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame) 1276 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS ame)
1269 isTransitionNavigation = dispatchNavigationTransitionData(); 1277 isTransitionNavigation = dispatchNavigationTransitionData();
1270 1278
1271 // stopAllLoaders can detach the LocalFrame, so protect it. 1279 // stopAllLoaders can detach the LocalFrame, so protect it.
1272 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 1280 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1273 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) { 1281 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose( )) && m_policyDocumentLoader) {
1274 m_policyDocumentLoader->detachFromFrame(); 1282 m_policyDocumentLoader->detachFromFrame();
1275 m_policyDocumentLoader = nullptr; 1283 m_policyDocumentLoader = nullptr;
1284 if (!m_stateMachine.committedFirstRealDocumentLoad())
1285 m_state = FrameStateComplete;
1276 checkCompleted(); 1286 checkCompleted();
1277 return; 1287 return;
1278 } 1288 }
1279 1289
1280 if (m_provisionalDocumentLoader) { 1290 if (m_provisionalDocumentLoader) {
1281 m_provisionalDocumentLoader->stopLoading(); 1291 m_provisionalDocumentLoader->stopLoading();
1282 if (m_provisionalDocumentLoader) 1292 if (m_provisionalDocumentLoader)
1283 m_provisionalDocumentLoader->detachFromFrame(); 1293 m_provisionalDocumentLoader->detachFromFrame();
1284 m_provisionalDocumentLoader = nullptr; 1294 m_provisionalDocumentLoader = nullptr;
1285 } 1295 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1442 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. 1452 // FIXME: We need a way to propagate sandbox flags to out-of-process frames.
1443 Frame* parentFrame = m_frame->tree().parent(); 1453 Frame* parentFrame = m_frame->tree().parent();
1444 if (parentFrame && parentFrame->isLocalFrame()) 1454 if (parentFrame && parentFrame->isLocalFrame())
1445 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); 1455 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags();
1446 if (FrameOwner* frameOwner = m_frame->owner()) 1456 if (FrameOwner* frameOwner = m_frame->owner())
1447 flags |= frameOwner->sandboxFlags(); 1457 flags |= frameOwner->sandboxFlags();
1448 return flags; 1458 return flags;
1449 } 1459 }
1450 1460
1451 } // namespace blink 1461 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698