Skip to content

Truly independent web browser

LibWeb: Remove ComputedValues statistics

Aliaksandr Kalenikbbd610e40f40
diff --git a/Libraries/LibWeb/CSS/ComputedValues.cpp b/Libraries/LibWeb/CSS/ComputedValues.cpp
index 3555c0f263b..f335a06e4fa 100644
--- a/Libraries/LibWeb/CSS/ComputedValues.cpp
+++ b/Libraries/LibWeb/CSS/ComputedValues.cpp
@@ -373,13 +373,7 @@ Vector<RefPtr<AbstractImageStyleValue const>> ComputedValues::MaskValues::mask_i
return abstract_image_items(mask_image);
}
-ComputedValues::Statistics ComputedValues::s_statistics;
-
-ComputedValues::ComputedValues()
-{
- ++s_statistics.live_instance_count;
- ++s_statistics.total_instances_created;
-}
+ComputedValues::ComputedValues() = default;
StyleRecordRef::StyleRecordRef(void const* record)
: m_record(record)
@@ -395,16 +389,11 @@ StyleRecordRef::~StyleRecordRef()
}
ComputedValues::ComputedValues(BorrowedStyleRecord)
- : m_is_style_record_view(true)
{
m_ref_count = 0;
}
-ComputedValues::~ComputedValues()
-{
- if (!m_is_style_record_view)
- --s_statistics.live_instance_count;
-}
+ComputedValues::~ComputedValues() = default;
bool ComputedValues::is_property_important(PropertyID property_id) const
{
diff --git a/Libraries/LibWeb/CSS/ComputedValues.h b/Libraries/LibWeb/CSS/ComputedValues.h
index 1d885126f2c..196a7df3485 100644
--- a/Libraries/LibWeb/CSS/ComputedValues.h
+++ b/Libraries/LibWeb/CSS/ComputedValues.h
@@ -384,12 +384,6 @@ public:
bool has_animated_values() const { return m_borrowed_base_values || m_base_values; }
AnimatedProperties const* animated_properties() const { return m_animated_properties.ptr(); }
- struct Statistics {
- u64 live_instance_count { 0 };
- u64 total_instances_created { 0 };
- };
- static Statistics const& statistics() { return s_statistics; }
-
// Returns the Rust-owned payload for direct read-only layout access. The
// pointer is borrowed from this immutable ComputedValues instance.
void const* style_group_payload(StyleGroupIndex) const;
@@ -570,8 +564,6 @@ private:
};
}
- static Statistics s_statistics;
-
static size_t property_bitmap_index(PropertyID property_id)
{
VERIFY(property_id >= first_longhand_property_id && property_id <= last_longhand_property_id);
@@ -893,7 +885,6 @@ private:
bool m_depends_on_viewport_metrics { false };
bool m_font_metrics_depend_on_viewport_metrics { false };
bool m_in_display_none_subtree { false };
- bool m_is_style_record_view { false };
};
// Reads one group of the style whose groups `record` points at: a style record's, or a style layout
diff --git a/Libraries/LibWeb/Internals/Internals.cpp b/Libraries/LibWeb/Internals/Internals.cpp
index 44eaefe9ad2..c6879ae05db 100644
--- a/Libraries/LibWeb/Internals/Internals.cpp
+++ b/Libraries/LibWeb/Internals/Internals.cpp
@@ -3540,16 +3540,6 @@ GC::Ref<JS::Object> Internals::style_group_sharing_info(DOM::Element& element)
return object;
}
-GC::Ref<JS::Object> Internals::computed_values_stats()
-{
- auto& realm = HTML::relevant_realm(window());
- auto const& statistics = CSS::ComputedValues::statistics();
- auto object = JS::Object::create(realm, nullptr);
- object->define_direct_property("liveComputedValues"_utf16_fly_string, JS::Value(statistics.live_instance_count), JS::default_attributes);
- object->define_direct_property("totalComputedValuesCreated"_utf16_fly_string, JS::Value(statistics.total_instances_created), JS::default_attributes);
- return object;
-}
-
void Internals::update_style()
{
window().associated_document().update_style();
diff --git a/Libraries/LibWeb/Internals/Internals.h b/Libraries/LibWeb/Internals/Internals.h
index 1c25cdda8c2..87ee7b3ad10 100644
--- a/Libraries/LibWeb/Internals/Internals.h
+++ b/Libraries/LibWeb/Internals/Internals.h
@@ -342,7 +342,6 @@ public:
void request_reentrant_animation_style_flush_for_testing(GC::Ref<DOM::Node>);
GC::Ref<JS::Object> layout_tree_build_stats();
GC::Ref<JS::Object> compare_layout_tree_with_full_rebuild();
- GC::Ref<JS::Object> computed_values_stats();
GC::Ref<JS::Object> style_engine_counters();
GC::Ref<JS::Object> style_memory_report();
u64 style_memory_of_frames();
diff --git a/Libraries/LibWeb/Internals/Internals.idl b/Libraries/LibWeb/Internals/Internals.idl
index 9a573068f4c..d0fb3cae6b8 100644
--- a/Libraries/LibWeb/Internals/Internals.idl
+++ b/Libraries/LibWeb/Internals/Internals.idl
@@ -430,10 +430,6 @@ interface Internals {
// returns { matches }, plus { incremental, full } on mismatch. This is a test oracle for
// incremental tree builds.
object compareLayoutTreeWithFullRebuild();
- // Returns process-wide ComputedValues instance and retained representation statistics.
- // Keys: liveComputedValues, totalComputedValuesCreated,
- // retainedLegacyComputedPropertyArrayHolders, retainedLegacyComputedPropertyArrayBytes.
- object computedValuesStats();
object styleEngineCounters();
// What the document's style engine holds on the heap, by owner, with the C++ style state its elements hold:
// { owners: { name: bytes }, elements, styledElements }.
diff --git a/Tests/LibWeb/Text/expected/css/computed-values-stats.txt b/Tests/LibWeb/Text/expected/css/computed-values-stats.txt
deleted file mode 100644
index 14997fb10c8..00000000000
--- a/Tests/LibWeb/Text/expected/css/computed-values-stats.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-liveComputedValues is a number: true
-totalComputedValuesCreated is a number: true
-totalComputedValuesCreated >= liveComputedValues: true
-restyle creates new ComputedValues: false
diff --git a/Tests/LibWeb/Text/input/css/computed-values-stats.html b/Tests/LibWeb/Text/input/css/computed-values-stats.html
deleted file mode 100644
index befb67693a4..00000000000
--- a/Tests/LibWeb/Text/input/css/computed-values-stats.html
+++ /dev/null
@@ -1,21 +0,0 @@
-<!DOCTYPE html>
-<script src="../include.js"></script>
-<div id="target">hello</div>
-<script>
- test(() => {
- let stats = internals.computedValuesStats();
- println(`liveComputedValues is a number: ${typeof stats.liveComputedValues === "number"}`);
- println(`totalComputedValuesCreated is a number: ${typeof stats.totalComputedValuesCreated === "number"}`);
- println(`totalComputedValuesCreated >= liveComputedValues: ${stats.totalComputedValuesCreated >= stats.liveComputedValues}`);
-
- // The style engine settles both records, through a display transition too, and creates no ComputedValues.
- const target = document.getElementById("target");
- target.style.transition = "display 1s allow-discrete";
- internals.updateStyle();
- let before = internals.computedValuesStats().totalComputedValuesCreated;
- target.style.display = "inline";
- internals.updateStyle();
- let after = internals.computedValuesStats().totalComputedValuesCreated;
- println(`restyle creates new ComputedValues: ${after > before}`);
- });
-</script>