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

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

Issue 1823863002: Simplify parsing/loading state, attempt #2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes Created 4 years, 9 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 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 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 loader->detachFromFrame(); 713 loader->detachFromFrame();
714 loader = nullptr; 714 loader = nullptr;
715 } 715 }
716 716
717 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp e, ClientRedirectPolicy clientRedirect) 717 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp e, ClientRedirectPolicy clientRedirect)
718 { 718 {
719 // If we have a state object, we cannot also be a new navigation. 719 // If we have a state object, we cannot also be a new navigation.
720 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward); 720 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward);
721 721
722 // If we have a provisional request for a different document, a fragment scr oll should cancel it. 722 // If we have a provisional request for a different document, a fragment scr oll should cancel it.
723 if (m_provisionalDocumentLoader) { 723 detachDocumentLoader(m_provisionalDocumentLoader);
724 m_provisionalDocumentLoader->stopLoading(); 724 if (!m_frame->host())
725 detachDocumentLoader(m_provisionalDocumentLoader); 725 return;
726 if (!m_frame->host())
727 return;
728 }
729 TemporaryChange<FrameLoadType> loadTypeChange(m_loadType, frameLoadType); 726 TemporaryChange<FrameLoadType> loadTypeChange(m_loadType, frameLoadType);
730 saveScrollState(); 727 saveScrollState();
731 728
732 KURL oldURL = m_frame->document()->url(); 729 KURL oldURL = m_frame->document()->url();
733 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme ntIdentifier() != oldURL.fragmentIdentifier(); 730 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme ntIdentifier() != oldURL.fragmentIdentifier();
734 if (hashChange) { 731 if (hashChange) {
735 // If we were in the autoscroll/panScroll mode we want to stop it before following the link to the anchor 732 // If we were in the autoscroll/panScroll mode we want to stop it before following the link to the anchor
736 m_frame->eventHandler().stopAutoscroll(); 733 m_frame->eventHandler().stopAutoscroll();
737 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url); 734 m_frame->localDOMWindow()->enqueueHashchangeEvent(oldURL, url);
738 } 735 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 995
999 void FrameLoader::stopAllLoaders() 996 void FrameLoader::stopAllLoaders()
1000 { 997 {
1001 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 998 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
1002 return; 999 return;
1003 1000
1004 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 1001 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
1005 if (m_inStopAllLoaders) 1002 if (m_inStopAllLoaders)
1006 return; 1003 return;
1007 1004
1008 // Calling stopLoading() on the provisional document loader can blow away 1005 // Stopping a document loader can blow away the frame from underneath.
1009 // the frame from underneath.
1010 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 1006 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1011 1007
1012 m_inStopAllLoaders = true; 1008 m_inStopAllLoaders = true;
1013 1009
1014 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) { 1010 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
1015 if (child->isLocalFrame()) 1011 if (child->isLocalFrame())
1016 toLocalFrame(child.get())->loader().stopAllLoaders(); 1012 toLocalFrame(child.get())->loader().stopAllLoaders();
1017 } 1013 }
1018 1014
1019 m_frame->document()->suppressLoadEvent(); 1015 m_frame->document()->suppressLoadEvent();
1020 // Don't stop loading the provisional loader if it is being protected (i.e.
1021 // it is about to be committed) See prepareForCommit() for more details.
1022 if (m_provisionalDocumentLoader && !m_protectProvisionalLoader)
1023 m_provisionalDocumentLoader->stopLoading();
1024 if (m_documentLoader) 1016 if (m_documentLoader)
1025 m_documentLoader->stopLoading(); 1017 m_documentLoader->fetcher()->stopFetching();
1026 m_frame->document()->cancelParsing(); 1018 m_frame->document()->cancelParsing();
1027
1028 if (!m_protectProvisionalLoader) 1019 if (!m_protectProvisionalLoader)
1029 detachDocumentLoader(m_provisionalDocumentLoader); 1020 detachDocumentLoader(m_provisionalDocumentLoader);
1030 1021
1031 m_checkTimer.stop(); 1022 m_checkTimer.stop();
1032 m_frame->navigationScheduler().cancel(); 1023 m_frame->navigationScheduler().cancel();
1033 1024
1025 // It's possible that the above actions won't have stopped loading if load
1026 // completion had been blocked on parsing or if we were in the middle of
1027 // committing an empty document. In that case, emulate a failed navigation.
1028 if (!m_provisionalDocumentLoader && m_documentLoader && m_frame->isLoading() )
1029 loadFailed(m_documentLoader.get(), ResourceError::cancelledError(m_docum entLoader->url()));
1030
1034 m_inStopAllLoaders = false; 1031 m_inStopAllLoaders = false;
1035 } 1032 }
1036 1033
1037 void FrameLoader::didAccessInitialDocument() 1034 void FrameLoader::didAccessInitialDocument()
1038 { 1035 {
1039 // We only need to notify the client once, and only for the main frame. 1036 // We only need to notify the client once, and only for the main frame.
1040 if (isLoadingMainFrame() && !m_didAccessInitialDocument) { 1037 if (isLoadingMainFrame() && !m_didAccessInitialDocument) {
1041 m_didAccessInitialDocument = true; 1038 m_didAccessInitialDocument = true;
1042 // Notify asynchronously, since this is called within a JavaScript secur ity check. 1039 // Notify asynchronously, since this is called within a JavaScript secur ity check.
1043 m_didAccessInitialDocumentTimer.startOneShot(0, BLINK_FROM_HERE); 1040 m_didAccessInitialDocumentTimer.startOneShot(0, BLINK_FROM_HERE);
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 1232
1236 Frame* parent = m_frame->tree().parent(); 1233 Frame* parent = m_frame->tree().parent();
1237 if (parent && parent->isLocalFrame()) 1234 if (parent && parent->isLocalFrame())
1238 toLocalFrame(parent)->loader().scheduleCheckCompleted(); 1235 toLocalFrame(parent)->loader().scheduleCheckCompleted();
1239 if (m_progressTracker) { 1236 if (m_progressTracker) {
1240 m_progressTracker->dispose(); 1237 m_progressTracker->dispose();
1241 m_progressTracker.clear(); 1238 m_progressTracker.clear();
1242 } 1239 }
1243 } 1240 }
1244 1241
1245 void FrameLoader::receivedMainResourceError(DocumentLoader* loader, const Resour ceError& error) 1242 void FrameLoader::loadFailed(DocumentLoader* loader, const ResourceError& error)
1246 { 1243 {
1247 // Retain because the stop may release the last reference to it. 1244 // Retain because the stop may release the last reference to it.
1248 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); 1245 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
1249 RefPtrWillBeRawPtr<DocumentLoader> protectDocumentLoader(loader); 1246 RefPtrWillBeRawPtr<DocumentLoader> protectDocumentLoader(loader);
1250 1247
1251 // FIXME: We really ought to be able to just check for isCancellation() here , but there are some 1248 if (!error.isCancellation() && m_frame->owner()) {
1252 // ResourceErrors that setIsCancellation() but aren't created by ResourceErr or::cancelledError().
1253 ResourceError c(ResourceError::cancelledError(KURL()));
1254 if ((error.errorCode() != c.errorCode() || error.domain() != c.domain()) && m_frame->owner()) {
1255 // FIXME: For now, fallback content doesn't work cross process. 1249 // FIXME: For now, fallback content doesn't work cross process.
1256 if (m_frame->owner()->isLocal()) 1250 if (m_frame->owner()->isLocal())
1257 m_frame->deprecatedLocalOwner()->renderFallbackContent(); 1251 m_frame->deprecatedLocalOwner()->renderFallbackContent();
1258 } 1252 }
1259 1253
1260 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType); 1254 HistoryCommitType historyCommitType = loadTypeToCommitType(m_loadType);
1261 if (loader == m_provisionalDocumentLoader) { 1255 if (loader == m_provisionalDocumentLoader) {
1262 client()->dispatchDidFailProvisionalLoad(error, historyCommitType); 1256 client()->dispatchDidFailProvisionalLoad(error, historyCommitType);
1263 if (loader != m_provisionalDocumentLoader) 1257 if (loader != m_provisionalDocumentLoader)
1264 return; 1258 return;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent()); 1397 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent());
1404 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType)); 1398 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType));
1405 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); 1399 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested);
1406 ResourceRequest& request = frameLoadRequest.resourceRequest(); 1400 ResourceRequest& request = frameLoadRequest.resourceRequest();
1407 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirect)) 1401 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirect))
1408 return; 1402 return;
1409 if (!shouldClose(navigationType == NavigationTypeReload)) 1403 if (!shouldClose(navigationType == NavigationTypeReload))
1410 return; 1404 return;
1411 1405
1412 m_frame->document()->cancelParsing(); 1406 m_frame->document()->cancelParsing();
1413 1407 detachDocumentLoader(m_provisionalDocumentLoader);
1414 if (m_provisionalDocumentLoader) {
1415 m_provisionalDocumentLoader->stopLoading();
1416 detachDocumentLoader(m_provisionalDocumentLoader);
1417 }
1418 1408
1419 // beforeunload fired above, and detaching a DocumentLoader can fire 1409 // beforeunload fired above, and detaching a DocumentLoader can fire
1420 // events, which can detach this frame. 1410 // events, which can detach this frame.
1421 if (!m_frame->host()) 1411 if (!m_frame->host())
1422 return; 1412 return;
1423 1413
1424 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, reques t, frameLoadRequest.substituteData().isValid() ? frameLoadRequest.substituteData () : defaultSubstituteDataForURL(request.url())); 1414 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, reques t, frameLoadRequest.substituteData().isValid() ? frameLoadRequest.substituteData () : defaultSubstituteDataForURL(request.url()));
1425 m_provisionalDocumentLoader->setNavigationType(navigationType); 1415 m_provisionalDocumentLoader->setNavigationType(navigationType);
1426 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(type == FrameLoad TypeReplaceCurrentItem); 1416 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(type == FrameLoad TypeReplaceCurrentItem);
1427 m_provisionalDocumentLoader->setIsClientRedirect(frameLoadRequest.clientRedi rect() == ClientRedirect); 1417 m_provisionalDocumentLoader->setIsClientRedirect(frameLoadRequest.clientRedi rect() == ClientRedirect);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 // FIXME: We need a way to propagate insecure requests policy flags to 1590 // FIXME: We need a way to propagate insecure requests policy flags to
1601 // out-of-process frames. For now, we'll always use default behavior. 1591 // out-of-process frames. For now, we'll always use default behavior.
1602 if (!parentFrame->isLocalFrame()) 1592 if (!parentFrame->isLocalFrame())
1603 return nullptr; 1593 return nullptr;
1604 1594
1605 ASSERT(toLocalFrame(parentFrame)->document()); 1595 ASSERT(toLocalFrame(parentFrame)->document());
1606 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1596 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1607 } 1597 }
1608 1598
1609 } // namespace blink 1599 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698