diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 02d59dc6fb..4af2f3f720 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -72,6 +72,7 @@ public: bool is_parent_node() const { return is_element() || is_document() || is_document_fragment(); } bool is_slottable() const { return is_element() || is_text(); } bool is_attribute() const { return type() == NodeType::ATTRIBUTE_NODE; } + virtual bool is_shadow_root() const { return false; } virtual bool requires_svg_container() const { return false; } virtual bool is_svg_container() const { return false; } diff --git a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h index 7ea5ca32ff..f550c0e5cb 100644 --- a/Userland/Libraries/LibWeb/DOM/ShadowRoot.h +++ b/Userland/Libraries/LibWeb/DOM/ShadowRoot.h @@ -34,6 +34,7 @@ public: private: // ^Node virtual FlyString node_name() const override { return "#shadow-root"; } + virtual bool is_shadow_root() const final { return true; } // NOTE: The specification doesn't seem to specify a default value for closed. Assuming false for now. bool m_closed { false }; @@ -41,4 +42,7 @@ private: bool m_available_to_element_internals { false }; }; +template<> +inline bool Node::fast_is() const { return is_shadow_root(); } + } diff --git a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h index 3a9343e8b2..e9b31876d5 100644 --- a/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h +++ b/Userland/Libraries/LibWeb/Layout/ListItemMarkerBox.h @@ -24,6 +24,7 @@ public: CSS::ListStyleType list_style_type() const { return m_list_style_type; } private: + virtual bool is_list_item_marker_box() const final { return true; } virtual bool can_have_children() const override { return false; } CSS::ListStyleType m_list_style_type { CSS::ListStyleType::None }; @@ -32,4 +33,7 @@ private: String m_text {}; }; +template<> +inline bool Node::fast_is() const { return is_list_item_marker_box(); } + } diff --git a/Userland/Libraries/LibWeb/Layout/Node.h b/Userland/Libraries/LibWeb/Layout/Node.h index f65f263142..46cedbd06f 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.h +++ b/Userland/Libraries/LibWeb/Layout/Node.h @@ -74,6 +74,8 @@ public: virtual bool is_svg_box() const { return false; } virtual bool is_svg_geometry_box() const { return false; } virtual bool is_label() const { return false; } + virtual bool is_replaced_box() const { return false; } + virtual bool is_list_item_marker_box() const { return false; } template bool fast_is() const = delete; diff --git a/Userland/Libraries/LibWeb/Layout/ReplacedBox.h b/Userland/Libraries/LibWeb/Layout/ReplacedBox.h index 55b8afc370..28032d5aa8 100644 --- a/Userland/Libraries/LibWeb/Layout/ReplacedBox.h +++ b/Userland/Libraries/LibWeb/Layout/ReplacedBox.h @@ -32,9 +32,14 @@ public: virtual bool can_have_children() const override { return false; } private: + virtual bool is_replaced_box() const final { return true; } + Optional m_intrinsic_width; Optional m_intrinsic_height; Optional m_intrinsic_aspect_ratio; }; +template<> +inline bool Node::fast_is() const { return is_replaced_box(); } + }