Commit dff8cc56 authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Centralize usage of Document::RemoveAllEventListenersRecursively

Change-Id: Ie69a1875ce18cba8ef8118e2d61340bf640ec811
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2333407
Commit-Queue: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Auto-Submit: Nate Chapin <japhet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794631}
parent da6e835a
...@@ -846,6 +846,7 @@ void LocalDOMWindow::FrameDestroyed() { ...@@ -846,6 +846,7 @@ void LocalDOMWindow::FrameDestroyed() {
// function should be renamed to Detach(), since in the Reset() case the frame // function should be renamed to Detach(), since in the Reset() case the frame
// is not being destroyed. // is not being destroyed.
document()->Shutdown(); document()->Shutdown();
document()->RemoveAllEventListenersRecursively();
GetAgent()->DetachContext(this); GetAgent()->DetachContext(this);
if (auto* agent_metrics = GetFrame()->GetPage()->GetAgentMetricsCollector()) if (auto* agent_metrics = GetFrame()->GetPage()->GetAgentMetricsCollector())
agent_metrics->DidDetachWindow(*this); agent_metrics->DidDetachWindow(*this);
......
...@@ -1681,9 +1681,6 @@ void DocumentLoader::CommitNavigation() { ...@@ -1681,9 +1681,6 @@ void DocumentLoader::CommitNavigation() {
// LocalDOMWindow to the Document that results from the network load. See also // LocalDOMWindow to the Document that results from the network load. See also
// Document::IsSecureTransitionTo. // Document::IsSecureTransitionTo.
if (global_object_reuse_policy != GlobalObjectReusePolicy::kUseExisting) { if (global_object_reuse_policy != GlobalObjectReusePolicy::kUseExisting) {
if (frame_->GetDocument())
frame_->GetDocument()->RemoveAllEventListenersRecursively();
auto* agent = GetWindowAgentForOrigin(frame_.Get(), security_origin.get()); auto* agent = GetWindowAgentForOrigin(frame_.Get(), security_origin.get());
frame_->SetDOMWindow(MakeGarbageCollected<LocalDOMWindow>(*frame_, agent)); frame_->SetDOMWindow(MakeGarbageCollected<LocalDOMWindow>(*frame_, agent));
......
...@@ -339,16 +339,8 @@ void FrameLoader::DispatchUnloadEvent( ...@@ -339,16 +339,8 @@ void FrameLoader::DispatchUnloadEvent(
FrameNavigationDisabler navigation_disabler(*frame_); FrameNavigationDisabler navigation_disabler(*frame_);
SaveScrollState(); SaveScrollState();
Document* document = frame_->GetDocument(); if (!SVGImage::IsInSVGImage(frame_->GetDocument()))
if (document && !SVGImage::IsInSVGImage(document)) { frame_->GetDocument()->DispatchUnloadEvents(committing_origin, timing);
document->DispatchUnloadEvents(committing_origin, timing);
// Remove event listeners if we're firing unload events for a reason other
// than committing a navigation. In the commit case, we'll determine whether
// event listeners should be retained when choosing whether to reuse the
// LocalDOMWindow.
if (!timing)
document->RemoveAllEventListenersRecursively();
}
} }
void FrameLoader::DidExplicitOpen() { void FrameLoader::DidExplicitOpen() {
......
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