Skip to content

Truly independent web browser

LibWeb: Keep no record of a run's root

Aliaksandr Kalenik0aa5d3288a17
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index 12431111c12..541ca95e5d1 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -4548,89 +4548,82 @@ mod stretch_cross_limit_tests {
..ContainingBlockConstraints::default()
};
let container_cells = used_values::cells_before_sizing(&callbacks, container, constraints);
- RunRecords::with_root(
- callbacks,
- container,
- Node::INVALID,
- container_cells,
- None,
- |records, callbacks| {
- let run = FormattingContextRun {
- records,
- box_: container,
- callbacks,
- should_collect_devtools_layout_data: false,
- treat_block_axis_percentage_insets_as_auto_beyond_root: false,
- fragments: None,
- fragmentainer: None,
- };
- let mut flex = FlexFormattingContext::new(&run, container_cells);
- let available = AvailableSpace {
- inline_size: if column && !definite_cross_basis {
- AvailableSize::Indefinite
- } else {
- AvailableSize::definite(px(100))
- },
- block_size: if column || definite_cross_basis {
- AvailableSize::definite(px(100))
- } else {
- AvailableSize::Indefinite
- },
- };
- flex.generate_items_and_determine_available_space(LayoutInput::new(
- available,
- constraints,
- ParticipationInParentFormattingContext::Root,
- ));
- assert_eq!(flex.flex_items.len(), 2);
- assert_eq!(flex.cross_axis_stretch_basis().is_some(), definite_cross_basis);
- if !definite_cross_basis {
- assert_eq!(flex.cross_axis_stretch_basis(), None);
- assert_eq!(flex.cross_size_limits(0), (px(0), CssPixels::from_raw(i32::MAX)));
- }
- // Initial cells have already applied the container-sized stretch limit. The preferred size must
- // survive this clamp so the final, larger line maximum can restore it.
- assert_eq!(flex.inner_cross_size(0), px(provisional));
- for index in 0..2 {
- flex.flex_items[index].main_size = Some(px(50));
- flex.determine_hypothetical_cross_size_of_item(index);
- }
- assert_eq!(flex.flex_items[0].hypothetical_cross_size, px(provisional));
- flex.flex_lines.push(FlexLine {
- items: vec![0, 1],
- ..FlexLine::default()
- });
- flex.calculate_cross_size_of_each_flex_line();
- assert_eq!(
- flex.flex_lines[0].cross_size,
- px(if max_constrained { 100 } else { 200 })
- );
- // The initial containing-block basis stays indefinite. Step 11 still resolves stretch limits
- // against the completed line below.
- assert_eq!(flex.cross_axis_stretch_basis().is_some(), definite_cross_basis);
- if !definite_cross_basis {
- assert_eq!(flex.cross_axis_stretch_basis(), None);
- assert_eq!(flex.cross_size_limits(0), (px(0), CssPixels::from_raw(i32::MAX)));
- }
- flex.determine_used_cross_size_of_each_flex_item();
- assert_eq!(flex.flex_items[0].cross_size, Some(px(final_size)));
- assert_eq!(flex.inner_cross_size(0), px(final_size));
- if max_constrained {
- // Match the immutable keyword-sizes-on-flex-item-001.html cases60–65 oracle.
- let item = &flex.flex_items[0];
- let border_box = item.cross_size.unwrap()
- + item.borders.cross_before
- + item.borders.cross_after
- + item.padding.cross_before
- + item.padding.cross_after;
- assert_eq!(border_box, px(90));
- }
- if auto {
- assert!(flex.has_definite_cross_size(0));
- }
- assert_eq!(flex.flex_items[1].cross_size, Some(px(200)));
- },
- );
+ RunRecords::with_root(callbacks, container, Node::INVALID, None, |records, callbacks| {
+ let run = FormattingContextRun {
+ records,
+ box_: container,
+ callbacks,
+ should_collect_devtools_layout_data: false,
+ treat_block_axis_percentage_insets_as_auto_beyond_root: false,
+ fragments: None,
+ fragmentainer: None,
+ };
+ let mut flex = FlexFormattingContext::new(&run, container_cells);
+ let available = AvailableSpace {
+ inline_size: if column && !definite_cross_basis {
+ AvailableSize::Indefinite
+ } else {
+ AvailableSize::definite(px(100))
+ },
+ block_size: if column || definite_cross_basis {
+ AvailableSize::definite(px(100))
+ } else {
+ AvailableSize::Indefinite
+ },
+ };
+ flex.generate_items_and_determine_available_space(LayoutInput::new(
+ available,
+ constraints,
+ ParticipationInParentFormattingContext::Root,
+ ));
+ assert_eq!(flex.flex_items.len(), 2);
+ assert_eq!(flex.cross_axis_stretch_basis().is_some(), definite_cross_basis);
+ if !definite_cross_basis {
+ assert_eq!(flex.cross_axis_stretch_basis(), None);
+ assert_eq!(flex.cross_size_limits(0), (px(0), CssPixels::from_raw(i32::MAX)));
+ }
+ // Initial cells have already applied the container-sized stretch limit. The preferred size must
+ // survive this clamp so the final, larger line maximum can restore it.
+ assert_eq!(flex.inner_cross_size(0), px(provisional));
+ for index in 0..2 {
+ flex.flex_items[index].main_size = Some(px(50));
+ flex.determine_hypothetical_cross_size_of_item(index);
+ }
+ assert_eq!(flex.flex_items[0].hypothetical_cross_size, px(provisional));
+ flex.flex_lines.push(FlexLine {
+ items: vec![0, 1],
+ ..FlexLine::default()
+ });
+ flex.calculate_cross_size_of_each_flex_line();
+ assert_eq!(
+ flex.flex_lines[0].cross_size,
+ px(if max_constrained { 100 } else { 200 })
+ );
+ // The initial containing-block basis stays indefinite. Step 11 still resolves stretch limits
+ // against the completed line below.
+ assert_eq!(flex.cross_axis_stretch_basis().is_some(), definite_cross_basis);
+ if !definite_cross_basis {
+ assert_eq!(flex.cross_axis_stretch_basis(), None);
+ assert_eq!(flex.cross_size_limits(0), (px(0), CssPixels::from_raw(i32::MAX)));
+ }
+ flex.determine_used_cross_size_of_each_flex_item();
+ assert_eq!(flex.flex_items[0].cross_size, Some(px(final_size)));
+ assert_eq!(flex.inner_cross_size(0), px(final_size));
+ if max_constrained {
+ // Match the immutable keyword-sizes-on-flex-item-001.html cases60–65 oracle.
+ let item = &flex.flex_items[0];
+ let border_box = item.cross_size.unwrap()
+ + item.borders.cross_before
+ + item.borders.cross_after
+ + item.padding.cross_before
+ + item.padding.cross_after;
+ assert_eq!(border_box, px(90));
+ }
+ if auto {
+ assert!(flex.has_definite_cross_size(0));
+ }
+ assert_eq!(flex.flex_items[1].cross_size, Some(px(200)));
+ });
arena
.free_subtree(container)
.destroy_shells_and_invoke_callbacks(&crate::stage::MainThread::for_test());
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 32173af49b9..bda9c335053 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -2245,9 +2245,6 @@ fn execute_formatting_context_run(
let parent_owns_root_input_cells = parent_owns_root_input_cells(&callbacks, box_, &input);
let checks_root_input_cells_its_parent_owns =
parent_owns_root_input_cells && (cfg!(debug_assertions) || run_repeatability::verification_is_enabled());
- // NB: The root's own box is sized in cells held in its parent's frame. The root's record holds its metrics in the
- // frame the root lays its contents out in.
- let own_frame = frame_established_by(&callbacks, box_);
// NB: The anchor-size() resolutions apply only in the parent's frame, where the root's own box is sized.
let root_anchor_resolved_values = match input.participation {
ParticipationInParentFormattingContext::AbsolutelyPositioned(inputs)
@@ -2264,7 +2261,6 @@ fn execute_formatting_context_run(
callbacks,
box_,
root_containing_block,
- root_cells.in_frame(callbacks.frame, own_frame),
root_anchor_resolved_values,
|records, callbacks| {
lay_out_run_root_and_contents(
@@ -2407,10 +2403,6 @@ fn lay_out_run_root_and_contents<'pass>(
} else {
body_input
};
- // NB: A root whose contents no formatting context lays out takes its cells back from its record, in its own frame.
- let root_record = records.used_values(box_);
- root_record.cells.set(own_root.get());
- let root_left_in_record = || root_record.cells.get();
let mut implementation = None;
let mut root_lines = used_values::LineDataState::Empty;
@@ -2425,7 +2417,7 @@ fn lay_out_run_root_and_contents<'pass>(
{
// An empty atomic block context has no body output. Root sizing and finalization still
// run through the shared paths around this branch.
- (ChildLayoutResult::default(), root_left_in_record())
+ (ChildLayoutResult::default(), own_root.get())
} else {
let mut context_implementation = create_formatting_context_implementation(
body_run,
@@ -2515,7 +2507,7 @@ fn lay_out_run_root_and_contents<'pass>(
);
(result, root_after_body)
}
- FormattingContextImplementation::InternalReplaced => (ChildLayoutResult::default(), root_left_in_record()),
+ FormattingContextImplementation::InternalReplaced => (ChildLayoutResult::default(), own_root.get()),
};
implementation = Some(context_implementation);
result_and_own_root_after_body
@@ -3600,7 +3592,7 @@ fn compute_root_layout(input: LayoutStageInput<'_>, should_collect_devtools_layo
percentage_basis_block_size: Some(viewport_block_size),
..ContainingBlockConstraints::default()
};
- RunRecords::with_unrooted(callbacks, root, NodeSlotId::INVALID, |entry_records, callbacks| {
+ RunRecords::with_root(callbacks, root, Node::INVALID, None, |entry_records, callbacks| {
let _trace = arena.layout_trace.pass(None);
let entry_fragments = std::rc::Rc::new(fragment_tree::RunFragmentBuilder::new_entry_accumulator(root));
let entry_run = FormattingContextRun {
@@ -3744,10 +3736,11 @@ fn compute_subtree_layout_fragments(input: LayoutStageInput<'_>, containing_bloc
} else {
(root, containing_block)
};
- RunRecords::with_unrooted(
+ RunRecords::with_root(
callbacks,
entry_root,
entry_root_containing_block,
+ None,
|entry_records, callbacks| {
let _trace = arena.layout_trace.pass(Some(root));
let entry_fragments =
@@ -3924,8 +3917,7 @@ mod baseline_tests {
document_in_quirks_mode: false,
},
);
- let parent_cells = used_values::RootInputCells::default();
- RunRecords::with_root(callbacks, parent, Node::INVALID, parent_cells, None, |_, callbacks| {
+ RunRecords::with_root(callbacks, parent, Node::INVALID, None, |_, callbacks| {
let child_cells = used_values::RootInputCells::default();
assert!(child_gives_container_baselines(&callbacks, parent, child));
let mut baselines = DerivedBaselines::default();
diff --git a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
index 1a168443d1d..337024ceb97 100644
--- a/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/grid_formatting_context.rs
@@ -1032,7 +1032,7 @@ struct GridItem {
column: i32,
column_span: usize,
// Accumulated while projecting a nested subgrid item into an ancestor's track
- // sizing without modifying the UsedValues owned by the nested grid context.
+ // sizing without modifying the cells the nested grid context holds for the item.
extra_margin_top: CssPixels,
extra_margin_right: CssPixels,
extra_margin_bottom: CssPixels,
@@ -3094,7 +3094,7 @@ impl<'pass> GridFormattingContext<'pass> {
// This extra layer of "margin" accumulates through multiple levels of
// subgrids.
//
- // NB: Scrollbar gutters are not represented in UsedValues yet.
+ // NB: The cells of a box do not hold its scrollbar gutters yet.
let position = item.position(axis);
let span = item.span(axis);
let track_count = self.axis_tracks(axis).len() as i32;
@@ -3173,7 +3173,6 @@ impl<'pass> GridFormattingContext<'pass> {
self.run.callbacks,
subgrid.box_,
containing_block,
- scratch_root,
None,
|records, callbacks| {
let scratch_run = FormattingContextRun {
diff --git a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs
index 008a6a0ca84..5edbdf0062f 100644
--- a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs
+++ b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs
@@ -59,7 +59,6 @@ impl ContentSizingScope {
callbacks,
self.node,
callbacks.in_flow_containing_block(self.node),
- self.root_cells,
|records, callbacks| {
size_content(&FormattingContextRun {
records,
diff --git a/Libraries/LibWeb/Rust/src/layout/mod.rs b/Libraries/LibWeb/Rust/src/layout/mod.rs
index fbca0d8f948..3cb42dc0183 100644
--- a/Libraries/LibWeb/Rust/src/layout/mod.rs
+++ b/Libraries/LibWeb/Rust/src/layout/mod.rs
@@ -111,6 +111,4 @@ pub(crate) use style_values::StyleValues;
pub(crate) use tree_builder::build_keeps_box;
pub(crate) use update_layout::MainThreadFfiEntry as UpdateMainThreadFfiEntry;
pub(crate) use update_layout::{ClockRound, ClockRoundDeclined, FlownRound, SealedRound};
-pub(crate) use used_values::{
- BoxMetricCells, BoxMetricCellsMut, FfiCssPixelPoint, FfiCssPixelRect, FfiCssPixelSize, UsedValues,
-};
+pub(crate) use used_values::{BoxMetricCells, BoxMetricCellsMut, FfiCssPixelPoint, FfiCssPixelRect, FfiCssPixelSize};
diff --git a/Libraries/LibWeb/Rust/src/layout/run_records.rs b/Libraries/LibWeb/Rust/src/layout/run_records.rs
index 8eaa2306a82..e639aaa8881 100644
--- a/Libraries/LibWeb/Rust/src/layout/run_records.rs
+++ b/Libraries/LibWeb/Rust/src/layout/run_records.rs
@@ -235,13 +235,12 @@ impl LayoutScratch {
}
}
-/// What a run keeps while it is in progress: the record of its root, built from the input cells its caller hands it, the
-/// anchor-size() resolutions of its root, and the percentage block size dependencies it resolves. Every other box the
-/// run lays out is laid out in a record the call laying it out owns, or handed to a run of its own. The scoped
-/// constructors lend the records to the run, so callers cannot extend their lifetime.
+/// What a run keeps while it is in progress: its root, the percentage block size dependencies it resolves and the
+/// anchor-size() resolutions of its root. It keeps no metrics of any box: the formatting context or call that lays out
+/// a box holds the box's cells, or hands the box to a run of its own. The scoped constructors lend this to the run, so
+/// callers cannot extend its lifetime.
pub(crate) struct RunRecords<'arena> {
root: Node,
- root_used: Option<UsedValues>,
scratch: &'arena LayoutScratch,
/// How many runs are in progress with this one, of which only the innermost hands over what it found out.
runs_in_progress_with_it: usize,
@@ -359,13 +358,12 @@ enum ContentSizing {
}
impl<'arena> RunRecords<'arena> {
- /// Runs `run` with the records of a run rooted at `root`, and the pass as that run sees it. The root's record holds
- /// `root_cells`. The style reads of an absolutely positioned root see `root_anchor_resolved_values`.
+ /// Runs `run` with what a run rooted at `root` keeps, and the pass as that run sees it. The style reads of an
+ /// absolutely positioned root see `root_anchor_resolved_values`.
pub(crate) fn with_root<R>(
callbacks: LayoutPass<'arena>,
root: Node,
root_containing_block: Node,
- root_cells: used_values::RootInputCells,
root_anchor_resolved_values: Option<Box<style_values::AnchorResolvedValues>>,
run: impl FnOnce(&Self, LayoutPass<'arena>) -> R,
) -> R {
@@ -373,7 +371,6 @@ impl<'arena> RunRecords<'arena> {
callbacks,
root,
root_containing_block,
- Some(root_cells),
root_anchor_resolved_values,
ContentSizing::Layout,
run,
@@ -384,14 +381,12 @@ impl<'arena> RunRecords<'arena> {
callbacks: LayoutPass<'arena>,
root: Node,
root_containing_block: Node,
- root_cells: used_values::RootInputCells,
run: impl FnOnce(&Self, LayoutPass<'arena>) -> R,
) -> R {
Self::enter(
callbacks,
root,
root_containing_block,
- Some(root_cells),
None,
ContentSizing::RootContributions,
run,
@@ -402,42 +397,22 @@ impl<'arena> RunRecords<'arena> {
callbacks: LayoutPass<'arena>,
root: Node,
root_containing_block: Node,
- root_cells: used_values::RootInputCells,
run: impl FnOnce(&Self, LayoutPass<'arena>) -> R,
) -> R {
Self::enter(
callbacks,
root,
root_containing_block,
- Some(root_cells),
None,
ContentSizing::RootContentInlineSizes,
run,
)
}
- pub(crate) fn with_unrooted<R>(
- callbacks: LayoutPass<'arena>,
- root: Node,
- root_containing_block: Node,
- run: impl FnOnce(&Self, LayoutPass<'arena>) -> R,
- ) -> R {
- Self::enter(
- callbacks,
- root,
- root_containing_block,
- None,
- None,
- ContentSizing::Layout,
- run,
- )
- }
-
fn enter<R>(
callbacks: LayoutPass<'arena>,
root: Node,
root_containing_block: Node,
- root_cells: Option<used_values::RootInputCells>,
root_anchor_resolved_values: Option<Box<style_values::AnchorResolvedValues>>,
content_sizing: ContentSizing,
run: impl FnOnce(&Self, LayoutPass<'arena>) -> R,
@@ -449,7 +424,6 @@ impl<'arena> RunRecords<'arena> {
let scratch = callbacks.scratch();
let records = Self {
root,
- root_used: root_cells.map(used_values::RootInputCells::materialize_record),
scratch,
runs_in_progress_with_it: scratch.begin_run(),
content_sizing,
@@ -490,26 +464,6 @@ impl<'arena> RunRecords<'arena> {
self.scratch.runs_in_progress() == self.runs_in_progress_with_it
}
- #[track_caller]
- pub(crate) fn used_values(&self, node: Node) -> &UsedValues {
- let caller = std::panic::Location::caller();
- self.used_values_if_owned(node).unwrap_or_else(|| {
- panic!(
- "the run rooted at slot {} does not own the record for slot {} (read at {caller})",
- self.root.slot_index(),
- node.slot_index(),
- )
- })
- }
-
- /// The record of `node` where it is the run's root, the only box a run keeps a record of.
- pub(crate) fn used_values_if_owned(&self, node: Node) -> Option<&UsedValues> {
- if node != self.root {
- return None;
- }
- self.root_used.as_ref()
- }
-
pub(crate) fn root(&self) -> Node {
self.root
}
@@ -603,7 +557,7 @@ mod tests {
use super::*;
#[test]
- fn a_nested_run_keeps_its_own_root_record() {
+ fn a_nested_run_keeps_its_own_root() {
let mut arena = LayoutNodeArena::new();
let scratch = LayoutScratch::default();
let root = arena.allocate_for_test().slot;
@@ -612,31 +566,23 @@ mod tests {
LayoutPass::for_test(&arena, &scratch),
root,
NodeSlotId::INVALID,
- used_values::RootInputCells::default(),
None,
|parent, _| {
- let root_used: *const UsedValues = parent.used_values(root);
+ assert_eq!(parent.root(), root);
RunRecords::with_root(
LayoutPass::for_test(&arena, &scratch),
child,
root,
- used_values::RootInputCells::default(),
None,
|nested, _| {
- assert!(nested.used_values_if_owned(root).is_none());
- assert!(nested.used_values_if_owned(child).is_some());
- assert!(parent.used_values_if_owned(child).is_none());
- RunRecords::with_unrooted(
- LayoutPass::for_test(&arena, &scratch),
- child,
- root,
- |unrooted, _| {
- assert!(unrooted.used_values_if_owned(child).is_none());
- },
- );
+ assert_eq!(nested.root(), child);
+ assert!(nested.resolves_percentage_block_size_dependency_of(child));
+ assert!(!nested.resolves_percentage_block_size_dependency_of(root));
+ assert!(!parent.resolves_percentage_block_size_dependency_of(child));
+ assert!(nested.anchor_resolved_values_of(child).is_none());
},
);
- assert!(std::ptr::eq(parent.used_values(root), root_used));
+ assert_eq!(parent.root(), root);
},
);
assert_eq!(scratch.runs_in_progress(), 0);
@@ -652,22 +598,15 @@ mod tests {
LayoutPass::for_test(&arena, &scratch),
root,
NodeSlotId::INVALID,
- used_values::RootInputCells::default(),
None,
|parent, _| {
- let root_used: *const UsedValues = parent.used_values(root);
let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
- RunRecords::with_root(
- LayoutPass::for_test(&arena, &scratch),
- child,
- root,
- used_values::RootInputCells::default(),
- None,
- |_, _| panic!("abort the nested measurement"),
- );
+ RunRecords::with_root(LayoutPass::for_test(&arena, &scratch), child, root, None, |_, _| {
+ panic!("abort the nested measurement")
+ });
}));
assert!(result.is_err());
- assert!(std::ptr::eq(parent.used_values(root), root_used));
+ assert_eq!(parent.root(), root);
assert_eq!(scratch.runs_in_progress(), 1);
},
);
diff --git a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
index 9337033b845..0de28915d1b 100644
--- a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
+++ b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs
@@ -196,7 +196,7 @@ impl ComparedLayouts<'_> {
assert_eq!(
checked_outputs.root_outcome.input_cells_left_by_run,
reference_outputs.root_outcome.input_cells_left_by_run,
- "{checked} left a root record {reference} does not"
+ "{checked} left root cells {reference} does not"
);
assert!(
checked_outputs.root_outcome.line_data.as_deref() == reference_outputs.root_outcome.line_data.as_deref(),
diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
index 2e3974762ce..27d7d496d3f 100644
--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
@@ -2413,7 +2413,6 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
self.callbacks,
node,
self.callbacks.in_flow_containing_block(node),
- root,
|records, callbacks| {
let sizing = SizingContext::new(records, callbacks);
let inline_size_under = |inline_size| {
@@ -3586,7 +3585,6 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
self.callbacks,
table_box,
self.callbacks.in_flow_containing_block(table_box),
- table_cells,
|records, callbacks| {
let table_run = FormattingContextRun {
records,
@@ -4379,35 +4377,22 @@ mod replaced_ratio_tests {
document_in_quirks_mode: false,
},
);
- let result = RunRecords::with_root(
- callbacks,
- node,
- Node::INVALID,
- used_values::RootInputCells::default(),
- None,
- |records, callbacks| {
- let context = SizingContext::new(records, callbacks);
- let mut metrics = used_values::RootInputCells::default();
- let available = AvailableSpace {
- inline_size: AvailableSize::Definite(CssPixels::from_integer(800)),
- block_size: AvailableSize::Indefinite,
- };
- let constraints = ContainingBlockConstraints::default();
- let inline = context.compute_inline_size_for_replaced_element(
- SizedBox::new(node, &metrics),
- available,
- constraints,
- );
- // NB: Match dimension_atomic_root: publish the used inline size before resolving the block size.
- metrics.set_content_inline_size(inline);
- let block = context.compute_block_size_for_replaced_element(
- SizedBox::new(node, &metrics),
- available,
- constraints,
- );
- (inline.to_int(), block.to_int())
- },
- );
+ let result = RunRecords::with_root(callbacks, node, Node::INVALID, None, |records, callbacks| {
+ let context = SizingContext::new(records, callbacks);
+ let mut metrics = used_values::RootInputCells::default();
+ let available = AvailableSpace {
+ inline_size: AvailableSize::Definite(CssPixels::from_integer(800)),
+ block_size: AvailableSize::Indefinite,
+ };
+ let constraints = ContainingBlockConstraints::default();
+ let inline =
+ context.compute_inline_size_for_replaced_element(SizedBox::new(node, &metrics), available, constraints);
+ // NB: Match dimension_atomic_root: publish the used inline size before resolving the block size.
+ metrics.set_content_inline_size(inline);
+ let block =
+ context.compute_block_size_for_replaced_element(SizedBox::new(node, &metrics), available, constraints);
+ (inline.to_int(), block.to_int())
+ });
arena
.free_subtree(node)
.destroy_shells_and_invoke_callbacks(&crate::stage::MainThread::for_test());
diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rs
index 2abccd8e248..1cdf2699729 100644
--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs
@@ -129,13 +129,6 @@ pub(crate) struct CommittedSvgFacts {
pub(crate) resource_content_units_are_object_bounding_box: bool,
}
-/// The per-box geometry stored in a Rust-owned layout pass.
-#[derive(Debug)]
-pub(crate) struct UsedValues {
- /// The box's sizes, size constraints and box sides.
- pub(crate) cells: Cell<RootInputCells>,
-}
-
/// The sizes, size constraints and box sides of a box.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub(crate) struct RootInputCells {
@@ -236,11 +229,6 @@ impl RootInputCells {
self.padding_bottom = fragment.padding_bottom;
}
- /// A record holding the cells.
- pub(crate) fn materialize_record(self) -> UsedValues {
- UsedValues { cells: Cell::new(self) }
- }
-
/// The cells, with the sizes, size constraints and box sides they hold in frame `from` read in frame `to` instead.
#[inline]
pub(crate) fn in_frame(mut self, from: geometry::Frame, to: geometry::Frame) -> Self {
@@ -277,8 +265,6 @@ impl RootInputCells {
}
}
-/// The sizes, size constraints and box sides of a box, with what derives from them, whether a run holds them in the box's
-/// record or its parent holds them as a value.
macro_rules! box_metric_getters {
($($name:ident: $value:ty,)+) => {
$(
@@ -290,6 +276,8 @@ macro_rules! box_metric_getters {
};
}
+/// The sizes, size constraints and box sides of a box, with what derives from them, whether a cell holds them or they
+/// are read as a value.
pub(crate) trait BoxMetricCells {
/// The sizes, size constraints and box sides these metrics hold.
fn cells(&self) -> RootInputCells;
diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs b/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs
index 99192494834..f14bbae2d79 100644
--- a/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs
+++ b/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs
@@ -645,7 +645,7 @@ pub(crate) fn first_fragment_padding_box_rect(arena: &impl GeometryRead, slot: N
/// centered on the grid line between two boxes, so only a part of it belongs to each: "the border-box of the table
/// includes half of the table border" and, for cells, "half the width of the collapsed border on each side".
/// https://www.w3.org/TR/CSS22/tables.html#collapsing-borders
-/// The border is split the same way layout splits it when placing the boxes (`UsedValues::border_left_collapsed`):
+/// The border is split the same way layout splits it when placing the boxes (`BoxMetricCells::border_left_collapsed`):
/// the part before the grid line goes to the box before the line, the part after it to the box after the line.
pub(crate) fn committed_border_box_edges(arena: &impl GeometryRead, slot: NodeSlotId) -> FfiPixelBox {
let border = committed_border(arena, slot);