Truly independent web browser
LibWeb: Remove style engine state that nothing reads
Andreas Klinga1b4386921f9
diff --git a/Libraries/LibWeb/CSS/StyleEngineInput.cpp b/Libraries/LibWeb/CSS/StyleEngineInput.cppindex 27746db11c0..24bd68f40cc 100644--- a/Libraries/LibWeb/CSS/StyleEngineInput.cpp+++ b/Libraries/LibWeb/CSS/StyleEngineInput.cpp@@ -2679,8 +2679,6 @@ bool record_element_presentational_hint_properties(DOM::Element& element, Readonvoid record_element_declarations_changed(DOM::Element& element, ElementDeclarationKind kind, bool had_declarations, bool has_declarations){- if (element.style_node_id() != no_style_node)- StyleEngineFFI::style_engine_note_element_declarations_changed(element.document().style_computer().style_engine().host(), element.style_node_id().value());element.document().flush_deferred_style_change_event();auto* style_engine = style_engine_for_published(element);if (!style_engine)diff --git a/Libraries/LibWeb/Rust/src/css/style/column.rs b/Libraries/LibWeb/Rust/src/css/style/column.rsindex f26905530fe..c1c4f78b351 100644--- a/Libraries/LibWeb/Rust/src/css/style/column.rs+++ b/Libraries/LibWeb/Rust/src/css/style/column.rs@@ -6,25 +6,10 @@use std::ops::{Deref, DerefMut};-/// A directly indexed column whose missing rows all have the same value.-///-/// NB: The default vacant value stays a type rather than a stored pointer. A column grows to the-/// highest identity written, so a column that a single high identity widens fills far more-/// rows than it will ever hold, and filling those through a pointer costs one indirect call-/// per row where the compiler can otherwise emit a block store.-#[derive(Clone)]+/// A directly indexed column whose missing rows all hold the default value.+#[derive(Clone, Default)]pub(super) struct Column<T> {entries: Vec<T>,- vacant: Option<fn() -> T>,-}--impl<T: Default> Default for Column<T> {- fn default() -> Self {- Self {- entries: Vec::new(),- vacant: None,- }- }}impl<T: Default> Column<T> {@@ -35,10 +20,7 @@ impl<T: Default> Column<T> {}let capacity_before = self.entries.capacity();let length = index.checked_add(1).expect("column identity space exhausted");- match self.vacant {- Some(vacant) => self.entries.resize_with(length, vacant),- None => self.entries.resize_with(length, T::default),- }+ self.entries.resize_with(length, T::default);((self.entries.capacity() - capacity_before) * size_of::<T>()) as u64}@@ -78,15 +60,6 @@ impl<T> DerefMut for Column<T> {}}-impl<T> IntoIterator for Column<T> {- type Item = T;- type IntoIter = std::vec::IntoIter<T>;-- fn into_iter(self) -> Self::IntoIter {- self.entries.into_iter()- }-}-/// A directly indexed packed boolean column.#[derive(Clone, Default)]pub(super) struct BitColumn {diff --git a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rsindex 6029d5523f8..18484edfb29 100644--- a/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs+++ b/Libraries/LibWeb/Rust/src/css/style/engine_calls.rs@@ -913,14 +913,6 @@ pub(crate) struct EngineMemo {pub(in crate::css::style) projection: std::cell::RefCell<super::pipeline::projection::ProjectionWriter>,/// What the host wrote beside the rows since its last barrier.unpublished: std::cell::RefCell<UnpublishedInputs>,- /// While a batch's reactions are applied, a host's own style application may rewrite the declarations of an- /// element in its shadow tree, after the engine computed that element's record from the ones it had. These name- /// the elements whose declarations changed that way, while `applying_reactions` counts the batches being applied.- declarations_changed_during_apply: std::cell::RefCell<super::HashSet<StyleNodeID>>,- applying_reactions: std::cell::Cell<u32>,- /// Whether the transaction the host takes is one a style update applies, whose reactions close over the elements- /// they inherit through as the engine computes them.- takes_transaction_to_apply: std::cell::Cell<bool>,/// What `LIBWEB_STYLE_SELFCHECK` asked for as the host started.pub(super) style_self_check: super::pipeline::SelfCheckSettings,/// Whether the self-check of a style update that flew is yet to run: it is the next update's to run.@@ -941,7 +933,7 @@ impl EngineMemo {/// Counts what the memo holds toward the host's own owner, but for its projection writer, whose rows count toward/// the projection.pub(crate) fn report_memory(&self, report: &mut super::memory_report::MemoryReport) {- use crate::heap_size::{set_bytes, vec_bytes};+ use crate::heap_size::vec_bytes;let unpublished = self.unpublished.borrow();let bytes = size_of::<Memo<*const c_void>>()+ self.held.borrow().heap_size()@@ -950,8 +942,7 @@ impl EngineMemo {+ self.baselines.borrow().heap_size()+ self.atoms.borrow().heap_size()+ vec_bytes(&unpublished.backing_elements)- + vec_bytes(&unpublished.declarations)- + set_bytes(&self.declarations_changed_during_apply.borrow());+ + vec_bytes(&unpublished.declarations);report.add(super::memory_report::MemoryOwner::HostMemo, bytes);}@@ -1017,25 +1008,6 @@ impl EngineMemo {pub(crate) fn follow_queued(&self, queued: crate::render_state::QueuedStyleChange<'_>) {self.deferred.borrow_mut().follow(queued);}-- /// Notes the declarations of `node` changed, where a batch's reactions are being applied.- fn note_declarations_changed(&self, node: StyleNodeID) {- if self.applying_reactions.get() > 0 {- self.declarations_changed_during_apply.borrow_mut().insert(node);- }- }-- /// Marks the transactions the host takes until the answer is dropped as ones a style update applies.- pub(crate) fn take_transactions_to_apply(&self) -> impl Drop + '_ {- struct Taking<'a>(&'a EngineMemo);- impl Drop for Taking<'_> {- fn drop(&mut self) {- self.0.takes_transaction_to_apply.set(false);- }- }- self.takes_transaction_to_apply.set(true);- Taking(self)- }}impl Default for EngineMemo {@@ -1050,9 +1022,6 @@ impl Default for EngineMemo {identities: Default::default(),projection: Default::default(),unpublished: Default::default(),- declarations_changed_during_apply: Default::default(),- applying_reactions: Default::default(),- takes_transaction_to_apply: Default::default(),style_self_check: super::pipeline::SelfCheckSettings::from_environment(),flown_update_awaits_self_check: Default::default(),}@@ -1414,14 +1383,6 @@ pub extern "C" fn style_engine_has_size_containers_needing_evaluation_after_layo}}-/// Notes that the host rewrote the declarations of `node`, which a batch of reactions being applied reads.-#[unsafe(no_mangle)]-pub extern "C" fn style_engine_note_element_declarations_changed(host: &DocumentHost, node: u32) {- if let Some(node) = StyleNodeID::from_raw(node) {- host.engine_memo().note_declarations_changed(node);- }-}-type MemoSlot<T> = std::cell::Cell<(u64, T)>;/// A direct-mapped memo of one answer per key, which keeps the answers of the keys the host asked about last. It doublesdiff --git a/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs b/Libraries/LibWeb/Rust/src/css/style/reaction_application.rsindex f38fe6bbb7b..01a51a579b3 100644--- a/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs+++ b/Libraries/LibWeb/Rust/src/css/style/reaction_application.rs@@ -164,11 +164,8 @@ impl Application<'_> {/// Takes the next style update of the host's update_style(), the one computed beside the event loop first where it/// drains it, and answers the style installation the render side made of it for the host to swap in.fn take_transaction(self, flown: bool) -> StyleInstallation {- {- let _taking = self.host.engine_memo().take_transactions_to_apply();- // SAFETY: The host lends its application for the call that updates the style.- unsafe { web_css_run_style_update(self.host_application, flown) };- }+ // SAFETY: The host lends its application for the call that updates the style.+ unsafe { web_css_run_style_update(self.host_application, flown) };self.host.take_transaction_installation().unwrap_or_default()}