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

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

Issue 1052993006: Refactor frame navigation/detach state cleanup to be more sane. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: shuffle Created 5 years, 8 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
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 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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();
282 clear(); 281 m_frame->detachChildren();
283 282
284 // clear() potentially detaches the frame from the document. The 283 // detachChildren() potentially detaches the frame from the document. The
285 // loading cannot continue in that case. 284 // loading cannot continue in that case.
286 if (!m_frame->page()) 285 if (!m_frame->page())
287 return; 286 return;
288 287
288 m_frame->document()->prepareForDestruction();
289 clear();
dcheng 2015/04/03 14:35:45 Consistency!
290
289 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument); 291 documentLoader->replaceDocumentWhileExecutingJavaScriptURL(init, source, own erDocument);
290 } 292 }
291 293
292 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject) 294 void FrameLoader::setHistoryItemStateForCommit(HistoryCommitType historyCommitTy pe, bool isPushOrReplaceState, PassRefPtr<SerializedScriptValue> stateObject)
293 { 295 {
294 if (m_provisionalItem) 296 if (m_provisionalItem)
295 m_currentItem = m_provisionalItem.release(); 297 m_currentItem = m_provisionalItem.release();
296 298
297 if (!m_currentItem || historyCommitType == StandardCommit) { 299 if (!m_currentItem || historyCommitType == StandardCommit) {
298 m_currentItem = HistoryItem::create(); 300 m_currentItem = HistoryItem::create();
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 if (m_documentLoader) { 965 if (m_documentLoader) {
964 client()->dispatchWillClose(); 966 client()->dispatchWillClose();
965 dispatchUnloadEvent(); 967 dispatchUnloadEvent();
966 } 968 }
967 m_frame->detachChildren(); 969 m_frame->detachChildren();
968 if (pdl != m_provisionalDocumentLoader) 970 if (pdl != m_provisionalDocumentLoader)
969 return; 971 return;
970 if (m_documentLoader) 972 if (m_documentLoader)
971 m_documentLoader->detachFromFrame(); 973 m_documentLoader->detachFromFrame();
972 m_documentLoader = m_provisionalDocumentLoader.release(); 974 m_documentLoader = m_provisionalDocumentLoader.release();
975 if (m_frame->document())
dcheng 2015/04/03 14:35:45 Similarly, this has to handle the null case due to
976 m_frame->document()->prepareForDestruction();
973 977
974 if (isLoadingMainFrame()) 978 if (isLoadingMainFrame())
975 m_frame->page()->chrome().client().needTouchEvents(false); 979 m_frame->page()->chrome().client().needTouchEvents(false);
976 980
977 client()->transitionToCommittedForNewPage(); 981 client()->transitionToCommittedForNewPage();
978 m_frame->navigationScheduler().cancel(); 982 m_frame->navigationScheduler().cancel();
979 m_frame->editor().clearLastEditCommand(); 983 m_frame->editor().clearLastEditCommand();
980 984
981 // If we are still in the process of initializing an empty document then 985 // If we are still in the process of initializing an empty document then
982 // its frame is not in a consistent state for rendering, so avoid setJSStatu sBarText 986 // its frame is not in a consistent state for rendering, so avoid setJSStatu sBarText
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 // FIXME: We need a way to propagate insecure requests policy flags to 1431 // 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. 1432 // out-of-process frames. For now, we'll always use default behavior.
1429 if (!parentFrame->isLocalFrame()) 1433 if (!parentFrame->isLocalFrame())
1430 return nullptr; 1434 return nullptr;
1431 1435
1432 ASSERT(toLocalFrame(parentFrame)->document()); 1436 ASSERT(toLocalFrame(parentFrame)->document());
1433 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ; 1437 return toLocalFrame(parentFrame)->document()->insecureNavigationsToUpgrade() ;
1434 } 1438 }
1435 1439
1436 } // namespace blink 1440 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698