Truly independent web browser
LibWeb: Remove the in-flow block reuse verification mode
Aliaksandr Kalenik2ab9601e6b2d
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 600ed64b652..36255b5d748 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -182,10 +182,6 @@ enum InFlowReuse {validity: fc_run_cache::FcRunCacheValidity,flow_position: CssPixels,abspos_containing_block_info_contributions_received: u64,- verify: Option<(- std::sync::Arc<in_flow_block_cache::InFlowBlockEntry>,- std::sync::Arc<fragment_tree::Fragment>,- )>,},}@@ -2603,17 +2599,7 @@ impl<'pass> BlockFormattingContext<'pass> {Some((entry, fragment))});if let Some((entry, fragment)) = hit {- if !in_flow_block_cache::verification_is_enabled() {- return InFlowReuse::Hit { entry, fragment };- }- return InFlowReuse::Store {- key,- validity,- flow_position: self.flow_position(),- abspos_containing_block_info_contributions_received: self- .abspos_containing_block_info_contributions_received(),- verify: Some((entry, fragment)),- };+ return InFlowReuse::Hit { entry, fragment };}InFlowReuse::Store {key,@@ -2621,7 +2607,6 @@ impl<'pass> BlockFormattingContext<'pass> {flow_position: self.flow_position(),abspos_containing_block_info_contributions_received: self.abspos_containing_block_info_contributions_received(),- verify: None,}}@@ -2697,7 +2682,6 @@ impl<'pass> BlockFormattingContext<'pass> {validity,flow_position,abspos_containing_block_info_contributions_received,- verify,} = attemptelse {return;@@ -2714,6 +2698,9 @@ impl<'pass> BlockFormattingContext<'pass> {&& self.abspos_containing_block_info_contributions_received()== abspos_containing_block_info_contributions_received&& used.border_box_block_size(false) != CssPixels::default();+ if !reusable {+ return;+ }let mut cells = used_values::UsedValuesCellState::capture(used);cells.has_content_offset = false;cells.content_offset = FfiCssPixelPoint::default();@@ -2735,25 +2722,10 @@ impl<'pass> BlockFormattingContext<'pass> {depends_on_percentage_block_size,fragment_identity: placed.fragment.identity,};- if let Some((stored, committed)) = verify {- let fragments = self.run.fragments.as_deref();- let was_reused = |slot: u32| fragments.is_some_and(|fragments| fragments.subtree_was_reused(slot));- in_flow_block_cache::verify_reuse(- node,- &stored,- &committed,- &entry,- &placed.fragment,- reusable,- &was_reused,- );- }- if reusable {- let committed_identity = arena.with_current_committed_fragment(node, |fragment| fragment.identity);- arena- .in_flow_block_cache_store()- .store(node.slot_index(), entry, committed_identity);- }+ let committed_identity = arena.with_current_committed_fragment(node, |fragment| fragment.identity);+ arena+ .in_flow_block_cache_store()+ .store(node.slot_index(), entry, committed_identity);}fn layout_block_level_children(diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rsindex a55defe264f..a0631a92b6a 100644--- a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs+++ b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs@@ -182,47 +182,6 @@ impl Fragment {&& self.continues_in_next_fragment == previous.continues_in_next_fragment}- /// Whether this fragment's subtree came out of layout like `previous`, ignoring which allocations hold the pieces.- /// A subtree this layout reused as a whole, as `was_reused` says by slot, carries no descendants, and compares- /// equal down to its root.- pub(crate) fn lays_out_like(&self, previous: &Fragment, was_reused: &impl Fn(u32) -> bool) -> bool {- let same_line_data = match (&self.line_data, &previous.line_data) {- (None, None) => true,- (Some(left), Some(right)) => left == right,- _ => false,- };- self.node == previous.node- && self.content_inline_size == previous.content_inline_size- && self.content_block_size == previous.content_block_size- && self.margin_left == previous.margin_left- && self.margin_right == previous.margin_right- && self.margin_top == previous.margin_top- && self.margin_bottom == previous.margin_bottom- && self.border_left == previous.border_left- && self.border_right == previous.border_right- && self.border_top == previous.border_top- && self.border_bottom == previous.border_bottom- && self.padding_left == previous.padding_left- && self.padding_right == previous.padding_right- && self.padding_top == previous.padding_top- && self.padding_bottom == previous.padding_bottom- && self.uses_collapsing_borders_model == previous.uses_collapsing_borders_model- && self.svg == previous.svg- && self.has_line_clamp_point == previous.has_line_clamp_point- && self.is_invisible_for_line_clamp == previous.is_invisible_for_line_clamp- && same_line_data- && ((self.children.is_empty() && was_reused(self.node.slot_index()))- || (self.children.len() == previous.children.len()- && self- .children- .iter()- .zip(&previous.children)- .all(|(link, previous_link)| {- link.has_same_placement(previous_link)- && link.fragment.lays_out_like(&previous_link.fragment, was_reused)- })))- }-pub(crate) fn has_same_child_placements(&self, previous: &Fragment) -> bool {self.children.len() == previous.children.len()&& self@@ -1411,10 +1370,6 @@ impl RunFragmentBuilder {self.inner.borrow().abspos_containing_block_info_contributions_received}- pub(crate) fn subtree_was_reused(&self, slot: u32) -> bool {- self.inner.borrow().reused_subtree_roots.contains(&slot)- }-fn attach(&self,inner: &mut RunFragmentBuilderInner,diff --git a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rsindex 484d9305457..4e6df13ef55 100644--- a/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs+++ b/Libraries/LibWeb/Rust/src/layout/in_flow_block_cache.rs@@ -139,52 +139,3 @@ impl InFlowBlockCacheStore {}}}--/// Whether every in-flow reuse also lays the child out and checks that both agree.-pub(super) fn verification_is_enabled() -> bool {- static ENABLED: std::sync::OnceLock<bool> = std::sync::OnceLock::new();- *ENABLED.get_or_init(|| std::env::var_os("LIBWEB_VERIFY_IN_FLOW_REUSE").is_some())-}--pub(super) fn verify_reuse(- node: Node,- stored: &InFlowBlockEntry,- committed: &fragment_tree::Fragment,- fresh: &InFlowBlockEntry,- fresh_fragment: &fragment_tree::Fragment,- fresh_is_reusable: bool,- was_reused: &impl Fn(u32) -> bool,-) {- assert!(- fresh_is_reusable,- "a reused in-flow layout of {node:?} is no longer reusable when laid out"- );- assert_eq!(- stored.cells, fresh.cells,- "the reused record of {node:?} differs from its layout"- );- assert_eq!(- stored.offset_from_flow_position, fresh.offset_from_flow_position,- "the reused offset of {node:?} differs from its layout"- );- assert_eq!(- stored.flow_position_advance, fresh.flow_position_advance,- "the reused flow advance of {node:?} differs from its layout"- );- assert!(- stored.outgoing_margins == fresh.outgoing_margins,- "the reused outgoing margins of {node:?} differ from its layout"- );- assert_eq!(- stored.margin_box_bottom_from_flow_position, fresh.margin_box_bottom_from_flow_position,- "the reused margin box bottom of {node:?} differs from its layout"- );- assert_eq!(- stored.depends_on_percentage_block_size, fresh.depends_on_percentage_block_size,- "the reused percentage block size dependency of {node:?} differs from its layout"- );- assert!(- fresh_fragment.lays_out_like(committed, was_reused),- "the reused subtree of {node:?} differs from its layout"- );-}diff --git a/Meta/Linters/check_rust_process_wide_state.py b/Meta/Linters/check_rust_process_wide_state.pyindex 1e66d9468e3..2aa2b8eda27 100755--- a/Meta/Linters/check_rust_process_wide_state.py+++ b/Meta/Linters/check_rust_process_wide_state.py@@ -118,7 +118,6 @@ RENDER_STATE_ALLOWED = {"css/style/mod.rs:SELECTOR_TRUTH_DERIVATION","css/style/mod.rs:STYLE_ANSWER_PATCH","css/style/mod.rs:STYLE_PLAN_PROVENANCE",- "layout/in_flow_block_cache.rs:ENABLED","layout/run_repeatability.rs:VERIFICATION","render_state/clock/hover.rs:LOGS",],