LibWeb: Expose full-style-invalidation counter through Internals

Full-subtree style invalidations are cheap to count where they happen
(Node::invalidate_style on a document node) but previously invisible to
tests. Surface the counter as fullStyleInvalidations alongside the
existing style invalidation counters so text tests can assert that a
given mutation path stayed surgical instead of degrading to a broad
document restyle.
This commit is contained in:
Andreas Kling 2026-04-22 22:27:04 +02:00 committed by Andreas Kling
parent e29281893a
commit 73aafc2ade
3 changed files with 3 additions and 0 deletions

View file

@ -853,6 +853,7 @@ public:
u64 has_match_invocations { 0 };
u64 has_result_cache_hits { 0 };
u64 has_result_cache_misses { 0 };
u64 full_style_invalidations { 0 };
u64 style_invalidations { 0 };
};
StyleInvalidationCounters& style_invalidation_counters() const { return m_style_invalidation_counters; }

View file

@ -463,6 +463,7 @@ void Node::invalidate_style(StyleInvalidationReason reason)
if (is_document()) {
auto& document = static_cast<DOM::Document&>(*this);
document.style_invalidation_counters().full_style_invalidations++;
document.set_needs_full_style_update(true);
return;
}

View file

@ -606,6 +606,7 @@ JS::Object* Internals::get_style_invalidation_counters()
object->define_direct_property("hasMatchInvocations"_utf16_fly_string, JS::Value(counters.has_match_invocations), JS::default_attributes);
object->define_direct_property("hasResultCacheHits"_utf16_fly_string, JS::Value(counters.has_result_cache_hits), JS::default_attributes);
object->define_direct_property("hasResultCacheMisses"_utf16_fly_string, JS::Value(counters.has_result_cache_misses), JS::default_attributes);
object->define_direct_property("fullStyleInvalidations"_utf16_fly_string, JS::Value(counters.full_style_invalidations), JS::default_attributes);
object->define_direct_property("styleInvalidations"_utf16_fly_string, JS::Value(counters.style_invalidations), JS::default_attributes);
return object;
}