Commit f273cbf9 authored by Jeremy Roman's avatar Jeremy Roman Committed by Commit Bot

Use custom type helpers for HTMLPortalElement.

Bug: 1040627
Change-Id: If4f98b2269a0266ea9c56630a7f968d5b04af2b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2013486
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: default avatarMason Freed <masonfreed@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734161}
parent d0fb5886
...@@ -43,6 +43,7 @@ class ElementLookupTrieWriter(json5_generator.Writer): ...@@ -43,6 +43,7 @@ class ElementLookupTrieWriter(json5_generator.Writer):
'interfaceHeaderDir': {}, 'interfaceHeaderDir': {},
'interfaceName': {}, 'interfaceName': {},
'noConstructor': {}, 'noConstructor': {},
'noTypeHelpers': {},
'runtimeEnabled': {}, 'runtimeEnabled': {},
} }
default_metadata = { default_metadata = {
......
...@@ -109,6 +109,7 @@ class CORE_EXPORT HTMLElement : public Element { ...@@ -109,6 +109,7 @@ class CORE_EXPORT HTMLElement : public Element {
virtual bool IsHTMLUnknownElement() const { return false; } virtual bool IsHTMLUnknownElement() const { return false; }
virtual bool IsPluginElement() const { return false; } virtual bool IsPluginElement() const { return false; }
virtual bool IsHTMLPortalElement() const { return false; }
// https://html.spec.whatwg.org/C/#category-label // https://html.spec.whatwg.org/C/#category-label
virtual bool IsLabelable() const; virtual bool IsLabelable() const;
......
...@@ -363,6 +363,9 @@ ...@@ -363,6 +363,9 @@
interfaceName: "HTMLPortalElement", interfaceName: "HTMLPortalElement",
interfaceHeaderDir: "third_party/blink/renderer/core/html/portal", interfaceHeaderDir: "third_party/blink/renderer/core/html/portal",
runtimeEnabled: "Portals", runtimeEnabled: "Portals",
// Portals could be enabled in some documents but not others (due to
// origin trials), so we need custom type helpers.
noTypeHelpers: true,
}, },
"pre", "pre",
{ {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/node.h" #include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/html/html_frame_owner_element.h" #include "third_party/blink/renderer/core/html/html_frame_owner_element.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink { namespace blink {
...@@ -39,6 +40,8 @@ class CORE_EXPORT HTMLPortalElement : public HTMLFrameOwnerElement { ...@@ -39,6 +40,8 @@ class CORE_EXPORT HTMLPortalElement : public HTMLFrameOwnerElement {
portal_client_receiver = {}); portal_client_receiver = {});
~HTMLPortalElement() override; ~HTMLPortalElement() override;
bool IsHTMLPortalElement() const final { return true; }
// ScriptWrappable overrides. // ScriptWrappable overrides.
void Trace(Visitor* visitor) override; void Trace(Visitor* visitor) override;
...@@ -132,6 +135,20 @@ class CORE_EXPORT HTMLPortalElement : public HTMLFrameOwnerElement { ...@@ -132,6 +135,20 @@ class CORE_EXPORT HTMLPortalElement : public HTMLFrameOwnerElement {
bool was_just_adopted_ = false; bool was_just_adopted_ = false;
}; };
// Type casting. Custom since adoption could lead to an HTMLPortalElement ending
// up in a document that doesn't have Portals enabled.
template <>
struct DowncastTraits<HTMLPortalElement> {
static bool AllowFrom(const HTMLElement& element) {
return element.IsHTMLPortalElement();
}
static bool AllowFrom(const Node& node) {
if (const HTMLElement* html_element = DynamicTo<HTMLElement>(node))
return html_element->IsHTMLPortalElement();
return false;
}
};
} // namespace blink } // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_PORTAL_HTML_PORTAL_ELEMENT_H_ #endif // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_PORTAL_HTML_PORTAL_ELEMENT_H_
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "third_party/blink/renderer/core/html/forms/text_control_element.h" #include "third_party/blink/renderer/core/html/forms/text_control_element.h"
#include "third_party/blink/renderer/core/html/html_plugin_element.h" #include "third_party/blink/renderer/core/html/html_plugin_element.h"
#include "third_party/blink/renderer/core/html/html_slot_element.h" #include "third_party/blink/renderer/core/html/html_slot_element.h"
#include "third_party/blink/renderer/core/html/portal/html_portal_element.h"
#include "third_party/blink/renderer/core/html_names.h" #include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/input/event_handler.h" #include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h" #include "third_party/blink/renderer/core/layout/hit_test_result.h"
......
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