OLD | NEW |
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 Loading... |
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 } |
248 | 250 |
249 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results | 251 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results |
250 // from a subsequent window.document.open / window.document.write call. | 252 // from a subsequent window.document.open / window.document.write call. |
251 // Canceling redirection here works for all cases because document.open | 253 // Canceling redirection here works for all cases because document.open |
252 // implicitly precedes document.write. | 254 // implicitly precedes document.write. |
253 m_frame->navigationScheduler().cancel(); | 255 m_frame->navigationScheduler().cancel(); |
254 } | 256 } |
255 | 257 |
256 void FrameLoader::clear() | 258 void FrameLoader::clear() |
257 { | 259 { |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 bool FrameLoader::isLoadingMainFrame() const | 956 bool FrameLoader::isLoadingMainFrame() const |
955 { | 957 { |
956 return m_frame->isMainFrame(); | 958 return m_frame->isMainFrame(); |
957 } | 959 } |
958 | 960 |
959 FrameLoadType FrameLoader::loadType() const | 961 FrameLoadType FrameLoader::loadType() const |
960 { | 962 { |
961 return m_loadType; | 963 return m_loadType; |
962 } | 964 } |
963 | 965 |
| 966 #if defined(ENABLE_LOAD_COMPLETION_HACKS) |
964 // This function is an incomprehensible mess and is only used in checkLoadComple
teForThisFrame. | 967 // This function is an incomprehensible mess and is only used in checkLoadComple
teForThisFrame. |
965 // If you're thinking of using it elsewhere, stop right now and reconsider your
life. | 968 // If you're thinking of using it elsewhere, stop right now and reconsider your
life. |
966 static bool isDocumentDoneLoading(Document* document) | 969 static bool isDocumentDoneLoading(Document* document) |
967 { | 970 { |
968 if (!document->loader()) | 971 if (!document->loader()) |
969 return true; | 972 return true; |
970 if (document->loader()->isLoadingMainResource()) | 973 if (document->loader()->isLoadingMainResource()) |
971 return false; | 974 return false; |
972 if (!document->loadEventFinished()) { | 975 if (!document->loadEventFinished()) |
973 if (document->loader()->isLoading() || document->isDelayingLoadEvent()) | 976 return false; |
974 return false; | |
975 } | |
976 if (document->fetcher()->requestCount()) | 977 if (document->fetcher()->requestCount()) |
977 return false; | 978 return false; |
978 if (document->processingLoadEvent()) | 979 if (document->processingLoadEvent()) |
979 return false; | 980 return false; |
980 if (document->hasActiveParser()) | |
981 return false; | |
982 return true; | 981 return true; |
983 } | 982 } |
| 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 Loading... |
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) |
1019 if (!isDocumentDoneLoading(m_frame->document()) && !m_inStopAllLoaders) | 1021 if (!isDocumentDoneLoading(m_frame->document()) && !m_inStopAllLoaders) |
1020 return false; | 1022 return false; |
| 1023 #else |
| 1024 if (m_inStopAllLoaders) |
| 1025 m_frame->document()->suppressLoadEvent(); |
| 1026 if (!m_frame->document()->loadEventFinished()) |
| 1027 return false; |
| 1028 #endif |
1021 | 1029 |
1022 m_state = FrameStateComplete; | 1030 m_state = FrameStateComplete; |
1023 | 1031 |
1024 // FIXME: Is this subsequent work important if we already navigated away? | 1032 // FIXME: Is this subsequent work important if we already navigated away? |
1025 // Maybe there are bugs because of that, or extra work we can skip because | 1033 // Maybe there are bugs because of that, or extra work we can skip because |
1026 // the new page is ready. | 1034 // the new page is ready. |
1027 | 1035 |
1028 // Retry restoring scroll offset since FrameStateComplete disables content | 1036 // Retry restoring scroll offset since FrameStateComplete disables content |
1029 // size clamping. | 1037 // size clamping. |
1030 restoreScrollPositionAndViewState(); | 1038 restoreScrollPositionAndViewState(); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1269 | 1277 |
1270 bool isTransitionNavigation = false; | 1278 bool isTransitionNavigation = false; |
1271 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL
oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS
ame) | 1279 if (RuntimeEnabledFeatures::navigationTransitionsEnabled() && type != FrameL
oadTypeReload && type != FrameLoadTypeReloadFromOrigin && type != FrameLoadTypeS
ame) |
1272 isTransitionNavigation = dispatchNavigationTransitionData(); | 1280 isTransitionNavigation = dispatchNavigationTransitionData(); |
1273 | 1281 |
1274 // stopAllLoaders can detach the LocalFrame, so protect it. | 1282 // stopAllLoaders can detach the LocalFrame, so protect it. |
1275 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 1283 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
1276 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho
uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose(
)) && m_policyDocumentLoader) { | 1284 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, sho
uldCheckMainWorldContentSecurityPolicy, isTransitionNavigation) || !shouldClose(
)) && m_policyDocumentLoader) { |
1277 m_policyDocumentLoader->detachFromFrame(); | 1285 m_policyDocumentLoader->detachFromFrame(); |
1278 m_policyDocumentLoader = nullptr; | 1286 m_policyDocumentLoader = nullptr; |
| 1287 if (!m_stateMachine.committedFirstRealDocumentLoad()) |
| 1288 m_state = FrameStateComplete; |
1279 checkCompleted(); | 1289 checkCompleted(); |
1280 return; | 1290 return; |
1281 } | 1291 } |
1282 | 1292 |
1283 if (m_provisionalDocumentLoader) { | 1293 if (m_provisionalDocumentLoader) { |
1284 m_provisionalDocumentLoader->stopLoading(); | 1294 m_provisionalDocumentLoader->stopLoading(); |
1285 if (m_provisionalDocumentLoader) | 1295 if (m_provisionalDocumentLoader) |
1286 m_provisionalDocumentLoader->detachFromFrame(); | 1296 m_provisionalDocumentLoader->detachFromFrame(); |
1287 m_provisionalDocumentLoader = nullptr; | 1297 m_provisionalDocumentLoader = nullptr; |
1288 } | 1298 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. | 1455 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. |
1446 Frame* parentFrame = m_frame->tree().parent(); | 1456 Frame* parentFrame = m_frame->tree().parent(); |
1447 if (parentFrame && parentFrame->isLocalFrame()) | 1457 if (parentFrame && parentFrame->isLocalFrame()) |
1448 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); | 1458 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); |
1449 if (FrameOwner* frameOwner = m_frame->owner()) | 1459 if (FrameOwner* frameOwner = m_frame->owner()) |
1450 flags |= frameOwner->sandboxFlags(); | 1460 flags |= frameOwner->sandboxFlags(); |
1451 return flags; | 1461 return flags; |
1452 } | 1462 } |
1453 | 1463 |
1454 } // namespace blink | 1464 } // namespace blink |
OLD | NEW |