diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-16 09:59:13 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-05-20 10:28:53 +0000 |
commit | 6c11fb357ec39bf087b8b632e2b1e375aef1b38b (patch) | |
tree | c8315530db18a8ee566521c39ab8a6af4f72bc03 /chromium/third_party/blink/renderer/core/html/portal | |
parent | 3ffaed019d0772e59d6cdb2d0d32fe4834c31f72 (diff) | |
download | qtwebengine-chromium-6c11fb357ec39bf087b8b632e2b1e375aef1b38b.tar.gz |
BASELINE: Update Chromium to 74.0.3729.159
Change-Id: I8d2497da544c275415aedd94dd25328d555de811
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/core/html/portal')
5 files changed, 91 insertions, 21 deletions
diff --git a/chromium/third_party/blink/renderer/core/html/portal/dom_window_portal_host.cc b/chromium/third_party/blink/renderer/core/html/portal/dom_window_portal_host.cc index 85e3cc58540..b86b3154914 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/dom_window_portal_host.cc +++ b/chromium/third_party/blink/renderer/core/html/portal/dom_window_portal_host.cc @@ -4,11 +4,21 @@ #include "third_party/blink/renderer/core/html/portal/dom_window_portal_host.h" +#include "third_party/blink/renderer/core/frame/local_dom_window.h" +#include "third_party/blink/renderer/core/frame/local_frame.h" +#include "third_party/blink/renderer/core/html/portal/portal_host.h" +#include "third_party/blink/renderer/core/page/page.h" + namespace blink { // static PortalHost* DOMWindowPortalHost::portalHost(LocalDOMWindow& window) { - return nullptr; + // The portal host is only exposed in the main frame of a page + // embedded in a portal. + if (!window.GetFrame() || !window.GetFrame()->IsMainFrame() || + !window.GetFrame()->GetPage()->InsidePortal()) + return nullptr; + return &PortalHost::From(window); } } // namespace blink diff --git a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.cc b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.cc index 87081ef45ba..ef7b239a2a0 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.cc +++ b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.cc @@ -53,25 +53,15 @@ ScriptPromise HTMLPortalElement::activate(ScriptState* script_state) { ScriptPromise promise = resolver->Promise(); if (portal_ptr_) { - portal_ptr_->Activate(WTF::Bind( - [](HTMLPortalElement* portal, ScriptPromiseResolver* resolver, - mojom::blink::PortalActivationStatus result) { - switch (result) { - case mojom::blink::PortalActivationStatus::kNotSupported: - resolver->Reject( - DOMException::Create(DOMExceptionCode::kNotSupportedError, - "Portal activation is not supported.")); - break; - - case mojom::blink::PortalActivationStatus::kSuccess: - resolver->Resolve(); - break; - - default: - NOTREACHED(); - } - }, - WrapPersistent(this), WrapPersistent(resolver))); + // The HTMLPortalElement is bound as a persistent so that it won't get + // garbage collected while there is a pending callback. This is necessary + // because the HTMLPortalElement owns the mojo interface, so if it were + // garbage collected the callback would never be called and the promise + // would never be resolved. + portal_ptr_->Activate( + WTF::Bind([](HTMLPortalElement* portal, + ScriptPromiseResolver* resolver) { resolver->Resolve(); }, + WrapPersistent(this), WrapPersistent(resolver))); } else { resolver->Reject(DOMException::Create( DOMExceptionCode::kInvalidStateError, @@ -134,4 +124,11 @@ LayoutObject* HTMLPortalElement::CreateLayoutObject( return new LayoutIFrame(this); } +void HTMLPortalElement::AttachLayoutTree(AttachContext& context) { + HTMLFrameOwnerElement::AttachLayoutTree(context); + + if (GetLayoutEmbeddedContent() && ContentFrame()) + SetEmbeddedContentView(ContentFrame()->View()); +} + } // namespace blink diff --git a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.h b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.h index d1ac773b7b4..c08b655ab4b 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.h +++ b/chromium/third_party/blink/renderer/core/html/portal/html_portal_element.h @@ -61,6 +61,7 @@ class CORE_EXPORT HTMLPortalElement : public HTMLFrameOwnerElement { ParsedFeaturePolicy ConstructContainerPolicy(Vector<String>*) const override { return ParsedFeaturePolicy(); } + void AttachLayoutTree(AttachContext& context) override; // Uniquely identifies the portal, this token is used by the browser process // to reference this portal when communicating with the renderer. diff --git a/chromium/third_party/blink/renderer/core/html/portal/portal_host.cc b/chromium/third_party/blink/renderer/core/html/portal/portal_host.cc new file mode 100644 index 00000000000..9e196025dad --- /dev/null +++ b/chromium/third_party/blink/renderer/core/html/portal/portal_host.cc @@ -0,0 +1,44 @@ +// Copyright 2019 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "third_party/blink/renderer/core/html/portal/portal_host.h" + +#include "third_party/blink/renderer/core/dom/document.h" +#include "third_party/blink/renderer/core/execution_context/execution_context.h" +#include "third_party/blink/renderer/core/frame/local_dom_window.h" +#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h" + +namespace blink { + +PortalHost::PortalHost(LocalDOMWindow& window) + : Supplement<LocalDOMWindow>(window) {} + +void PortalHost::Trace(Visitor* visitor) { + EventTargetWithInlineData::Trace(visitor); + Supplement<LocalDOMWindow>::Trace(visitor); +} + +// static +const char PortalHost::kSupplementName[] = "PortalHost"; + +// static +PortalHost& PortalHost::From(LocalDOMWindow& window) { + PortalHost* portal_host = + Supplement<LocalDOMWindow>::From<PortalHost>(window); + if (!portal_host) { + portal_host = MakeGarbageCollected<PortalHost>(window); + Supplement<LocalDOMWindow>::ProvideTo<PortalHost>(window, portal_host); + } + return *portal_host; +} + +const AtomicString& PortalHost::InterfaceName() const { + return event_target_names::kPortalHost; +} + +ExecutionContext* PortalHost::GetExecutionContext() const { + return GetSupplementable()->document(); +} + +} // namespace blink diff --git a/chromium/third_party/blink/renderer/core/html/portal/portal_host.h b/chromium/third_party/blink/renderer/core/html/portal/portal_host.h index f40660728f4..fc0ed222e24 100644 --- a/chromium/third_party/blink/renderer/core/html/portal/portal_host.h +++ b/chromium/third_party/blink/renderer/core/html/portal/portal_host.h @@ -7,11 +7,29 @@ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/dom/events/event_target.h" +#include "third_party/blink/renderer/platform/supplementable.h" namespace blink { -class CORE_EXPORT PortalHost : public EventTargetWithInlineData { +class ExecutionContext; +class LocalDOMWindow; + +class CORE_EXPORT PortalHost : public EventTargetWithInlineData, + public Supplement<LocalDOMWindow> { DEFINE_WRAPPERTYPEINFO(); + USING_GARBAGE_COLLECTED_MIXIN(PortalHost); + + public: + explicit PortalHost(LocalDOMWindow& window); + + void Trace(Visitor* visitor) override; + + static const char kSupplementName[]; + static PortalHost& From(LocalDOMWindow& window); + + // EventTarget overrides + const AtomicString& InterfaceName() const override; + ExecutionContext* GetExecutionContext() const override; }; } // namespace blink |