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

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

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | Source/core/loader/HistoryItem.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, UpdateBackForwardListPolicy updateBackForwardList, ClientRe directPolicy clientRedirect) 574 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip tValue> stateObject, UpdateBackForwardListPolicy updateBackForwardList, ClientRe directPolicy clientRedirect)
575 { 575 {
576 // If we have a state object, we cannot also be a new navigation. 576 // If we have a state object, we cannot also be a new navigation.
577 ASSERT(!stateObject || updateBackForwardList == DoNotUpdateBackForwardList); 577 ASSERT(!stateObject || updateBackForwardList == DoNotUpdateBackForwardList);
578 578
579 // If we have a provisional request for a different document, a fragment scr oll should cancel it. 579 // If we have a provisional request for a different document, a fragment scr oll should cancel it.
580 if (m_provisionalDocumentLoader) { 580 if (m_provisionalDocumentLoader) {
581 m_provisionalDocumentLoader->stopLoading(); 581 m_provisionalDocumentLoader->stopLoading();
582 if (m_provisionalDocumentLoader) 582 if (m_provisionalDocumentLoader)
583 m_provisionalDocumentLoader->detachFromFrame(); 583 m_provisionalDocumentLoader->detachFromFrame();
584 m_provisionalDocumentLoader = 0; 584 m_provisionalDocumentLoader = nullptr;
585 } 585 }
586 saveDocumentAndScrollState(); 586 saveDocumentAndScrollState();
587 587
588 KURL oldURL = m_frame->document()->url(); 588 KURL oldURL = m_frame->document()->url();
589 // If we were in the autoscroll/panScroll mode we want to stop it before fol lowing the link to the anchor 589 // If we were in the autoscroll/panScroll mode we want to stop it before fol lowing the link to the anchor
590 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme ntIdentifier() != oldURL.fragmentIdentifier(); 590 bool hashChange = equalIgnoringFragmentIdentifier(url, oldURL) && url.fragme ntIdentifier() != oldURL.fragmentIdentifier();
591 if (hashChange) { 591 if (hashChange) {
592 m_frame->eventHandler().stopAutoscroll(); 592 m_frame->eventHandler().stopAutoscroll();
593 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url); 593 m_frame->domWindow()->enqueueHashchangeEvent(oldURL, url);
594 } 594 }
595 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect); 595 m_documentLoader->setIsClientRedirect(clientRedirect == ClientRedirect);
596 m_documentLoader->setReplacesCurrentHistoryItem(updateBackForwardList == DoN otUpdateBackForwardList); 596 m_documentLoader->setReplacesCurrentHistoryItem(updateBackForwardList == DoN otUpdateBackForwardList);
597 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, 0, updat eBackForwardList); 597 updateForSameDocumentNavigation(url, SameDocumentNavigationDefault, nullptr, updateBackForwardList);
598 598
599 // It's important to model this as a load that starts and immediately finish es. 599 // It's important to model this as a load that starts and immediately finish es.
600 // Otherwise, the parent frame may think we never finished loading. 600 // Otherwise, the parent frame may think we never finished loading.
601 started(); 601 started();
602 602
603 // We need to scroll to the fragment whether or not a hash change occurred, since 603 // We need to scroll to the fragment whether or not a hash change occurred, since
604 // the user might have scrolled since the previous navigation. 604 // the user might have scrolled since the previous navigation.
605 scrollToFragmentWithParentBoundary(url); 605 scrollToFragmentWithParentBoundary(url);
606 606
607 m_isComplete = false; 607 m_isComplete = false;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 if (action.policy() == NavigationPolicyDownload) 730 if (action.policy() == NavigationPolicyDownload)
731 m_client->loadURLExternally(action.resourceRequest(), NavigationPoli cyDownload); 731 m_client->loadURLExternally(action.resourceRequest(), NavigationPoli cyDownload);
732 else 732 else
733 createWindowForRequest(request, m_frame, action.policy(), request.sh ouldSendReferrer()); 733 createWindowForRequest(request, m_frame, action.policy(), request.sh ouldSendReferrer());
734 return; 734 return;
735 } 735 }
736 736
737 const KURL& url = request.resourceRequest().url(); 737 const KURL& url = request.resourceRequest().url();
738 if (shouldPerformFragmentNavigation(request.formState(), request.resourceReq uest().httpMethod(), newLoadType, url)) { 738 if (shouldPerformFragmentNavigation(request.formState(), request.resourceReq uest().httpMethod(), newLoadType, url)) {
739 m_documentLoader->setTriggeringAction(action); 739 m_documentLoader->setTriggeringAction(action);
740 loadInSameDocument(url, 0, newLoadType == FrameLoadTypeStandard ? Update BackForwardList : DoNotUpdateBackForwardList, request.clientRedirect()); 740 loadInSameDocument(url, nullptr, newLoadType == FrameLoadTypeStandard ? UpdateBackForwardList : DoNotUpdateBackForwardList, request.clientRedirect());
741 return; 741 return;
742 } 742 }
743 bool sameURL = shouldTreatURLAsSameAsCurrent(url); 743 bool sameURL = shouldTreatURLAsSameAsCurrent(url);
744 loadWithNavigationAction(action, newLoadType, request.formState(), request.s ubstituteData(), request.clientRedirect()); 744 loadWithNavigationAction(action, newLoadType, request.formState(), request.s ubstituteData(), request.clientRedirect());
745 // Example of this case are sites that reload the same URL with a different cookie 745 // Example of this case are sites that reload the same URL with a different cookie
746 // driving the generated content, or a master frame with links that drive a target 746 // driving the generated content, or a master frame with links that drive a target
747 // frame, where the user has clicked on the same link repeatedly. 747 // frame, where the user has clicked on the same link repeatedly.
748 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST") 748 if (sameURL && newLoadType != FrameLoadTypeReload && newLoadType != FrameLoa dTypeReloadFromOrigin && request.resourceRequest().httpMethod() != "POST")
749 m_loadType = FrameLoadTypeSame; 749 m_loadType = FrameLoadTypeSame;
750 } 750 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 if (!m_currentItem) 788 if (!m_currentItem)
789 return; 789 return;
790 790
791 ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), Reload IgnoringCacheData); 791 ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), Reload IgnoringCacheData);
792 if (!overrideURL.isEmpty()) { 792 if (!overrideURL.isEmpty()) {
793 request.setURL(overrideURL); 793 request.setURL(overrideURL);
794 request.clearHTTPReferrer(); 794 request.clearHTTPReferrer();
795 } 795 }
796 796
797 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro mOrigin : FrameLoadTypeReload; 797 FrameLoadType type = reloadPolicy == EndToEndReload ? FrameLoadTypeReloadFro mOrigin : FrameLoadTypeReload;
798 loadWithNavigationAction(NavigationAction(request, type), type, 0, Substitut eData(), NotClientRedirect, overrideEncoding); 798 loadWithNavigationAction(NavigationAction(request, type), type, nullptr, Sub stituteData(), NotClientRedirect, overrideEncoding);
799 } 799 }
800 800
801 void FrameLoader::stopAllLoaders() 801 void FrameLoader::stopAllLoaders()
802 { 802 {
803 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal) 803 if (m_frame->document()->pageDismissalEventBeingDispatched() != Document::No Dismissal)
804 return; 804 return;
805 805
806 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this. 806 // If this method is called from within this method, infinite recursion can occur (3442218). Avoid this.
807 if (m_inStopAllLoaders) 807 if (m_inStopAllLoaders)
808 return; 808 return;
809 809
810 // Calling stopLoading() on the provisional document loader can blow away 810 // Calling stopLoading() on the provisional document loader can blow away
811 // the frame from underneath. 811 // the frame from underneath.
812 RefPtr<Frame> protect(m_frame); 812 RefPtr<Frame> protect(m_frame);
813 813
814 m_inStopAllLoaders = true; 814 m_inStopAllLoaders = true;
815 815
816 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling()) 816 for (RefPtr<Frame> child = m_frame->tree().firstChild(); child; child = chil d->tree().nextSibling())
817 child->loader().stopAllLoaders(); 817 child->loader().stopAllLoaders();
818 if (m_provisionalDocumentLoader) 818 if (m_provisionalDocumentLoader)
819 m_provisionalDocumentLoader->stopLoading(); 819 m_provisionalDocumentLoader->stopLoading();
820 if (m_documentLoader) 820 if (m_documentLoader)
821 m_documentLoader->stopLoading(); 821 m_documentLoader->stopLoading();
822 822
823 if (m_provisionalDocumentLoader) 823 if (m_provisionalDocumentLoader)
824 m_provisionalDocumentLoader->detachFromFrame(); 824 m_provisionalDocumentLoader->detachFromFrame();
825 m_provisionalDocumentLoader = 0; 825 m_provisionalDocumentLoader = nullptr;
826 826
827 m_checkTimer.stop(); 827 m_checkTimer.stop();
828 828
829 m_inStopAllLoaders = false; 829 m_inStopAllLoaders = false;
830 830
831 // detachFromParent() can be called multiple times on same Frame, which 831 // detachFromParent() can be called multiple times on same Frame, which
832 // means we may no longer have a FrameLoaderClient to talk to. 832 // means we may no longer have a FrameLoaderClient to talk to.
833 if (m_client) 833 if (m_client)
834 m_client->didStopAllLoaders(); 834 m_client->didStopAllLoaders();
835 } 835 }
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 945
946 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) { 946 if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
947 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror(); 947 const ResourceError& error = m_provisionalDocumentLoader->mainDocumentEr ror();
948 if (error.isNull()) 948 if (error.isNull())
949 return; 949 return;
950 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader; 950 RefPtr<DocumentLoader> loader = m_provisionalDocumentLoader;
951 m_client->dispatchDidFailProvisionalLoad(error); 951 m_client->dispatchDidFailProvisionalLoad(error);
952 if (loader != m_provisionalDocumentLoader) 952 if (loader != m_provisionalDocumentLoader)
953 return; 953 return;
954 m_provisionalDocumentLoader->detachFromFrame(); 954 m_provisionalDocumentLoader->detachFromFrame();
955 m_provisionalDocumentLoader = 0; 955 m_provisionalDocumentLoader = nullptr;
956 m_progressTracker->progressCompleted(); 956 m_progressTracker->progressCompleted();
957 m_state = FrameStateComplete; 957 m_state = FrameStateComplete;
958 } 958 }
959 959
960 if (m_state != FrameStateCommittedPage) 960 if (m_state != FrameStateCommittedPage)
961 return; 961 return;
962 962
963 if (!m_documentLoader || (m_documentLoader->isLoadingInAPISense() && !m_inSt opAllLoaders)) 963 if (!m_documentLoader || (m_documentLoader->isLoadingInAPISense() && !m_inSt opAllLoaders))
964 return; 964 return;
965 965
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 childrenToDetach.reserveCapacity(m_frame->tree().childCount()); 1027 childrenToDetach.reserveCapacity(m_frame->tree().childCount());
1028 for (Frame* child = m_frame->tree().lastChild(); child; child = child->tree( ).previousSibling()) 1028 for (Frame* child = m_frame->tree().lastChild(); child; child = child->tree( ).previousSibling())
1029 childrenToDetach.append(child); 1029 childrenToDetach.append(child);
1030 FrameVector::iterator end = childrenToDetach.end(); 1030 FrameVector::iterator end = childrenToDetach.end();
1031 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it) 1031 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it)
1032 (*it)->loader().detachFromParent(); 1032 (*it)->loader().detachFromParent();
1033 } 1033 }
1034 1034
1035 void FrameLoader::closeAndRemoveChild(Frame* child) 1035 void FrameLoader::closeAndRemoveChild(Frame* child)
1036 { 1036 {
1037 child->setView(0); 1037 child->setView(nullptr);
1038 if (child->ownerElement() && child->page()) 1038 if (child->ownerElement() && child->page())
1039 child->page()->decrementSubframeCount(); 1039 child->page()->decrementSubframeCount();
1040 child->willDetachFrameHost(); 1040 child->willDetachFrameHost();
1041 child->loader().detachClient(); 1041 child->loader().detachClient();
1042 } 1042 }
1043 1043
1044 // Called every time a resource is completely loaded or an error is received. 1044 // Called every time a resource is completely loaded or an error is received.
1045 void FrameLoader::checkLoadComplete() 1045 void FrameLoader::checkLoadComplete()
1046 { 1046 {
1047 ASSERT(m_client->hasWebView()); 1047 ASSERT(m_client->hasWebView());
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 detachChildren(); 1100 detachChildren();
1101 // stopAllLoaders() needs to be called after detachChildren(), because detac hedChildren() 1101 // stopAllLoaders() needs to be called after detachChildren(), because detac hedChildren()
1102 // will trigger the unload event handlers of any child frames, and those eve nt 1102 // will trigger the unload event handlers of any child frames, and those eve nt
1103 // handlers might start a new subresource load in this frame. 1103 // handlers might start a new subresource load in this frame.
1104 stopAllLoaders(); 1104 stopAllLoaders();
1105 1105
1106 InspectorInstrumentation::frameDetachedFromParent(m_frame); 1106 InspectorInstrumentation::frameDetachedFromParent(m_frame);
1107 1107
1108 if (m_documentLoader) 1108 if (m_documentLoader)
1109 m_documentLoader->detachFromFrame(); 1109 m_documentLoader->detachFromFrame();
1110 m_documentLoader = 0; 1110 m_documentLoader = nullptr;
1111 1111
1112 if (!m_client) 1112 if (!m_client)
1113 return; 1113 return;
1114 1114
1115 // FIXME: All this code belongs up in Page. 1115 // FIXME: All this code belongs up in Page.
1116 if (Frame* parent = m_frame->tree().parent()) { 1116 if (Frame* parent = m_frame->tree().parent()) {
1117 parent->loader().closeAndRemoveChild(m_frame); 1117 parent->loader().closeAndRemoveChild(m_frame);
1118 parent->loader().scheduleCheckCompleted(); 1118 parent->loader().scheduleCheckCompleted();
1119 } else { 1119 } else {
1120 m_frame->setView(0); 1120 m_frame->setView(nullptr);
1121 m_frame->willDetachFrameHost(); 1121 m_frame->willDetachFrameHost();
1122 detachClient(); 1122 detachClient();
1123 } 1123 }
1124 m_frame->detachFromFrameHost(); 1124 m_frame->detachFromFrameHost();
1125 1125
1126 } 1126 }
1127 1127
1128 void FrameLoader::detachClient() 1128 void FrameLoader::detachClient()
1129 { 1129 {
1130 ASSERT(m_client); 1130 ASSERT(m_client);
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 m_policyDocumentLoader->setOverrideEncoding(parent->loader().documentLoa der()->overrideEncoding()); 1291 m_policyDocumentLoader->setOverrideEncoding(parent->loader().documentLoa der()->overrideEncoding());
1292 else if (!overrideEncoding.isEmpty()) 1292 else if (!overrideEncoding.isEmpty())
1293 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding); 1293 m_policyDocumentLoader->setOverrideEncoding(overrideEncoding);
1294 else if (m_documentLoader) 1294 else if (m_documentLoader)
1295 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding()); 1295 m_policyDocumentLoader->setOverrideEncoding(m_documentLoader->overrideEn coding());
1296 1296
1297 // stopAllLoaders can detach the Frame, so protect it. 1297 // stopAllLoaders can detach the Frame, so protect it.
1298 RefPtr<Frame> protect(m_frame); 1298 RefPtr<Frame> protect(m_frame);
1299 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request) || !shouldClose()) && m_policyDocumentLoader) { 1299 if ((!m_policyDocumentLoader->shouldContinueForNavigationPolicy(request) || !shouldClose()) && m_policyDocumentLoader) {
1300 m_policyDocumentLoader->detachFromFrame(); 1300 m_policyDocumentLoader->detachFromFrame();
1301 m_policyDocumentLoader = 0; 1301 m_policyDocumentLoader = nullptr;
1302 return; 1302 return;
1303 } 1303 }
1304 1304
1305 // A new navigation is in progress, so don't clear the history's provisional item. 1305 // A new navigation is in progress, so don't clear the history's provisional item.
1306 stopAllLoaders(); 1306 stopAllLoaders();
1307 1307
1308 // <rdar://problem/6250856> - In certain circumstances on pages with multipl e frames, stopAllLoaders() 1308 // <rdar://problem/6250856> - In certain circumstances on pages with multipl e frames, stopAllLoaders()
1309 // might detach the current FrameLoader, in which case we should bail on thi s newly defunct load. 1309 // might detach the current FrameLoader, in which case we should bail on thi s newly defunct load.
1310 if (!m_frame->page() || !m_policyDocumentLoader) 1310 if (!m_frame->page() || !m_policyDocumentLoader)
1311 return; 1311 return;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1406 } 1406 }
1407 1407
1408 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy) 1408 void FrameLoader::loadHistoryItem(HistoryItem* item, HistoryLoadType historyLoad Type, ResourceRequestCachePolicy cachePolicy)
1409 { 1409 {
1410 m_provisionalItem = item; 1410 m_provisionalItem = item;
1411 if (historyLoadType == HistorySameDocumentLoad) { 1411 if (historyLoadType == HistorySameDocumentLoad) {
1412 loadInSameDocument(item->url(), item->stateObject(), DoNotUpdateBackForw ardList, NotClientRedirect); 1412 loadInSameDocument(item->url(), item->stateObject(), DoNotUpdateBackForw ardList, NotClientRedirect);
1413 restoreScrollPositionAndViewState(ForcedRestoreForSameDocumentHistoryNav igation); 1413 restoreScrollPositionAndViewState(ForcedRestoreForSameDocumentHistoryNav igation);
1414 return; 1414 return;
1415 } 1415 }
1416 loadWithNavigationAction(NavigationAction(requestFromHistoryItem(item, cache Policy), FrameLoadTypeBackForward), FrameLoadTypeBackForward, 0, SubstituteData( )); 1416 loadWithNavigationAction(NavigationAction(requestFromHistoryItem(item, cache Policy), FrameLoadTypeBackForward), FrameLoadTypeBackForward, nullptr, Substitut eData());
1417 } 1417 }
1418 1418
1419 void FrameLoader::dispatchDocumentElementAvailable() 1419 void FrameLoader::dispatchDocumentElementAvailable()
1420 { 1420 {
1421 m_client->documentElementAvailable(); 1421 m_client->documentElementAvailable();
1422 } 1422 }
1423 1423
1424 void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds() 1424 void FrameLoader::dispatchDidClearWindowObjectsInAllWorlds()
1425 { 1425 {
1426 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript)) 1426 if (!m_frame->script().canExecuteScripts(NotAboutToExecuteScript))
(...skipping 21 matching lines...) Expand all
1448 { 1448 {
1449 SandboxFlags flags = m_forcedSandboxFlags; 1449 SandboxFlags flags = m_forcedSandboxFlags;
1450 if (Frame* parentFrame = m_frame->tree().parent()) 1450 if (Frame* parentFrame = m_frame->tree().parent())
1451 flags |= parentFrame->document()->sandboxFlags(); 1451 flags |= parentFrame->document()->sandboxFlags();
1452 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement()) 1452 if (HTMLFrameOwnerElement* ownerElement = m_frame->ownerElement())
1453 flags |= ownerElement->sandboxFlags(); 1453 flags |= ownerElement->sandboxFlags();
1454 return flags; 1454 return flags;
1455 } 1455 }
1456 1456
1457 } // namespace WebCore 1457 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | Source/core/loader/HistoryItem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698