LibWeb: Add more fast_is<T> helpers for layout and paintable nodes

This commit is contained in:
Andreas Kling 2025-04-18 10:28:46 +02:00 committed by Andreas Kling
parent aecb144df0
commit 877391d569
Notes: github-actions[bot] 2025-04-18 12:47:24 +00:00
4 changed files with 20 additions and 0 deletions

View file

@ -101,6 +101,7 @@ public:
virtual bool is_svg_geometry_box() const { return false; }
virtual bool is_svg_mask_box() const { return false; }
virtual bool is_svg_svg_box() const { return false; }
virtual bool is_svg_graphics_box() const { return false; }
virtual bool is_label() const { return false; }
virtual bool is_replaced_box() const { return false; }
virtual bool is_list_item_box() const { return false; }
@ -108,6 +109,7 @@ public:
virtual bool is_fieldset_box() const { return false; }
virtual bool is_legend_box() const { return false; }
virtual bool is_table_wrapper() const { return false; }
virtual bool is_node_with_style() const { return false; }
virtual bool is_node_with_style_and_box_model_metrics() const { return false; }
template<typename T>
@ -245,6 +247,8 @@ protected:
NodeWithStyle(DOM::Document&, DOM::Node*, NonnullOwnPtr<CSS::ComputedValues>);
private:
virtual bool is_node_with_style() const final { return true; }
void reset_table_box_computed_values_used_by_wrapper_to_init_values();
void propagate_style_to_anonymous_wrappers();
@ -252,6 +256,9 @@ private:
RefPtr<CSS::AbstractImageStyleValue const> m_list_style_image;
};
template<>
inline bool Node::fast_is<NodeWithStyle>() const { return is_node_with_style(); }
class NodeWithStyleAndBoxModelMetrics : public NodeWithStyle {
GC_CELL(NodeWithStyleAndBoxModelMetrics, NodeWithStyle);

View file

@ -23,6 +23,12 @@ public:
SVG::SVGGraphicsElement const& dom_node() const { return as<SVG::SVGGraphicsElement>(SVGBox::dom_node()); }
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
private:
virtual bool is_svg_graphics_box() const override { return true; }
};
template<>
inline bool Node::fast_is<SVGGraphicsBox>() const { return is_svg_graphics_box(); }
}

View file

@ -125,6 +125,7 @@ public:
[[nodiscard]] virtual bool is_paintable_box() const { return false; }
[[nodiscard]] virtual bool is_paintable_with_lines() const { return false; }
[[nodiscard]] virtual bool is_svg_paintable() const { return false; }
[[nodiscard]] virtual bool is_svg_svg_paintable() const { return false; }
[[nodiscard]] virtual bool is_text_paintable() const { return false; }
DOM::Document const& document() const;

View file

@ -28,6 +28,12 @@ public:
protected:
SVGSVGPaintable(Layout::SVGSVGBox const&);
private:
virtual bool is_svg_svg_paintable() const final { return true; }
};
template<>
inline bool Paintable::fast_is<SVGSVGPaintable>() const { return is_svg_svg_paintable(); }
}