Truly independent web browser
LibWeb: Remove layout purposes
Aliaksandr Kalenik6edc8ed224d6
diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rsindex 62f3d2e3ad8..b2e78777136 100644--- a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs+++ b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs@@ -128,7 +128,6 @@ impl ContainingBlockGeometry {}pub(crate) struct AbsposEngine<'pass> {- purpose: formatting_context::LayoutPurpose,records: &'pass RunRecords<'pass>,callbacks: LayoutPass<'pass>,fragments: Option<std::rc::Rc<fragment_tree::RunFragmentBuilder>>,@@ -137,7 +136,6 @@ pub(crate) struct AbsposEngine<'pass> {impl<'pass> AbsposEngine<'pass> {pub(crate) fn for_run(run: &FormattingContextRun<'pass>) -> Self {Self {- purpose: run.purpose,records: run.records,callbacks: run.callbacks,fragments: run.fragments.clone(),@@ -248,7 +246,7 @@ impl<'pass> AbsposEngine<'pass> {#[inline]fn sizing(&self) -> sizing_context::SizingContext<'pass> {- sizing_context::SizingContext::new(self.purpose, self.records, self.callbacks)+ sizing_context::SizingContext::new(self.records, self.callbacks)}#[inline]@@ -3794,7 +3792,6 @@ pub(crate) fn drain_abspos_with_placed_containing_blocks() {let accumulator_root = entry_fragments.root_node();let run = FormattingContextRun {- purpose: formatting_context::LayoutPurpose::Commit,records,box_: accumulator_root,layout_mode: LayoutMode::Normal,diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 4d302710e10..85481f3d02f 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -513,7 +513,7 @@ impl<'pass> BlockFormattingContext<'pass> {#[inline]pub(crate) fn sizing(&self) -> sizing_context::SizingContext<'pass> {- sizing_context::SizingContext::new(self.run.purpose, self.run.records, self.run.callbacks)+ sizing_context::SizingContext::new(self.run.records, self.run.callbacks)}fn place_child(&self, node: Node, offset: FfiCssPixelPoint) {@@ -3263,13 +3263,6 @@ impl<'pass> BlockFormattingContext<'pass> {&& self.is_multicol_container()}- fn layout_multicol_container(&self, run: &FormattingContextRun<'pass>, input: LayoutInput) {- let scratch = self.run.callbacks.scratch();- scratch.begin_measurement_memo();- self.layout_multicol_container_rows(run, input);- scratch.end_measurement_memo();- }-fn layout_multicol_container_rows(&self, run: &FormattingContextRun<'pass>, input: LayoutInput) {let root = self.run.box_;let root_used = self.used(root);@@ -3668,9 +3661,9 @@ impl<'pass> BlockFormattingContext<'pass> {let mut tried_early_breaks: Vec<Node> = early_break_before.into_iter().collect();let mut minimal_space_shortage_of_discarded_attempts = None;let inline_items = self.column_inline_items.get_or_init(Default::default);- let (purpose, builds_fragments) = match column_layout_use {- ColumnLayoutUse::BalancingProbe => (formatting_context::LayoutPurpose::Measurement, false),- ColumnLayoutUse::ContainerContent => (self.run.purpose, self.run.fragments.is_some()),+ let builds_fragments = match column_layout_use {+ ColumnLayoutUse::BalancingProbe => false,+ ColumnLayoutUse::ContainerContent => self.run.fragments.is_some(),};loop {let fragmentainer = std::rc::Rc::new(fragmentation::FragmentainerContext::new(@@ -3681,13 +3674,8 @@ impl<'pass> BlockFormattingContext<'pass> {early_break_before,allows_early_break_requests,));- let outputs = formatting_context::run_fragmentainer(- &self.run,- purpose,- builds_fragments,- input,- fragmentainer.clone(),- );+ let outputs =+ formatting_context::run_fragmentainer(&self.run, builds_fragments, input, fragmentainer.clone());if outputs.result.depends_on_percentage_block_size {self.used(self.run.box_).has_descendant_that_depends_on_percentage_block_size@@ -3892,7 +3880,7 @@ impl<'pass> BlockFormattingContext<'pass> {}}if self.lays_out_multicol_container(input) {- self.layout_multicol_container(run, input);+ self.layout_multicol_container_rows(run, input);if self.facts(self.run.box_).is_list_item_box() {self.layout_list_item_marker(run,@@ -4406,7 +4394,6 @@ impl<'pass> BlockFormattingContext<'pass> {|| style.display().is_table_inside(){return formatting_context::independent_root_automatic_block_size(- self.run.purpose,self.run.records,&self.run.callbacks,node,diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rsindex ff6a7779171..c11a1cdeb81 100644--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs@@ -228,7 +228,7 @@ impl<'pass> FlexFormattingContext<'pass> {#[inline]fn sizing(&self) -> sizing_context::SizingContext<'pass> {- sizing_context::SizingContext::new(self.run.purpose, self.run.records, self.run.callbacks)+ sizing_context::SizingContext::new(self.run.records, self.run.callbacks)}fn create_used_values(&self, node: Node) -> &'pass UsedValues {diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex c258a158970..c7e60387aea 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -112,18 +112,6 @@ pub(crate) enum TableWrapperInlineSizeMode {UseTableUsedInlineSizeIfNotAuto,}-#[derive(Clone, Copy, Debug, PartialEq, Eq)]-pub(crate) enum LayoutPurpose {- Commit,- Measurement,-}--impl LayoutPurpose {- pub(crate) fn is_measurement(self) -> bool {- self == Self::Measurement- }-}-#[derive(Clone, Copy, Debug, PartialEq, Eq)]pub(crate) enum RootFragments {WhereTheRunInputAllows,@@ -196,7 +184,6 @@ impl<'pass> MeasurementState<'pass> {.callbacks.containing_block_for_child_run(node, &input.participation);run_formatting_context(- LayoutPurpose::Measurement,root_fragments,None,node_used,@@ -220,7 +207,6 @@ impl<'pass> MeasurementState<'pass> {pub(crate) fn run_fragmentainer(outer: &FormattingContextRun,- purpose: LayoutPurpose,builds_fragments: bool,input: LayoutInput,fragmentainer: std::rc::Rc<fragmentation::FragmentainerContext>,@@ -231,7 +217,6 @@ pub(crate) fn run_fragmentainer(.callbacks.containing_block_for_child_run(box_, &input.participation);execute_formatting_context_run(- purpose,builds_fragments,used_values::RootInputCells::capture(outer.records.used_values(box_)),box_,@@ -1308,7 +1293,6 @@ pub unsafe extern "C" fn document_host_set_layout_host_callbacks(#[derive(Clone)]pub(crate) struct FormattingContextRun<'pass> {- pub(crate) purpose: LayoutPurpose,pub(crate) records: &'pass RunRecords<'pass>,pub(crate) box_: Node,pub(crate) layout_mode: LayoutMode,@@ -1324,7 +1308,6 @@ impl<'pass> FormattingContextRun<'pass> {/// This run, laying out in `frame`.pub(crate) fn in_frame_of(&self, frame: geometry::Frame) -> Self {Self {- purpose: self.purpose,records: self.records,box_: self.box_,layout_mode: self.layout_mode,@@ -1340,7 +1323,7 @@ impl<'pass> FormattingContextRun<'pass> {#[inline]pub(crate) fn sizing(&self) -> sizing_context::SizingContext<'pass> {- sizing_context::SizingContext::new(self.purpose, self.records, self.callbacks)+ sizing_context::SizingContext::new(self.records, self.callbacks)}pub(crate) fn outputs(@@ -1538,7 +1521,6 @@ fn register_table_abspos_descendants(run: &FormattingContextRun, parent: Node) {}pub(crate) fn independent_root_automatic_block_size(- purpose: LayoutPurpose,records: &RunRecords<'_>,callbacks: &LayoutPass<'_>,node: Node,@@ -1567,7 +1549,7 @@ pub(crate) fn independent_root_automatic_block_size(// max-content size.// https://drafts.csswg.org/css-flexbox-1/#algo-main-container// https://www.w3.org/TR/css-grid-2/#intrinsic-sizes- return sizing_context::SizingContext::new(purpose, records, *callbacks).calculate_max_content_block_size(+ return sizing_context::SizingContext::new(records, *callbacks).calculate_max_content_block_size(node,available_inner_space.inline_size.to_px_or_zero(),constraints,@@ -1622,7 +1604,6 @@ fn eagerly_resolve_atomic_flex_root_auto_block_size(None,|| {independent_root_automatic_block_size(- run.purpose,run.records,&run.callbacks,node,@@ -1933,7 +1914,6 @@ fn body_input_with_inner_available_space(run: &FormattingContextRun, input: &Lay#[expect(clippy::too_many_arguments)]pub(super) fn run_formatting_context(- purpose: LayoutPurpose,root_fragments: RootFragments,parent_fragments: Option<&fragment_tree::RunFragmentBuilder>,parent_used: &UsedValues,@@ -1961,7 +1941,6 @@ pub(super) fn run_formatting_context();if callbacks.scratch().reads_no_memoized_layout() {let outputs = execute_formatting_context_run(- purpose,builds_fragments,root_cells,box_,@@ -1980,22 +1959,6 @@ pub(super) fn run_formatting_context(return absorb_run_outputs(&callbacks, parent_fragments, parent_used, box_, &input, outputs, false);}let cache_key = fc_run_cache::FcRunCacheKey::new(fc_type, layout_mode, input, root_cells);- let memoizes_measurement = purpose.is_measurement()- && callbacks.scratch().memoizes_measurements()- && fc_run_cache::can_describe_run(- box_,- parent_grid.is_some(),- should_collect_devtools_layout_data,- &callbacks,- &cache_key,- );- if memoizes_measurement- && let Some(outputs) = callbacks- .scratch()- .memoized_measurement(box_, purpose, layout_mode, &cache_key)- {- return absorb_run_outputs(&callbacks, parent_fragments, parent_used, box_, &input, outputs, false);- }let cache_attempt = match fc_run_cache::FcRunCacheAttempt::probe(box_,parent_grid.is_some(),@@ -2007,7 +1970,6 @@ pub(super) fn run_formatting_context(Ok(attempt) => attempt,Err(hit) => {if let Some(result) = reuse_committed_subtree_as_it_is(- purpose,parent_fragments,parent_used,box_,@@ -2029,7 +1991,7 @@ pub(super) fn run_formatting_context(let _trace = callbacks.arena().layout_trace- .run(box_, fc_type, purpose, layout_mode, || action);+ .run(box_, fc_type, layout_mode, || action);let outputs = if builds_fragments {hit.entry.outputs_to_replay(reuses_committed_subtree)} else {@@ -2049,11 +2011,10 @@ pub(super) fn run_formatting_context(let _trace = callbacks.arena().layout_trace- .run(box_, fc_type, purpose, layout_mode, || cache_attempt.trace_action());+ .run(box_, fc_type, layout_mode, || cache_attempt.trace_action());let previous_line_data = cache_attempt.previous_line_data();let discarded_outputs = run_repeatability::lay_out_discarded_run(&callbacks, || {execute_formatting_context_run(- purpose,builds_fragments,root_cells,box_,@@ -2071,7 +2032,6 @@ pub(super) fn run_formatting_context()});let outputs = execute_formatting_context_run(- purpose,builds_fragments,root_cells,box_,@@ -2090,11 +2050,6 @@ pub(super) fn run_formatting_context(if let Some(discarded_outputs) = &discarded_outputs {run_repeatability::verify_repeated_run(&callbacks, box_, discarded_outputs, &outputs);}- if memoizes_measurement {- callbacks- .scratch()- .memoize_measurement(box_, purpose, layout_mode, cache_key, &outputs);- }cache_attempt.conclude(&callbacks, box_, cache_key, &input, &outputs);absorb_run_outputs(&callbacks, parent_fragments, parent_used, box_, &input, outputs, false)}@@ -2103,9 +2058,7 @@ pub(super) fn run_formatting_context(/// stored run left, and the run's placement attaches the box's committed fragment as it is. That is exact where the/// committed subtree is the one the stored run produced, the box is plain, and nothing from the stored run reaches/// past its root.-#[expect(clippy::too_many_arguments)]fn reuse_committed_subtree_as_it_is(- purpose: LayoutPurpose,parent_fragments: Option<&fragment_tree::RunFragmentBuilder>,root_used: &UsedValues,box_: Node,@@ -2138,13 +2091,10 @@ fn reuse_committed_subtree_as_it_is(if !root_used.shows_box_of_fragment(&fragment) {return None;}- let _trace = callbacks.arena().layout_trace.run(- box_,- cache_key.fc_type(),- purpose,- LayoutMode::Normal,- || "REUSE SUBTREE",- );+ let _trace = callbacks+ .arena()+ .layout_trace+ .run(box_, cache_key.fc_type(), LayoutMode::Normal, || "REUSE SUBTREE");fragments.hold_reused_committed_fragment(box_, root_used, fragment);callbacks.scratch()@@ -2172,19 +2122,16 @@ pub(crate) fn content_inline_sizes_are_measured_by_layout(callbacks: &LayoutPassfn lays_out_box_for_its_content_inline_sizes(callbacks: &LayoutPass<'_>,box_: Node,- purpose: LayoutPurpose,layout_mode: LayoutMode,participation: ParticipationInParentFormattingContext,) -> bool {- purpose.is_measurement()- && layout_mode == LayoutMode::IntrinsicSizing+ layout_mode == LayoutMode::IntrinsicSizing&& participation == ParticipationInParentFormattingContext::Root&& content_inline_sizes_are_measured_by_layout(callbacks, box_)}#[expect(clippy::too_many_arguments)]fn execute_formatting_context_run(- purpose: LayoutPurpose,builds_fragments: bool,root_cells: used_values::RootInputCells,box_: Node,@@ -2210,7 +2157,6 @@ fn execute_formatting_context_run(&root_used,|records, callbacks| {let run = FormattingContextRun {- purpose,records,box_,layout_mode,@@ -2251,13 +2197,7 @@ fn execute_formatting_context_run(} = apply_root_sizing_directives(run, &input, fc_type);debug_assert!(!body_input.available_space.inline_size.is_intrinsic_sizing_constraint()- || lays_out_box_for_its_content_inline_sizes(- &callbacks,- box_,- purpose,- layout_mode,- input.participation- ),+ || lays_out_box_for_its_content_inline_sizes(&callbacks, box_, layout_mode, input.participation),"only a box whose content inline sizes are measured by layout lays out under an intrinsic inline size");@@ -2707,7 +2647,6 @@ fn finalize_atomic_root_block_size(Some(automatic_content_block_size_of_completed_body_run),),None => independent_root_automatic_block_size(- run.purpose,run.records,&run.callbacks,node,@@ -2868,7 +2807,6 @@ pub(crate) fn layout_inside_child(input.sizing.flex_self_block_size_resolution_space =dimension_root_in_parent_scope(parent_block, child, &input, child_run_builds_fragments);let result = run_formatting_context(- run.purpose,RootFragments::WhereTheRunInputAllows,run.fragments.as_deref(),used,@@ -2931,7 +2869,6 @@ pub(crate) fn run_table_cell_ahead_of_its_intrinsic_block_padding(let builds_fragments = run_builds_fragments(LayoutMode::Normal, &input, false);let execute = |previous_line_data| {execute_formatting_context_run(- LayoutPurpose::Commit,builds_fragments,root_cells,cell,@@ -2974,7 +2911,6 @@ pub(crate) fn run_table_cell_ahead_of_its_intrinsic_block_padding(let _trace = run.callbacks.arena().layout_trace.run(cell,FormattingContextType::Block,- LayoutPurpose::Commit,LayoutMode::Normal,|| "READ RESULT AHEAD OF INTRINSIC BLOCK PADDING",);@@ -2984,7 +2920,6 @@ pub(crate) fn run_table_cell_ahead_of_its_intrinsic_block_padding(let _trace = run.callbacks.arena().layout_trace.run(cell,FormattingContextType::Block,- LayoutPurpose::Commit,LayoutMode::Normal,|| "RUN AHEAD OF INTRINSIC BLOCK PADDING",);@@ -3313,7 +3248,6 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layolet viewport_used = entry_records.create_used_values(&callbacks, root, root_constraints);let entry_fragments = std::rc::Rc::new(fragment_tree::RunFragmentBuilder::new_entry_accumulator(root));let entry_run = FormattingContextRun {- purpose: LayoutPurpose::Commit,records: entry_records,box_: root,layout_mode: LayoutMode::Normal,@@ -3346,7 +3280,6 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layo.with_forced_sizes(viewport_inline_size, viewport_block_size);let fc_type = independent_formatting_context_type(root_for_layout, &callbacks);run_formatting_context(- LayoutPurpose::Commit,RootFragments::WhereTheRunInputAllows,Some(&entry_fragments),root_for_layout_used,@@ -3461,7 +3394,6 @@ fn compute_subtree_layout_fragments(input: LayoutStageInput<'_>, containing_bloclet entry_fragments =std::rc::Rc::new(fragment_tree::RunFragmentBuilder::new_entry_accumulator(entry_root));let entry_run = FormattingContextRun {- purpose: LayoutPurpose::Commit,records: entry_records,box_: entry_root,layout_mode: LayoutMode::Normal,@@ -3507,7 +3439,6 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {let fc_type = formatting_context_type_created_by_box(facts).expect("partial relayout root must establish an independent formatting context");run_formatting_context(- run.purpose,RootFragments::WhereTheRunInputAllows,Some(fragments),root_used,diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rsindex 0142ab8cd63..08974cea165 100644--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs@@ -1317,7 +1317,7 @@ impl<'pass> GridFormattingContext<'pass> {#[inline]fn sizing(&self) -> sizing_context::SizingContext<'pass> {- sizing_context::SizingContext::new(self.run.purpose, self.run.records, self.run.callbacks)+ sizing_context::SizingContext::new(self.run.records, self.run.callbacks)}fn parent_grid(&self) -> Option<&ParentGridData<'pass>> {@@ -2999,7 +2999,6 @@ impl<'pass> GridFormattingContext<'pass> {&scratch_root,|records, callbacks| {let scratch_run = FormattingContextRun {- purpose: formatting_context::LayoutPurpose::Measurement,records,box_: subgrid.box_,layout_mode: LayoutMode::IntrinsicSizing,diff --git a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rsindex 2d3ade5313a..6f04fd409e9 100644--- a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs+++ b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs@@ -50,7 +50,6 @@ impl ContentSizingScope {&self.root,|records, callbacks| {size_content(&FormattingContextRun {- purpose: formatting_context::LayoutPurpose::Measurement,records,box_: self.node,layout_mode: LayoutMode::IntrinsicSizing,diff --git a/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rsindex dce9faf6cbc..d9b21651445 100644--- a/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs@@ -47,7 +47,6 @@ pub(super) fn layout_replaced_with_children(wrapper_state.set_content_inline_size(content_inline_size);let wrapper_result = formatting_context::run_formatting_context(- run.purpose,formatting_context::RootFragments::WhereTheRunInputAllows,run.fragments.as_deref(),wrapper_state,diff --git a/Libraries/LibWeb/Rust/src/layout/run_records.rs b/Libraries/LibWeb/Rust/src/layout/run_records.rsindex 2db7c3cfe92..ea7fa14d687 100644--- a/Libraries/LibWeb/Rust/src/layout/run_records.rs+++ b/Libraries/LibWeb/Rust/src/layout/run_records.rs@@ -22,7 +22,6 @@ pub(crate) struct LayoutScratch {/// The inline items a block container generated, kept for its later runs in the same pass. The/// items borrow fonts for the current pass, so the stashes are cleared when the pass ends.inline_item_stashes: RefCell<HashMap<NodeSlotId, super::inline_level_iterator::StashedInlineItems>>,- measurement_memo: RefCell<MeasurementMemo>,/// The styles of the boxes being laid out with one of their position options, which the style reads of each box/// see in place of the style of its row./// https://drafts.csswg.org/css-anchor-position-1/#apply-a-position-option@@ -110,19 +109,6 @@ impl HostFindings {}}-#[derive(Default)]-struct MeasurementMemo {- depth: usize,- runs: HashMap<NodeSlotId, Vec<MemoizedMeasurement>>,-}--struct MemoizedMeasurement {- purpose: super::formatting_context::LayoutPurpose,- layout_mode: super::formatting_context::LayoutMode,- key: super::fc_run_cache::FcRunCacheKey,- outputs: super::formatting_context::RunOutputs,-}-// Between passes the scratch holds no record, so it can move to the thread a layout stage runs on.const _: () = {const fn assert_send<T: Send>() {}@@ -146,7 +132,6 @@ impl Default for LayoutScratch {run_record_stack: RunRecordStack::default(),intrinsic_size_caches: Default::default(),inline_item_stashes: RefCell::new(HashMap::default()),- measurement_memo: RefCell::new(MeasurementMemo::default()),position_option_styles: RefCell::new(Vec::new()),has_position_option_styles: Cell::new(false),host_findings_of_runs_in_progress: RefCell::new(Vec::new()),@@ -216,7 +201,7 @@ impl LayoutScratch {}/// Whether a run whose result is discarded is in progress, which reads no memoized layout from before it and keeps- /// none: the run cache, the in-flow block cache, inline item stashes, memoized measurements and intrinsic sizes.+ /// none: the run cache, the in-flow block cache, inline item stashes and intrinsic sizes.pub(crate) fn reads_no_memoized_layout(&self) -> bool {self.discarded_runs_in_progress.get() > 0}@@ -242,58 +227,6 @@ impl LayoutScratch {std::mem::take(&mut self.host_findings_outside_runs.borrow_mut())}- pub(crate) fn begin_measurement_memo(&self) {- self.measurement_memo.borrow_mut().depth += 1;- }-- pub(crate) fn end_measurement_memo(&self) {- let mut memo = self.measurement_memo.borrow_mut();- memo.depth -= 1;- if memo.depth == 0 {- memo.runs.clear();- }- }-- pub(crate) fn memoizes_measurements(&self) -> bool {- self.measurement_memo.borrow().depth > 0 && !self.reads_no_memoized_layout()- }-- pub(super) fn memoized_measurement(- &self,- box_: NodeSlotId,- purpose: super::formatting_context::LayoutPurpose,- layout_mode: super::formatting_context::LayoutMode,- key: &super::fc_run_cache::FcRunCacheKey,- ) -> Option<super::formatting_context::RunOutputs> {- self.measurement_memo- .borrow()- .runs- .get(&box_)?- .iter()- .find(|memoized| memoized.purpose == purpose && memoized.layout_mode == layout_mode && memoized.key == *key)- .map(|memoized| memoized.outputs.clone())- }-- pub(super) fn memoize_measurement(- &self,- box_: NodeSlotId,- purpose: super::formatting_context::LayoutPurpose,- layout_mode: super::formatting_context::LayoutMode,- key: super::fc_run_cache::FcRunCacheKey,- outputs: &super::formatting_context::RunOutputs,- ) {- let mut memo = self.measurement_memo.borrow_mut();- if memo.depth == 0 {- return;- }- memo.runs.entry(box_).or_default().push(MemoizedMeasurement {- purpose,- layout_mode,- key,- outputs: outputs.clone(),- });- }-/// Lets go of what the pass that just committed kept for itself.pub(crate) fn end_layout_pass(&self) {self.inline_item_stashes.borrow_mut().clear();diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rsindex ae906b7f29e..1241061f5c5 100644--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs@@ -111,7 +111,6 @@ pub(crate) struct TableWrapperBlockSizes {}pub(crate) struct SizingContext<'pass> {- purpose: formatting_context::LayoutPurpose,records: &'pass RunRecords<'pass>,callbacks: LayoutPass<'pass>,style_cache: Cell<Option<(Node, &'pass FfiStylePayloads)>>,@@ -165,13 +164,8 @@ pub(crate) fn stretch_fit_block_margins(impl<'pass> SizingContext<'pass> {#[inline]- pub(crate) fn new(- purpose: formatting_context::LayoutPurpose,- records: &'pass RunRecords<'pass>,- callbacks: LayoutPass<'pass>,- ) -> Self {+ pub(crate) fn new(records: &'pass RunRecords<'pass>, callbacks: LayoutPass<'pass>) -> Self {Self {- purpose,records,callbacks,style_cache: Cell::new(None),@@ -2215,7 +2209,7 @@ impl<'pass> SizingContext<'pass> {self.callbacks.in_flow_containing_block(node),&root,|records, callbacks| {- let sizing = SizingContext::new(self.purpose, records, callbacks);+ let sizing = SizingContext::new(records, callbacks);let inline_size_under = |inline_size| {sizing.atomic_root_content_inline_size(node,@@ -3140,11 +3134,7 @@ impl<'pass> SizingContext<'pass> {kind: IntrinsicSizeCacheKind,) -> CssPixels {let own_frame = formatting_context::frame_established_by(&self.callbacks, node);- let sizing = SizingContext::new(- self.purpose,- self.records,- self.callbacks.in_frame_of(own_frame.writing_mode()),- );+ let sizing = SizingContext::new(self.records, self.callbacks.in_frame_of(own_frame.writing_mode()));let constraints_in_own_frame = ContainingBlockConstraints {percentage_basis_inline_size: constraints.percentage_basis_block_size,percentage_basis_block_size: constraints.percentage_basis_inline_size,@@ -3432,7 +3422,6 @@ impl<'pass> SizingContext<'pass> {&table_used,|records, callbacks| {let table_run = FormattingContextRun {- purpose: formatting_context::LayoutPurpose::Measurement,records,box_: table_box,layout_mode: LayoutMode::IntrinsicSizing,diff --git a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rsindex 38f5d47bb57..5fe64e429fb 100644--- a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs@@ -1103,7 +1103,7 @@ impl<'pass> TableFormattingContext<'pass> {#[inline]fn sizing(&self) -> sizing_context::SizingContext<'pass> {- sizing_context::SizingContext::new(self.run.purpose, self.run.records, self.run.callbacks)+ sizing_context::SizingContext::new(self.run.records, self.run.callbacks)}fn parent(&self, node: Node) -> Node {diff --git a/Libraries/LibWeb/Rust/src/layout/trace.rs b/Libraries/LibWeb/Rust/src/layout/trace.rsindex f94fa9f1783..3fafe2a8344 100644--- a/Libraries/LibWeb/Rust/src/layout/trace.rs+++ b/Libraries/LibWeb/Rust/src/layout/trace.rs@@ -5,7 +5,7 @@*/use super::LayoutNodeArena;-use super::formatting_context::{FormattingContextType, LayoutMode, LayoutPurpose};+use super::formatting_context::{FormattingContextType, LayoutMode};use super::layout_node_arena::IntrinsicSizeCacheKind;use super::node_data::{NodeFlag, NodeKind, NodeSlotId};use crate::render_state::DocumentHost;@@ -195,7 +195,6 @@ impl LayoutTrace {&self,root: NodeSlotId,fc_type: FormattingContextType,- purpose: LayoutPurpose,mode: LayoutMode,action: impl FnOnce() -> &'static str,) -> Option<Scope<'_>> {@@ -211,13 +210,11 @@ impl LayoutTrace {FormattingContextType::InternalReplaced => "internal-replaced",FormattingContextType::InternalDummy => "internal-dummy",};- let measurement = match (purpose.is_measurement(), mode) {- (false, LayoutMode::Normal) => "",- (false, LayoutMode::IntrinsicSizing) => " (intrinsic)",- (true, LayoutMode::Normal) => " (measurement)",- (true, LayoutMode::IntrinsicSizing) => " (measurement, intrinsic)",+ let intrinsic = match mode {+ LayoutMode::Normal => "",+ LayoutMode::IntrinsicSizing => " (intrinsic)",};- format!("/{context}{measurement} {}", action())+ format!("/{context}{intrinsic} {}", action())})}}@@ -425,13 +422,11 @@ mod tests {arena.layout_trace.begin();arena.begin_active_layout_pass();- drop(arena.layout_trace.run(- owner.slot,- FormattingContextType::Block,- LayoutPurpose::Commit,- LayoutMode::Normal,- || "RUN",- ));+ drop(+ arena+ .layout_trace+ .run(owner.slot, FormattingContextType::Block, LayoutMode::Normal, || "RUN"),+ );assert!(arena.leave_active_layout_pass());let names = arena.layout_tracediff --git a/Tests/LibWeb/Text/expected/layout-test-harness.txt b/Tests/LibWeb/Text/expected/layout-test-harness.txtindex 7a6093235f8..6333e82d72c 100644--- a/Tests/LibWeb/Text/expected/layout-test-harness.txt+++ b/Tests/LibWeb/Text/expected/layout-test-harness.txt@@ -8,7 +8,7 @@ PASS: bypass is different from a missPASS: extra passPASS: nested workPASS: repeated run-PASS: measurement purpose+PASS: intrinsic sizingPASS: traces mutation, flush and checksPASS: stops tracing after a throwing mutationPASS: stops tracing after a failed checkdiff --git a/Tests/LibWeb/Text/input/layout-min-height-block-root-skips-content-measurement.html b/Tests/LibWeb/Text/input/layout-min-height-block-root-skips-content-measurement.htmlindex b05cacf7f89..f1f89013c4b 100644--- a/Tests/LibWeb/Text/input/layout-min-height-block-root-skips-content-measurement.html+++ b/Tests/LibWeb/Text/input/layout-min-height-block-root-skips-content-measurement.html@@ -13,7 +13,7 @@// Whether a change inside `root` has it lay out its content in a measurement run before its own layout.const measuresContentFirst = (root, change) => {const work = layoutWork(change);- return work.count(event => event.event === "run" && event.box.endsWith(`#${root.id}`) && event.measurement && !event.intrinsic) > 0;+ return work.count(event => event.event === "run" && event.box.endsWith(`#${root.id}`) && event.action === "RUN" && !event.intrinsic) > 1;};test(() => {diff --git a/Tests/LibWeb/Text/input/layout-run-cache-anonymous-flex-item-forwards-percentage-height.html b/Tests/LibWeb/Text/input/layout-run-cache-anonymous-flex-item-forwards-percentage-height.htmlindex 777d18cb5db..82cf1119012 100644--- a/Tests/LibWeb/Text/input/layout-run-cache-anonymous-flex-item-forwards-percentage-height.html+++ b/Tests/LibWeb/Text/input/layout-run-cache-anonymous-flex-item-forwards-percentage-height.html@@ -30,7 +30,7 @@BlockContainer(anonymous) MEASURE max-content inline (cache=miss) FROM ITEMSBlockContainer(anonymous) MEASURE min-content inline (cache=hit)BlockContainer(anonymous) MEASURE max-content block (cache=miss)- BlockContainer(anonymous)/block (measurement, intrinsic) RUN (cache=bypass)+ BlockContainer(anonymous)/block (intrinsic) RUN (cache=bypass)BlockContainer<DIV>#plain MEASURE max-content block (cache=hit)BlockContainer(anonymous)/block RUN (cache=miss)BlockContainer<SPAN>#inline-block/block RUN (cache=miss)diff --git a/Tests/LibWeb/Text/input/layout-run-cache-measured-content-committed-by-replay.html b/Tests/LibWeb/Text/input/layout-run-cache-measured-content-committed-by-replay.htmlindex 8e504aebe1f..360f779c60c 100644--- a/Tests/LibWeb/Text/input/layout-run-cache-measured-content-committed-by-replay.html+++ b/Tests/LibWeb/Text/input/layout-run-cache-measured-content-committed-by-replay.html@@ -63,12 +63,12 @@@viewport/block RUN (cache=bypass)BlockContainer<HTML>/block RUN (cache=miss)BlockContainer<BUTTON>#button/block RUN (cache=miss)- BlockContainer<BUTTON>#button/block (measurement) RUN (cache=bypass)- BlockContainer(anonymous)/flex (measurement) RUN (cache=miss)+ BlockContainer<BUTTON>#button/block RUN (cache=bypass)+ BlockContainer(anonymous)/flex RUN (cache=miss)BlockContainer(anonymous) MEASURE max-content block (cache=hit)BlockContainer(anonymous) MEASURE max-content block (cache=hit)- BlockContainer(anonymous)/block (measurement) RUN (cache=miss)- BlockContainer<DIV>#marker.marker/block (measurement) REUSE SUBTREE+ BlockContainer(anonymous)/block RUN (cache=miss)+ BlockContainer<DIV>#marker.marker/block REUSE SUBTREEBlockContainer(anonymous)/flex REUSE SUBTREEBlockContainer<DIV>#spacer REUSE IN-FLOW SUBTREE`,@@ -86,12 +86,12 @@@viewport/block RUN (cache=bypass)BlockContainer<HTML>/block RUN (cache=miss)BlockContainer<BUTTON>#button/block RUN (cache=miss)- BlockContainer<BUTTON>#button/block (measurement) RUN (cache=bypass)- BlockContainer(anonymous)/flex (measurement) RUN (cache=miss)+ BlockContainer<BUTTON>#button/block RUN (cache=bypass)+ BlockContainer(anonymous)/flex RUN (cache=miss)BlockContainer(anonymous) MEASURE max-content block (cache=hit)BlockContainer(anonymous) MEASURE max-content block (cache=hit)- BlockContainer(anonymous)/block (measurement) RUN (cache=miss)- BlockContainer<DIV>#marker.marker/block (measurement) REUSE SUBTREE+ BlockContainer(anonymous)/block RUN (cache=miss)+ BlockContainer<DIV>#marker.marker/block REUSE SUBTREEBlockContainer(anonymous)/flex REPLAY FRAGMENTSBlockContainer<DIV>#spacer REUSE IN-FLOW SUBTREE`,diff --git a/Tests/LibWeb/Text/input/layout-run-cache-measurement-replay-of-recommitted-subtree-misses.html b/Tests/LibWeb/Text/input/layout-run-cache-measurement-replay-of-recommitted-subtree-misses.htmlindex 211b0b44ab0..a3d471c6123 100644--- a/Tests/LibWeb/Text/input/layout-run-cache-measurement-replay-of-recommitted-subtree-misses.html+++ b/Tests/LibWeb/Text/input/layout-run-cache-measurement-replay-of-recommitted-subtree-misses.html@@ -62,12 +62,12 @@@viewport/block RUN (cache=bypass)BlockContainer<HTML>/block RUN (cache=miss)BlockContainer<BUTTON>#button/block RUN (cache=miss)- BlockContainer<BUTTON>#button/block (measurement) RUN (cache=bypass)- BlockContainer(anonymous)/flex (measurement) RUN (cache=miss)+ BlockContainer<BUTTON>#button/block RUN (cache=bypass)+ BlockContainer(anonymous)/flex RUN (cache=miss)BlockContainer(anonymous) MEASURE max-content block (cache=hit)BlockContainer(anonymous) MEASURE max-content block (cache=hit)- BlockContainer(anonymous)/block (measurement) RUN (cache=miss)- BlockContainer<DIV>#marker.marker/block (measurement) REUSE SUBTREE+ BlockContainer(anonymous)/block RUN (cache=miss)+ BlockContainer<DIV>#marker.marker/block REUSE SUBTREEBlockContainer(anonymous)/flex RUN (cache=miss)BlockContainer(anonymous) MEASURE max-content block (cache=hit)BlockContainer(anonymous)/block REUSE SUBTREE@@ -84,16 +84,16 @@@viewport/block RUN (cache=bypass)BlockContainer<HTML>/block RUN (cache=miss)BlockContainer<BUTTON>#button/block RUN (cache=miss)- BlockContainer<BUTTON>#button/block (measurement) RUN (cache=bypass)- BlockContainer(anonymous)/flex (measurement) RUN (cache=miss)+ BlockContainer<BUTTON>#button/block RUN (cache=bypass)+ BlockContainer(anonymous)/flex RUN (cache=miss)BlockContainer(anonymous) MEASURE max-content block (cache=miss)- BlockContainer(anonymous)/block (measurement, intrinsic) RUN (cache=bypass)- BlockContainer<DIV>#marker.marker/block (measurement, intrinsic) RUN (cache=miss)+ BlockContainer(anonymous)/block (intrinsic) RUN (cache=bypass)+ BlockContainer<DIV>#marker.marker/block (intrinsic) RUN (cache=miss)BlockContainer<DIV>#marker.marker MEASURE max-content inline (cache=hit)BlockContainer<DIV>#marker.marker MEASURE min-content inline (cache=hit)BlockContainer(anonymous) MEASURE max-content block (cache=hit)- BlockContainer(anonymous)/block (measurement) RUN (cache=miss)- BlockContainer<DIV>#marker.marker/block (measurement) RUN (cache=miss)+ BlockContainer(anonymous)/block RUN (cache=miss)+ BlockContainer<DIV>#marker.marker/block RUN (cache=miss)BlockContainer<DIV>#marker.marker MEASURE max-content inline (cache=hit)BlockContainer<DIV>#marker.marker MEASURE min-content inline (cache=hit)BlockContainer(anonymous)/flex RUN (cache=miss)@@ -114,12 +114,12 @@@viewport/block RUN (cache=bypass)BlockContainer<HTML>/block RUN (cache=miss)BlockContainer<BUTTON>#button/block RUN (cache=miss)- BlockContainer<BUTTON>#button/block (measurement) RUN (cache=bypass)- BlockContainer(anonymous)/flex (measurement) RUN (cache=miss)+ BlockContainer<BUTTON>#button/block RUN (cache=bypass)+ BlockContainer(anonymous)/flex RUN (cache=miss)BlockContainer(anonymous) MEASURE max-content block (cache=hit)BlockContainer(anonymous) MEASURE max-content block (cache=hit)- BlockContainer(anonymous)/block (measurement) RUN (cache=miss)- BlockContainer<DIV>#marker.marker/block (measurement) RUN (cache=miss)+ BlockContainer(anonymous)/block RUN (cache=miss)+ BlockContainer<DIV>#marker.marker/block RUN (cache=miss)BlockContainer<DIV>#marker.marker MEASURE max-content inline (cache=hit)BlockContainer<DIV>#marker.marker MEASURE min-content inline (cache=hit)BlockContainer(anonymous)/flex REPLAY FRAGMENTSdiff --git a/Tests/LibWeb/Text/input/layout-run-cache-nested-reuse-under-measurement.html b/Tests/LibWeb/Text/input/layout-run-cache-nested-reuse-under-measurement.htmlindex b4fa96eaf2b..e9dda51600c 100644--- a/Tests/LibWeb/Text/input/layout-run-cache-nested-reuse-under-measurement.html+++ b/Tests/LibWeb/Text/input/layout-run-cache-nested-reuse-under-measurement.html@@ -28,12 +28,12 @@BlockContainer<TD>#cell MEASURE min-content inline (cache=hit)BlockContainer<TD>#cell MEASURE max-content inline (cache=hit)BlockContainer<TD>#cell MEASURE max-content block (cache=miss)- BlockContainer<TD>#cell/block (measurement, intrinsic) RUN (cache=bypass)- BlockContainer<DIV>#nested/block (measurement, intrinsic) RUN (cache=miss)+ BlockContainer<TD>#cell/block (intrinsic) RUN (cache=bypass)+ BlockContainer<DIV>#nested/block (intrinsic) RUN (cache=miss)BlockContainer<TD>#cell MEASURE max-content block (cache=hit)BlockContainer<TD>#cell MEASURE CELL (cache=miss)- BlockContainer<TD>#cell/block (measurement) RUN (cache=miss)- BlockContainer<DIV>#nested/block (measurement) RUN (cache=miss)+ BlockContainer<TD>#cell/block RUN (cache=miss)+ BlockContainer<DIV>#nested/block RUN (cache=miss)BlockContainer<TD>#cell/block RUN (cache=miss)BlockContainer<DIV>#nested/block REPLAY FRAGMENTS`,@@ -57,12 +57,12 @@BlockContainer<TD>#cell MEASURE min-content inline (cache=hit)BlockContainer<TD>#cell MEASURE max-content inline (cache=hit)BlockContainer<TD>#cell MEASURE max-content block (cache=miss)- BlockContainer<TD>#cell/block (measurement, intrinsic) RUN (cache=bypass)- BlockContainer<DIV>#nested/block (measurement, intrinsic) READ RESULT+ BlockContainer<TD>#cell/block (intrinsic) RUN (cache=bypass)+ BlockContainer<DIV>#nested/block (intrinsic) READ RESULTBlockContainer<TD>#cell MEASURE max-content block (cache=hit)BlockContainer<TD>#cell MEASURE CELL (cache=miss)- BlockContainer<TD>#cell/block (measurement) RUN (cache=miss)- BlockContainer<DIV>#nested/block (measurement) REUSE SUBTREE+ BlockContainer<TD>#cell/block RUN (cache=miss)+ BlockContainer<DIV>#nested/block REUSE SUBTREEBlockContainer<TD>#cell/block RUN (cache=miss)BlockContainer<DIV>#nested/block REUSE SUBTREE`,diff --git a/Tests/LibWeb/Text/input/layout-run-cache-table-cell-ahead-of-intrinsic-padding.html b/Tests/LibWeb/Text/input/layout-run-cache-table-cell-ahead-of-intrinsic-padding.htmlindex e968124fa36..977377ffab4 100644--- a/Tests/LibWeb/Text/input/layout-run-cache-table-cell-ahead-of-intrinsic-padding.html+++ b/Tests/LibWeb/Text/input/layout-run-cache-table-cell-ahead-of-intrinsic-padding.html@@ -73,7 +73,7 @@BlockContainer<TD>#text-cell MEASURE CELL (cache=miss)BlockContainer<TD>#text-cell/block RUN AHEAD OF INTRINSIC BLOCK PADDINGBlockContainer<TD>#markup-cell MEASURE CELL (cache=miss)- BlockContainer<TD>#markup-cell/block (measurement) RUN (cache=miss)+ BlockContainer<TD>#markup-cell/block RUN (cache=miss)BlockContainer<TD>#text-cell/block REPLAY FRAGMENTSBlockContainer<TD>#markup-cell/block RUN (cache=miss)`,@@ -105,12 +105,12 @@BlockContainer<TD>#markup-cell MEASURE min-content inline (cache=hit)BlockContainer<TD>#markup-cell MEASURE max-content inline (cache=hit)BlockContainer<TD>#markup-cell MEASURE max-content block (cache=miss)- BlockContainer<TD>#markup-cell/block (measurement, intrinsic) RUN (cache=bypass)+ BlockContainer<TD>#markup-cell/block (intrinsic) RUN (cache=bypass)BlockContainer<TD>#markup-cell MEASURE max-content block (cache=miss)- BlockContainer<TD>#markup-cell/block (measurement, intrinsic) RUN (cache=bypass)+ BlockContainer<TD>#markup-cell/block (intrinsic) RUN (cache=bypass)BlockContainer<TD>#text-cell MEASURE CELL (cache=hit)BlockContainer<TD>#markup-cell MEASURE CELL (cache=miss)- BlockContainer<TD>#markup-cell/block (measurement) RUN (cache=miss)+ BlockContainer<TD>#markup-cell/block RUN (cache=miss)BlockContainer<TD>#text-cell/block REUSE SUBTREEBlockContainer<TD>#markup-cell/block RUN (cache=miss)`,@@ -138,19 +138,19 @@BlockContainer<TD>#text-cell MEASURE min-content inline (cache=hit)BlockContainer<TD>#text-cell MEASURE max-content inline (cache=hit)BlockContainer<TD>#text-cell MEASURE max-content block (cache=miss)- BlockContainer<TD>#text-cell/block (measurement, intrinsic) RUN (cache=bypass)+ BlockContainer<TD>#text-cell/block (intrinsic) RUN (cache=bypass)BlockContainer<TD>#text-cell MEASURE max-content block (cache=miss)- BlockContainer<TD>#text-cell/block (measurement, intrinsic) RUN (cache=bypass)+ BlockContainer<TD>#text-cell/block (intrinsic) RUN (cache=bypass)BlockContainer<TD>#markup-cell MEASURE min-content inline (cache=hit)BlockContainer<TD>#markup-cell MEASURE max-content inline (cache=hit)BlockContainer<TD>#markup-cell MEASURE max-content block (cache=miss)- BlockContainer<TD>#markup-cell/block (measurement, intrinsic) RUN (cache=bypass)+ BlockContainer<TD>#markup-cell/block (intrinsic) RUN (cache=bypass)BlockContainer<TD>#markup-cell MEASURE max-content block (cache=miss)- BlockContainer<TD>#markup-cell/block (measurement, intrinsic) RUN (cache=bypass)+ BlockContainer<TD>#markup-cell/block (intrinsic) RUN (cache=bypass)BlockContainer<TD>#text-cell MEASURE CELL (cache=miss)BlockContainer<TD>#text-cell/block RUN AHEAD OF INTRINSIC BLOCK PADDINGBlockContainer<TD>#markup-cell MEASURE CELL (cache=miss)- BlockContainer<TD>#markup-cell/block (measurement) RUN (cache=miss)+ BlockContainer<TD>#markup-cell/block RUN (cache=miss)BlockContainer<TD>#text-cell/block REPLAY FRAGMENTSBlockContainer<TD>#markup-cell/block RUN (cache=miss)`,diff --git a/Tests/LibWeb/Text/input/layout-run-cache-table-percentage-cell-height-misses.html b/Tests/LibWeb/Text/input/layout-run-cache-table-percentage-cell-height-misses.htmlindex ce048147f99..13d2eb9efad 100644--- a/Tests/LibWeb/Text/input/layout-run-cache-table-percentage-cell-height-misses.html+++ b/Tests/LibWeb/Text/input/layout-run-cache-table-percentage-cell-height-misses.html@@ -38,7 +38,7 @@BlockContainer<TD>#percentage-cell MEASURE max-content block (cache=hit)BlockContainer<TD>#percentage-cell MEASURE CELL (cache=hit)BlockContainer<TD>#percentage-cell MEASURE CELL (cache=miss)- BlockContainer<TD>#percentage-cell/block (measurement) RUN (cache=miss)+ BlockContainer<TD>#percentage-cell/block RUN (cache=miss)BlockContainer<TD>#percentage-cell/block RUN (cache=miss)BlockContainer<TD>#fixed-cell MEASURE min-content inline (cache=hit)BlockContainer<TD>#fixed-cell MEASURE max-content inline (cache=hit)diff --git a/Tests/LibWeb/Text/input/layout-test-harness.html b/Tests/LibWeb/Text/input/layout-test-harness.htmlindex fb9768b96c1..6f385c91400 100644--- a/Tests/LibWeb/Text/input/layout-test-harness.html+++ b/Tests/LibWeb/Text/input/layout-test-harness.html@@ -20,7 +20,7 @@ test(() => {["extra pass", expected, expected + expected, true],["nested work", expected, expected.replace(" #sibling", " #sibling"), true],["repeated run", expected, expected + " #sibling/block REUSE SUBTREE\n", true],- ["measurement purpose", expected, expected.replace("#target/block", "#target/block (measurement)"), true],+ ["intrinsic sizing", expected, expected.replace("#target/block", "#target/block (intrinsic)"), true],];for (const [name, expected, actual, differs] of cases) {const passed = (layoutTraceDifference(expected, actual) !== null) === differs;@@ -72,7 +72,7 @@ test(() => {" BlockContainer(anonymous) MEASURE min-content inline (cache=hit)"," BlockContainer<DIV>#column MEASURE min-content inline (cache=miss) FROM CHILDREN"," Box<DIV>#item MEASURE max-content block (cache=miss)",- " Box<DIV>#item/flex (measurement, intrinsic) RUN (cache=bypass)",+ " Box<DIV>#item/flex (intrinsic) RUN (cache=bypass)"," Box<TABLE>#table/table (intrinsic) RUN (cache=bypass)"," BlockContainer<TD>.cell MEASURE CELL (cache=miss)"," BlockContainer<TD>.cell/block RUN AHEAD OF INTRINSIC BLOCK PADDING",@@ -84,20 +84,20 @@ test(() => {].join("\n");const expectedEvents = [{ depth: 0, event: "layout", partial: false },- { depth: 1, event: "run", box: "@viewport", formattingContext: "block", measurement: false, intrinsic: false, action: "RUN", cache: "bypass" },- { depth: 2, event: "run", box: "Box<DIV>#flex", formattingContext: "flex", measurement: false, intrinsic: false, action: "RUN", cache: "miss" },+ { depth: 1, event: "run", box: "@viewport", formattingContext: "block", intrinsic: false, action: "RUN", cache: "bypass" },+ { depth: 2, event: "run", box: "Box<DIV>#flex", formattingContext: "flex", intrinsic: false, action: "RUN", cache: "miss" },{ depth: 3, event: "measure", box: "BlockContainer(anonymous)", size: "max-content inline", cache: "miss", from: "items" },{ depth: 3, event: "measure", box: "BlockContainer(anonymous)", size: "min-content inline", cache: "hit" },{ depth: 3, event: "measure", box: "BlockContainer<DIV>#column", size: "min-content inline", cache: "miss", from: "children" },{ depth: 3, event: "measure", box: "Box<DIV>#item", size: "max-content block", cache: "miss" },- { depth: 4, event: "run", box: "Box<DIV>#item", formattingContext: "flex", measurement: true, intrinsic: true, action: "RUN", cache: "bypass" },- { depth: 3, event: "run", box: "Box<TABLE>#table", formattingContext: "table", measurement: false, intrinsic: true, action: "RUN", cache: "bypass" },+ { depth: 4, event: "run", box: "Box<DIV>#item", formattingContext: "flex", intrinsic: true, action: "RUN", cache: "bypass" },+ { depth: 3, event: "run", box: "Box<TABLE>#table", formattingContext: "table", intrinsic: true, action: "RUN", cache: "bypass" },{ depth: 4, event: "measure cell", box: "BlockContainer<TD>.cell", cache: "miss" },- { depth: 5, event: "run", box: "BlockContainer<TD>.cell", formattingContext: "block", measurement: false, intrinsic: false, action: "RUN AHEAD OF INTRINSIC BLOCK PADDING" },+ { depth: 5, event: "run", box: "BlockContainer<TD>.cell", formattingContext: "block", intrinsic: false, action: "RUN AHEAD OF INTRINSIC BLOCK PADDING" },{ depth: 4, event: "measure cell", box: "BlockContainer<TD>.cell", cache: "hit" },{ depth: 4, event: "reuse in-flow subtree", box: "BlockContainer<DIV>" },{ depth: 0, event: "layout", partial: true, box: "Box<DIV>#flex" },- { depth: 1, event: "run", box: "Box<DIV>#flex", formattingContext: "flex", measurement: false, intrinsic: false, action: "REPLAY FRAGMENTS" },+ { depth: 1, event: "run", box: "Box<DIV>#flex", formattingContext: "flex", intrinsic: false, action: "REPLAY FRAGMENTS" },];// JSON leaves out the properties a line does not have.const parsedEvents = parseLayoutTrace(trace);diff --git a/Tests/LibWeb/Text/input/layout-test.js b/Tests/LibWeb/Text/input/layout-test.jsindex f9fe962baa3..3b24e24ef78 100644--- a/Tests/LibWeb/Text/input/layout-test.js+++ b/Tests/LibWeb/Text/input/layout-test.js@@ -23,7 +23,7 @@ function layoutTraceDifference(expected, actual) {const layoutTraceLines = (() => {const box = String.raw`(\S+)`;const cache = String.raw`\(cache=(\w+)\)`;- const runFlags = String.raw`(?: \((measurement)?(?:, )?(intrinsic)?\))?`;+ const runFlags = String.raw`(?: \((intrinsic)\))?`;return [["layout FULL", () => ({ event: "layout", partial: false })],[`layout PARTIAL ${box}`, box => ({ event: "layout", partial: true, box })],@@ -35,11 +35,10 @@ const layoutTraceLines = (() => {[`${box} REUSE IN-FLOW SUBTREE`, box => ({ event: "reuse in-flow subtree", box })],[`${box}/([a-z-]+)${runFlags} ([A-Z][A-Z -]*[A-Z])(?: ${cache})?`,- (box, formattingContext, measurement, intrinsic, action, cache) => ({+ (box, formattingContext, intrinsic, action, cache) => ({event: "run",box,formattingContext,- measurement: !!measurement,intrinsic: !!intrinsic,action,cache,@@ -51,7 +50,7 @@ const layoutTraceLines = (() => {// Parses a layout trace into one event per line. Each event has its depth, its kind in `event`, and the// name of the box it is about in `box`, except for a full layout pass:// layout `partial`-// run `formattingContext`, `measurement`, `intrinsic`, `action`, `cache`+// run `formattingContext`, `intrinsic`, `action`, `cache`// reuse in-flow subtree// measure `size` ("min-content inline", ...), `cache`, `from` ("items", "flex items",// "grid tracks", "children", "columns", "replaced content")diff --git a/Tests/LibWeb/Text/input/svg-measurement-skips-descendants.html b/Tests/LibWeb/Text/input/svg-measurement-skips-descendants.htmlindex 106d5073942..6f0b74d4df5 100644--- a/Tests/LibWeb/Text/input/svg-measurement-skips-descendants.html+++ b/Tests/LibWeb/Text/input/svg-measurement-skips-descendants.html@@ -46,8 +46,8 @@BlockContainer<HTML>/block RUN (cache=miss)Box<DIV>#grid/grid RUN (cache=miss)BlockContainer<MAIN>#article MEASURE max-content block (cache=miss)- BlockContainer<MAIN>#article/block (measurement, intrinsic) RUN (cache=bypass)- SVGSVGBox<svg>#svg/svg (measurement, intrinsic) READ RESULT+ BlockContainer<MAIN>#article/block (intrinsic) RUN (cache=bypass)+ SVGSVGBox<svg>#svg/svg (intrinsic) READ RESULTBlockContainer<MAIN>#article MEASURE max-content block (cache=hit)BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)@@ -71,8 +71,8 @@BlockContainer<HTML>/block RUN (cache=miss)Box<DIV>#grid/grid RUN (cache=miss)BlockContainer<MAIN>#article MEASURE max-content block (cache=miss)- BlockContainer<MAIN>#article/block (measurement, intrinsic) RUN (cache=bypass)- SVGSVGBox<svg>#svg/svg (measurement, intrinsic) RUN (cache=miss)+ BlockContainer<MAIN>#article/block (intrinsic) RUN (cache=bypass)+ SVGSVGBox<svg>#svg/svg (intrinsic) RUN (cache=miss)BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)BlockContainer<MAIN>#article MEASURE max-content block (cache=hit)diff --git a/Tests/LibWeb/Text/input/table-measurement-reuse-work.html b/Tests/LibWeb/Text/input/table-measurement-reuse-work.htmlindex b8fd832a649..c395600c2f3 100644--- a/Tests/LibWeb/Text/input/table-measurement-reuse-work.html+++ b/Tests/LibWeb/Text/input/table-measurement-reuse-work.html@@ -33,12 +33,12 @@TableWrapper(anonymous) MEASURE max-content inline (cache=hit)Box<DIV>#item MEASURE min-content inline (cache=hit)Box<DIV>#item MEASURE max-content block (cache=miss)- Box<DIV>#item/flex (measurement, intrinsic) RUN (cache=bypass)+ Box<DIV>#item/flex (intrinsic) RUN (cache=bypass)TableWrapper(anonymous) MEASURE max-content block (cache=miss)- TableWrapper(anonymous)/block (measurement, intrinsic) RUN (cache=bypass)- Box<TABLE>#table/table (measurement, intrinsic) RUN (cache=miss)+ TableWrapper(anonymous)/block (intrinsic) RUN (cache=bypass)+ Box<TABLE>#table/table (intrinsic) RUN (cache=miss)BlockContainer<TD>#cell MEASURE CELL (cache=miss)- BlockContainer<TD>#cell/block (measurement, intrinsic) RUN (cache=miss)+ BlockContainer<TD>#cell/block (intrinsic) RUN (cache=miss)BlockContainer<TD> MEASURE CELL (cache=hit)TableWrapper(anonymous) MEASURE max-content block (cache=hit)TableWrapper(anonymous) MEASURE max-content block (cache=hit)@@ -48,7 +48,7 @@TableWrapper(anonymous)/block RUN (cache=miss)Box<TABLE>#table/table RUN (cache=miss)BlockContainer<TD>#cell MEASURE CELL (cache=miss)- BlockContainer<TD>#cell/block (measurement) RUN (cache=miss)+ BlockContainer<TD>#cell/block RUN (cache=miss)BlockContainer<TD> MEASURE CELL (cache=hit)BlockContainer<TD>#cell/block RUN (cache=miss)BlockContainer<DIV> REUSE IN-FLOW SUBTREE