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

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

Issue 2862293002: Finish removing FrameLoader::Clear() (Closed)
Patch Set: Drop unnecessary #include Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 26 matching lines...) Expand all
37 #include "core/loader/FrameLoader.h" 37 #include "core/loader/FrameLoader.h"
38 38
39 #include <memory> 39 #include <memory>
40 #include "bindings/core/v8/ScriptController.h" 40 #include "bindings/core/v8/ScriptController.h"
41 #include "bindings/core/v8/serialization/SerializedScriptValue.h" 41 #include "bindings/core/v8/serialization/SerializedScriptValue.h"
42 #include "core/HTMLNames.h" 42 #include "core/HTMLNames.h"
43 #include "core/dom/Document.h" 43 #include "core/dom/Document.h"
44 #include "core/dom/Element.h" 44 #include "core/dom/Element.h"
45 #include "core/dom/TaskRunnerHelper.h" 45 #include "core/dom/TaskRunnerHelper.h"
46 #include "core/dom/ViewportDescription.h" 46 #include "core/dom/ViewportDescription.h"
47 #include "core/editing/Editor.h"
48 #include "core/events/GestureEvent.h" 47 #include "core/events/GestureEvent.h"
49 #include "core/events/KeyboardEvent.h" 48 #include "core/events/KeyboardEvent.h"
50 #include "core/events/MouseEvent.h" 49 #include "core/events/MouseEvent.h"
51 #include "core/events/PageTransitionEvent.h" 50 #include "core/events/PageTransitionEvent.h"
52 #include "core/frame/ContentSettingsClient.h" 51 #include "core/frame/ContentSettingsClient.h"
53 #include "core/frame/FrameView.h" 52 #include "core/frame/FrameView.h"
54 #include "core/frame/LocalDOMWindow.h" 53 #include "core/frame/LocalDOMWindow.h"
55 #include "core/frame/LocalFrame.h" 54 #include "core/frame/LocalFrame.h"
56 #include "core/frame/LocalFrameClient.h" 55 #include "core/frame/LocalFrameClient.h"
57 #include "core/frame/Settings.h" 56 #include "core/frame/Settings.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 } 350 }
352 } 351 }
353 352
354 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing 353 // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing
355 // away results from a subsequent window.document.open / window.document.write 354 // away results from a subsequent window.document.open / window.document.write
356 // call. Canceling redirection here works for all cases because document.open 355 // call. Canceling redirection here works for all cases because document.open
357 // implicitly precedes document.write. 356 // implicitly precedes document.write.
358 frame_->GetNavigationScheduler().Cancel(); 357 frame_->GetNavigationScheduler().Cancel();
359 } 358 }
360 359
361 void FrameLoader::Clear() {
362 // clear() is called during (Local)Frame detachment or when reusing a
363 // FrameLoader by putting a new Document within it
364 // (DocumentLoader::ensureWriter().)
365 if (state_machine_.CreatingInitialEmptyDocument())
366 return;
367
368 frame_->GetEditor().Clear();
Nate Chapin 2017/05/17 18:18:59 Move this and the next line to LocalFrame::Documen
369 frame_->GetEventHandler().Clear();
370 if (frame_->View())
371 frame_->View()->Clear();
Nate Chapin 2017/05/17 18:18:59 We just got a new FrameView, no need to clear it.
372
373 if (state_machine_.IsDisplayingInitialEmptyDocument())
374 state_machine_.AdvanceTo(FrameLoaderStateMachine::kCommittedFirstRealLoad);
Nate Chapin 2017/05/17 18:18:59 Moved to DocumentLoader.
375
376 TakeObjectSnapshot();
377 }
378
379 // This is only called by ScriptController::executeScriptIfJavaScriptURL and 360 // This is only called by ScriptController::executeScriptIfJavaScriptURL and
380 // always contains the result of evaluating a javascript: url. This is the 361 // always contains the result of evaluating a javascript: url. This is the
381 // <iframe src="javascript:'html'"> case. 362 // <iframe src="javascript:'html'"> case.
382 void FrameLoader::ReplaceDocumentWhileExecutingJavaScriptURL( 363 void FrameLoader::ReplaceDocumentWhileExecutingJavaScriptURL(
383 const String& source, 364 const String& source,
384 Document* owner_document) { 365 Document* owner_document) {
385 if (!frame_->GetDocument()->Loader() || 366 if (!frame_->GetDocument()->Loader() ||
386 frame_->GetDocument()->PageDismissalEventBeingDispatched() != 367 frame_->GetDocument()->PageDismissalEventBeingDispatched() !=
387 Document::kNoDismissal) 368 Document::kNoDismissal)
388 return; 369 return;
389 370
390 DocumentLoader* document_loader(frame_->GetDocument()->Loader()); 371 DocumentLoader* document_loader(frame_->GetDocument()->Loader());
391 372
392 UseCounter::Count(*frame_->GetDocument(), 373 UseCounter::Count(*frame_->GetDocument(),
393 UseCounter::kReplaceDocumentViaJavaScriptURL); 374 UseCounter::kReplaceDocumentViaJavaScriptURL);
394 375
395 // Prepare a DocumentInit before clearing the frame, because it may need to 376 // Prepare a DocumentInit before clearing the frame, because it may need to
396 // inherit an aliased security context. 377 // inherit an aliased security context.
397 DocumentInit init(owner_document, frame_->GetDocument()->Url(), frame_); 378 DocumentInit init(owner_document, frame_->GetDocument()->Url(), frame_);
398 init.WithNewRegistrationContext(); 379 init.WithNewRegistrationContext();
399 380
400 StopAllLoaders(); 381 StopAllLoaders();
401 // Don't allow any new child frames to load in this frame: attaching a new 382 // Don't allow any new child frames to load in this frame: attaching a new
402 // child frame during or after detaching children results in an attached 383 // child frame during or after detaching children results in an attached
403 // frame on a detached DOM tree, which is bad. 384 // frame on a detached DOM tree, which is bad.
404 SubframeLoadingDisabler disabler(frame_->GetDocument()); 385 SubframeLoadingDisabler disabler(frame_->GetDocument());
405 frame_->DetachChildren(); 386 frame_->DetachChildren();
406 frame_->GetDocument()->Shutdown(); 387 frame_->GetDocument()->Shutdown();
407 Clear();
408 388
409 // detachChildren() potentially detaches the frame from the document. The 389 // detachChildren() potentially detaches the frame from the document. The
410 // loading cannot continue in that case. 390 // loading cannot continue in that case.
411 if (!frame_->GetPage()) 391 if (!frame_->GetPage())
412 return; 392 return;
413 393
414 Client()->TransitionToCommittedForNewPage(); 394 Client()->TransitionToCommittedForNewPage();
415 document_loader->ReplaceDocumentWhileExecutingJavaScriptURL(init, source); 395 document_loader->ReplaceDocumentWhileExecutingJavaScriptURL(init, source);
416 } 396 }
417 397
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 // TODO(japhet): This is needed because the browser process DCHECKs if the 1691 // TODO(japhet): This is needed because the browser process DCHECKs if the
1712 // first entry we commit in a new frame has replacement set. It's unclear 1692 // first entry we commit in a new frame has replacement set. It's unclear
1713 // whether the DCHECK is right, investigate removing this special case. 1693 // whether the DCHECK is right, investigate removing this special case.
1714 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem && 1694 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem &&
1715 (!Opener() || !request.Url().IsEmpty()); 1695 (!Opener() || !request.Url().IsEmpty());
1716 loader->SetReplacesCurrentHistoryItem(replace_current_item); 1696 loader->SetReplacesCurrentHistoryItem(replace_current_item);
1717 return loader; 1697 return loader;
1718 } 1698 }
1719 1699
1720 } // namespace blink 1700 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698