mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-08 06:09:58 +00:00
LibWeb: Add fast_is<T> optimization for more paintables
We were doing a lot of dynamic_cast with these types, so let's avoid it.
This commit is contained in:
parent
4eca3781c7
commit
84bedebb09
Notes:
github-actions[bot]
2025-09-22 13:02:05 +00:00
Author: https://github.com/awesomekling
Commit: 84bedebb09
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6265
4 changed files with 20 additions and 0 deletions
|
|
@ -118,10 +118,13 @@ public:
|
||||||
bool fast_is() const = delete;
|
bool fast_is() const = delete;
|
||||||
|
|
||||||
[[nodiscard]] virtual bool is_navigable_container_viewport_paintable() const { return false; }
|
[[nodiscard]] virtual bool is_navigable_container_viewport_paintable() const { return false; }
|
||||||
|
[[nodiscard]] virtual bool is_viewport_paintable() const { return false; }
|
||||||
[[nodiscard]] virtual bool is_paintable_box() const { return false; }
|
[[nodiscard]] virtual bool is_paintable_box() const { return false; }
|
||||||
[[nodiscard]] virtual bool is_paintable_with_lines() 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_paintable() const { return false; }
|
||||||
[[nodiscard]] virtual bool is_svg_svg_paintable() const { return false; }
|
[[nodiscard]] virtual bool is_svg_svg_paintable() const { return false; }
|
||||||
|
[[nodiscard]] virtual bool is_svg_path_paintable() const { return false; }
|
||||||
|
[[nodiscard]] virtual bool is_svg_graphics_paintable() const { return false; }
|
||||||
[[nodiscard]] virtual bool is_text_paintable() const { return false; }
|
[[nodiscard]] virtual bool is_text_paintable() const { return false; }
|
||||||
|
|
||||||
DOM::Document const& document() const;
|
DOM::Document const& document() const;
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,12 @@ protected:
|
||||||
SVGGraphicsPaintable(Layout::SVGGraphicsBox const&);
|
SVGGraphicsPaintable(Layout::SVGGraphicsBox const&);
|
||||||
|
|
||||||
ComputedTransforms m_computed_transforms;
|
ComputedTransforms m_computed_transforms;
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual bool is_svg_graphics_paintable() const final { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool Paintable::fast_is<SVGGraphicsPaintable>() const { return is_svg_graphics_paintable(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,12 @@ protected:
|
||||||
SVGPathPaintable(Layout::SVGGraphicsBox const&);
|
SVGPathPaintable(Layout::SVGGraphicsBox const&);
|
||||||
|
|
||||||
Optional<Gfx::Path> m_computed_path = {};
|
Optional<Gfx::Path> m_computed_path = {};
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual bool is_svg_path_paintable() const final { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool Paintable::fast_is<SVGPathPaintable>() const { return is_svg_path_paintable(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ public:
|
||||||
ReadonlySpan<GC::Ref<PaintableBox>> paintable_boxes_with_auto_content_visibility() const { return m_paintable_boxes_with_auto_content_visibility; }
|
ReadonlySpan<GC::Ref<PaintableBox>> paintable_boxes_with_auto_content_visibility() const { return m_paintable_boxes_with_auto_content_visibility; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual bool is_viewport_paintable() const override { return true; }
|
||||||
|
|
||||||
void build_stacking_context_tree();
|
void build_stacking_context_tree();
|
||||||
|
|
||||||
explicit ViewportPaintable(Layout::Viewport const&);
|
explicit ViewportPaintable(Layout::Viewport const&);
|
||||||
|
|
@ -57,4 +59,7 @@ private:
|
||||||
Vector<GC::Ref<PaintableBox>> m_paintable_boxes_with_auto_content_visibility;
|
Vector<GC::Ref<PaintableBox>> m_paintable_boxes_with_auto_content_visibility;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline bool Paintable::fast_is<ViewportPaintable>() const { return is_viewport_paintable(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue