| 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 m_currentItem->setVisualViewportScrollPoint(m_frame->host()->visualViewport(
).visibleRect().location()); | 246 m_currentItem->setVisualViewportScrollPoint(m_frame->host()->visualViewport(
).visibleRect().location()); |
| 247 | 247 |
| 248 if (m_frame->isMainFrame()) | 248 if (m_frame->isMainFrame()) |
| 249 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); | 249 m_currentItem->setPageScaleFactor(m_frame->page()->pageScaleFactor()); |
| 250 | 250 |
| 251 client()->didUpdateCurrentHistoryItem(); | 251 client()->didUpdateCurrentHistoryItem(); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void FrameLoader::dispatchUnloadEvent() | 254 void FrameLoader::dispatchUnloadEvent() |
| 255 { | 255 { |
| 256 // If the frame is unloading, the provisional loader should no longer be |
| 257 // protected. It will be detached soon. |
| 258 if (m_provisionalDocumentLoader) |
| 259 m_provisionalDocumentLoader->setProtect(false); |
| 256 saveScrollState(); | 260 saveScrollState(); |
| 257 | 261 |
| 258 if (m_frame->document() && !SVGImage::isInSVGImage(m_frame->document())) | 262 if (m_frame->document() && !SVGImage::isInSVGImage(m_frame->document())) |
| 259 m_frame->document()->dispatchUnloadEvents(); | 263 m_frame->document()->dispatchUnloadEvents(); |
| 260 | 264 |
| 261 if (Page* page = m_frame->page()) | 265 if (Page* page = m_frame->page()) |
| 262 page->undoStack().didUnloadFrame(*m_frame); | 266 page->undoStack().didUnloadFrame(*m_frame); |
| 263 } | 267 } |
| 264 | 268 |
| 265 void FrameLoader::didExplicitOpen() | 269 void FrameLoader::didExplicitOpen() |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 if (m_frame->document()->loadEventFinished()) | 683 if (m_frame->document()->loadEventFinished()) |
| 680 client()->didStopLoading(); | 684 client()->didStopLoading(); |
| 681 } | 685 } |
| 682 | 686 |
| 683 void FrameLoader::detachDocumentLoader(RefPtrWillBeMember<DocumentLoader>& loade
r) | 687 void FrameLoader::detachDocumentLoader(RefPtrWillBeMember<DocumentLoader>& loade
r) |
| 684 { | 688 { |
| 685 if (!loader) | 689 if (!loader) |
| 686 return; | 690 return; |
| 687 | 691 |
| 688 loader->detachFromFrame(); | 692 loader->detachFromFrame(); |
| 689 loader = nullptr; | 693 if (!loader || !loader->frame()) |
| 694 loader = nullptr; |
| 690 } | 695 } |
| 691 | 696 |
| 692 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp
e, ClientRedirectPolicy clientRedirect) | 697 void FrameLoader::loadInSameDocument(const KURL& url, PassRefPtr<SerializedScrip
tValue> stateObject, FrameLoadType frameLoadType, HistoryLoadType historyLoadTyp
e, ClientRedirectPolicy clientRedirect) |
| 693 { | 698 { |
| 694 // If we have a state object, we cannot also be a new navigation. | 699 // If we have a state object, we cannot also be a new navigation. |
| 695 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward); | 700 ASSERT(!stateObject || frameLoadType == FrameLoadTypeBackForward); |
| 696 | 701 |
| 697 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. | 702 // If we have a provisional request for a different document, a fragment scr
oll should cancel it. |
| 698 if (m_provisionalDocumentLoader) { | 703 if (m_provisionalDocumentLoader) { |
| 699 m_provisionalDocumentLoader->stopLoading(); | 704 m_provisionalDocumentLoader->stopLoading(); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 985 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); | 990 RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get()); |
| 986 | 991 |
| 987 m_inStopAllLoaders = true; | 992 m_inStopAllLoaders = true; |
| 988 | 993 |
| 989 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child;
child = child->tree().nextSibling()) { | 994 for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child;
child = child->tree().nextSibling()) { |
| 990 if (child->isLocalFrame()) | 995 if (child->isLocalFrame()) |
| 991 toLocalFrame(child.get())->loader().stopAllLoaders(); | 996 toLocalFrame(child.get())->loader().stopAllLoaders(); |
| 992 } | 997 } |
| 993 | 998 |
| 994 m_frame->document()->suppressLoadEvent(); | 999 m_frame->document()->suppressLoadEvent(); |
| 1000 // Don't stop loading the provisional loader if it is being protected (i.e. |
| 1001 // it is about to be committed) See prepareForCommit() for more details. |
| 995 if (m_provisionalDocumentLoader) | 1002 if (m_provisionalDocumentLoader) |
| 996 m_provisionalDocumentLoader->stopLoading(); | 1003 m_provisionalDocumentLoader->stopLoading(); |
| 997 if (m_documentLoader) | 1004 if (m_documentLoader) |
| 998 m_documentLoader->stopLoading(); | 1005 m_documentLoader->stopLoading(); |
| 999 m_frame->document()->cancelParsing(); | 1006 m_frame->document()->cancelParsing(); |
| 1000 | 1007 |
| 1001 detachDocumentLoader(m_provisionalDocumentLoader); | 1008 detachDocumentLoader(m_provisionalDocumentLoader); |
| 1002 | 1009 |
| 1003 m_checkTimer.stop(); | 1010 m_checkTimer.stop(); |
| 1004 m_frame->navigationScheduler().cancel(); | 1011 m_frame->navigationScheduler().cancel(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 client()->dispatchWillClose(); | 1062 client()->dispatchWillClose(); |
| 1056 dispatchUnloadEvent(); | 1063 dispatchUnloadEvent(); |
| 1057 } | 1064 } |
| 1058 m_frame->detachChildren(); | 1065 m_frame->detachChildren(); |
| 1059 // The previous calls to dispatchUnloadEvent() and detachChildren() can | 1066 // The previous calls to dispatchUnloadEvent() and detachChildren() can |
| 1060 // execute arbitrary script via things like unload events. If the executed | 1067 // execute arbitrary script via things like unload events. If the executed |
| 1061 // script intiates a new load or causes the current frame to be detached, | 1068 // script intiates a new load or causes the current frame to be detached, |
| 1062 // we need to abandon the current load. | 1069 // we need to abandon the current load. |
| 1063 if (pdl != m_provisionalDocumentLoader) | 1070 if (pdl != m_provisionalDocumentLoader) |
| 1064 return false; | 1071 return false; |
| 1072 // detachFromFrame() will abort XHRs that haven't completed, which can |
| 1073 // trigger event listeners for 'abort'. These event listeners might call |
| 1074 // window.stop(), which will in turn detach the provisional document loader. |
| 1075 // At this point, the provisional document loader should not detach, because |
| 1076 // then the FrameLoader would not have any attached DocumentLoaders. |
| 1065 if (m_documentLoader) { | 1077 if (m_documentLoader) { |
| 1066 FrameNavigationDisabler navigationDisabler(*m_frame); | 1078 FrameNavigationDisabler navigationDisabler(*m_frame); |
| 1079 m_provisionalDocumentLoader->setProtect(true); |
| 1067 detachDocumentLoader(m_documentLoader); | 1080 detachDocumentLoader(m_documentLoader); |
| 1081 if (m_provisionalDocumentLoader) |
| 1082 m_provisionalDocumentLoader->setProtect(false); |
| 1068 } | 1083 } |
| 1069 // detachFromFrame() will abort XHRs that haven't completed, which can | 1084 // 'abort' listeners can also detach the frame. |
| 1070 // trigger event listeners for 'abort'. These event listeners might detach | |
| 1071 // the frame. | |
| 1072 // TODO(dcheng): Investigate if this can be moved above the check that | |
| 1073 // m_provisionalDocumentLoader hasn't changed. | |
| 1074 if (!m_frame->client()) | 1085 if (!m_frame->client()) |
| 1075 return false; | 1086 return false; |
| 1087 ASSERT(m_provisionalDocumentLoader == pdl); |
| 1076 // No more events will be dispatched so detach the Document. | 1088 // No more events will be dispatched so detach the Document. |
| 1077 // TODO(yoav): Should we also be nullifying domWindow's document (or domWind
ow) since the doc is now detached? | 1089 // TODO(yoav): Should we also be nullifying domWindow's document (or domWind
ow) since the doc is now detached? |
| 1078 if (m_frame->document()) | 1090 if (m_frame->document()) |
| 1079 m_frame->document()->detach(); | 1091 m_frame->document()->detach(); |
| 1080 m_documentLoader = m_provisionalDocumentLoader.release(); | 1092 m_documentLoader = m_provisionalDocumentLoader.release(); |
| 1081 | 1093 |
| 1082 return true; | 1094 return true; |
| 1083 } | 1095 } |
| 1084 | 1096 |
| 1085 void FrameLoader::commitProvisionalLoad() | 1097 void FrameLoader::commitProvisionalLoad() |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 // FIXME: We need a way to propagate insecure requests policy flags to | 1573 // FIXME: We need a way to propagate insecure requests policy flags to |
| 1562 // out-of-process frames. For now, we'll always use default behavior. | 1574 // out-of-process frames. For now, we'll always use default behavior. |
| 1563 if (!parentFrame->isLocalFrame()) | 1575 if (!parentFrame->isLocalFrame()) |
| 1564 return nullptr; | 1576 return nullptr; |
| 1565 | 1577 |
| 1566 ASSERT(toLocalFrame(parentFrame)->document()); | 1578 ASSERT(toLocalFrame(parentFrame)->document()); |
| 1567 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; | 1579 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade()
; |
| 1568 } | 1580 } |
| 1569 | 1581 |
| 1570 } // namespace blink | 1582 } // namespace blink |
| OLD | NEW |