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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (!m_stateMachine.committedFirstRealDocumentLoad()) | 260 if (!m_stateMachine.committedFirstRealDocumentLoad()) |
261 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad
); | 261 m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad
); |
262 | 262 |
263 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results | 263 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
away results |
264 // from a subsequent window.document.open / window.document.write call. | 264 // from a subsequent window.document.open / window.document.write call. |
265 // Canceling redirection here works for all cases because document.open | 265 // Canceling redirection here works for all cases because document.open |
266 // implicitly precedes document.write. | 266 // implicitly precedes document.write. |
267 m_frame->navigationScheduler().cancel(); | 267 m_frame->navigationScheduler().cancel(); |
268 } | 268 } |
269 | 269 |
| 270 void FrameLoader::didStartForFrame(DocumentLoader* loader) |
| 271 { |
| 272 if (m_state == FrameStateProvisional && loader == m_provisionalDocumentLoade
r.get()) |
| 273 stopDocumentLoaders(); |
| 274 } |
| 275 |
270 void FrameLoader::clear() | 276 void FrameLoader::clear() |
271 { | 277 { |
272 if (m_stateMachine.creatingInitialEmptyDocument()) | 278 if (m_stateMachine.creatingInitialEmptyDocument()) |
273 return; | 279 return; |
274 | 280 |
275 m_frame->editor().clear(); | 281 m_frame->editor().clear(); |
276 m_frame->document()->cancelParsing(); | 282 m_frame->document()->cancelParsing(); |
277 m_frame->document()->prepareForDestruction(); | 283 m_frame->document()->prepareForDestruction(); |
278 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); | 284 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); |
279 | 285 |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 else if (!m_documentLoader->unreachableURL().isEmpty()) | 767 else if (!m_documentLoader->unreachableURL().isEmpty()) |
762 request.setURL(m_documentLoader->unreachableURL()); | 768 request.setURL(m_documentLoader->unreachableURL()); |
763 | 769 |
764 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro
mOrigin : FrameLoadTypeReload; | 770 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro
mOrigin : FrameLoadTypeReload; |
765 NavigationAction action(request, type, request.httpMethod() == "POST"); | 771 NavigationAction action(request, type, request.httpMethod() == "POST"); |
766 loadWithNavigationAction(action, type, 0, SubstituteData(), NotClientRedirec
t, overrideEncoding); | 772 loadWithNavigationAction(action, type, 0, SubstituteData(), NotClientRedirec
t, overrideEncoding); |
767 } | 773 } |
768 | 774 |
769 void FrameLoader::stopAllLoaders() | 775 void FrameLoader::stopAllLoaders() |
770 { | 776 { |
| 777 stopProvisionalLoaders(); |
| 778 stopDocumentLoaders(); |
| 779 } |
| 780 |
| 781 void FrameLoader::stopProvisionalLoaders() |
| 782 { |
771 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) | 783 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) |
772 return; | 784 return; |
773 | 785 |
774 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. | 786 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. |
775 if (m_inStopAllLoaders) | 787 if (m_inStopAllLoaders) |
776 return; | 788 return; |
777 | 789 |
778 // Calling stopLoading() on the provisional document loader can blow away | 790 // Calling stopLoading() on the provisional document loader can blow away |
779 // the frame from underneath. | 791 // the frame from underneath. |
780 RefPtr<Frame> protect(m_frame); | 792 RefPtr<Frame> protect(m_frame); |
781 | 793 |
782 m_inStopAllLoaders = true; | 794 m_inStopAllLoaders = true; |
783 | 795 |
| 796 if (m_provisionalDocumentLoader) { |
| 797 m_provisionalDocumentLoader->stopLoading(); |
| 798 m_provisionalDocumentLoader->detachFromFrame(); |
| 799 } |
| 800 |
| 801 m_provisionalDocumentLoader = 0; |
| 802 |
| 803 m_inStopAllLoaders = false; |
| 804 |
| 805 if (m_state == FrameStateProvisional) |
| 806 m_client->didStopActiveLoader(); |
| 807 } |
| 808 |
| 809 void FrameLoader::stopDocumentLoaders() |
| 810 { |
| 811 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No
Dismissal) |
| 812 return; |
| 813 |
| 814 // If this method is called from within this method, infinite recursion can
occur (3442218). Avoid this. |
| 815 if (m_inStopAllLoaders) |
| 816 return; |
| 817 |
| 818 // Calling stopLoading() on the provisional document loader can blow away |
| 819 // the frame from underneath. |
| 820 RefPtr<Frame> protect(m_frame); |
| 821 |
| 822 m_inStopAllLoaders = true; |
| 823 |
784 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil
d->tree().nextSibling()) | 824 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil
d->tree().nextSibling()) |
785 child->loader().stopAllLoaders(); | 825 child->loader().stopAllLoaders(); |
786 if (m_provisionalDocumentLoader) | 826 |
787 m_provisionalDocumentLoader->stopLoading(); | |
788 if (m_documentLoader) | 827 if (m_documentLoader) |
789 m_documentLoader->stopLoading(); | 828 m_documentLoader->stopLoading(); |
790 | 829 |
791 if (m_provisionalDocumentLoader) | |
792 m_provisionalDocumentLoader->detachFromFrame(); | |
793 m_provisionalDocumentLoader = 0; | |
794 | |
795 m_checkTimer.stop(); | |
796 | |
797 m_inStopAllLoaders = false; | 830 m_inStopAllLoaders = false; |
798 | 831 |
799 // detachFromParent() can be called multiple times on same Frame, which | 832 // detachFromParent() can be called multiple times on same Frame, which |
800 // means we may no longer have a FrameLoaderClient to talk to. | 833 // means we may no longer have a FrameLoaderClient to talk to. |
801 if (m_client) | 834 if (m_client) |
802 m_client->didStopAllLoaders(); | 835 m_client->didStopActiveLoader(); |
803 } | 836 } |
804 | 837 |
805 void FrameLoader::didAccessInitialDocument() | 838 void FrameLoader::didAccessInitialDocument() |
806 { | 839 { |
807 // We only need to notify the client once, and only for the main frame. | 840 // We only need to notify the client once, and only for the main frame. |
808 if (isLoadingMainFrame() && !m_didAccessInitialDocument) { | 841 if (isLoadingMainFrame() && !m_didAccessInitialDocument) { |
809 m_didAccessInitialDocument = true; | 842 m_didAccessInitialDocument = true; |
810 // Notify asynchronously, since this is called within a JavaScript secur
ity check. | 843 // Notify asynchronously, since this is called within a JavaScript secur
ity check. |
811 m_didAccessInitialDocumentTimer.startOneShot(0); | 844 m_didAccessInitialDocumentTimer.startOneShot(0); |
812 } | 845 } |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn
coding()); | 1318 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn
coding()); |
1286 | 1319 |
1287 // stopAllLoaders can detach the Frame, so protect it. | 1320 // stopAllLoaders can detach the Frame, so protect it. |
1288 RefPtr<Frame> protect(m_frame); | 1321 RefPtr<Frame> protect(m_frame); |
1289 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, Doc
umentLoader::PolicyCheckStandard) || !shouldClose()) && m_policyDocumentLoader)
{ | 1322 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request, Doc
umentLoader::PolicyCheckStandard) || !shouldClose()) && m_policyDocumentLoader)
{ |
1290 m_policyDocumentLoader->detachFromFrame(); | 1323 m_policyDocumentLoader->detachFromFrame(); |
1291 m_policyDocumentLoader = 0; | 1324 m_policyDocumentLoader = 0; |
1292 return; | 1325 return; |
1293 } | 1326 } |
1294 | 1327 |
1295 // A new navigation is in progress, so don't clear the history's provisional
item. | 1328 stopProvisionalLoaders(); |
1296 stopAllLoaders(); | |
1297 | 1329 |
1298 // <rdar://problem/6250856> - In certain circumstances on pages with multipl
e frames, stopAllLoaders() | 1330 // <rdar://problem/6250856> - In certain circumstances on pages with multipl
e frames, stopAllLoaders() |
1299 // might detach the current FrameLoader, in which case we should bail on thi
s newly defunct load. | 1331 // might detach the current FrameLoader, in which case we should bail on thi
s newly defunct load. |
1300 if (!m_frame->page() || !m_policyDocumentLoader) | 1332 if (!m_frame->page() || !m_policyDocumentLoader) |
1301 return; | 1333 return; |
1302 | 1334 |
1303 if (isLoadingMainFrame()) | 1335 if (isLoadingMainFrame()) |
1304 m_frame->page()->inspectorController().resume(); | 1336 m_frame->page()->inspectorController().resume(); |
1305 m_frame->navigationScheduler().cancel(); | 1337 m_frame->navigationScheduler().cancel(); |
1306 | 1338 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1472 { | 1504 { |
1473 SandboxFlags flags = m_forcedSandboxFlags; | 1505 SandboxFlags flags = m_forcedSandboxFlags; |
1474 if (Frame* parentFrame = m_frame->tree().parent()) | 1506 if (Frame* parentFrame = m_frame->tree().parent()) |
1475 flags |= parentFrame->document()->sandboxFlags(); | 1507 flags |= parentFrame->document()->sandboxFlags(); |
1476 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) | 1508 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) |
1477 flags |= ownerElement->sandboxFlags(); | 1509 flags |= ownerElement->sandboxFlags(); |
1478 return flags; | 1510 return flags; |
1479 } | 1511 } |
1480 | 1512 |
1481 } // namespace WebCore | 1513 } // namespace WebCore |
OLD | NEW |