Chromium Code Reviews| 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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 void FrameLoader::clear() | 235 void FrameLoader::clear() |
| 236 { | 236 { |
| 237 // clear() is called during (Local)Frame detachment or when | 237 // clear() is called during (Local)Frame detachment or when |
| 238 // reusing a FrameLoader by putting a new Document within it | 238 // reusing a FrameLoader by putting a new Document within it |
| 239 // (DocumentLoader::ensureWriter().) | 239 // (DocumentLoader::ensureWriter().) |
| 240 if (m_stateMachine.creatingInitialEmptyDocument()) | 240 if (m_stateMachine.creatingInitialEmptyDocument()) |
| 241 return; | 241 return; |
| 242 | 242 |
| 243 m_frame->editor().clear(); | 243 m_frame->editor().clear(); |
| 244 m_frame->document()->cancelParsing(); | 244 m_frame->document()->cancelParsing(); |
| 245 m_frame->document()->prepareForDestruction(); | |
| 246 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); | 245 m_frame->document()->removeFocusedElementOfSubtree(m_frame->document()); |
| 247 m_frame->selection().prepareForDestruction(); | 246 m_frame->selection().prepareForDestruction(); |
| 248 m_frame->eventHandler().clear(); | 247 m_frame->eventHandler().clear(); |
| 249 if (m_frame->view()) | 248 if (m_frame->view()) |
| 250 m_frame->view()->clear(); | 249 m_frame->view()->clear(); |
| 251 | 250 |
| 252 m_frame->script().enableEval(); | 251 m_frame->script().enableEval(); |
| 253 | 252 |
| 254 m_frame->navigationScheduler().cancel(); | 253 m_frame->navigationScheduler().cancel(); |
| 255 | 254 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 272 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); | 271 RefPtr<DocumentLoader> documentLoader(m_frame->document()->loader()); |
| 273 | 272 |
| 274 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL); | 273 UseCounter::count(*m_frame->document(), UseCounter::ReplaceDocumentViaJavaSc riptURL); |
| 275 | 274 |
| 276 // Prepare a DocumentInit before clearing the frame, because it may need to | 275 // Prepare a DocumentInit before clearing the frame, because it may need to |
| 277 // inherit an aliased security context. | 276 // inherit an aliased security context. |
| 278 DocumentInit init(m_frame->document()->url(), m_frame); | 277 DocumentInit init(m_frame->document()->url(), m_frame); |
| 279 init.withNewRegistrationContext(); | 278 init.withNewRegistrationContext(); |
| 280 | 279 |
| 281 stopAllLoaders(); | 280 stopAllLoaders(); |
| 281 m_frame->detachChildren(); | |
| 282 m_frame->document()->prepareForDestruction(); | |
| 282 clear(); | 283 clear(); |
| 283 | 284 |
| 284 // clear() potentially detaches the frame from the document. The | 285 // detachChildren() potentially detaches the frame from the document. The |
| 285 // loading cannot continue in that case. | 286 // loading cannot continue in that case. |
| 286 if (!m_frame->page()) | 287 if (!m_frame->page()) |
| 287 return; | 288 return; |
| 288 | 289 |
| 289 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument); | 290 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument); |
| 290 } | 291 } |
| 291 | 292 |
| 292 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) | 293 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) |
| 293 { | 294 { |
| 294 if (m_provisionalItem) | 295 if (m_provisionalItem) |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 957 } | 958 } |
| 958 | 959 |
| 959 // The call to dispatchUnloadEvent() can execute arbitrary JavaScript. | 960 // The call to dispatchUnloadEvent() can execute arbitrary JavaScript. |
| 960 // If the script initiates a new load, we need to abandon the current load, | 961 // If the script initiates a new load, we need to abandon the current load, |
| 961 // or the two will stomp each other. | 962 // or the two will stomp each other. |
| 962 // detachChildren will similarly trigger child frame unload event handlers. | 963 // detachChildren will similarly trigger child frame unload event handlers. |
| 963 if (m_documentLoader) { | 964 if (m_documentLoader) { |
| 964 client()->dispatchWillClose(); | 965 client()->dispatchWillClose(); |
| 965 dispatchUnloadEvent(); | 966 dispatchUnloadEvent(); |
| 966 } | 967 } |
| 967 m_frame->detachChildren(); | 968 if (m_frame->document()) { |
| 969 m_frame->detachChildren(); | |
|
Nate Chapin
2015/04/03 20:42:32
It's clear to me why detachChildren() is a noop if
dcheng
2015/04/03 20:47:20
The idea is if there's no document, there should b
| |
| 970 m_frame->document()->prepareForDestruction(); | |
| 971 } else { | |
| 972 // If there is no document, this is the creation of the initial empty | |
| 973 // doc, and there should be no child frames. | |
| 974 ASSERT(m_frame->tree().childCount() == 0); | |
|
Nate Chapin
2015/04/03 20:42:32
Maybe drop this else{} clause and ASSERT this unco
dcheng
2015/04/03 20:47:20
Done.
| |
| 975 } | |
| 968 if (pdl != m_provisionalDocumentLoader) | 976 if (pdl != m_provisionalDocumentLoader) |
| 969 return; | 977 return; |
| 970 if (m_documentLoader) | 978 if (m_documentLoader) |
| 971 m_documentLoader->detachFromFrame(); | 979 m_documentLoader->detachFromFrame(); |
| 972 m_documentLoader = m_provisionalDocumentLoader.release(); | 980 m_documentLoader = m_provisionalDocumentLoader.release(); |
| 973 | 981 |
| 974 if (isLoadingMainFrame()) | 982 if (isLoadingMainFrame()) |
| 975 m_frame->page()->chrome().client().needTouchEvents(false); | 983 m_frame->page()->chrome().client().needTouchEvents(false); |
| 976 | 984 |
| 977 client()->transitionToCommittedForNewPage(); | 985 client()->transitionToCommittedForNewPage(); |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1427 // FIXME: We need a way to propagate insecure requests policy flags to | 1435 // FIXME: We need a way to propagate insecure requests policy flags to |
| 1428 // out-of-process frames. For now, we'll always use default behavior. | 1436 // out-of-process frames. For now, we'll always use default behavior. |
| 1429 if (!parentFrame->isLocalFrame()) | 1437 if (!parentFrame->isLocalFrame()) |
| 1430 return nullptr; | 1438 return nullptr; |
| 1431 | 1439 |
| 1432 ASSERT(toLocalFrame(parentFrame)->document()); | 1440 ASSERT(toLocalFrame(parentFrame)->document()); |
| 1433 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; | 1441 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; |
| 1434 } | 1442 } |
| 1435 | 1443 |
| 1436 } // namespace blink | 1444 } // namespace blink |
| OLD | NEW |