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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 client()->dispatchDidReceiveTitle(m_frame->document()->title()); | 718 client()->dispatchDidReceiveTitle(m_frame->document()->title()); |
719 if (m_frame->document()->loadEventFinished()) | 719 if (m_frame->document()->loadEventFinished()) |
720 client()->didStopLoading(); | 720 client()->didStopLoading(); |
721 } | 721 } |
722 | 722 |
723 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) | 723 void FrameLoader::detachDocumentLoader(Member<DocumentLoader>& loader) |
724 { | 724 { |
725 if (!loader) | 725 if (!loader) |
726 return; | 726 return; |
727 | 727 |
728 FrameNavigationDisabler navigationDisabler(*m_frame); | |
728 loader->detachFromFrame(); | 729 loader->detachFromFrame(); |
729 loader = nullptr; | 730 loader = nullptr; |
730 } | 731 } |
731 | 732 |
732 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp e, ClientRedirectPolicy clientRedirect, Document* initiatingDocument) | 733 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp e, ClientRedirectPolicy clientRedirect, Document* initiatingDocument) |
733 { | 734 { |
734 // If we have a state object, we cannot also be a new navigation. | 735 // If we have a state object, we cannot also be a new navigation. |
735 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward); | 736 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward); |
736 | 737 |
737 // If we have a provisional request for a different document, a fragment scr oll should cancel it. | 738 // If we have a provisional request for a different document, a fragment scr oll should cancel it. |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1105 // execute arbitrary script via things like unload events. If the executed | 1106 // execute arbitrary script via things like unload events. If the executed |
1106 // script intiates a new load or causes the current frame to be detached, | 1107 // script intiates a new load or causes the current frame to be detached, |
1107 // we need to abandon the current load. | 1108 // we need to abandon the current load. |
1108 if (pdl != m_provisionalDocumentLoader) | 1109 if (pdl != m_provisionalDocumentLoader) |
1109 return false; | 1110 return false; |
1110 // detachFromFrame() will abort XHRs that haven't completed, which can | 1111 // detachFromFrame() will abort XHRs that haven't completed, which can |
1111 // trigger event listeners for 'abort'. These event listeners might call | 1112 // trigger event listeners for 'abort'. These event listeners might call |
1112 // window.stop(), which will in turn detach the provisional document loader. | 1113 // window.stop(), which will in turn detach the provisional document loader. |
1113 // At this point, the provisional document loader should not detach, because | 1114 // At this point, the provisional document loader should not detach, because |
1114 // then the FrameLoader would not have any attached DocumentLoaders. | 1115 // then the FrameLoader would not have any attached DocumentLoaders. |
1115 if (m_documentLoader) { | 1116 if (m_documentLoader) { |
dcheng
2016/06/17 20:03:45
Unrelated nit: I wonder if we should just remove t
| |
1116 FrameNavigationDisabler navigationDisabler(*m_frame); | |
1117 TemporaryChange<bool> inDetachDocumentLoader(m_protectProvisionalLoader, true); | 1117 TemporaryChange<bool> inDetachDocumentLoader(m_protectProvisionalLoader, true); |
1118 detachDocumentLoader(m_documentLoader); | 1118 detachDocumentLoader(m_documentLoader); |
1119 } | 1119 } |
1120 // 'abort' listeners can also detach the frame. | 1120 // 'abort' listeners can also detach the frame. |
1121 if (!m_frame->client()) | 1121 if (!m_frame->client()) |
1122 return false; | 1122 return false; |
1123 ASSERT(m_provisionalDocumentLoader == pdl); | 1123 ASSERT(m_provisionalDocumentLoader == pdl); |
1124 // No more events will be dispatched so detach the Document. | 1124 // No more events will be dispatched so detach the Document. |
1125 // TODO(yoav): Should we also be nullifying domWindow's document (or domWind ow) since the doc is now detached? | 1125 // TODO(yoav): Should we also be nullifying domWindow's document (or domWind ow) since the doc is now detached? |
1126 if (m_frame->document()) | 1126 if (m_frame->document()) |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1413 return; | 1413 return; |
1414 | 1414 |
1415 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent()); | 1415 NavigationType navigationType = determineNavigationType(type, frameLoadReque st.resourceRequest().httpBody() || frameLoadRequest.form(), frameLoadRequest.tri ggeringEvent()); |
1416 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType)); | 1416 frameLoadRequest.resourceRequest().setRequestContext(determineRequestContext FromNavigationType(navigationType)); |
1417 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); | 1417 frameLoadRequest.resourceRequest().setFrameType(m_frame->isMainFrame() ? Web URLRequest::FrameTypeTopLevel : WebURLRequest::FrameTypeNested); |
1418 ResourceRequest& request = frameLoadRequest.resourceRequest(); | 1418 ResourceRequest& request = frameLoadRequest.resourceRequest(); |
1419 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect)) | 1419 if (!shouldContinueForNavigationPolicy(request, frameLoadRequest.substituteD ata(), nullptr, frameLoadRequest.shouldCheckMainWorldContentSecurityPolicy(), na vigationType, navigationPolicy, type == FrameLoadTypeReplaceCurrentItem, frameLo adRequest.clientRedirect() == ClientRedirectPolicy::ClientRedirect)) |
1420 return; | 1420 return; |
1421 | 1421 |
1422 m_frame->document()->cancelParsing(); | 1422 m_frame->document()->cancelParsing(); |
1423 if (m_provisionalDocumentLoader) { | 1423 detachDocumentLoader(m_provisionalDocumentLoader); |
1424 FrameNavigationDisabler navigationDisabler(*m_frame); | |
1425 detachDocumentLoader(m_provisionalDocumentLoader); | |
1426 } | |
1427 | 1424 |
1428 // beforeunload fired above, and detaching a DocumentLoader can fire | 1425 // beforeunload fired above, and detaching a DocumentLoader can fire |
1429 // events, which can detach this frame. | 1426 // events, which can detach this frame. |
1430 if (!m_frame->host()) | 1427 if (!m_frame->host()) |
1431 return; | 1428 return; |
1432 | 1429 |
1433 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, reques t, frameLoadRequest.substituteData().isValid() ? frameLoadRequest.substituteData () : defaultSubstituteDataForURL(request.url())); | 1430 m_provisionalDocumentLoader = client()->createDocumentLoader(m_frame, reques t, frameLoadRequest.substituteData().isValid() ? frameLoadRequest.substituteData () : defaultSubstituteDataForURL(request.url())); |
1434 m_provisionalDocumentLoader->setNavigationType(navigationType); | 1431 m_provisionalDocumentLoader->setNavigationType(navigationType); |
1435 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(type == FrameLoad TypeReplaceCurrentItem); | 1432 m_provisionalDocumentLoader->setReplacesCurrentHistoryItem(type == FrameLoad TypeReplaceCurrentItem); |
1436 m_provisionalDocumentLoader->setIsClientRedirect(frameLoadRequest.clientRedi rect() == ClientRedirectPolicy::ClientRedirect); | 1433 m_provisionalDocumentLoader->setIsClientRedirect(frameLoadRequest.clientRedi rect() == ClientRedirectPolicy::ClientRedirect); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1612 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); | 1609 tracedValue->setString("documentLoaderURL", m_documentLoader ? m_documentLoa der->url() : String()); |
1613 return tracedValue; | 1610 return tracedValue; |
1614 } | 1611 } |
1615 | 1612 |
1616 inline void FrameLoader::takeObjectSnapshot() const | 1613 inline void FrameLoader::takeObjectSnapshot() const |
1617 { | 1614 { |
1618 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); | 1615 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID("loading", "FrameLoader", this, toTraced Value()); |
1619 } | 1616 } |
1620 | 1617 |
1621 } // namespace blink | 1618 } // namespace blink |
OLD | NEW |