Skip to content

Truly independent web browser

LibWeb: Size boxes in cells rather than in views of a record

Aliaksandr Kalenikccafb718e56b
diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
index c6ebcee80dc..a757703a7c0 100644
--- a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
+++ b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
@@ -130,36 +130,38 @@ impl ContainingBlockGeometry {
}
}
-/// An absolutely positioned box this engine sizes: its record, the used insets the engine resolves for it, and the
-/// anchor-size() resolutions its style reads.
+/// An absolutely positioned box this engine sizes: its cells, held in `frame`, the used insets the engine resolves for
+/// it, and the anchor-size() resolutions its style reads.
#[derive(Clone, Copy)]
pub(crate) struct OutOfFlowBox<'a> {
pub(crate) node: Node,
- pub(crate) record: used_values::CellsInFrame<'a>,
+ pub(crate) cells: &'a Cell<used_values::RootInputCells>,
+ pub(crate) frame: geometry::Frame,
used_insets: &'a Cell<run_records::UsedInsets>,
anchor_resolved_values: Option<&'a style_values::AnchorResolvedValues>,
}
impl<'a> OutOfFlowBox<'a> {
pub(crate) fn new(
- sized: sizing_context::SizedRecord<'a>,
+ sized: sizing_context::SizedCells<'a>,
used_insets: &'a Cell<run_records::UsedInsets>,
anchor_resolved_values: Option<&'a style_values::AnchorResolvedValues>,
) -> Self {
Self {
node: sized.node,
- record: sized.record,
+ cells: sized.cells,
+ frame: sized.frame,
used_insets,
anchor_resolved_values,
}
}
- fn sized_record(&self) -> sizing_context::SizedRecord<'a> {
- sizing_context::SizedRecord::new(self.node, self.record)
+ fn sized_cells(&self) -> sizing_context::SizedCells<'a> {
+ sizing_context::SizedCells::new(self.node, self.cells, self.frame)
}
- fn sized_box(&self) -> sizing_context::SizedBox<'_> {
- sizing_context::SizedBox::of_own_metrics(self.node, &self.record, self.record.reader())
+ fn sized_box(&self) -> sizing_context::SizedBox<'a> {
+ sizing_context::SizedBox::of_own_metrics(self.node, self.cells, self.frame)
}
}
@@ -227,7 +229,7 @@ impl<'pass> AbsposEngine<'pass> {
}
let placement = self.placement_of(space_box).unwrap_or_else(|| {
panic!(
- "an entry's space chain crossed an unplaced or foreign record before meeting its containing block's chain (slot {})",
+ "an entry's space chain crossed a box the run did not place before meeting its containing block's chain (slot {})",
space_box.slot_index()
)
});
@@ -1836,7 +1838,7 @@ impl AbsposEngine<'_> {
sized: OutOfFlowBox<'_>,
rect: abspos_inputs::StaticPositionRect,
) -> geometry::LogicalOffset {
- let metrics = sized.record;
+ let metrics = sized.cells;
let collapsed = metrics.uses_collapsing_borders_model();
aligned_static_offset(
rect,
@@ -1953,7 +1955,7 @@ impl AbsposEngine<'_> {
auto_margin_overflow: AutoMarginOverflow,
) -> (AutoPx, CssPixels, CssPixels, AutoPx, AutoPx) {
let style = self.style_of(sized).with_resolved_insets(resolved_anchor_insets);
- let used = sized.record;
+ let used = sized.cells;
let border_left = style.border_left_width();
let border_right = style.border_right_width();
let padding_left = used.padding_left();
@@ -2021,7 +2023,7 @@ impl AbsposEngine<'_> {
}
let content_inline_size = shrink_to_fit(left, margin_left, margin_right, right);
inline_size = Some(content_inline_size);
- sized.record.set_content_inline_size(content_inline_size);
+ sized.cells.set_content_inline_size(content_inline_size);
left = self.static_offset(sized, static_position_rect).inline_offset;
right = solve_for_right(left, inline_size, margin_left, margin_right);
}
@@ -2224,7 +2226,7 @@ impl AbsposEngine<'_> {
}
}
- let used = sized.record;
+ let used = sized.cells;
used.set_content_inline_size(auto_px_value(used_inline_size));
Self::set_used_inline_insets(sized, left, right);
used.update_cells(|cells| {
@@ -2260,7 +2262,7 @@ impl AbsposEngine<'_> {
};
let containing_block_inline_size = available_space.inline_size.to_px_or_zero();
let style = self.style_of(sized).with_resolved_insets(resolved_anchor_insets);
- let used = sized.record;
+ let used = sized.cells;
let available = containing_block_inline_size
- inline_size
- style.border_left_width()
@@ -2277,7 +2279,7 @@ impl AbsposEngine<'_> {
ReplacedAxisBehavior { auto_margin_overflow },
);
- let used = sized.record;
+ let used = sized.cells;
Self::set_used_inline_insets(sized, solution.start, solution.end);
used.update_cells(|cells| {
cells.margin_left = solution.margin_start;
@@ -2410,9 +2412,9 @@ impl AbsposEngine<'_> {
// NB: That makes the automatic block size the shrink-to-fit size of the box's own inline axis, within the
// inset-modified containing block, as it is in the inline axis of a box in the frame's writing mode.
if let BlockSizePass::AfterInsideLayout { .. } = pass {
- return Some(sized.record.content_block_size());
+ return Some(sized.cells.content_block_size());
}
- let inline_size = sized.record.content_inline_size();
+ let inline_size = sized.cells.content_inline_size();
let preferred = sizing.calculate_max_content_block_size(sized.sized_box(), inline_size, constraints);
let size = if preferred <= stretch_fit_block_size {
preferred
@@ -2436,7 +2438,7 @@ impl AbsposEngine<'_> {
BlockSizePass::AfterInsideLayout { .. } => Some(CssPixels::default()),
};
}
- let inner = sized.record.available_inner_space_or_constraints_from(available_space);
+ let inner = sized.cells.available_inner_space_or_constraints_from(available_space);
Some(sizing.calculate_fit_content_size(sized.sized_box(), SizingAxis::Block, inner, constraints))
}
@@ -2455,7 +2457,7 @@ impl AbsposEngine<'_> {
let style = self.style_of(sized).with_resolved_insets(resolved_anchor_insets);
let containing_block_inline_size = available_space.inline_size.to_px_or_zero();
let containing_block_block_size = available_space.block_size.to_px_or_zero();
- let used = sized.record;
+ let used = sized.cells;
let padding_top = used.padding_top();
let padding_bottom = used.padding_bottom();
let mut solution = BlockAxisSolution {
@@ -2524,7 +2526,7 @@ impl AbsposEngine<'_> {
resolved_anchor_insets,
solution.block_size,
);
- sized.record.set_content_block_size(auto_px_value(constrained));
+ sized.cells.set_content_block_size(auto_px_value(constrained));
solution.top = Some(self.static_offset(sized, static_position_rect).block_offset);
solution.bottom = Some(solve_for(solution.bottom, false, solution));
} else if solution.top.is_some() && solution.block_size.is_some() && solution.bottom.is_some() {
@@ -2596,7 +2598,7 @@ impl AbsposEngine<'_> {
let node = sized.node;
let style = self.style_of(sized);
let mut intrinsic_available_space = available_space;
- intrinsic_available_space.inline_size = AvailableSize::definite(sized.record.content_inline_size());
+ intrinsic_available_space.inline_size = AvailableSize::definite(sized.cells.content_inline_size());
let initial = if self.facts(node).is_table_wrapper() {
Some(self.sizing().compute_table_box_block_size_inside_wrapper(
sized.sized_box(),
@@ -2712,7 +2714,7 @@ impl AbsposEngine<'_> {
);
}
- let used = sized.record;
+ let used = sized.cells;
used.set_content_block_size(auto_px_value(solution.block_size));
if style.height().is_auto() && pass == BlockSizePass::BeforeInsideLayout {
// NB: A box that establishes an orthogonal flow is sized in this axis before its contents are laid out,
@@ -2774,7 +2776,7 @@ impl AbsposEngine<'_> {
if let Some(minimum) = self.sizing().automatic_minimum_size_from_aspect_ratio(
sized.sized_box(),
SizingAxis::Block,
- sized.record.content_inline_size(),
+ sized.cells.content_inline_size(),
block_size,
available_space,
constraints,
@@ -2785,7 +2787,7 @@ impl AbsposEngine<'_> {
}
let containing_block_block_size = available_space.block_size.to_px_or_zero();
let style = self.style_of(sized).with_resolved_insets(resolved_anchor_insets);
- let used = sized.record;
+ let used = sized.cells;
let available = containing_block_block_size
- block_size
- style.border_top_width()
@@ -2802,7 +2804,7 @@ impl AbsposEngine<'_> {
ReplacedAxisBehavior { auto_margin_overflow },
);
- let used = sized.record;
+ let used = sized.cells;
used.set_content_block_size(block_size);
if style.height().is_auto() && pass == BlockSizePass::BeforeInsideLayout {
// https://drafts.csswg.org/css-sizing-4/#aspect-ratio-automatic
@@ -2886,7 +2888,7 @@ impl<'pass> AbsposEngine<'pass> {
"an out-of-flow root with anchor() insets must arrive with their resolutions"
);
let style = self.style_of(sized).with_resolved_insets(resolved);
- sized.record.update_cells(|cells| {
+ sized.cells.update_cells(|cells| {
cells.border_left = style.border_left_width();
cells.border_right = style.border_right_width();
cells.border_top = style.border_top_width();
@@ -2916,7 +2918,7 @@ impl<'pass> AbsposEngine<'pass> {
);
{
- let used = sized.record;
+ let used = sized.cells;
if !style.inset_left().is_auto() && !style.inset_right().is_auto() {
used.update_cells(|cells| cells.has_definite_inline_size = true);
}
@@ -2930,8 +2932,8 @@ impl<'pass> AbsposEngine<'pass> {
if !self.facts(node).creates_block_formatting_context() {
let block_size_resolved_from_aspect_ratio = style.height().is_auto()
&& self.facts(node).has_preferred_aspect_ratio()
- && sized.record.has_definite_inline_size();
- let used = sized.record;
+ && sized.cells.has_definite_inline_size();
+ let used = sized.cells;
used.update_cells(|cells| cells.has_definite_inline_size = true);
if (!style.height().is_auto() && !style.height().is_intrinsic_sizing_constraint())
|| block_size_resolved_from_aspect_ratio
@@ -2941,7 +2943,7 @@ impl<'pass> AbsposEngine<'pass> {
}
self.sizing()
- .make_form_control_content_box_definite(sized.sized_record(), available_space, constraints, None);
+ .make_form_control_content_box_definite(sized.sized_cells(), available_space, constraints, None);
}
pub(crate) fn finalize_out_of_flow_root_after_inside_layout(
@@ -2970,7 +2972,7 @@ impl<'pass> AbsposEngine<'pass> {
}
{
- let used = sized.record;
+ let used = sized.cells;
let collapsed = used.uses_collapsing_borders_model();
// https://drafts.csswg.org/css-anchor-position-1/#position-area-alignment
// NB: A position area aligns the box within its inset-modified containing block even when both insets
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
index 7655a670331..fdc2d0d601f 100644
--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs
@@ -835,7 +835,7 @@ impl<'pass> BlockFormattingContext<'pass> {
/// The cells `child` is laid out in, a box this block formatting context lays out itself.
#[track_caller]
- fn record_of<'record>(&self, child: ChildSizedHere<'record>) -> &'record Cell<used_values::RootInputCells> {
+ fn cells_laid_out_here<'cells>(&self, child: ChildSizedHere<'cells>) -> &'cells Cell<used_values::RootInputCells> {
child
.cells_laid_out_here()
.unwrap_or_else(|| panic!("{:?} is sized ahead of its run, not laid out here", child.node))
@@ -843,15 +843,8 @@ impl<'pass> BlockFormattingContext<'pass> {
/// `child`, a box this block formatting context lays out itself, as a box its sizing steps size there.
#[track_caller]
- fn sized_record_of<'record>(&self, child: ChildSizedHere<'record>) -> sizing_context::SizedRecord<'record> {
- sizing_context::SizedRecord::new(
- child.node,
- used_values::CellsInFrame::of_cells(
- self.record_of(child),
- self.run.callbacks.frame,
- self.run.callbacks.frame,
- ),
- )
+ fn sized_cells_of<'cells>(&self, child: ChildSizedHere<'cells>) -> sizing_context::SizedCells<'cells> {
+ sizing_context::SizedCells::new(child.node, self.cells_laid_out_here(child), self.run.callbacks.frame)
}
fn register_contained_abspos_child(&self, node: Node, block_offset: CssPixels, block_container: BlockContainer) {
@@ -1955,7 +1948,7 @@ impl<'pass> BlockFormattingContext<'pass> {
// box with in-flow children where they collapse through each of them.
// (see https://github.com/w3c/csswg-drafts/pull/13699 )
margins_can_collapse_through_box_itself(self.facts(node), self.style(node), || {
- self.record_of(sized_child).border_box_block_size(false)
+ self.cells_laid_out_here(sized_child).border_box_block_size(false)
}) && children.is_none_or(|children| !children.has_child_whose_margins_do_not_collapse_through)
}
@@ -2468,7 +2461,7 @@ impl<'pass> BlockFormattingContext<'pass> {
content_offset: Some(content_offset),
margin_box_block_end: Some(margin_box_block_end),
..LaidOutBlockLevelBox::of_box(
- Self::laid_out_box_in_record_its_layout_owns(sized_child, entry.baselines),
+ Self::laid_out_box_of_box_laid_out_here(sized_child, entry.baselines),
fragment_facts,
)
});
@@ -2537,7 +2530,7 @@ impl<'pass> BlockFormattingContext<'pass> {
return Some(LaidOutBlockLevelBox {
collapses_through: self.margins_collapse_through(sized_child, None),
..LaidOutBlockLevelBox::of_box(
- Self::laid_out_box_in_record_its_layout_owns(sized_child, DerivedBaselines::default()),
+ Self::laid_out_box_of_box_laid_out_here(sized_child, DerivedBaselines::default()),
fragment_facts,
)
});
@@ -2547,8 +2540,8 @@ impl<'pass> BlockFormattingContext<'pass> {
let box_opens_top_margin_group = !has_independent_formatting_context
&& continuation.is_none()
- && self.record_of(sized_child).border_top() == CssPixels::default()
- && self.record_of(sized_child).padding_top() == CssPixels::default()
+ && self.cells_laid_out_here(sized_child).border_top() == CssPixels::default()
+ && self.cells_laid_out_here(sized_child).padding_top() == CssPixels::default()
&& !self.margin_state.borrow().has_open_top_margin_group();
let container_facts = self.facts(block_container.node);
@@ -2594,7 +2587,8 @@ impl<'pass> BlockFormattingContext<'pass> {
);
let float_avoidance_inline_size = probe.opportunity;
if !has_independent_formatting_context && let Some(content_inline_size) = probe.content_inline_size {
- self.record_of(sized_child).set_content_inline_size(content_inline_size);
+ self.cells_laid_out_here(sized_child)
+ .set_content_inline_size(content_inline_size);
}
let content_inline_size_now = probe
.content_inline_size
@@ -2663,8 +2657,8 @@ impl<'pass> BlockFormattingContext<'pass> {
} else {
CssPixels::default()
};
- if continuation.is_some() && self.record_of(sized_child).has_definite_block_size() {
- let used = self.record_of(sized_child);
+ if continuation.is_some() && self.cells_laid_out_here(sized_child).has_definite_block_size() {
+ let used = self.cells_laid_out_here(sized_child);
used.set_content_block_size(
(used.content_block_size() - continuation_inner_size_excess).max(CssPixels::default()),
);
@@ -2778,11 +2772,11 @@ impl<'pass> BlockFormattingContext<'pass> {
let space_available_for_children = if facts.is_anonymous() {
available_space
} else {
- self.record_of(sized_child)
+ self.cells_laid_out_here(sized_child)
.available_inner_space_or_constraints_from(available_space)
};
- if self.record_of(sized_child).border_top() > CssPixels::default()
- || self.record_of(sized_child).padding_top() > CssPixels::default()
+ if self.cells_laid_out_here(sized_child).border_top() > CssPixels::default()
+ || self.cells_laid_out_here(sized_child).padding_top() > CssPixels::default()
{
// margin-top of block container can't collapse with its children if it has non-zero border or padding.
self.margin_state.borrow_mut().reset();
@@ -2795,8 +2789,8 @@ impl<'pass> BlockFormattingContext<'pass> {
self.discard_block_start_margin_of_next_child.set(
discards_block_start_margin
&& !facts.children_are_inline()
- && self.record_of(sized_child).border_top() == CssPixels::default()
- && self.record_of(sized_child).padding_top() == CssPixels::default(),
+ && self.cells_laid_out_here(sized_child).border_top() == CssPixels::default()
+ && self.cells_laid_out_here(sized_child).padding_top() == CssPixels::default(),
);
}
let content_box_position_in_root = FfiCssPixelPoint {
@@ -2833,7 +2827,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let final_content_block_offset = if introduced_clearance {
content_block_offset
} else {
- block_offset + resolved_margin_top + self.record_of(sized_child).border_box_top(false)
+ block_offset + resolved_margin_top + self.cells_laid_out_here(sized_child).border_box_top(false)
};
if box_is_positioned_by_fieldset_layout {
legend_flow_position = Some(geometry::LogicalOffset {
@@ -2876,14 +2870,14 @@ impl<'pass> BlockFormattingContext<'pass> {
{
let content_block_size = self.compute_automatic_block_size_for_block_level_element(
sized_child,
- self.record_of(sized_child)
+ self.cells_laid_out_here(sized_child)
.available_inner_space_or_constraints_from(available_space_for_block_size_resolution),
input.containing_block_constraints,
None,
summary_of_children_laid_out_in_this_flow.as_ref(),
);
self.sizing().apply_automatic_minimum_block_size_from_aspect_ratio(
- self.sized_record_of(sized_child),
+ self.sized_cells_of(sized_child),
available_space_for_block_size_resolution,
input.containing_block_constraints,
Some(content_block_size),
@@ -2922,13 +2916,15 @@ impl<'pass> BlockFormattingContext<'pass> {
let block_size = fragmentainer.block_size?;
let content_block_start_in_root = content_block_start_in_root?;
let can_break_after_block_start_edges = self.box_can_break_inside(node, has_unbreakable_lines)
- && content_block_start_in_root - self.record_of(sized_child).border_box_top(false) < block_size;
+ && content_block_start_in_root - self.cells_laid_out_here(sized_child).border_box_top(false)
+ < block_size;
if can_break_after_block_start_edges && content_block_start_in_root > block_size {
fragmentainer.note_space_shortage(content_block_start_in_root);
}
let breaks_inside = can_break_after_block_start_edges
&& content_block_start_in_root <= block_size
- && content_block_start_in_root + self.record_of(sized_child).content_block_size() > block_size
+ && content_block_start_in_root + self.cells_laid_out_here(sized_child).content_block_size()
+ > block_size
&& content_block_start_in_root
+ children
.map_or(CssPixels::default(), ChildrenSummary::block_end_of_content)
@@ -2943,7 +2939,7 @@ impl<'pass> BlockFormattingContext<'pass> {
})
});
if let Some(mut token) = broken_token {
- let used = self.record_of(sized_child);
+ let used = self.cells_laid_out_here(sized_child);
if let (Some(block_size), Some(content_block_start_in_root)) =
(fragmentainer.block_size, content_block_start_in_root)
{
@@ -3106,7 +3102,7 @@ impl<'pass> BlockFormattingContext<'pass> {
has_unbreakable_lines,
collapses_through,
laid_out_box: laid_out_box_handed_back_by_its_run.unwrap_or_else(|| {
- Self::laid_out_box_in_record_its_layout_owns(
+ Self::laid_out_box_of_box_laid_out_here(
sized_child,
baselines_of_contents_laid_out_in_this_flow.unwrap_or_default(),
)
@@ -3119,7 +3115,7 @@ impl<'pass> BlockFormattingContext<'pass> {
}
/// The box `child` as this flow laid it out in cells its layout owns, with the `baselines` of its contents.
- fn laid_out_box_in_record_its_layout_owns(
+ fn laid_out_box_of_box_laid_out_here(
child: ChildSizedHere<'_>,
baselines: DerivedBaselines,
) -> run_records::LaidOutChildBox {
@@ -3226,7 +3222,7 @@ impl<'pass> BlockFormattingContext<'pass> {
) -> (FfiCssPixelPoint, CssPixels) {
let node = sized_child.node;
self.run.callbacks.arena().layout_trace.reused_in_flow_subtree(node);
- self.record_of(sized_child).set(entry.cells);
+ self.cells_laid_out_here(sized_child).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(
@@ -3285,7 +3281,7 @@ impl<'pass> BlockFormattingContext<'pass> {
let Some((content_offset, placed)) = placed else {
return;
};
- let used = self.record_of(sized_child);
+ let used = self.cells_laid_out_here(sized_child);
// NB: A reused child tells its parent that margins do not collapse through it, which holds only for a child
// whose border box has a block size.
let reusable = !placed.exports_payloads
@@ -3666,7 +3662,7 @@ impl<'pass> BlockFormattingContext<'pass> {
children: Option<&ChildrenSummary>,
) {
let node = sized_child.node;
- let used = self.record_of(sized_child);
+ let used = self.cells_laid_out_here(sized_child);
if used.has_definite_block_size() {
used.set_content_block_size((used.content_block_size() - consumed_block_size).max(CssPixels::default()));
return;
@@ -5050,7 +5046,7 @@ impl<'pass> BlockFormattingContext<'pass> {
} else {
margin_state.current_collapsed_margin()
};
- let used = self.record_of(sized_child);
+ let used = self.cells_laid_out_here(sized_child);
if used.padding_bottom() == CssPixels::default() && used.border_bottom() == CssPixels::default() {
margin_state.box_last_in_flow_child_margin_bottom_collapsed = true;
margin_bottom = CssPixels::default();
diff --git a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
index 541ca95e5d1..0fb484208d7 100644
--- a/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/flex_formatting_context.rs
@@ -3649,14 +3649,7 @@ impl<'pass> FlexFormattingContext<'pass> {
fn resolve_own_auto_block_size(&self, automatic_block_size: CssPixels, resolution_space: AvailableSpace) {
self.sizing().resolve_used_block_size_if_treated_as_auto(
- sizing_context::SizedRecord::new(
- self.run.box_,
- used_values::CellsInFrame::of_cells(
- &self.container_cells,
- self.run.callbacks.frame,
- self.run.callbacks.frame,
- ),
- ),
+ sizing_context::SizedCells::new(self.run.box_, &self.container_cells, self.run.callbacks.frame),
resolution_space,
self.layout_input.unwrap().containing_block_constraints,
Some(automatic_block_size),
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index bda9c335053..c6f95ee3d13 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -1609,7 +1609,7 @@ pub(crate) fn flex_self_block_size_resolution_space(
// Flex containers with an automatic block size are treated as max-content, so resolve it early.
fn eagerly_resolve_atomic_flex_root_auto_block_size(
run: &FormattingContextRun,
- sized_root: sizing_context::SizedRecord<'_>,
+ sized_root: sizing_context::SizedCells<'_>,
input: &LayoutInput,
inline_definite_space: AvailableSpace,
) {
@@ -1634,7 +1634,7 @@ fn eagerly_resolve_atomic_flex_root_auto_block_size(
&sizing,
sized_root.sized_box(),
sized_root
- .record
+ .cells
.available_inner_space_or_constraints_from(inline_definite_space),
input.containing_block_constraints,
None,
@@ -1650,7 +1650,7 @@ struct RootSizingOutcome {
fn apply_root_sizing_directives(
run: &FormattingContextRun,
- sized_root: sizing_context::SizedRecord<'_>,
+ sized_root: sizing_context::SizedCells<'_>,
input: &LayoutInput,
fc_type: FormattingContextType,
root_used_insets: &Cell<run_records::UsedInsets>,
@@ -1662,7 +1662,7 @@ fn apply_root_sizing_directives(
}
ParticipationInParentFormattingContext::Float { .. } => {
resolve_float_root_block_size_ahead_of_its_contents(run, sized_root, input);
- body_input_with_inner_available_space(&sized_root.record, input)
+ body_input_with_inner_available_space(sized_root.cells, input)
}
ParticipationInParentFormattingContext::AtomicInline => {
let run_cache_may_reuse_this_run_at_other_available_inline_sizes =
@@ -1673,9 +1673,9 @@ fn apply_root_sizing_directives(
input.containing_block_constraints,
run_cache_may_reuse_this_run_at_other_available_inline_sizes,
);
- let mut body_input = body_input_with_inner_available_space(&sized_root.record, input);
+ let mut body_input = body_input_with_inner_available_space(sized_root.cells, input);
let inline_definite_space = AvailableSpace {
- inline_size: AvailableSize::definite(sized_root.record.content_inline_size()),
+ inline_size: AvailableSize::definite(sized_root.cells.content_inline_size()),
block_size: AvailableSize::Indefinite,
};
let flex_self_resolution_space = flex_self_block_size_resolution_space(
@@ -1699,12 +1699,12 @@ fn apply_root_sizing_directives(
),
abspos_inputs,
);
- body_input_with_inner_available_space(&sized_root.record, input)
+ body_input_with_inner_available_space(sized_root.cells, input)
}
ParticipationInParentFormattingContext::Item => {
if cfg!(debug_assertions) && run.fragments.is_some() {
debug_assert!(
- sized_root.record.has_definite_inline_size(),
+ sized_root.cells.has_definite_inline_size(),
"container-internal run root must arrive with a container-assigned inline size"
);
}
@@ -1713,7 +1713,7 @@ fn apply_root_sizing_directives(
ParticipationInParentFormattingContext::Root => {
let directives = input.sizing;
if directives.forced_content_inline_size.is_some() || directives.forced_content_block_size.is_some() {
- let used = sized_root.record;
+ let used = sized_root.cells;
if let Some(inline_size) = directives.forced_content_inline_size {
used.set_content_inline_size(inline_size);
}
@@ -1733,7 +1733,7 @@ fn apply_root_sizing_directives(
fn dimension_block_level_root(
run: &FormattingContextRun,
- sized_root: sizing_context::SizedRecord<'_>,
+ sized_root: sizing_context::SizedCells<'_>,
input: &LayoutInput,
fc_type: FormattingContextType,
) -> LayoutInput {
@@ -1743,10 +1743,10 @@ fn dimension_block_level_root(
let sizing = run.sizing();
let style = StyleValues::for_node(&run.callbacks, node);
let flex_self_resolution_space = size_block_level_root_ahead_of_its_contents(run, sized_root, input);
- let mut body_input = body_input_with_inner_available_space(&sized_root.record, input);
+ let mut body_input = body_input_with_inner_available_space(sized_root.cells, input);
body_input.sizing.flex_self_block_size_resolution_space = flex_self_resolution_space;
if let Some(block_size) = input.sizing.forced_content_block_size {
- let used = sized_root.record;
+ let used = sized_root.cells;
used.set_content_block_size(block_size);
used.update_cells(|cells| cells.has_definite_block_size = true);
body_input.available_space.block_size = AvailableSize::definite(block_size);
@@ -1783,11 +1783,11 @@ fn dimension_block_level_root(
/// automatic block size in, if it does.
fn size_block_level_root_ahead_of_its_contents(
run: &FormattingContextRun,
- sized_root: sizing_context::SizedRecord<'_>,
+ sized_root: sizing_context::SizedCells<'_>,
input: &LayoutInput,
) -> Option<AvailableSpace> {
let node = run.box_;
- let root = sized_root.record;
+ let root = sized_root.cells;
let constraints = input.containing_block_constraints;
let sizing = run.sizing();
let facts = NodeFacts::new(&run.callbacks, node);
@@ -1822,11 +1822,11 @@ fn size_block_level_root_ahead_of_its_contents(
/// inline size its block formatting context gave it.
fn resolve_float_root_block_size_ahead_of_its_contents(
run: &FormattingContextRun,
- sized_root: sizing_context::SizedRecord<'_>,
+ sized_root: sizing_context::SizedCells<'_>,
input: &LayoutInput,
) {
let node = run.box_;
- let root = sized_root.record;
+ let root = sized_root.cells;
let available_space = input.available_space;
let constraints = input.containing_block_constraints;
let sizing = run.sizing();
@@ -1890,13 +1890,13 @@ pub(crate) fn content_block_size_for_aspect_ratio_minimum(
fn finalize_block_level_root(
run: &FormattingContextRun,
- sized_root: sizing_context::SizedRecord<'_>,
+ sized_root: sizing_context::SizedCells<'_>,
input: &LayoutInput,
body_result: &ChildLayoutResult,
) {
let node = run.box_;
if let Some(inline_size) = body_result.table_wrapper_content_inline_size {
- sized_root.record.set_content_inline_size(inline_size);
+ sized_root.cells.set_content_inline_size(inline_size);
}
let style = StyleValues::for_node(&run.callbacks, node);
if !style.display().is_table_inside() && input.sizing.forced_content_block_size.is_none() {
@@ -1918,12 +1918,12 @@ fn finalize_block_level_root(
fn finalize_float_root(
run: &FormattingContextRun,
- sized_root: sizing_context::SizedRecord<'_>,
+ sized_root: sizing_context::SizedCells<'_>,
input: &LayoutInput,
body_result: &ChildLayoutResult,
) {
if let Some(inline_size) = body_result.table_wrapper_content_inline_size {
- sized_root.record.set_content_inline_size(inline_size);
+ sized_root.cells.set_content_inline_size(inline_size);
}
run.sizing().resolve_used_block_size_if_treated_as_auto(
sized_root,
@@ -1963,10 +1963,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::CellsInFrame::of_cells(cells, run.callbacks.frame, run.callbacks.frame),
- ),
+ sizing_context::SizedCells::new(child, cells, run.callbacks.frame),
&used_insets,
anchor_resolved_values.as_ref(),
);
@@ -2372,10 +2369,7 @@ fn lay_out_run_root_and_contents<'pass>(
table_inline_layout => (None, table_inline_layout),
};
let root = Cell::new(root_cells);
- let sized_root = sizing_context::SizedRecord::new(
- box_,
- used_values::CellsInFrame::of_cells(&root, parent_frame, parent_frame),
- );
+ let sized_root = sizing_context::SizedCells::new(box_, &root, parent_frame);
let root_used_insets = Cell::new(run_records::UsedInsets::default());
let RootSizingOutcome {
body_input,
@@ -2391,10 +2385,7 @@ fn lay_out_run_root_and_contents<'pass>(
body_input_in_own_frame(
run,
body_run,
- sizing_context::SizedRecord::new(
- box_,
- used_values::CellsInFrame::of_cells(&own_root, own_frame, own_frame),
- ),
+ sizing_context::SizedCells::new(box_, &own_root, own_frame),
&input,
body_input,
parent_frame,
@@ -2584,7 +2575,7 @@ fn lay_out_run_root_and_contents<'pass>(
&& let Some(block_size) =
content_block_size_adopted_after_run(&input, result.automatic_content_block_size)
{
- sized_root.record.set_content_block_size(block_size);
+ sized_root.cells.set_content_block_size(block_size);
}
}
ParticipationInParentFormattingContext::Root => {}
@@ -2700,14 +2691,14 @@ pub(crate) fn frame_established_by(callbacks: &LayoutPass<'_>, node: Node) -> ge
fn body_input_in_own_frame(
run: &FormattingContextRun,
body_run: &FormattingContextRun,
- sized_root_in_own_frame: sizing_context::SizedRecord<'_>,
+ sized_root_in_own_frame: sizing_context::SizedCells<'_>,
input: &LayoutInput,
body_input: LayoutInput,
parent_frame: geometry::Frame,
own_frame: geometry::Frame,
) -> LayoutInput {
let node = run.box_;
- let used = sized_root_in_own_frame.record;
+ let used = sized_root_in_own_frame.cells;
if !parent_frame.is_orthogonal_to(own_frame) {
// NB: Sizes keep their axes between frames that are not orthogonal, so the contents are laid out with the
// input the root's sizing gave them, apart from the parent's block formatting context they leave.
@@ -2819,7 +2810,7 @@ fn result_in_parent_frame(
fn finalize_atomic_root_block_size(
run: &FormattingContextRun,
- sized_root: sizing_context::SizedRecord<'_>,
+ sized_root: sizing_context::SizedCells<'_>,
input: &LayoutInput,
automatic_content_block_size_of_completed_body_run: CssPixels,
) {
@@ -2950,10 +2941,7 @@ pub(crate) fn layout_inside_child_with_input_cells(
// parent run, which will also construct its fragment when placing the box.
let cells_of_this_layout = Cell::new(child_input_cells);
let committed_fragment = run.sizing().dimension_empty_atomic_root(
- sizing_context::SizedRecord::new(
- child,
- used_values::CellsInFrame::of_cells(&cells_of_this_layout, run.callbacks.frame, run.callbacks.frame),
- ),
+ sizing_context::SizedCells::new(child, &cells_of_this_layout, run.callbacks.frame),
input.available_space,
input.containing_block_constraints,
child_run_builds_fragments,
diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
index 27d7d496d3f..e6ca4dd5fce 100644
--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
@@ -20,10 +20,6 @@ pub(crate) struct ResolvedBlockSize {
}
impl ResolvedBlockSize {
- pub(crate) fn apply_to_record(self, used: used_values::CellsInFrame<'_>) {
- used.update_cells(|cells| self.apply_to_cells(cells));
- }
-
pub(crate) fn apply_to_cells(self, cells: &mut used_values::RootInputCells) {
cells.set_content_block_size(self.content_block_size);
if self.makes_block_size_definite {
@@ -130,8 +126,8 @@ pub(crate) struct TableWrapperBlockSizes {
pub(crate) wrapper_content_block_size: CssPixels,
}
-/// A box a sizing step sizes, with the sizes, size constraints and box sides the step reads of it: held in its record
-/// or in cells of the parent that sizes it.
+/// A box a sizing step sizes, with the sizes, size constraints and box sides the step reads of it: held in cells of its
+/// own or in cells of the parent that sizes it.
#[derive(Clone, Copy)]
pub(crate) struct SizedBox<'metrics> {
pub(crate) node: Node,
@@ -184,20 +180,22 @@ impl<'metrics> SizedBox<'metrics> {
}
}
-/// A box a sizing step sizes in its record, which the step writes what it resolves to.
+/// A box a sizing step sizes in its own cells, held in `frame`. The step reads the cells in that frame and writes to
+/// them what it resolves.
#[derive(Clone, Copy)]
-pub(crate) struct SizedRecord<'record> {
+pub(crate) struct SizedCells<'cells> {
pub(crate) node: Node,
- pub(crate) record: used_values::CellsInFrame<'record>,
+ pub(crate) cells: &'cells Cell<used_values::RootInputCells>,
+ pub(crate) frame: geometry::Frame,
}
-impl<'record> SizedRecord<'record> {
- pub(crate) fn new(node: Node, record: used_values::CellsInFrame<'record>) -> Self {
- Self { node, record }
+impl<'cells> SizedCells<'cells> {
+ pub(crate) fn new(node: Node, cells: &'cells Cell<used_values::RootInputCells>, frame: geometry::Frame) -> Self {
+ Self { node, cells, frame }
}
- pub(crate) fn sized_box(&self) -> SizedBox<'_> {
- SizedBox::of_own_metrics(self.node, &self.record, self.record.reader())
+ pub(crate) fn sized_box(&self) -> SizedBox<'cells> {
+ SizedBox::of_own_metrics(self.node, self.cells, self.frame)
}
}
@@ -1932,27 +1930,27 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
/// box's content block size is known. Without a known content block size, the content is measured.
pub(crate) fn apply_automatic_minimum_block_size_from_aspect_ratio(
&self,
- sized_record: SizedRecord<'_>,
+ sized_cells: SizedCells<'_>,
available_space: AvailableSpace,
constraints: ContainingBlockConstraints,
content_block_size: Option<CssPixels>,
) {
- let sized = sized_record.sized_box();
+ let sized = sized_cells.sized_box();
if !self.block_size_is_ratio_dependent(sized, available_space, constraints) {
return;
}
let Some(minimum) = self.automatic_minimum_size_from_aspect_ratio(
sized,
SizingAxis::Block,
- sized_record.record.content_inline_size(),
- sized_record.record.content_block_size(),
+ sized_cells.cells.content_inline_size(),
+ sized_cells.cells.content_block_size(),
available_space,
constraints,
content_block_size,
) else {
return;
};
- let used = sized_record.record;
+ let used = sized_cells.cells;
if used.content_block_size() < minimum {
used.set_content_block_size(minimum);
}
@@ -1960,13 +1958,13 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
pub(crate) fn resolve_used_block_size_if_not_treated_as_auto(
&self,
- sized_record: SizedRecord<'_>,
+ sized_cells: SizedCells<'_>,
available_space: AvailableSpace,
constraints: ContainingBlockConstraints,
) {
- let sized = sized_record.sized_box();
+ let sized = sized_cells.sized_box();
if let Some(resolved) = self.used_block_size_if_not_treated_as_auto(sized, available_space, constraints) {
- resolved.apply_to_record(sized_record.record);
+ sized_cells.cells.update_cells(|cells| resolved.apply_to_cells(cells));
}
}
@@ -1996,13 +1994,13 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
pub(crate) fn resolve_used_block_size_if_treated_as_auto(
&self,
- sized_record: SizedRecord<'_>,
+ sized_cells: SizedCells<'_>,
available_space: AvailableSpace,
constraints: ContainingBlockConstraints,
child_automatic_block_size: Option<CssPixels>,
automatic_block_size_fallback: impl FnOnce() -> CssPixels,
) {
- let sized = sized_record.sized_box();
+ let sized = sized_cells.sized_box();
if let Some(resolved) = self.used_block_size_if_treated_as_auto(
sized,
available_space,
@@ -2010,7 +2008,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
child_automatic_block_size,
automatic_block_size_fallback,
) {
- resolved.apply_to_record(sized_record.record);
+ sized_cells.cells.update_cells(|cells| resolved.apply_to_cells(cells));
}
}
@@ -2102,36 +2100,36 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
pub(crate) fn resolve_box_model_metrics_against_inline_basis(
&self,
- sized_record: SizedRecord<'_>,
+ sized_cells: SizedCells<'_>,
containing_inline_size: CssPixels,
) {
- let node = sized_record.node;
+ let node = sized_cells.node;
let style = self.style(node);
- let used = sized_record.record;
- used.resolve_box_model(&style, containing_inline_size);
+ let used = sized_cells.cells;
+ used.update_cells(|cells| cells.resolve_box_model(&style, containing_inline_size));
}
/// Sizes an empty atomic block. Where a committing layout takes its metrics from its committed fragment as they
/// are, returns that fragment.
pub(crate) fn dimension_empty_atomic_root(
&self,
- sized_record: SizedRecord<'_>,
+ sized_cells: SizedCells<'_>,
available_space: AvailableSpace,
constraints: ContainingBlockConstraints,
layout_builds_fragments: bool,
) -> Option<std::sync::Arc<fragment_tree::Fragment>> {
- if layout_builds_fragments && let Some(fragment) = self.try_reuse_empty_atomic_root_metrics(sized_record) {
+ if layout_builds_fragments && let Some(fragment) = self.try_reuse_empty_atomic_root_metrics(sized_cells) {
return Some(fragment);
}
- self.dimension_empty_atomic_root_fresh(sized_record, available_space, constraints);
+ self.dimension_empty_atomic_root_fresh(sized_cells, available_space, constraints);
None
}
fn try_reuse_empty_atomic_root_metrics(
&self,
- sized_record: SizedRecord<'_>,
+ sized_cells: SizedCells<'_>,
) -> Option<std::sync::Arc<fragment_tree::Fragment>> {
- let node = sized_record.node;
+ let node = sized_cells.node;
let facts = self.facts(node);
debug_assert!(
formatting_context::formatting_context_type_created_by_box(facts)
@@ -2158,55 +2156,55 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
{
return None;
}
- let used = sized_record.record;
+ let used = sized_cells.cells;
self.callbacks
.arena()
.with_current_committed_fragment(node, |fragment| {
- used.set_box_metrics_from_fragment(fragment);
+ used.update_cells(|cells| cells.take_box_metrics_of_fragment(fragment));
fragment.clone()
})
}
fn dimension_empty_atomic_root_fresh(
&self,
- sized_record: SizedRecord<'_>,
+ sized_cells: SizedCells<'_>,
available_space: AvailableSpace,
constraints: ContainingBlockConstraints,
) {
- let sized = sized_record.sized_box();
- self.dimension_atomic_root(sized_record, available_space, constraints, false);
+ let sized = sized_cells.sized_box();
+ self.dimension_atomic_root(sized_cells, available_space, constraints, false);
self.resolve_used_block_size_if_treated_as_auto(
- sized_record,
+ sized_cells,
available_space,
constraints,
Some(CssPixels::default()),
|| unreachable!("an empty atomic block has a zero automatic content block size"),
);
if !self.box_is_sized_as_replaced_element(sized, available_space, constraints) {
- self.resolve_used_block_size_if_not_treated_as_auto(sized_record, available_space, constraints);
+ self.resolve_used_block_size_if_not_treated_as_auto(sized_cells, available_space, constraints);
}
}
pub(crate) fn dimension_atomic_root(
&self,
- sized_record: SizedRecord<'_>,
+ sized_cells: SizedCells<'_>,
available_space: AvailableSpace,
constraints: ContainingBlockConstraints,
report_for_run_cache_the_available_inline_sizes_this_sizing_repeats_for: bool,
) -> Option<CssPixels> {
- let sized = sized_record.sized_box();
+ let sized = sized_cells.sized_box();
let node = sized.node;
let containing_inline_size = available_space.inline_size.to_px_or_zero();
let style = self.style(node);
- self.resolve_box_model_metrics_against_inline_basis(sized_record, containing_inline_size);
+ self.resolve_box_model_metrics_against_inline_basis(sized_cells, containing_inline_size);
let facts = self.facts(node);
if self.box_is_sized_as_replaced_element(sized, available_space, constraints) {
let inline_size = self.compute_inline_size_for_replaced_element(sized, available_space, constraints);
- sized_record.record.set_content_inline_size(inline_size);
+ sized_cells.cells.set_content_inline_size(inline_size);
let block_size = self.compute_block_size_for_replaced_element(sized, available_space, constraints);
- sized_record.record.set_content_block_size(block_size);
+ sized_cells.cells.set_content_block_size(block_size);
// Native form controls lay out their internal shadow contents against the concrete size produced by
// replaced sizing. That size remains definite when a min/max constraint clamps the automatic preferred
@@ -2222,21 +2220,21 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
let block_size_is_automatic = self.preferred_block_size(node, constraints).is_auto()
|| self.should_treat_block_size_as_auto(sized, available_space, constraints);
- let block_size_is_definite_from_aspect_ratio = sized_record.record.has_definite_inline_size()
+ let block_size_is_definite_from_aspect_ratio = sized_cells.cells.has_definite_inline_size()
&& facts.has_preferred_aspect_ratio()
&& block_size_is_automatic;
if native_control_block_size_constraint_is_active || block_size_is_definite_from_aspect_ratio {
- sized_record
- .record
+ sized_cells
+ .cells
.update_cells(|cells| cells.has_definite_block_size = true);
}
return None;
}
let resolution = self.calculate_atomic_root_content_inline_size(sized, available_space, constraints);
- sized_record
- .record
+ sized_cells
+ .cells
.set_content_inline_size(resolution.content_inline_size);
let sizing_repeats_for_available_inline_sizes_at_or_above =
report_for_run_cache_the_available_inline_sizes_this_sizing_repeats_for
@@ -2253,8 +2251,8 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
inline_size: AvailableSize::definite(resolution.content_inline_size),
block_size: AvailableSize::Indefinite,
};
- self.resolve_used_block_size_if_not_treated_as_auto(sized_record, inline_definite_space, constraints);
- self.make_form_control_content_box_definite(sized_record, available_space, constraints, None);
+ self.resolve_used_block_size_if_not_treated_as_auto(sized_cells, inline_definite_space, constraints);
+ self.make_form_control_content_box_definite(sized_cells, available_space, constraints, None);
sizing_repeats_for_available_inline_sizes_at_or_above
}
@@ -2720,7 +2718,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
self.single_content_inline_size(
sized,
constraints,
- self.definite_block_size_of_replaced_box_in_record(sized),
+ self.definite_block_size_of_replaced_box_in_held_metrics(sized),
IntrinsicSizeCacheKind::MaxContentInline,
)
}
@@ -2739,7 +2737,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
)
}
- fn definite_block_size_of_replaced_box_in_record(&self, sized: SizedBox<'_>) -> Option<CssPixels> {
+ fn definite_block_size_of_replaced_box_in_held_metrics(&self, sized: SizedBox<'_>) -> Option<CssPixels> {
let node = sized.node;
if !self.facts(node).is_replaced_box() {
return None;
@@ -3461,12 +3459,12 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
/// before the content is laid out, also where a min or max block size decides an automatic block size.
pub(crate) fn make_form_control_content_box_definite(
&self,
- sized_record: SizedRecord<'_>,
+ sized_cells: SizedCells<'_>,
available_space: AvailableSpace,
constraints: ContainingBlockConstraints,
measured_content_block_size: Option<CssPixels>,
) {
- let sized = sized_record.sized_box();
+ let sized = sized_cells.sized_box();
let node = sized.node;
let facts = self.facts(node);
// https://drafts.csswg.org/css-ui-4/#input-rules
@@ -3544,7 +3542,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
if !content_box_needs_to_be_definite {
return;
}
- sized_record.record.update_cells(|cells| {
+ sized_cells.cells.update_cells(|cells| {
cells.set_content_block_size(used_block_size);
cells.has_definite_block_size = true;
cells.has_definite_block_size_only_for_button_content_alignment =
diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rs
index 1cdf2699729..3bccb9b87c0 100644
--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs
@@ -451,58 +451,6 @@ impl BoxMetricCellsMut for Cell<RootInputCells> {
}
}
-/// Cells held in frame `held`, read and written in frame `reader`.
-#[derive(Clone, Copy)]
-pub(crate) struct CellsInFrame<'a> {
- cells: &'a Cell<RootInputCells>,
- held: geometry::Frame,
- reader: geometry::Frame,
-}
-
-impl<'a> CellsInFrame<'a> {
- /// `cells`, held in frame `held`, read in frame `reader`.
- #[inline]
- pub(crate) fn of_cells(cells: &'a Cell<RootInputCells>, held: geometry::Frame, reader: geometry::Frame) -> Self {
- Self { cells, held, reader }
- }
-
- /// The frame the cells are read in.
- pub(crate) fn reader(&self) -> geometry::Frame {
- self.reader
- }
-
- /// 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);
- self.cells.set(cells.in_frame(self.reader, self.held));
- }
-
- pub(crate) fn set_content_inline_size(self, value: CssPixels) {
- self.update_cells(|cells| cells.set_content_inline_size(value));
- }
-
- pub(crate) fn set_content_block_size(self, value: CssPixels) {
- self.update_cells(|cells| cells.set_content_block_size(value));
- }
-
- /// Resolves every margin, border and padding of `style`, with percentages against `basis`.
- pub(crate) fn resolve_box_model(self, style: &StyleValues<'_>, basis: CssPixels) {
- self.update_cells(|cells| cells.resolve_box_model(style, basis));
- }
-
- pub(crate) fn set_box_metrics_from_fragment(self, fragment: &fragment_tree::Fragment) {
- self.update_cells(|cells| cells.take_box_metrics_of_fragment(fragment));
- }
-}
-
-impl BoxMetricCells for CellsInFrame<'_> {
- #[inline]
- fn cells(&self) -> RootInputCells {
- self.cells.get().in_frame(self.held, self.reader)
- }
-}
-
/// The part of a collapsed border that lies after its grid line (below or right of it), the rest lying before it.
/// A collapsed border "is centered on the grid line" (CSS 2.2 §17.6.2), but layout keeps box edges on whole CSS
/// pixels, so the border is split on whole pixels, an odd width giving its extra pixel to the part before the line.