Commit 412e1f9d authored by Daniel Cheng's avatar Daniel Cheng Committed by Chromium LUCI CQ

Remove unnecessary null checks in LocalDOMWindow::InstallNewDocument.

Change-Id: I9d4c9bf676be75bc2b6bec5d18515de092b99d6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2616946
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Auto-Submit: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarNate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#841718}
parent 00f3d447
...@@ -609,25 +609,29 @@ bool LocalDOMWindow::HasInsecureContextInAncestors() { ...@@ -609,25 +609,29 @@ bool LocalDOMWindow::HasInsecureContextInAncestors() {
} }
Document* LocalDOMWindow::InstallNewDocument(const DocumentInit& init) { Document* LocalDOMWindow::InstallNewDocument(const DocumentInit& init) {
DCHECK_EQ(init.GetWindow(), this); // Blink should never attempt to install a new Document to a LocalDOMWindow
// that's not attached to a LocalFrame.
DCHECK(GetFrame());
// Either:
// - `this` should be a new LocalDOMWindow, that has never had a Document
// associated with it or
// - `this` is being reused, and the previous Document has been disassociated
// via `ClearForReuse()`.
DCHECK(!document_); DCHECK(!document_);
DCHECK_EQ(init.GetWindow(), this);
document_ = init.CreateDocument(); document_ = init.CreateDocument();
document_->Initialize(); document_->Initialize();
if (!GetFrame())
return document_;
GetScriptController().UpdateDocument(); GetScriptController().UpdateDocument();
document_->GetViewportData().UpdateViewportDescription(); document_->GetViewportData().UpdateViewportDescription();
if (FrameScheduler* frame_scheduler = GetFrame()->GetFrameScheduler()) {
auto* frame_scheduler = GetFrame()->GetFrameScheduler();
frame_scheduler->TraceUrlChange(document_->Url().GetString()); frame_scheduler->TraceUrlChange(document_->Url().GetString());
frame_scheduler->SetCrossOriginToMainFrame( frame_scheduler->SetCrossOriginToMainFrame(
GetFrame()->IsCrossOriginToMainFrame()); GetFrame()->IsCrossOriginToMainFrame());
}
if (GetFrame()->GetPage() && GetFrame()->View()) {
GetFrame()->GetPage()->GetChromeClient().InstallSupplements(*GetFrame()); GetFrame()->GetPage()->GetChromeClient().InstallSupplements(*GetFrame());
}
return document_; return document_;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment