Skip to content

Truly independent web browser

LibWeb: Read box records through a view in the reader's frame

Aliaksandr Kalenik66d78750e179
diff --git a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
index 9a869908008..cbcb607b17b 100644
--- a/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
+++ b/Libraries/LibWeb/Rust/src/layout/abspos_engine.rs
@@ -265,9 +265,17 @@ impl<'pass> AbsposEngine<'pass> {
NodeFacts::new(&self.callbacks, node)
}
+ /// The record of `node`, read in the frame this engine places boxes in.
#[track_caller]
- fn used(&self, node: Node) -> &'pass UsedValues {
- self.records.used_values(node)
+ fn used(&self, node: Node) -> used_values::RecordInFrame<'pass> {
+ used_values::RecordInFrame::new(self.records.used_values(node), self.callbacks.frame)
+ }
+
+ /// The sizes, size constraints and box sides of `node`, with its record read in the frame this engine places boxes
+ /// in.
+ #[track_caller]
+ fn box_metrics(&self, node: Node) -> run_records::BoxMetrics<'pass> {
+ self.records.box_metrics_in_frame(node, self.callbacks.frame)
}
fn base_containing_block_info(
@@ -790,7 +798,9 @@ impl AbsposEngine<'_> {
}
let containing_block_geometry = match entry_containing_block_geometry {
Some(geometry) => *geometry,
- None => ContainingBlockGeometry::from_box_metrics(self.used(containing_block), FfiCssPixelPoint::default()),
+ None => {
+ ContainingBlockGeometry::from_box_metrics(&self.used(containing_block), FfiCssPixelPoint::default())
+ }
};
let default_anchor_box = if style.has_position_anchor() {
self.anchor_lookup(node, style.position_anchor_name())
@@ -976,7 +986,7 @@ impl AbsposEngine<'_> {
if inputs.resolved_anchor_sizes.is_empty() {
return;
}
- let used = self.used(node);
+ let used = self.used(node).record();
if used.anchor_resolved_values.get().is_none() {
let _ = used
.anchor_resolved_values
@@ -1797,7 +1807,7 @@ pub(crate) fn solve_replaced_axis(
impl AbsposEngine<'_> {
fn static_offset(&self, node: Node, rect: abspos_inputs::StaticPositionRect) -> geometry::LogicalOffset {
- let metrics = self.records.box_metrics_of(node);
+ let metrics = self.box_metrics(node);
let collapsed = metrics.uses_collapsing_borders_model();
aligned_static_offset(
rect,
@@ -3149,7 +3159,7 @@ impl<'pass> AbsposEngine<'pass> {
};
let static_offset = self.static_offset(node, inputs.static_position_rect);
- let metrics = self.records.box_metrics_of(node);
+ let metrics = self.box_metrics(node);
let collapsed = metrics.uses_collapsing_borders_model();
let mut used_offset = geometry::LogicalOffset {
inline_offset: if inputs.containing_block_info.inline_axis_mode
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
index ee09f06c1bf..0b6d09c2699 100644
--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs
@@ -1310,6 +1310,12 @@ impl<'pass> FormattingContextRun<'pass> {
sizing_context::SizingContext::new(self.records, self.callbacks)
}
+ /// 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)
+ }
+
/// Hands what the layout of `node` produced besides its geometry to the box's fragment, where this run builds
/// fragments.
pub(crate) fn update_fragment_payloads_of(
@@ -1329,11 +1335,10 @@ impl<'pass> FormattingContextRun<'pass> {
inputs_never_observed: fc_run_cache::RunInputsTheStoredRunNeverObserved,
parent_owns_root_input_cells: bool,
) -> RunOutputs {
- let record = self.records.used_values(self.box_);
+ let record = self.root_record();
let root_outcome = RunRootOutcome {
- input_cells_left_by_run: (!parent_owns_root_input_cells)
- .then(|| used_values::RootInputCells::capture(record)),
- line_data: record.finish_line_data(&self.callbacks),
+ input_cells_left_by_run: (!parent_owns_root_input_cells).then(|| record.cells()),
+ line_data: record.record().finish_line_data(&self.callbacks),
};
RunOutputs {
result,
@@ -1579,8 +1584,7 @@ fn eagerly_resolve_atomic_flex_root_auto_block_size(
independent_root_automatic_block_size(
&sizing,
node,
- run.records
- .used_values(node)
+ run.root_record()
.available_inner_space_or_constraints_from(inline_definite_space),
input.containing_block_constraints,
None,
@@ -1617,7 +1621,7 @@ fn apply_root_sizing_directives(
);
let mut body_input = body_input_with_inner_available_space(run, input);
let inline_definite_space = AvailableSpace {
- inline_size: AvailableSize::definite(run.records.used_values(run.box_).content_inline_size()),
+ inline_size: AvailableSize::definite(run.root_record().content_inline_size()),
block_size: AvailableSize::Indefinite,
};
let flex_self_resolution_space = flex_self_block_size_resolution_space(
@@ -1639,7 +1643,7 @@ fn apply_root_sizing_directives(
ParticipationInParentFormattingContext::Item => {
if cfg!(debug_assertions) && run.fragments.is_some() {
debug_assert!(
- run.records.used_values(run.box_).has_definite_inline_size(),
+ run.root_record().has_definite_inline_size(),
"container-internal run root must arrive with a container-assigned inline size"
);
}
@@ -1648,7 +1652,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 = run.records.used_values(run.box_);
+ let used = run.root_record();
if let Some(inline_size) = directives.forced_content_inline_size {
used.set_content_inline_size(inline_size);
}
@@ -1680,7 +1684,7 @@ fn dimension_block_level_root(
let mut body_input = body_input_with_inner_available_space(run, 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 = run.records.used_values(node);
+ let used = run.root_record();
used.set_content_block_size(block_size);
used.set_has_definite_block_size(true);
body_input.available_space.block_size = AvailableSize::definite(block_size);
@@ -1711,7 +1715,7 @@ fn size_block_level_root_ahead_of_its_contents(
input: &LayoutInput,
) -> Option<AvailableSpace> {
let node = run.box_;
- let root = run.records.used_values(node);
+ let root = run.root_record();
let constraints = input.containing_block_constraints;
let sizing = run.sizing();
let facts = NodeFacts::new(&run.callbacks, node);
@@ -1746,7 +1750,7 @@ 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, input: &LayoutInput) {
let node = run.box_;
- let root = run.records.used_values(node);
+ let root = run.root_record();
let available_space = input.available_space;
let constraints = input.containing_block_constraints;
let sizing = run.sizing();
@@ -1832,7 +1836,7 @@ fn in_flow_children_margin_box_block_extent(
fn finalize_block_level_root(run: &FormattingContextRun, input: &LayoutInput, body_result: &ChildLayoutResult) {
let node = run.box_;
if let Some(inline_size) = body_result.table_wrapper_content_inline_size {
- run.records.used_values(node).set_content_inline_size(inline_size);
+ run.root_record().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() {
@@ -1855,7 +1859,7 @@ fn finalize_block_level_root(run: &FormattingContextRun, input: &LayoutInput, bo
fn finalize_float_root(run: &FormattingContextRun, input: &LayoutInput, body_result: &ChildLayoutResult) {
let node = run.box_;
if let Some(inline_size) = body_result.table_wrapper_content_inline_size {
- run.records.used_values(node).set_content_inline_size(inline_size);
+ run.root_record().set_content_inline_size(inline_size);
}
run.sizing().resolve_used_block_size_if_treated_as_auto(
node,
@@ -1919,8 +1923,7 @@ fn size_skipped_independent_root(
fn body_input_with_inner_available_space(run: &FormattingContextRun, input: &LayoutInput) -> LayoutInput {
let inner_available_space = run
- .records
- .used_values(run.box_)
+ .root_record()
.available_inner_space_or_constraints_from(input.available_space);
let mut body_input = *input;
body_input.available_space = inner_available_space;
@@ -2218,7 +2221,7 @@ fn execute_formatting_context_run(
parent_owns_root_input_cells,
);
let root_cells_left_by_run = checks_root_input_cells_its_parent_owns
- .then(|| used_values::RootInputCells::capture(records.used_values(box_)));
+ .then(|| used_values::RecordInFrame::new(records.used_values(box_), callbacks.frame).cells());
(outputs, root_cells_left_by_run)
},
);
@@ -2458,7 +2461,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)
{
- run.records.used_values(run.box_).set_content_block_size(block_size);
+ run.root_record().set_content_block_size(block_size);
}
}
ParticipationInParentFormattingContext::Root => {}
diff --git a/Libraries/LibWeb/Rust/src/layout/run_records.rs b/Libraries/LibWeb/Rust/src/layout/run_records.rs
index 46407d71195..173ad2dcc76 100644
--- a/Libraries/LibWeb/Rust/src/layout/run_records.rs
+++ b/Libraries/LibWeb/Rust/src/layout/run_records.rs
@@ -404,7 +404,7 @@ pub(crate) struct ChildLaidOutByItsOwnRun {
#[derive(Clone, Copy)]
pub(crate) enum BoxMetrics<'records> {
LaidOutByItsOwnRun(LaidOutChildBox),
- LaidOutByThisRun(&'records UsedValues),
+ LaidOutByThisRun(used_values::RecordInFrame<'records>),
/// A child this run sizes in cells of its own before laying it out by a run of its own.
BeingSizedByItsParent(used_values::RootInputCells),
}
@@ -413,7 +413,7 @@ impl BoxMetrics<'_> {
pub(crate) fn input_cells(&self) -> used_values::RootInputCells {
match self {
Self::LaidOutByItsOwnRun(laid_out) => laid_out.cells,
- Self::LaidOutByThisRun(record) => used_values::RootInputCells::capture(record),
+ Self::LaidOutByThisRun(record) => record.cells(),
Self::BeingSizedByItsParent(cells) => *cells,
}
}
@@ -421,7 +421,7 @@ impl BoxMetrics<'_> {
pub(crate) fn content_baselines(&self) -> DerivedBaselines {
match self {
Self::LaidOutByItsOwnRun(laid_out) => laid_out.baselines,
- Self::LaidOutByThisRun(record) => record.content_baselines_from_cells(),
+ Self::LaidOutByThisRun(record) => record.record().content_baselines_from_cells(),
Self::BeingSizedByItsParent(_) => DerivedBaselines::default(),
}
}
@@ -1083,7 +1083,12 @@ impl<'arena> RunRecords<'arena> {
/// out by a run of its own.
pub(crate) fn box_metrics_of_if_owned(&self, node: Node) -> Option<BoxMetrics<'_>> {
let index = match self.held_box(node)? {
- HeldBox::RootWithRecord => return self.root_used.as_ref().map(BoxMetrics::LaidOutByThisRun),
+ HeldBox::RootWithRecord => {
+ return self
+ .root_used
+ .as_ref()
+ .map(|record| BoxMetrics::LaidOutByThisRun(used_values::RecordInFrame::in_its_own_frame(record)));
+ }
HeldBox::Kept(index) => index,
};
let record = match &self.scratch.kept_boxes.borrow()[index as usize].holding {
@@ -1096,9 +1101,30 @@ impl<'arena> RunRecords<'arena> {
}
};
// SAFETY: This run registered the record, and it stays on the stack until this run returns.
- Some(BoxMetrics::LaidOutByThisRun(unsafe {
- self.scratch.run_record_stack.get(record).as_ref()
- }))
+ Some(BoxMetrics::LaidOutByThisRun(
+ used_values::RecordInFrame::in_its_own_frame(unsafe { self.scratch.run_record_stack.get(record).as_ref() }),
+ ))
+ }
+
+ /// The sizes, size constraints, box sides and baselines of `node` as box_metrics_of() has them, with the record of a
+ /// box this run lays out read in frame `reader`.
+ #[track_caller]
+ pub(crate) fn box_metrics_in_frame(&self, node: Node, reader: geometry::Frame) -> BoxMetrics<'_> {
+ match self.box_metrics_in_frame_if_owned(node, reader) {
+ Some(metrics) => metrics,
+ None => self.panic_for_box_not_held(node),
+ }
+ }
+
+ /// The sizes, size constraints, box sides and baselines of `node` as box_metrics_of_if_owned() has them, with the
+ /// record of a box this run lays out read in frame `reader`.
+ pub(crate) fn box_metrics_in_frame_if_owned(&self, node: Node, reader: geometry::Frame) -> Option<BoxMetrics<'_>> {
+ Some(match self.box_metrics_of_if_owned(node)? {
+ BoxMetrics::LaidOutByThisRun(record) => {
+ BoxMetrics::LaidOutByThisRun(used_values::RecordInFrame::new(record.record(), reader))
+ }
+ metrics_kept_as_a_value => metrics_kept_as_a_value,
+ })
}
/// The sizes, size constraints and box sides this run holds for `node`, if it holds the box, read in frame `reader`.
diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs
index 5d2222643ae..13ef51bc9b6 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: &UsedValues) {
+ pub(crate) fn apply_to_record(self, used: used_values::RecordInFrame<'_>) {
used.set_content_block_size(self.content_block_size);
if self.makes_block_size_definite {
used.set_has_definite_block_size(true);
@@ -251,9 +251,10 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
style.with_anchor_resolved_values(anchor_resolved_values)
}
+ /// The record of `node`, read in the frame this context sizes in.
#[track_caller]
- fn used(&self, node: Node) -> &'pass UsedValues {
- self.records.used_values(node)
+ fn used(&self, node: Node) -> used_values::RecordInFrame<'pass> {
+ used_values::RecordInFrame::new(self.records.used_values(node), self.callbacks.frame)
}
/// The sizes, size constraints and box sides of `node` as this context sizes it.
@@ -264,7 +265,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
{
return run_records::BoxMetrics::BeingSizedByItsParent(cells);
}
- self.records.box_metrics_of(node)
+ self.records.box_metrics_in_frame(node, self.callbacks.frame)
}
/// The sizes, size constraints and box sides of `node` as this context sizes it, if its run holds them.
@@ -274,7 +275,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {
{
return Some(run_records::BoxMetrics::BeingSizedByItsParent(cells));
}
- self.records.box_metrics_of_if_owned(node)
+ self.records.box_metrics_in_frame_if_owned(node, self.callbacks.frame)
}
fn first_child(&self, node: Node) -> Node {
diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rs
index d52a0a2f0f5..42d4041656b 100644
--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs
+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs
@@ -261,30 +261,9 @@ impl Default for UsedValues {
}
impl UsedValues {
- /// Resolves the left and right margins, borders and padding of `style`, with percentages against `basis`.
- pub(crate) fn resolve_horizontal_box_model(&self, style: &StyleValues<'_>, basis: CssPixels) {
- self.margin_left.set(style.margin_left().to_px(basis));
- self.margin_right.set(style.margin_right().to_px(basis));
- self.border_left.set(style.border_left_width());
- self.border_right.set(style.border_right_width());
- self.padding_left.set(style.padding_left().to_px(basis));
- self.padding_right.set(style.padding_right().to_px(basis));
- }
-
- /// Resolves the top and bottom margins, borders and padding of `style`, with percentages against `basis`.
- pub(crate) fn resolve_vertical_box_model(&self, style: &StyleValues<'_>, basis: CssPixels) {
- self.margin_top.set(style.margin_top().to_px(basis));
- self.margin_bottom.set(style.margin_bottom().to_px(basis));
- self.border_top.set(style.border_top_width());
- self.border_bottom.set(style.border_bottom_width());
- self.padding_top.set(style.padding_top().to_px(basis));
- self.padding_bottom.set(style.padding_bottom().to_px(basis));
- }
-
/// Resolves every margin, border and padding of `style`, with percentages against `basis`.
pub(crate) fn resolve_box_model(&self, style: &StyleValues<'_>, basis: CssPixels) {
- self.resolve_horizontal_box_model(style, basis);
- self.resolve_vertical_box_model(style, basis);
+ RecordInFrame::in_its_own_frame(self).resolve_box_model(style, basis);
}
pub(crate) fn line_data_ref(&self) -> Option<Ref<'_, LineDataState>> {
@@ -619,20 +598,7 @@ impl UsedValues {
}
pub(crate) fn set_box_metrics_from_fragment(&self, fragment: &fragment_tree::Fragment) {
- self.set_content_inline_size(fragment.content_inline_size);
- self.set_content_block_size(fragment.content_block_size);
- self.margin_left.set(fragment.margin_left);
- self.margin_right.set(fragment.margin_right);
- self.margin_top.set(fragment.margin_top);
- self.margin_bottom.set(fragment.margin_bottom);
- self.border_left.set(fragment.border_left);
- self.border_right.set(fragment.border_right);
- self.border_top.set(fragment.border_top);
- self.border_bottom.set(fragment.border_bottom);
- self.padding_left.set(fragment.padding_left);
- self.padding_right.set(fragment.padding_right);
- self.padding_top.set(fragment.padding_top);
- self.padding_bottom.set(fragment.padding_bottom);
+ RecordInFrame::in_its_own_frame(self).set_box_metrics_from_fragment(fragment);
}
/// Whether `fragment` shows this record's box as it stands: its metrics, and the very line data it holds.
@@ -842,6 +808,260 @@ macro_rules! impl_box_metric_cells {
impl_box_metric_cells!(UsedValues, cell);
impl_box_metric_cells!(RootInputCells, value);
+/// 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.
+#[derive(Clone, Copy)]
+pub(crate) struct RecordInFrame<'record> {
+ record: &'record UsedValues,
+ reader: geometry::Frame,
+}
+
+impl<'record> RecordInFrame<'record> {
+ /// The 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 {
+ Self {
+ record,
+ reader: record.frame.get(),
+ }
+ }
+
+ /// The record, for what it holds besides the metrics this view projects.
+ #[inline]
+ pub(crate) fn record(self) -> &'record UsedValues {
+ self.record
+ }
+
+ #[inline]
+ fn sizes_swap_axes(self) -> bool {
+ self.record.frame.get().is_orthogonal_to(self.reader)
+ }
+
+ /// The side the record holds the given side of the reader's frame on.
+ #[inline]
+ fn stored_side(self, side: geometry::Side) -> geometry::Side {
+ let record_frame = self.record.frame.get();
+ if record_frame == self.reader {
+ return side;
+ }
+ self.reader.side_in(side, record_frame)
+ }
+
+ /// The record's input cells, read in the reader's frame.
+ pub(crate) fn cells(self) -> RootInputCells {
+ RootInputCells::capture(self.record).in_frame(self.record.frame.get(), self.reader)
+ }
+
+ pub(crate) fn set_content_inline_size(self, value: CssPixels) {
+ if self.sizes_swap_axes() {
+ self.record.set_content_block_size(value);
+ self.record.set_has_definite_block_size(true);
+ } else {
+ self.record.set_content_inline_size(value);
+ }
+ }
+
+ pub(crate) fn set_content_block_size(self, value: CssPixels) {
+ if self.sizes_swap_axes() {
+ self.record
+ .content_inline_size
+ .set(clamp_to_max_dimension_value(value.max(CssPixels::default())));
+ } else {
+ self.record.set_content_block_size(value);
+ }
+ }
+
+ #[track_caller]
+ pub(crate) fn set_margin(self, side: geometry::Side, value: CssPixels) {
+ self.record.set_margin(self.stored_side(side), value);
+ }
+
+ #[track_caller]
+ pub(crate) fn set_border(self, side: geometry::Side, value: CssPixels) {
+ self.record.set_border(self.stored_side(side), value);
+ }
+
+ #[track_caller]
+ pub(crate) fn set_padding(self, side: geometry::Side, value: CssPixels) {
+ self.record.set_padding(self.stored_side(side), value);
+ }
+
+ pub(crate) fn set_has_definite_inline_size(self, value: bool) {
+ if self.sizes_swap_axes() {
+ self.record.set_has_definite_block_size(value);
+ } else {
+ self.record.set_has_definite_inline_size(value);
+ }
+ }
+
+ pub(crate) fn set_has_definite_block_size(self, value: bool) {
+ if self.sizes_swap_axes() {
+ self.record.set_has_definite_inline_size(value);
+ } else {
+ self.record.set_has_definite_block_size(value);
+ }
+ }
+
+ pub(crate) fn set_has_definite_block_size_only_for_button_content_alignment(self, value: bool) {
+ self.record
+ .set_has_definite_block_size_only_for_button_content_alignment(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.set_margin(geometry::Side::Left, style.margin_left().to_px(basis));
+ self.set_margin(geometry::Side::Right, style.margin_right().to_px(basis));
+ self.set_border(geometry::Side::Left, style.border_left_width());
+ self.set_border(geometry::Side::Right, style.border_right_width());
+ self.set_padding(geometry::Side::Left, style.padding_left().to_px(basis));
+ self.set_padding(geometry::Side::Right, style.padding_right().to_px(basis));
+ self.set_margin(geometry::Side::Top, style.margin_top().to_px(basis));
+ self.set_margin(geometry::Side::Bottom, style.margin_bottom().to_px(basis));
+ self.set_border(geometry::Side::Top, style.border_top_width());
+ self.set_border(geometry::Side::Bottom, style.border_bottom_width());
+ self.set_padding(geometry::Side::Top, style.padding_top().to_px(basis));
+ self.set_padding(geometry::Side::Bottom, style.padding_bottom().to_px(basis));
+ }
+
+ pub(crate) fn set_box_metrics_from_fragment(self, fragment: &fragment_tree::Fragment) {
+ self.set_content_inline_size(fragment.content_inline_size);
+ self.set_content_block_size(fragment.content_block_size);
+ self.set_margin(geometry::Side::Left, fragment.margin_left);
+ self.set_margin(geometry::Side::Right, fragment.margin_right);
+ self.set_margin(geometry::Side::Top, fragment.margin_top);
+ self.set_margin(geometry::Side::Bottom, fragment.margin_bottom);
+ self.set_border(geometry::Side::Left, fragment.border_left);
+ self.set_border(geometry::Side::Right, fragment.border_right);
+ self.set_border(geometry::Side::Top, fragment.border_top);
+ self.set_border(geometry::Side::Bottom, fragment.border_bottom);
+ self.set_padding(geometry::Side::Left, fragment.padding_left);
+ self.set_padding(geometry::Side::Right, fragment.padding_right);
+ self.set_padding(geometry::Side::Top, fragment.padding_top);
+ self.set_padding(geometry::Side::Bottom, fragment.padding_bottom);
+ }
+}
+
+impl BoxMetricCells for RecordInFrame<'_> {
+ #[inline]
+ fn content_inline_size(&self) -> CssPixels {
+ if self.sizes_swap_axes() {
+ self.record.content_block_size.get()
+ } else {
+ self.record.content_inline_size.get()
+ }
+ }
+
+ #[inline]
+ fn content_block_size(&self) -> CssPixels {
+ if self.sizes_swap_axes() {
+ self.record.content_inline_size.get()
+ } else {
+ self.record.content_block_size.get()
+ }
+ }
+
+ #[inline]
+ fn margin_left(&self) -> CssPixels {
+ self.record.margin_cell(self.stored_side(geometry::Side::Left)).get()
+ }
+
+ #[inline]
+ fn margin_right(&self) -> CssPixels {
+ self.record.margin_cell(self.stored_side(geometry::Side::Right)).get()
+ }
+
+ #[inline]
+ fn margin_top(&self) -> CssPixels {
+ self.record.margin_cell(self.stored_side(geometry::Side::Top)).get()
+ }
+
+ #[inline]
+ fn margin_bottom(&self) -> CssPixels {
+ self.record.margin_cell(self.stored_side(geometry::Side::Bottom)).get()
+ }
+
+ #[inline]
+ fn border_left(&self) -> CssPixels {
+ self.record.border_cell(self.stored_side(geometry::Side::Left)).get()
+ }
+
+ #[inline]
+ fn border_right(&self) -> CssPixels {
+ self.record.border_cell(self.stored_side(geometry::Side::Right)).get()
+ }
+
+ #[inline]
+ fn border_top(&self) -> CssPixels {
+ self.record.border_cell(self.stored_side(geometry::Side::Top)).get()
+ }
+
+ #[inline]
+ fn border_bottom(&self) -> CssPixels {
+ self.record.border_cell(self.stored_side(geometry::Side::Bottom)).get()
+ }
+
+ #[inline]
+ fn padding_left(&self) -> CssPixels {
+ self.record.padding_cell(self.stored_side(geometry::Side::Left)).get()
+ }
+
+ #[inline]
+ fn padding_right(&self) -> CssPixels {
+ self.record.padding_cell(self.stored_side(geometry::Side::Right)).get()
+ }
+
+ #[inline]
+ fn padding_top(&self) -> CssPixels {
+ self.record.padding_cell(self.stored_side(geometry::Side::Top)).get()
+ }
+
+ #[inline]
+ fn padding_bottom(&self) -> CssPixels {
+ self.record.padding_cell(self.stored_side(geometry::Side::Bottom)).get()
+ }
+
+ #[inline]
+ fn has_definite_inline_size(&self) -> bool {
+ if self.sizes_swap_axes() {
+ self.record.has_definite_block_size.get()
+ } else {
+ self.record.has_definite_inline_size.get()
+ }
+ }
+
+ #[inline]
+ fn has_definite_block_size(&self) -> bool {
+ if self.sizes_swap_axes() {
+ self.record.has_definite_inline_size.get()
+ } else {
+ self.record.has_definite_block_size.get()
+ }
+ }
+
+ #[inline]
+ fn has_definite_block_size_only_for_button_content_alignment(&self) -> bool {
+ self.record
+ .has_definite_block_size_only_for_button_content_alignment
+ .get()
+ }
+
+ #[inline]
+ fn uses_collapsing_borders_model(&self) -> bool {
+ self.record.uses_collapsing_borders_model.get()
+ }
+
+ #[inline]
+ fn is_collapsed_borders_table_box(&self) -> bool {
+ self.record.is_collapsed_borders_table_box.get()
+ }
+}
+
/// 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.