Skip to content

Truly independent web browser

LibWeb: Keep a record's metrics in one cell

Aliaksandr Kalenikb7cf821abe6c
diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
index 5004ff3af85..c6ebcee80dc 100644
--- a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
+++ b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
@@ -135,7 +135,7 @@ impl ContainingBlockGeometry {
#[derive(Clone, Copy)]
pub(crate) struct OutOfFlowBox<'a> {
pub(crate) node: Node,
- pub(crate) record: used_values::RecordInFrame<'a>,
+ pub(crate) record: used_values::CellsInFrame<'a>,
used_insets: &'a Cell<run_records::UsedInsets>,
anchor_resolved_values: Option<&'a style_values::AnchorResolvedValues>,
}
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index d8934d94241..a24774118b8 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -120,7 +120,7 @@ pub(crate) struct BlockContainer {
impl BlockContainer {
/// The run's root, as the block container of the boxes laid out in it.
pub(crate) fn root_of(run: &FormattingContextRun<'_>) -> Self {
- let cells = used_values::RootInputCells::capture(run.records.used_values(run.box_));
+ let cells = run.records.used_values(run.box_).cells();
Self {
node: run.box_,
cells,
@@ -824,7 +824,7 @@ impl<'pass> BlockFormattingContext<'pass> {
/// The sizes, size constraints and box sides of `child`, a box this block formatting context sizes.
fn metrics_of(&self, child: ChildSizedHere<'_>) -> used_values::RootInputCells {
match child.sized_in {
- SizedIn::Record(record) => used_values::RootInputCells::capture(record),
+ SizedIn::Record(record) => record.cells.get(),
SizedIn::CellsAheadOfItsRun(cells) => cells.get(),
}
}
@@ -833,7 +833,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let mut cells = self.metrics_of(child);
update(&mut cells);
match child.sized_in {
- SizedIn::Record(record) => cells.apply_to_record(record),
+ SizedIn::Record(record) => record.cells.set(cells),
SizedIn::CellsAheadOfItsRun(cells_ahead) => cells_ahead.set(cells),
}
}
@@ -851,7 +851,7 @@ impl<'pass> BlockFormattingContext<'pass> {
fn sized_record_of<'record>(&self, child: ChildSizedHere<'record>) -> sizing_context::SizedRecord<'record> {
sizing_context::SizedRecord::new(
child.node,
- used_values::RecordInFrame::new(self.record_of(child), self.run.callbacks.frame),
+ used_values::CellsInFrame::new(self.record_of(child), self.run.callbacks.frame),
)
}
@@ -3233,7 +3233,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let node = sized_child.node;
self.run.callbacks.arena().layout_trace.reused_in_flow_subtree(node);
let used = self.record_of(sized_child);
- entry.cells.apply_to_record(used);
+ used.cells.set(entry.cells);
let flow_position = self.flow_position();
*self.margin_state.borrow_mut() = entry.outgoing_margins.clone();
formatting_context::propagate_percentage_block_size_dependency_to_containing_block(
@@ -3251,7 +3251,7 @@ impl<'pass> BlockFormattingContext<'pass> {
&self.run,
node,
formatting_context::PlacedChild::new(fragment_tree::FragmentGeometry {
- cells: used_values::RecordInFrame::new(used, self.run.callbacks.frame).cells(),
+ cells: used_values::CellsInFrame::new(used, self.run.callbacks.frame).cells(),
line_data: None,
})
.with_in_flow_box_insets(insets),
@@ -3306,7 +3306,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let entry = in_flow_block_cache::InFlowBlockEntry {
key,
validity,
- cells: used_values::RootInputCells::capture(used),
+ cells: used.cells(),
baselines,
offset_from_flow_position: FfiCssPixelPoint {
x: content_offset.x,
@@ -4520,7 +4520,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let measurement_result = formatting_context::lay_out_measurement_root_for_its_result(
self.run.callbacks,
self.run.box_,
- used_values::RootInputCells::capture(self.used(self.run.box_)),
+ self.used(self.run.box_).cells(),
LayoutInput {
sizing: RootSizingDirectives {
finds_automatic_line_clamp_lines: true,
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index cc06bca9a69..a26fea1796b 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -265,7 +265,7 @@ impl<'pass> FlexFormattingContext<'pass> {
/// sizes it in.
fn box_metrics(&self, node: Node) -> used_values::RootInputCells {
if node == self.run.box_ {
- return used_values::RootInputCells::capture(self.container_used());
+ return self.container_used().cells();
}
let index = self
.index_of_flex_item(node)
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index 70bf7d7565c..3887e291388 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -163,7 +163,7 @@ pub(crate) fn run_fragmentainer(
.containing_block_for_child_run(box_, &input.participation);
execute_formatting_context_run(
builds_fragments,
- used_values::RecordInFrame::new(outer.records.used_values(box_), outer.callbacks.frame).cells(),
+ used_values::CellsInFrame::new(outer.records.used_values(box_), outer.callbacks.frame).cells(),
box_,
root_containing_block,
None,
@@ -386,7 +386,7 @@ impl PlacedChild {
) -> Self {
let callbacks = &run.callbacks;
Self::new(fragment_tree::FragmentGeometry {
- cells: used_values::RecordInFrame::new(record, callbacks.frame).cells(),
+ cells: used_values::CellsInFrame::new(record, callbacks.frame).cells(),
// NB: Only a run that builds fragments shows the lines it laid out in the boxes it places.
line_data: run
.fragments
@@ -397,7 +397,7 @@ impl PlacedChild {
lines,
callbacks.arena(),
record.content_inline_size(),
- record.frame.get().writing_mode(),
+ record.frame.writing_mode(),
))
})
})
@@ -1361,8 +1361,8 @@ impl<'pass> FormattingContextRun<'pass> {
/// The record of the run's root, read in the frame this run lays out in.
#[track_caller]
- pub(crate) fn root_record(&self) -> used_values::RecordInFrame<'pass> {
- used_values::RecordInFrame::new(self.records.used_values(self.box_), self.callbacks.frame)
+ pub(crate) fn root_record(&self) -> used_values::CellsInFrame<'pass> {
+ used_values::CellsInFrame::new(self.records.used_values(self.box_), self.callbacks.frame)
}
/// Hands what the layout of `node` produced besides its geometry to the box's fragment, where this run builds
@@ -1956,7 +1956,7 @@ fn size_skipped_independent_root(
});
let used_insets = Cell::new(run_records::UsedInsets::default());
let sized_child = abspos_engine::OutOfFlowBox::new(
- sizing_context::SizedRecord::new(child, used_values::RecordInFrame::new(record, run.callbacks.frame)),
+ sizing_context::SizedRecord::new(child, used_values::CellsInFrame::new(record, run.callbacks.frame)),
&used_insets,
anchor_resolved_values.as_ref(),
);
@@ -2278,14 +2278,14 @@ fn execute_formatting_context_run(
if input.sizing.root_keeps_its_committed_geometry {
assert_eq!(
sizes_and_box_sides(
- used_values::RecordInFrame::new(records.used_values(box_), callbacks.frame).cells()
+ used_values::CellsInFrame::new(records.used_values(box_), callbacks.frame).cells()
),
sizes_and_box_sides(root_cells),
"the run of {box_:?} changed the committed geometry of its root"
);
}
let root_cells_left_by_run = checks_root_input_cells_its_parent_owns
- .then(|| used_values::RecordInFrame::new(records.used_values(box_), callbacks.frame).cells());
+ .then(|| used_values::CellsInFrame::new(records.used_values(box_), callbacks.frame).cells());
(outputs, root_cells_left_by_run)
},
);
@@ -2511,7 +2511,7 @@ fn lay_out_run_root_and_contents<'pass>(
root_lines.finish(
callbacks.arena(),
record.content_inline_size(),
- record.frame.get().writing_mode(),
+ record.frame.writing_mode(),
);
result = result_in_parent_frame(run, result, parent_frame, own_frame);
}
@@ -2578,7 +2578,7 @@ fn lay_out_run_root_and_contents<'pass>(
let root_line_data = root_lines.finish(
callbacks.arena(),
record.content_inline_size(),
- record.frame.get().writing_mode(),
+ record.frame.writing_mode(),
);
result.depends_on_percentage_block_size = run.sizing().resolve_percentage_block_size_dependency(run.box_);
let item_run_observations_are_known = !run_is_handed_table_inline_layout_outside_its_key;
@@ -2906,7 +2906,7 @@ pub(crate) fn layout_inside_child_with_input_cells(
let committed_fragment = run.sizing().dimension_empty_atomic_root(
sizing_context::SizedRecord::new(
child,
- used_values::RecordInFrame::new(&record_of_this_layout, run.callbacks.frame),
+ used_values::CellsInFrame::new(&record_of_this_layout, run.callbacks.frame),
),
input.available_space,
input.containing_block_constraints,
@@ -2919,7 +2919,7 @@ pub(crate) fn layout_inside_child_with_input_cells(
run.fragments.is_some()
&& fragment.is_plain_box()
&& fragment_tree::FragmentGeometry {
- cells: used_values::RootInputCells::capture(&record_of_this_layout),
+ cells: record_of_this_layout.cells(),
line_data: None,
}
.shows_box_of_fragment(fragment)
diff --git a/Libraries/LibWeb/Rust/src/layout/run_records.rs b/Libraries/LibWeb/Rust/src/layout/run_records.rs
index 3cd82bf2b22..8f5d38ed624 100644
--- a/Libraries/LibWeb/Rust/src/layout/run_records.rs
+++ b/Libraries/LibWeb/Rust/src/layout/run_records.rs
@@ -304,7 +304,7 @@ impl LaidOutChildBox {
/// sizes the child itself instead of handing it to a run of its own.
pub(crate) fn sized_in_parent_run(record: &UsedValues, baselines: DerivedBaselines) -> Self {
Self {
- cells: used_values::RootInputCells::capture(record),
+ cells: record.cells(),
baselines,
// NB: A box that establishes an orthogonal flow is laid out by a run of its own.
orthogonal_flow_baselines: None,
diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
index 8f4f27b43bc..ed493710bbe 100644
--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
@@ -20,7 +20,7 @@ pub(crate) struct ResolvedBlockSize {
}
impl ResolvedBlockSize {
- pub(crate) fn apply_to_record(self, used: used_values::RecordInFrame<'_>) {
+ pub(crate) fn apply_to_record(self, used: used_values::CellsInFrame<'_>) {
used.update_cells(|cells| self.apply_to_cells(cells));
}
@@ -188,11 +188,11 @@ impl<'metrics> SizedBox<'metrics> {
#[derive(Clone, Copy)]
pub(crate) struct SizedRecord<'record> {
pub(crate) node: Node,
- pub(crate) record: used_values::RecordInFrame<'record>,
+ pub(crate) record: used_values::CellsInFrame<'record>,
}
impl<'record> SizedRecord<'record> {
- pub(crate) fn new(node: Node, record: used_values::RecordInFrame<'record>) -> Self {
+ pub(crate) fn new(node: Node, record: used_values::CellsInFrame<'record>) -> Self {
Self { node, record }
}
@@ -4375,12 +4375,12 @@ mod replaced_ratio_tests {
callbacks,
node,
Node::INVALID,
- used_values::RootInputCells::capture(&UsedValues::default()),
+ used_values::RootInputCells::default(),
callbacks.frame,
None,
|records, callbacks| {
let context = SizingContext::new(records, callbacks);
- let mut metrics = used_values::RootInputCells::capture(&UsedValues::default());
+ let mut metrics = used_values::RootInputCells::default();
let available = AvailableSpace {
inline_size: AvailableSize::Definite(CssPixels::from_integer(800)),
block_size: AvailableSize::Indefinite,
diff --git a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
index a0a01d0c9af..02c5443a491 100644
--- a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs
@@ -1882,7 +1882,7 @@ impl<'pass> SvgFormattingContext<'pass> {
let placed_child = formatting_context::PlacedChild::of_record(record, None, &self.run);
self.place_laid_out_child(node, placed_child, x, y, None);
LaidOutSvgElement {
- cells: used_values::RootInputCells::capture(record),
+ cells: record.cells(),
content_offset: FfiCssPixelPoint { x, y },
}
}
@@ -2255,7 +2255,7 @@ impl<'pass> SvgFormattingContext<'pass> {
}),
);
Some(LaidOutSvgElement {
- cells: used_values::RootInputCells::capture(used),
+ cells: used.cells(),
content_offset: committed_offset,
})
}
diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rs
index a4f5ceb9b36..84f2509a1da 100644
--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs
@@ -132,116 +132,44 @@ pub(crate) struct CommittedSvgFacts {
/// The per-box geometry stored in a Rust-owned layout pass.
#[derive(Debug)]
pub(crate) struct UsedValues {
- pub content_inline_size: Cell<CssPixels>,
- pub content_block_size: Cell<CssPixels>,
-
- pub margin_left: Cell<CssPixels>,
- pub margin_right: Cell<CssPixels>,
- pub margin_top: Cell<CssPixels>,
- pub margin_bottom: Cell<CssPixels>,
-
- pub border_left: Cell<CssPixels>,
- pub border_right: Cell<CssPixels>,
- pub border_top: Cell<CssPixels>,
- pub border_bottom: Cell<CssPixels>,
-
- pub padding_left: Cell<CssPixels>,
- pub padding_right: Cell<CssPixels>,
- pub padding_top: Cell<CssPixels>,
- pub padding_bottom: Cell<CssPixels>,
-
- pub has_definite_inline_size: Cell<bool>,
- pub has_definite_block_size: Cell<bool>,
+ /// The box's sizes, size constraints and box sides, held in `frame`.
+ pub(crate) cells: Cell<RootInputCells>,
+ /// The frame the box's sizes, size constraints and box sides are held in.
+ pub(crate) frame: geometry::Frame,
+}
+
+/// The sizes, size constraints and box sides of a box.
+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
+pub(crate) struct RootInputCells {
+ pub(crate) content_inline_size: CssPixels,
+ pub(crate) content_block_size: CssPixels,
+
+ pub(crate) margin_left: CssPixels,
+ pub(crate) margin_right: CssPixels,
+ pub(crate) margin_top: CssPixels,
+ pub(crate) margin_bottom: CssPixels,
+
+ pub(crate) border_left: CssPixels,
+ pub(crate) border_right: CssPixels,
+ pub(crate) border_top: CssPixels,
+ pub(crate) border_bottom: CssPixels,
+
+ pub(crate) padding_left: CssPixels,
+ pub(crate) padding_right: CssPixels,
+ pub(crate) padding_top: CssPixels,
+ pub(crate) padding_bottom: CssPixels,
+
+ pub(crate) has_definite_inline_size: bool,
+ pub(crate) has_definite_block_size: bool,
/// A button, or the anonymous wrapper of its content, whose automatic block size was made definite only so the
/// content can be centered within a larger min-height. Percentages inside the button still treat it as indefinite.
- pub has_definite_block_size_only_for_button_content_alignment: Cell<bool>,
- pub uses_collapsing_borders_model: Cell<bool>,
+ pub(crate) has_definite_block_size_only_for_button_content_alignment: bool,
+ pub(crate) uses_collapsing_borders_model: bool,
/// In the collapsing borders model, whether this is the table box rather than a cell. Both store the full widths
/// of the collapsed borders at their edges, of which only a part lies inside the box (see border_left_collapsed()
/// and friends): the table's border area lies outside the grid, so it owns the part of an outer border on the far
/// side of the first or last grid line, while a cell owns the part on the inner side of its grid lines.
- pub is_collapsed_borders_table_box: Cell<bool>,
-
- /// The frame the box's sizes, size constraints and box sides are held in.
- pub(crate) frame: Cell<geometry::Frame>,
-}
-
-impl Default for UsedValues {
- fn default() -> Self {
- let zero = CssPixels::from_raw(0);
- Self {
- content_inline_size: Cell::new(zero),
- content_block_size: Cell::new(zero),
- margin_left: Cell::new(zero),
- margin_right: Cell::new(zero),
- margin_top: Cell::new(zero),
- margin_bottom: Cell::new(zero),
- border_left: Cell::new(zero),
- border_right: Cell::new(zero),
- border_top: Cell::new(zero),
- border_bottom: Cell::new(zero),
- padding_left: Cell::new(zero),
- padding_right: Cell::new(zero),
- padding_top: Cell::new(zero),
- padding_bottom: Cell::new(zero),
- has_definite_inline_size: Cell::new(false),
- has_definite_block_size: Cell::new(false),
- has_definite_block_size_only_for_button_content_alignment: Cell::new(false),
- uses_collapsing_borders_model: Cell::new(false),
- is_collapsed_borders_table_box: Cell::new(false),
- frame: Cell::new(geometry::Frame::PHYSICAL),
- }
- }
-}
-
-macro_rules! used_values_cells {
- ($name:ident { $($field:ident: $type:ty,)+ }) => {
- #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
- pub(crate) struct $name {
- $(pub(crate) $field: $type,)+
- }
-
- impl $name {
- #[inline]
- pub(crate) fn capture(used: &UsedValues) -> Self {
- Self {
- $($field: used.$field.get(),)+
- }
- }
-
- pub(crate) fn apply_to_record(&self, used: &UsedValues) {
- $(
- if used.$field.get() != self.$field {
- used.$field.set(self.$field);
- }
- )+
- }
- }
- };
-}
-
-used_values_cells! {
- RootInputCells {
- content_inline_size: CssPixels,
- content_block_size: CssPixels,
- margin_left: CssPixels,
- margin_right: CssPixels,
- margin_top: CssPixels,
- margin_bottom: CssPixels,
- border_left: CssPixels,
- border_right: CssPixels,
- border_top: CssPixels,
- border_bottom: CssPixels,
- padding_left: CssPixels,
- padding_right: CssPixels,
- padding_top: CssPixels,
- padding_bottom: CssPixels,
- has_definite_inline_size: bool,
- has_definite_block_size: bool,
- has_definite_block_size_only_for_button_content_alignment: bool,
- uses_collapsing_borders_model: bool,
- is_collapsed_borders_table_box: bool,
- }
+ pub(crate) is_collapsed_borders_table_box: bool,
}
impl RootInputCells {
@@ -266,11 +194,13 @@ impl RootInputCells {
}
pub(crate) fn set_content_inline_size(&mut self, value: CssPixels) {
+ // Negative inline sizes are not allowed in CSS. We have a bug somewhere! Clamp to 0 to avoid doing too much damage.
self.content_inline_size = clamp_to_max_dimension_value(value.max(CssPixels::default()));
self.has_definite_inline_size = true;
}
pub(crate) fn set_content_block_size(&mut self, value: CssPixels) {
+ // Negative block sizes are not allowed in CSS. We have a bug somewhere! Clamp to 0 to avoid doing too much damage.
self.content_block_size = clamp_to_max_dimension_value(value.max(CssPixels::default()));
}
@@ -309,11 +239,11 @@ impl RootInputCells {
}
/// A record holding the cells, which hold the box's metrics in `frame`.
- pub(crate) fn materialize_record(&self, frame: geometry::Frame) -> UsedValues {
- let record = UsedValues::default();
- record.frame.set(frame);
- self.apply_to_record(&record);
- record
+ pub(crate) fn materialize_record(self, frame: geometry::Frame) -> UsedValues {
+ UsedValues {
+ cells: Cell::new(self),
+ frame,
+ }
}
/// The cells, with the sizes, size constraints and box sides they hold in frame `from` read in frame `to` instead.
@@ -355,26 +285,21 @@ impl RootInputCells {
impl UsedValues {
/// Writes the record's metrics, which `write` sees and changes as the record holds them.
pub(crate) fn update_cells(&self, write: impl FnOnce(&mut RootInputCells)) {
- let mut cells = RootInputCells::capture(self);
+ let mut cells = self.cells.get();
write(&mut cells);
- cells.apply_to_record(self);
+ self.cells.set(cells);
}
pub(crate) fn set_content_inline_size(&self, value: CssPixels) {
- // Negative inline sizes are not allowed in CSS. We have a bug somewhere! Clamp to 0 to avoid doing too much damage.
- self.content_inline_size
- .set(clamp_to_max_dimension_value(value.max(CssPixels::default())));
- self.has_definite_inline_size.set(true);
+ self.update_cells(|cells| cells.set_content_inline_size(value));
}
pub(crate) fn set_content_block_size(&self, value: CssPixels) {
- // Negative block sizes are not allowed in CSS. We have a bug somewhere! Clamp to 0 to avoid doing too much damage.
- self.content_block_size
- .set(clamp_to_max_dimension_value(value.max(CssPixels::default())));
+ self.update_cells(|cells| cells.set_content_block_size(value));
}
pub(crate) fn set_box_metrics_from_fragment(&self, fragment: &fragment_tree::Fragment) {
- RecordInFrame::in_its_own_frame(self).set_box_metrics_from_fragment(fragment);
+ self.update_cells(|cells| cells.take_box_metrics_of_fragment(fragment));
}
}
@@ -531,7 +456,7 @@ pub(crate) trait BoxMetricCells {
impl BoxMetricCells for UsedValues {
#[inline]
fn cells(&self) -> RootInputCells {
- RootInputCells::capture(self)
+ self.cells.get()
}
}
@@ -542,42 +467,35 @@ impl BoxMetricCells for RootInputCells {
}
}
-/// A record as a reader in frame `reader` sees it: the sizes, size constraints and box sides the record holds in its own
-/// frame, read and written in the reader's frame.
+/// Cells held in frame `held`, read and written in frame `reader`.
#[derive(Clone, Copy)]
-pub(crate) struct RecordInFrame<'record> {
- record: &'record UsedValues,
+pub(crate) struct CellsInFrame<'a> {
+ cells: &'a Cell<RootInputCells>,
+ held: geometry::Frame,
reader: geometry::Frame,
}
-impl<'record> RecordInFrame<'record> {
- /// The record, read in frame `reader`.
+impl<'a> CellsInFrame<'a> {
+ /// The cells of `record`, read in frame `reader`.
#[inline]
- pub(crate) fn new(record: &'record UsedValues, reader: geometry::Frame) -> Self {
- Self { record, reader }
- }
-
- /// The record, read in the frame it holds its metrics in.
- #[inline]
- pub(crate) fn in_its_own_frame(record: &'record UsedValues) -> Self {
+ pub(crate) fn new(record: &'a UsedValues, reader: geometry::Frame) -> Self {
Self {
- record,
- reader: record.frame.get(),
+ cells: &record.cells,
+ held: record.frame,
+ reader,
}
}
- /// The frame the record is read in.
+ /// The frame the cells are read in.
pub(crate) fn reader(&self) -> geometry::Frame {
self.reader
}
- /// Writes the record's metrics, which `write` sees and changes as the reader's frame has them.
+ /// Writes the cells, which `write` sees and changes as the reader's frame has them.
pub(crate) fn update_cells(self, write: impl FnOnce(&mut RootInputCells)) {
let mut cells = self.cells();
write(&mut cells);
- cells
- .in_frame(self.reader, self.record.frame.get())
- .apply_to_record(self.record);
+ self.cells.set(cells.in_frame(self.reader, self.held));
}
pub(crate) fn set_content_inline_size(self, value: CssPixels) {
@@ -598,10 +516,10 @@ impl<'record> RecordInFrame<'record> {
}
}
-impl BoxMetricCells for RecordInFrame<'_> {
+impl BoxMetricCells for CellsInFrame<'_> {
#[inline]
fn cells(&self) -> RootInputCells {
- RootInputCells::capture(self.record).in_frame(self.record.frame.get(), self.reader)
+ self.cells.get().in_frame(self.held, self.reader)
}
}