mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
LibWeb: Cache Document's decoded-SVG status in a bool member
Document::is_decoded_svg() was reached through two pointer hops and a virtual call into PageClient on every invocation. It showed up at 1.9% self time in a YouTube playback profile, and it's also called for every document in the hot documents_in_this_event_loop_matching() loop that runs on every rendering update. The page's client is fixed for the lifetime of a document, so we can cache the answer at construction time and serve future calls from a plain member load.
This commit is contained in:
committed by
Andreas Kling
parent
12d9aaebb3
commit
5a3845b330
Notes:
github-actions[bot]
2026-04-24 17:00:06 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/5a3845b3300 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/9076
@@ -514,6 +514,8 @@ Document::Document(JS::Realm& realm, URL::URL const& url, TemporaryDocumentForFr
|
||||
.has_legacy_override_built_ins_interface_extended_attribute = true,
|
||||
};
|
||||
|
||||
m_is_decoded_svg = m_page->client().is_svg_page_client();
|
||||
|
||||
m_cursor_blink_timer = Core::Timer::create_repeating(500, [this] {
|
||||
auto cursor_position = this->cursor_position();
|
||||
if (!cursor_position)
|
||||
@@ -6882,11 +6884,6 @@ void Document::unregister_shadow_root(Badge<DOM::ShadowRoot>, DOM::ShadowRoot& s
|
||||
m_shadow_roots.remove(shadow_root);
|
||||
}
|
||||
|
||||
bool Document::is_decoded_svg() const
|
||||
{
|
||||
return page().client().is_svg_page_client();
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/css-position-4/#add-an-element-to-the-top-layer
|
||||
void Document::add_an_element_to_the_top_layer(GC::Ref<Element> element)
|
||||
{
|
||||
|
||||
@@ -917,7 +917,7 @@ public:
|
||||
size_t transition_generation() const { return m_transition_generation; }
|
||||
|
||||
// Does document represent an embedded svg img
|
||||
[[nodiscard]] bool is_decoded_svg() const;
|
||||
[[nodiscard]] bool is_decoded_svg() const { return m_is_decoded_svg; }
|
||||
|
||||
Vector<GC::Root<Range>> find_matching_text(String const&, CaseSensitivity);
|
||||
|
||||
@@ -1287,6 +1287,8 @@ private:
|
||||
bool m_needs_full_style_update { false };
|
||||
bool m_needs_full_layout_tree_update { false };
|
||||
|
||||
bool m_is_decoded_svg { false };
|
||||
|
||||
bool m_is_running_update_layout { false };
|
||||
|
||||
HashTable<GC::Ref<Layout::SVGSVGBox>> m_svg_roots_needing_relayout;
|
||||
|
||||
Reference in New Issue
Block a user