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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 stopLoading(); | 242 stopLoading(); |
243 | 243 |
244 if (Page* page = m_frame->page()) | 244 if (Page* page = m_frame->page()) |
245 page->undoStack().didUnloadFrame(*m_frame); | 245 page->undoStack().didUnloadFrame(*m_frame); |
246 return true; | 246 return true; |
247 } | 247 } |
248 | 248 |
249 void FrameLoader::didExplicitOpen() | 249 void FrameLoader::didExplicitOpen() |
250 { | 250 { |
251 // Calling document.open counts as committing the first real document load. | 251 // Calling document.open counts as committing the first real document load. |
252 if (!m_stateMachine.committedFirstRealDocumentLoad()) { | 252 if (!m_stateMachine.committedFirstRealDocumentLoad()) |
253 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); | 253 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad ); |
254 m_progressTracker->progressStarted(); | 254 |
255 } | 255 m_progressTracker->progressStarted(); |
256 | 256 |
257 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results | 257 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results |
258 // from a subsequent window.document.open / window.document.write call. | 258 // from a subsequent window.document.open / window.document.write call. |
259 // Canceling redirection here works for all cases because document.open | 259 // Canceling redirection here works for all cases because document.open |
260 // implicitly precedes document.write. | 260 // implicitly precedes document.write. |
261 m_frame->navigationScheduler().cancel(); | 261 m_frame->navigationScheduler().cancel(); |
262 } | 262 } |
263 | 263 |
264 void FrameLoader::clear() | 264 void FrameLoader::clear() |
265 { | 265 { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
439 scrollToFragmentWithParentBoundary(m_frame->document()->url()); | 439 scrollToFragmentWithParentBoundary(m_frame->document()->url()); |
440 } | 440 } |
441 | 441 |
442 void FrameLoader::loadDone() | 442 void FrameLoader::loadDone() |
443 { | 443 { |
444 checkCompleted(); | 444 checkCompleted(); |
445 } | 445 } |
446 | 446 |
447 bool FrameLoader::allChildrenAreComplete() const | 447 bool FrameLoader::allChildrenAreComplete() const |
448 { | 448 { |
449 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().nextSibling()) { | 449 for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree ().traverseNext(m_frame)) { |
450 if (!child->isLocalFrame()) { | 450 if (child->isLoading()) |
451 if (!child->checkLoadComplete()) { | |
452 return false; | |
453 } | |
454 continue; | |
455 } | |
456 LocalFrame* frame = toLocalFrame(child); | |
457 if (!frame->document()->isLoadCompleted() || frame->loader().m_provision alDocumentLoader) | |
458 return false; | 451 return false; |
459 } | 452 } |
460 return true; | 453 return true; |
461 } | 454 } |
462 | 455 |
463 bool FrameLoader::allAncestorsAreComplete() const | 456 bool FrameLoader::allAncestorsAreComplete() const |
464 { | 457 { |
465 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) { | 458 for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent ()) { |
466 if (ancestor->isLocalFrame()) { | 459 if (ancestor->isLoading()) |
467 if (!toLocalFrame(ancestor)->document()->loadEventFinished()) | 460 return false; |
468 return false; | |
469 } else { | |
470 if (!ancestor->checkLoadComplete()) { | |
471 return false; | |
472 } | |
473 } | |
474 | |
475 } | 461 } |
476 return true; | 462 return true; |
477 } | 463 } |
478 | 464 |
479 void FrameLoader::checkCompleted() | 465 void FrameLoader::checkCompleted() |
480 { | 466 { |
481 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 467 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
482 | 468 |
483 if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstR ealDocumentLoad()) | |
484 return; | |
485 | |
486 // Are we still parsing? | 469 // Are we still parsing? |
487 if (m_frame->document()->parsing() || m_frame->document()->isInDOMContentLoa ded()) | 470 if (m_frame->document()->parsing() || m_frame->document()->isInDOMContentLoa ded()) |
488 return; | 471 return; |
489 | 472 |
490 // Still waiting imports? | 473 // Still waiting imports? |
491 if (!m_frame->document()->haveImportsLoaded()) | 474 if (!m_frame->document()->haveImportsLoaded()) |
492 return; | 475 return; |
493 | 476 |
494 // Still waiting for images/scripts? | 477 // Still waiting for images/scripts? |
495 if (m_frame->document()->fetcher()->requestCount()) | 478 if (m_frame->document()->fetcher()->requestCount()) |
(...skipping 13 matching lines...) Expand all Loading... | |
509 m_frame->document()->implicitClose(); | 492 m_frame->document()->implicitClose(); |
510 | 493 |
511 m_frame->navigationScheduler().startTimer(); | 494 m_frame->navigationScheduler().startTimer(); |
512 | 495 |
513 // Retry restoring scroll offset since finishing the load event disables con tent | 496 // Retry restoring scroll offset since finishing the load event disables con tent |
514 // size clamping. | 497 // size clamping. |
515 restoreScrollPositionAndViewState(); | 498 restoreScrollPositionAndViewState(); |
516 if (m_frame->view()) | 499 if (m_frame->view()) |
517 m_frame->view()->handleLoadCompleted(); | 500 m_frame->view()->handleLoadCompleted(); |
518 | 501 |
502 // FIXME: this if() statement is gross, but all clauses appear to be necessa ry. In order: | |
503 // * Don't send stop notifications for inital empty documents, since they do n't generate start notifications. | |
504 // * We might have already sent stop notifications and be re-completing. (th is is hopefully fixable) | |
505 // * The readystatechanged or load event may have disconnected this frame. | |
506 // * An event might have restarted a child frame. | |
507 // * An event might have restarted this frame by scheduling a new navigation . | |
508 // * We might have declined to run the load event due to an imminent content -initiated navigation. | |
509 if (m_stateMachine.committedFirstRealDocumentLoad() && m_frame->isLoading() && client() && allChildrenAreComplete() && !m_provisionalDocumentLoader && m_fra me->document()->loadEventFinished()) { | |
dcheng
2015/01/09 07:43:55
For readability, it might be nice to split this to
| |
510 m_loadType = FrameLoadTypeStandard; | |
511 m_progressTracker->progressCompleted(); | |
512 m_frame->localDOMWindow()->finishedLoading(); | |
513 | |
514 // Report mobile vs. desktop page statistics. This will only report on A ndroid. | |
515 if (m_frame->isMainFrame()) | |
516 m_frame->document()->viewportDescription().reportMobilePageStats(m_f rame); | |
517 client()->dispatchDidFinishLoad(); | |
518 } | |
519 | |
519 Frame* parent = m_frame->tree().parent(); | 520 Frame* parent = m_frame->tree().parent(); |
520 if (parent && parent->isLocalFrame()) | 521 if (parent && parent->isLocalFrame()) |
521 toLocalFrame(parent)->loader().checkCompleted(); | 522 toLocalFrame(parent)->loader().checkCompleted(); |
522 if (m_frame->page()) | |
523 checkLoadComplete(); | |
524 } | 523 } |
525 | 524 |
526 void FrameLoader::checkTimerFired(Timer<FrameLoader>*) | 525 void FrameLoader::checkTimerFired(Timer<FrameLoader>*) |
527 { | 526 { |
528 if (Page* page = m_frame->page()) { | 527 if (Page* page = m_frame->page()) { |
529 if (page->defersLoading()) | 528 if (page->defersLoading()) |
530 return; | 529 return; |
531 } | 530 } |
532 checkCompleted(); | 531 checkCompleted(); |
533 } | 532 } |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
984 bool FrameLoader::isLoadingMainFrame() const | 983 bool FrameLoader::isLoadingMainFrame() const |
985 { | 984 { |
986 return m_frame->isMainFrame(); | 985 return m_frame->isMainFrame(); |
987 } | 986 } |
988 | 987 |
989 FrameLoadType FrameLoader::loadType() const | 988 FrameLoadType FrameLoader::loadType() const |
990 { | 989 { |
991 return m_loadType; | 990 return m_loadType; |
992 } | 991 } |
993 | 992 |
994 bool FrameLoader::checkLoadCompleteForThisFrame() | |
995 { | |
996 ASSERT(client()->hasWebView()); | |
997 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | |
998 | |
999 bool allChildrenAreDoneLoading = true; | |
1000 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) { | |
1001 allChildrenAreDoneLoading &= child->checkLoadComplete(); | |
1002 } | |
1003 if (!allChildrenAreDoneLoading) | |
1004 return false; | |
1005 | |
1006 if (!m_frame->isLoading()) | |
1007 return true; | |
1008 if (m_provisionalDocumentLoader || !m_documentLoader) | |
1009 return false; | |
1010 if (!m_frame->document()->loadEventFinished()) | |
1011 return false; | |
1012 if (!m_stateMachine.committedFirstRealDocumentLoad()) | |
1013 return true; | |
1014 | |
1015 m_progressTracker->progressCompleted(); | |
1016 m_frame->localDOMWindow()->finishedLoading(); | |
1017 | |
1018 // Report mobile vs. desktop page statistics. This will only report on Andro id. | |
1019 if (m_frame->isMainFrame()) | |
1020 m_frame->document()->viewportDescription().reportMobilePageStats(m_frame ); | |
1021 | |
1022 client()->dispatchDidFinishLoad(); | |
1023 m_loadType = FrameLoadTypeStandard; | |
1024 return true; | |
1025 } | |
1026 | |
1027 void FrameLoader::restoreScrollPositionAndViewState() | 993 void FrameLoader::restoreScrollPositionAndViewState() |
1028 { | 994 { |
1029 FrameView* view = m_frame->view(); | 995 FrameView* view = m_frame->view(); |
1030 if (!m_frame->page() || !view || !m_currentItem || !m_stateMachine.committed FirstRealDocumentLoad()) | 996 if (!m_frame->page() || !view || !m_currentItem || !m_stateMachine.committed FirstRealDocumentLoad()) |
1031 return; | 997 return; |
1032 | 998 |
1033 if (!needsHistoryItemRestore(m_loadType)) | 999 if (!needsHistoryItemRestore(m_loadType)) |
1034 return; | 1000 return; |
1035 | 1001 |
1036 // This tries to balance 1. restoring as soon as possible, 2. detecting | 1002 // This tries to balance 1. restoring as soon as possible, 2. detecting |
(...skipping 27 matching lines...) Expand all Loading... | |
1064 } else { | 1030 } else { |
1065 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint()) ; | 1031 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint()) ; |
1066 } | 1032 } |
1067 | 1033 |
1068 if (m_frame->isMainFrame()) { | 1034 if (m_frame->isMainFrame()) { |
1069 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator()) | 1035 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll ingCoordinator()) |
1070 scrollingCoordinator->frameViewRootLayerDidChange(view); | 1036 scrollingCoordinator->frameViewRootLayerDidChange(view); |
1071 } | 1037 } |
1072 } | 1038 } |
1073 | 1039 |
1074 // Called every time a resource is completely loaded or an error is received. | |
1075 void FrameLoader::checkLoadComplete() | |
1076 { | |
1077 ASSERT(client()->hasWebView()); | |
1078 m_frame->page()->mainFrame()->checkLoadComplete(); | |
1079 } | |
1080 | |
1081 String FrameLoader::userAgent(const KURL& url) const | 1040 String FrameLoader::userAgent(const KURL& url) const |
1082 { | 1041 { |
1083 String userAgent = client()->userAgent(url); | 1042 String userAgent = client()->userAgent(url); |
1084 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); | 1043 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); |
1085 return userAgent; | 1044 return userAgent; |
1086 } | 1045 } |
1087 | 1046 |
1088 void FrameLoader::detach() | 1047 void FrameLoader::detach() |
1089 { | 1048 { |
1090 #if !ENABLE(OILPAN) | 1049 #if !ENABLE(OILPAN) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1127 m_progressTracker->progressCompleted(); | 1086 m_progressTracker->progressCompleted(); |
1128 } else { | 1087 } else { |
1129 ASSERT(loader == m_documentLoader); | 1088 ASSERT(loader == m_documentLoader); |
1130 if (m_frame->document()->parser()) | 1089 if (m_frame->document()->parser()) |
1131 m_frame->document()->parser()->stopParsing(); | 1090 m_frame->document()->parser()->stopParsing(); |
1132 if (!m_provisionalDocumentLoader && m_frame->isLoading()) { | 1091 if (!m_provisionalDocumentLoader && m_frame->isLoading()) { |
1133 client()->dispatchDidFailLoad(error); | 1092 client()->dispatchDidFailLoad(error); |
1134 m_progressTracker->progressCompleted(); | 1093 m_progressTracker->progressCompleted(); |
1135 } | 1094 } |
1136 } | 1095 } |
1137 | |
1138 checkCompleted(); | 1096 checkCompleted(); |
1139 if (m_frame->page()) | |
1140 checkLoadComplete(); | |
1141 } | 1097 } |
1142 | 1098 |
1143 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) | 1099 bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const S tring& httpMethod, FrameLoadType loadType, const KURL& url) |
1144 { | 1100 { |
1145 ASSERT(loadType != FrameLoadTypeReloadFromOrigin); | 1101 ASSERT(loadType != FrameLoadTypeReloadFromOrigin); |
1146 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading, | 1102 // We don't do this if we are submitting a form with method other than "GET" , explicitly reloading, |
1147 // currently displaying a frameset, or if the URL does not have a fragment. | 1103 // currently displaying a frameset, or if the URL does not have a fragment. |
1148 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) | 1104 return (!isFormSubmission || equalIgnoringCase(httpMethod, "GET")) |
1149 && loadType != FrameLoadTypeReload | 1105 && loadType != FrameLoadTypeReload |
1150 && loadType != FrameLoadTypeSame | 1106 && loadType != FrameLoadTypeSame |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1445 | 1401 |
1446 // FIXME: We need a way to propagate strict mixed content checking flags to | 1402 // FIXME: We need a way to propagate strict mixed content checking flags to |
1447 // out-of-process frames. For now, we'll always enforce. | 1403 // out-of-process frames. For now, we'll always enforce. |
1448 if (!parentFrame->isLocalFrame()) | 1404 if (!parentFrame->isLocalFrame()) |
1449 return true; | 1405 return true; |
1450 | 1406 |
1451 return toLocalFrame(parentFrame)->document()->shouldEnforceStrictMixedConten tChecking(); | 1407 return toLocalFrame(parentFrame)->document()->shouldEnforceStrictMixedConten tChecking(); |
1452 } | 1408 } |
1453 | 1409 |
1454 } // namespace blink | 1410 } // namespace blink |
OLD | NEW |