Commit 289a50a3 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Move destruction of an adopted-but-not-inserted portal into...

Move destruction of an adopted-but-not-inserted portal into HTMLPortalElement::ExpireAdoptionLifetime.

Change-Id: Id7323e014838ae9c06434369f4d7e1124062275a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761400Reviewed-by: default avatarLucas Gadani <lfg@chromium.org>
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689110}
parent 7e49da29
......@@ -2586,21 +2586,6 @@ void WebLocalFrameImpl::OnPortalActivated(
if (debugger)
debugger->ExternalAsyncTaskFinished(blink_data.sender_stack_trace_id);
event->ExpireAdoptionLifetime();
// After dispatching the portalactivate event, we check to see if we need to
// cleanup the portal hosting the predecessor. If the portal was created,
// but wasn't inserted or activated, we destroy it.
//
// TODO(jbroman): This should probably be done as part of
// ExpireAdoptionLifetime, now that the event knows about the adopted
// HTMLPortalElement explicitly.
HTMLPortalElement* portal_element =
DocumentPortals::From(*(GetFrame()->GetDocument()))
.GetPortal(portal_token);
if (portal_element && !portal_element->isConnected() &&
!portal_element->IsActivating()) {
portal_element->ConsumePortal();
}
}
void WebLocalFrameImpl::ForwardMessageFromHost(
......
......@@ -87,6 +87,12 @@ void HTMLPortalElement::ConsumePortal() {
void HTMLPortalElement::ExpireAdoptionLifetime() {
was_just_adopted_ = false;
// After dispatching the portalactivate event, we check to see if we need to
// cleanup the portal hosting the predecessor. If the portal was created,
// but wasn't inserted or activated, we destroy it.
if (!CanHaveGuestContents() && !IsActivating())
ConsumePortal();
}
// https://wicg.github.io/portals/#htmlportalelement-may-have-a-guest-browsing-context
......
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