| 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 } | 927 } |
| 928 | 928 |
| 929 // The call to closeURL() invokes the unload event handler, which can execut
e arbitrary | 929 // The call to closeURL() invokes the unload event handler, which can execut
e arbitrary |
| 930 // JavaScript. If the script initiates a new load, we need to abandon the cu
rrent load, | 930 // JavaScript. If the script initiates a new load, we need to abandon the cu
rrent load, |
| 931 // or the two will stomp each other. | 931 // or the two will stomp each other. |
| 932 // detachChildren will similarly trigger child frame unload event handlers. | 932 // detachChildren will similarly trigger child frame unload event handlers. |
| 933 if (m_documentLoader) { | 933 if (m_documentLoader) { |
| 934 client()->dispatchWillClose(); | 934 client()->dispatchWillClose(); |
| 935 closeURL(); | 935 closeURL(); |
| 936 } | 936 } |
| 937 detachChildren(); | 937 m_frame->detachChildren(); |
| 938 if (pdl != m_provisionalDocumentLoader) | 938 if (pdl != m_provisionalDocumentLoader) |
| 939 return; | 939 return; |
| 940 if (m_documentLoader) | 940 if (m_documentLoader) |
| 941 m_documentLoader->detachFromFrame(); | 941 m_documentLoader->detachFromFrame(); |
| 942 m_documentLoader = m_provisionalDocumentLoader.release(); | 942 m_documentLoader = m_provisionalDocumentLoader.release(); |
| 943 m_state = FrameStateCommittedPage; | 943 m_state = FrameStateCommittedPage; |
| 944 | 944 |
| 945 if (isLoadingMainFrame()) | 945 if (isLoadingMainFrame()) |
| 946 m_frame->page()->chrome().client().needTouchEvents(false); | 946 m_frame->page()->chrome().client().needTouchEvents(false); |
| 947 | 947 |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 } else { | 1097 } else { |
| 1098 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint())
; | 1098 view->setScrollPositionNonProgrammatically(m_currentItem->scrollPoint())
; |
| 1099 } | 1099 } |
| 1100 | 1100 |
| 1101 if (m_frame->isMainFrame()) { | 1101 if (m_frame->isMainFrame()) { |
| 1102 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll
ingCoordinator()) | 1102 if (ScrollingCoordinator* scrollingCoordinator = m_frame->page()->scroll
ingCoordinator()) |
| 1103 scrollingCoordinator->frameViewRootLayerDidChange(view); | 1103 scrollingCoordinator->frameViewRootLayerDidChange(view); |
| 1104 } | 1104 } |
| 1105 } | 1105 } |
| 1106 | 1106 |
| 1107 void FrameLoader::detachChildren() | |
| 1108 { | |
| 1109 typedef Vector<RefPtr<LocalFrame> > FrameVector; | |
| 1110 FrameVector childrenToDetach; | |
| 1111 childrenToDetach.reserveCapacity(m_frame->tree().childCount()); | |
| 1112 for (Frame* child = m_frame->tree().lastChild(); child; child = child->tree(
).previousSibling()) { | |
| 1113 if (child->isLocalFrame()) | |
| 1114 childrenToDetach.append(toLocalFrame(child)); | |
| 1115 } | |
| 1116 FrameVector::iterator end = childrenToDetach.end(); | |
| 1117 for (FrameVector::iterator it = childrenToDetach.begin(); it != end; ++it) | |
| 1118 (*it)->loader().detachFromParent(); | |
| 1119 } | |
| 1120 | |
| 1121 // Called every time a resource is completely loaded or an error is received. | 1107 // Called every time a resource is completely loaded or an error is received. |
| 1122 void FrameLoader::checkLoadComplete() | 1108 void FrameLoader::checkLoadComplete() |
| 1123 { | 1109 { |
| 1124 ASSERT(client()->hasWebView()); | 1110 ASSERT(client()->hasWebView()); |
| 1125 if (Page* page = m_frame->page()) { | 1111 if (Page* page = m_frame->page()) { |
| 1126 if (page->mainFrame()->isLocalFrame()) | 1112 if (page->mainFrame()->isLocalFrame()) |
| 1127 page->deprecatedLocalMainFrame()->loader().checkLoadCompleteForThisF
rame(); | 1113 page->deprecatedLocalMainFrame()->loader().checkLoadCompleteForThisF
rame(); |
| 1128 } | 1114 } |
| 1129 } | 1115 } |
| 1130 | 1116 |
| 1131 String FrameLoader::userAgent(const KURL& url) const | 1117 String FrameLoader::userAgent(const KURL& url) const |
| 1132 { | 1118 { |
| 1133 String userAgent = client()->userAgent(url); | 1119 String userAgent = client()->userAgent(url); |
| 1134 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); | 1120 InspectorInstrumentation::applyUserAgentOverride(m_frame, &userAgent); |
| 1135 return userAgent; | 1121 return userAgent; |
| 1136 } | 1122 } |
| 1137 | 1123 |
| 1138 void FrameLoader::frameDetached() | |
| 1139 { | |
| 1140 // stopAllLoaders can detach the LocalFrame, so protect it. | |
| 1141 RefPtr<LocalFrame> protect(m_frame); | |
| 1142 stopAllLoaders(); | |
| 1143 detachFromParent(); | |
| 1144 } | |
| 1145 | |
| 1146 void FrameLoader::detachFromParent() | 1124 void FrameLoader::detachFromParent() |
| 1147 { | 1125 { |
| 1148 // Temporary explosions. We should never re-enter this code when this condit
ion is true. | 1126 // Temporary explosions. We should never re-enter this code when this condit
ion is true. |
| 1149 RELEASE_ASSERT(!m_willDetachClient); | 1127 RELEASE_ASSERT(!m_willDetachClient); |
| 1150 | 1128 // The caller must protect a reference to m_frame. |
| 1151 // stopAllLoaders can detach the LocalFrame, so protect it. | 1129 ASSERT(m_frame->refCount() > 1); |
| 1152 RefPtr<LocalFrame> protect(m_frame); | |
| 1153 | |
| 1154 closeURL(); | |
| 1155 detachChildren(); | |
| 1156 // stopAllLoaders() needs to be called after detachChildren(), because detac
hedChildren() | |
| 1157 // will trigger the unload event handlers of any child frames, and those eve
nt | |
| 1158 // handlers might start a new subresource load in this frame. | |
| 1159 stopAllLoaders(); | |
| 1160 | 1130 |
| 1161 InspectorInstrumentation::frameDetachedFromParent(m_frame); | 1131 InspectorInstrumentation::frameDetachedFromParent(m_frame); |
| 1162 | 1132 |
| 1163 if (m_documentLoader) | 1133 if (m_documentLoader) |
| 1164 m_documentLoader->detachFromFrame(); | 1134 m_documentLoader->detachFromFrame(); |
| 1165 m_documentLoader = nullptr; | 1135 m_documentLoader = nullptr; |
| 1166 | 1136 |
| 1167 if (!client()) | 1137 if (!client()) |
| 1168 return; | 1138 return; |
| 1169 | 1139 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1525 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. | 1495 // FIXME: We need a way to propagate sandbox flags to out-of-process frames. |
| 1526 Frame* parentFrame = m_frame->tree().parent(); | 1496 Frame* parentFrame = m_frame->tree().parent(); |
| 1527 if (parentFrame && parentFrame->isLocalFrame()) | 1497 if (parentFrame && parentFrame->isLocalFrame()) |
| 1528 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); | 1498 flags |= toLocalFrame(parentFrame)->document()->sandboxFlags(); |
| 1529 if (FrameOwner* frameOwner = m_frame->owner()) | 1499 if (FrameOwner* frameOwner = m_frame->owner()) |
| 1530 flags |= frameOwner->sandboxFlags(); | 1500 flags |= frameOwner->sandboxFlags(); |
| 1531 return flags; | 1501 return flags; |
| 1532 } | 1502 } |
| 1533 | 1503 |
| 1534 } // namespace blink | 1504 } // namespace blink |
| OLD | NEW |