Truly independent web browser
LibWeb: Keep what a child's run hands back as a value
Aliaksandr Kalenik4c22a651c641
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex fa2ba9837ca..ffdf8a53628 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -127,6 +127,7 @@ pub(crate) fn run_root_without_parent_fragments(let ChildRunOutcome {result,fragment_arrival,+ ..} = run_formatting_context(None,&root_used,@@ -1110,6 +1111,30 @@ pub(crate) struct RunRootOutcome {}impl RunRootOutcome {+ /// What the parent keeps of the root once its run returns, given the input cells it handed the run.+ fn laid_out_child_box(+ &self,+ root_cells: used_values::RootInputCells,+ content_block_size_adopted_after_run: Option<CssPixels>,+ ) -> run_records::LaidOutChildBox {+ let (mut cells, outputs) = match self.cells {+ RootCellsOutcome::AllCells(state) => (state.inputs, state.outputs),+ RootCellsOutcome::OutputCellsOnly(outputs) => (root_cells, outputs),+ };+ if let Some(block_size) = content_block_size_adopted_after_run {+ cells.content_block_size = clamp_to_max_dimension_value(block_size.max(CssPixels::default()));+ }+ run_records::LaidOutChildBox {+ cells,+ baselines: DerivedBaselines {+ inline_alignment: outputs.inline_alignment_baseline,+ first: outputs.has_first_baseline.then_some(outputs.first_baseline),+ last: outputs.has_last_baseline.then_some(outputs.last_baseline),+ },+ orthogonal_flow_baselines: outputs.orthogonal_flow_baselines,+ }+ }+fn apply_to_record(self, record: &UsedValues, content_block_size_adopted_after_run: Option<CssPixels>) {self.cells.apply_to_record(record);if let Some(block_size) = content_block_size_adopted_after_run@@ -1917,11 +1942,12 @@ fn body_input_with_inner_available_space(run: &FormattingContextRun, input: &Laybody_input}-/// What a child's run gives its parent: its result, and the fragments its placement takes where the parent builds-/// fragments.+/// What a child's run gives its parent: its result, the box as the parent keeps it, and the fragments its placement+/// takes where the parent builds fragments.#[must_use]pub(crate) struct ChildRunOutcome {pub(crate) result: ChildLayoutResult,+ pub(crate) laid_out_box: run_records::LaidOutChildBox,pub(crate) fragment_arrival: Option<fragment_tree::ChildFragmentArrival>,}@@ -1959,7 +1985,16 @@ pub(super) fn run_formatting_context(table_inline_layout,None,);- return absorb_run_outputs(&callbacks, parent_fragments, parent_used, box_, &input, outputs, false);+ return absorb_run_outputs(+ &callbacks,+ parent_fragments,+ parent_used,+ box_,+ &input,+ root_cells,+ outputs,+ false,+ );}let cache_key = fc_run_cache::FcRunCacheKey::new(fc_type, input, root_cells);let cache_attempt = match fc_run_cache::FcRunCacheAttempt::probe(@@ -1973,17 +2008,19 @@ pub(super) fn run_formatting_context() {Ok(attempt) => attempt,Err(hit) => {- if let Some((result, fragment)) = reuse_committed_subtree_as_it_is(+ if let Some((result, laid_out_box, fragment)) = reuse_committed_subtree_as_it_is(parent_fragments,parent_used,box_,&input,+ root_cells,&callbacks,&cache_key,&hit,) {return ChildRunOutcome {result,+ laid_out_box,fragment_arrival: Some(fragment_tree::ChildFragmentArrival::CommittedFragment {fragment,reuses_subtree: true,@@ -2010,6 +2047,7 @@ pub(super) fn run_formatting_context(parent_used,box_,&input,+ root_cells,outputs,reuses_committed_subtree,);@@ -2079,22 +2117,37 @@ pub(super) fn run_formatting_context();}cache_attempt.conclude(&callbacks, box_, cache_key, &input, &outputs);- absorb_run_outputs(&callbacks, parent_fragments, parent_used, box_, &input, outputs, false)+ absorb_run_outputs(+ &callbacks,+ parent_fragments,+ parent_used,+ box_,+ &input,+ root_cells,+ outputs,+ false,+ )}/// Takes a committing run of `box_` from the cache hit `hit` with nothing replayed: its root record gets what the/// stored run left, and the run's placement attaches the box's committed fragment as it is. That is exact where the/// committed subtree is the one the stored run produced, the box is plain, and nothing from the stored run reaches/// past its root.+#[expect(clippy::too_many_arguments)]fn reuse_committed_subtree_as_it_is(parent_fragments: Option<&fragment_tree::RunFragmentBuilder>,root_used: &UsedValues,box_: Node,input: &LayoutInput,+ root_cells: used_values::RootInputCells,callbacks: &LayoutPass<'_>,cache_key: &fc_run_cache::FcRunCacheKey,hit: &fc_run_cache::FcRunCacheHit,-) -> Option<(ChildLayoutResult, std::sync::Arc<fragment_tree::Fragment>)> {+) -> Option<(+ ChildLayoutResult,+ run_records::LaidOutChildBox,+ std::sync::Arc<fragment_tree::Fragment>,+)> {parent_fragments?;let entry = &*hit.entry;if !hit.reuses_committed_subtree@@ -2112,10 +2165,13 @@ fn reuse_committed_subtree_as_it_is(.arena().with_current_committed_fragment(box_, |fragment| fragment.is_plain_box().then(|| fragment.clone())).flatten()?;- entry.outputs.root_outcome.clone().apply_to_record(- root_used,- content_block_size_adopted_after_run(input, entry.outputs.result.automatic_content_block_size),- );+ let content_block_size_adopted_after_run =+ content_block_size_adopted_after_run(input, entry.outputs.result.automatic_content_block_size);+ entry+ .outputs+ .root_outcome+ .clone()+ .apply_to_record(root_used, content_block_size_adopted_after_run);if !root_used.shows_box_of_fragment(&fragment) {return None;}@@ -2126,7 +2182,11 @@ fn reuse_committed_subtree_as_it_is(callbacks.scratch().receive_host_findings(entry.outputs.host_findings.clone());- Some((entry.outputs.result, fragment))+ let laid_out_box = entry+ .outputs+ .root_outcome+ .laid_out_child_box(root_cells, content_block_size_adopted_after_run);+ Some((entry.outputs.result, laid_out_box, fragment))}pub(crate) fn explicit_intrinsic_inner_inline_size(facts: &NodeFacts<'_>) -> CssPixels {@@ -2836,6 +2896,7 @@ pub(crate) fn layout_inside_child(dimension_root_in_parent_scope(parent_block, child, &input, true);let ChildRunOutcome {result,+ laid_out_box,fragment_arrival,} = run_formatting_context(run.fragments.as_deref(),@@ -2849,6 +2910,7 @@ pub(crate) fn layout_inside_child(input,run.records.take_table_inline_layout(child),);+ run.records.receive_laid_out_child_box(child, laid_out_box);ChildLayout {outcome: ChildLayoutOutcome::Created(result),fragment_arrival,@@ -3168,12 +3230,14 @@ pub(super) fn run_reads_content_block_size_adopted_after_it(&& fc_type.registers_abspos_children_against_its_final_block_size()}+#[expect(clippy::too_many_arguments)]fn absorb_run_outputs(callbacks: &LayoutPass<'_>,parent_fragments: Option<&fragment_tree::RunFragmentBuilder>,parent_used: &UsedValues,child: Node,input: &LayoutInput,+ root_cells: used_values::RootInputCells,outputs: RunOutputs,reuses_committed_subtree: bool,) -> ChildRunOutcome {@@ -3185,10 +3249,10 @@ fn absorb_run_outputs(host_findings,} = outputs;callbacks.scratch().receive_host_findings(host_findings);- root_outcome.apply_to_record(- parent_used,- content_block_size_adopted_after_run(input, result.automatic_content_block_size),- );+ let content_block_size_adopted_after_run =+ content_block_size_adopted_after_run(input, result.automatic_content_block_size);+ let laid_out_box = root_outcome.laid_out_child_box(root_cells, content_block_size_adopted_after_run);+ root_outcome.apply_to_record(parent_used, content_block_size_adopted_after_run);let fragment_arrival = parent_fragments.and(root).map(|root| {debug_assert!(root.node == child, "a child run returned a root for a different box");fragment_tree::ChildFragmentArrival::RunRoot {@@ -3198,6 +3262,7 @@ fn absorb_run_outputs(});ChildRunOutcome {result,+ laid_out_box,fragment_arrival,}}diff --git a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rsindex 8ad25a35266..8d47415f238 100644--- a/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/math_formatting_context.rs@@ -2143,7 +2143,6 @@ impl<'pass> MathFormattingContext<'pass> {ParticipationInParentFormattingContext::AtomicInline,);input.sizing.math_stretch_size_constraint = stretch_size_constraint;- let used = run.records.used_values(child);let formatting_context::ChildLayout {outcome,fragment_arrival,@@ -2152,21 +2151,20 @@ impl<'pass> MathFormattingContext<'pass> {self.fragment_arrivals_of_children.borrow_mut().push(fragment_arrival);}outcome.report_percentage_block_size_dependency_of(run, child);+ let metrics = run.records.box_metrics_of(child);let baselines = match outcome {ChildLayoutOutcome::Created(result) => result.baselines,- ChildLayoutOutcome::ReenterCurrent | ChildLayoutOutcome::Skipped { .. } => {- used.content_baselines_from_cells()- }+ ChildLayoutOutcome::ReenterCurrent | ChildLayoutOutcome::Skipped { .. } => metrics.content_baselines(),};- let collapsed = used.uses_collapsing_borders_model.get();- let block_size = used.margin_box_block_size(collapsed);+ let collapsed = metrics.uses_collapsing_borders_model();+ let block_size = metrics.margin_box_block_size(collapsed);// NB: A box without a baseline is aligned by its line-under margin edge.let ascent = baselines.first- .map_or(block_size, |baseline| used.margin_box_top(collapsed) + baseline);+ .map_or(block_size, |baseline| metrics.margin_box_top(collapsed) + baseline);Child {node: child,- inline_size: used.margin_box_inline_size(collapsed),+ inline_size: metrics.margin_box_inline_size(collapsed),ascent,descent: block_size - ascent,}@@ -2277,8 +2275,8 @@ impl<'pass> MathFormattingContext<'pass> {}for (child, position) in children.iter().zip(content.positions.iter()) {- let used = run.records.used_values(child.node);- let collapsed = used.uses_collapsing_borders_model.get();+ let metrics = run.records.box_metrics_of(child.node);+ let collapsed = metrics.uses_collapsing_borders_model();let line_left_offset = if is_rtl {content.inline_size - position.line_left_offset - child.inline_size} else {@@ -2286,8 +2284,11 @@ impl<'pass> MathFormattingContext<'pass> {};let margin_box_top = content.ascent + position.baseline_shift - child.ascent;let offset = FfiCssPixelPoint {- x: math_content_line_left + line_left_offset + used.margin_left.get() + used.border_box_left(collapsed),- y: margin_box_top + used.margin_box_top(collapsed),+ x: math_content_line_left+ + line_left_offset+ + metrics.margin_left()+ + metrics.border_box_left(collapsed),+ y: margin_box_top + metrics.margin_box_top(collapsed),};let fragment_arrival = self.take_fragment_arrival_of_child(child.node);formatting_context::place_laid_out_child(run, child.node, offset, None, fragment_arrival);diff --git a/Libraries/LibWeb/Rust/src/layout/mod.rs b/Libraries/LibWeb/Rust/src/layout/mod.rsindex 3236f99f9c2..bf295c9069d 100644--- a/Libraries/LibWeb/Rust/src/layout/mod.rs+++ b/Libraries/LibWeb/Rust/src/layout/mod.rs@@ -111,4 +111,4 @@ pub(crate) use style_values::StyleValues;pub(crate) use tree_builder::build_keeps_box;pub(crate) use update_layout::MainThreadFfiEntry as UpdateMainThreadFfiEntry;pub(crate) use update_layout::{ClockRound, ClockRoundDeclined, FlownRound, SealedRound};-pub(crate) use used_values::{FfiCssPixelPoint, FfiCssPixelRect, FfiCssPixelSize, UsedValues};+pub(crate) use used_values::{BoxMetricCells, FfiCssPixelPoint, FfiCssPixelRect, FfiCssPixelSize, UsedValues};diff --git a/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rsindex 50725f27023..0662be89bfc 100644--- a/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/replaced_with_children_formatting_context.rs@@ -49,6 +49,7 @@ pub(super) fn layout_replaced_with_children(let formatting_context::ChildRunOutcome {result: wrapper_result,fragment_arrival,+ ..} = formatting_context::run_formatting_context(run.fragments.as_deref(),wrapper_state,diff --git a/Libraries/LibWeb/Rust/src/layout/run_records.rs b/Libraries/LibWeb/Rust/src/layout/run_records.rsindex 0fe40a3e8a1..0f9bc8ccac0 100644--- a/Libraries/LibWeb/Rust/src/layout/run_records.rs+++ b/Libraries/LibWeb/Rust/src/layout/run_records.rs@@ -299,6 +299,8 @@ pub(crate) struct RunRecords<'arena> {/// What the parent of the root of a run that owns its root record decides about it, which the stack keeps for every/// other record.root_facts_decided_by_parent: Cell<FactsDecidedByParent>,+ /// What this run keeps of the children laid out by runs of their own, as those runs handed them back.+ laid_out_child_boxes: RefCell<HashMap<Node, LaidOutChildBox>>,// Wrapper sizing hands this state to the wrapper's child run, which consumes it while laying// out the table box. Keeping it on the run prevents measurement state from escaping a pass.table_inline_layouts: RefCell<HashMap<Node, table_formatting_context::TableInlineLayout>>,@@ -343,6 +345,81 @@ pub(crate) struct FactsDecidedByParent {pub(crate) fragment_facts: FragmentFactsDecidedByParent,}+/// What the parent of a box laid out by a run of its own keeps of the box once that run returns: its sizes, size+/// constraints and box sides in the parent's frame, and its baselines.+#[derive(Clone, Copy, Debug, PartialEq, Eq)]+pub(crate) struct LaidOutChildBox {+ pub(crate) cells: used_values::RootInputCells,+ pub(crate) baselines: DerivedBaselines,+ /// For a box that establishes an orthogonal flow, its baselines along the horizontal axis of the parent's frame.+ pub(crate) orthogonal_flow_baselines: Option<DerivedBaselines>,+}++impl LaidOutChildBox {+ /// The box as `record` holds it.+ pub(crate) fn as_record_holds_it(record: &UsedValues) -> Self {+ Self {+ cells: used_values::RootInputCells::capture(record),+ baselines: record.content_baselines_from_cells(),+ orthogonal_flow_baselines: record.orthogonal_flow_baselines.get(),+ }+ }+}++/// The sizes, size constraints, box sides and baselines of a box as a run sees them: kept as a value for a child laid+/// out by a run of its own, or read from the record of a box the run lays out itself.+#[derive(Clone, Copy)]+pub(crate) enum BoxMetrics<'records> {+ LaidOutByItsOwnRun(LaidOutChildBox),+ LaidOutByThisRun(&'records UsedValues),+}++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(),+ }+ }+}++macro_rules! box_metrics_getters {+ ($($name:ident: $value:ty,)+) => {+ impl BoxMetricCells for BoxMetrics<'_> {+ $(+ #[inline]+ fn $name(&self) -> $value {+ match self {+ Self::LaidOutByItsOwnRun(laid_out) => laid_out.cells.$name(),+ Self::LaidOutByThisRun(record) => record.$name(),+ }+ }+ )++ }+ };+}++box_metrics_getters! {+ 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,+ uses_collapsing_borders_model: bool,+ is_collapsed_borders_table_box: bool,+}+/// Where a run keeps the record of a box it owns.#[derive(Clone, Copy)]enum OwnedRecord {@@ -484,6 +561,7 @@ impl<'arena> RunRecords<'arena> {stack_length_at_start: scratch.run_record_stack.length(),records_outside_table: RefCell::new(HashMap::default()),root_facts_decided_by_parent: Cell::new(FactsDecidedByParent::default()),+ laid_out_child_boxes: RefCell::new(HashMap::default()),table_inline_layouts: RefCell::new(HashMap::default()),content_sizing,percentage_block_size_dependencies_in_progress: RefCell::new(smallvec::smallvec![(@@ -827,6 +905,40 @@ impl<'arena> RunRecords<'arena> {}}+ /// Keeps what the run of `child`, a box this run holds the record of, handed back once it returned.+ #[track_caller]+ pub(crate) fn receive_laid_out_child_box(&self, child: Node, laid_out: LaidOutChildBox) {+ assert_ne!(child, self.root, "a run lays out its own root");+ self.used_values(child);+ self.laid_out_child_boxes.borrow_mut().insert(child, laid_out);+ }++ /// The sizes, size constraints, box sides and baselines of `node`, a box this run lays out or a child of one laid+ /// out by a run of its own.+ #[track_caller]+ pub(crate) fn box_metrics_of(&self, node: Node) -> BoxMetrics<'_> {+ let record = self.used_values(node);+ let laid_out = {+ let laid_out_child_boxes = self.laid_out_child_boxes.borrow();+ if laid_out_child_boxes.is_empty() {+ None+ } else {+ laid_out_child_boxes.get(&node).copied()+ }+ };+ let Some(laid_out) = laid_out else {+ return BoxMetrics::LaidOutByThisRun(record);+ };+ if cfg!(debug_assertions) || super::run_repeatability::verification_is_enabled() {+ assert_eq!(+ laid_out,+ LaidOutChildBox::as_record_holds_it(record),+ "the parent's record of {node:?} changed after its run handed the box back"+ );+ }+ BoxMetrics::LaidOutByItsOwnRun(laid_out)+ }+pub(crate) fn store_table_inline_layout(&self, table: Node, layout: table_formatting_context::TableInlineLayout) {self.table_inline_layouts.borrow_mut().insert(table, layout);}diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rsindex c14ed798eaf..07c5b0c75f8 100644--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs@@ -582,14 +582,6 @@ impl UsedValues {scratch.content_block_size.set(self.content_block_size.get());}- pub(crate) fn has_definite_inline_size(&self) -> bool {- self.has_definite_inline_size.get()- }-- pub(crate) fn has_definite_block_size(&self) -> bool {- self.has_definite_block_size.get()- }-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@@ -645,123 +637,188 @@ impl UsedValues {&& fragment.uses_collapsing_borders_model == self.uses_collapsing_borders_model.get()}- fn collapsed_border_share(&self, width: CssPixels, start_edge: bool) -> CssPixels {- collapsed_border_share(width, start_edge, self.is_collapsed_borders_table_box.get())+ pub(crate) fn available_inner_space_or_constraints_from(&self, outer: AvailableSpace) -> AvailableSpace {+ use AvailableSize;++ let mut inline_size = if self.has_definite_inline_size.get() {+ AvailableSize::definite(self.content_inline_size.get())+ } else {+ AvailableSize::Indefinite+ };+ let block_size = if self.has_definite_block_size.get() {+ AvailableSize::definite(self.content_block_size.get())+ } else {+ AvailableSize::Indefinite+ };+ if inline_size == AvailableSize::Indefinite+ && matches!(outer.inline_size, AvailableSize::MinContent | AvailableSize::MaxContent)+ {+ inline_size = outer.inline_size;+ }+ AvailableSpace {+ inline_size,+ block_size,+ }}+}- pub(crate) fn border_left_collapsed(&self, collapsed: bool) -> CssPixels {+/// The sizes, size constraints and box sides of a box, with what derives from them, whether a run holds them in the box's+/// record or its parent holds them as a value.+pub(crate) trait BoxMetricCells {+ fn content_inline_size(&self) -> CssPixels;+ fn content_block_size(&self) -> CssPixels;+ fn margin_left(&self) -> CssPixels;+ fn margin_right(&self) -> CssPixels;+ fn margin_top(&self) -> CssPixels;+ fn margin_bottom(&self) -> CssPixels;+ fn border_left(&self) -> CssPixels;+ fn border_right(&self) -> CssPixels;+ fn border_top(&self) -> CssPixels;+ fn border_bottom(&self) -> CssPixels;+ fn padding_left(&self) -> CssPixels;+ fn padding_right(&self) -> CssPixels;+ fn padding_top(&self) -> CssPixels;+ fn padding_bottom(&self) -> CssPixels;+ fn has_definite_inline_size(&self) -> bool;+ fn has_definite_block_size(&self) -> bool;+ fn uses_collapsing_borders_model(&self) -> bool;+ fn is_collapsed_borders_table_box(&self) -> bool;++ fn border_left_collapsed(&self, collapsed: bool) -> CssPixels {if collapsed {- self.collapsed_border_share(self.border_left.get(), true)+ collapsed_border_share(self.border_left(), true, self.is_collapsed_borders_table_box())} else {- self.border_left.get()+ self.border_left()}}- pub(crate) fn border_right_collapsed(&self, collapsed: bool) -> CssPixels {+ fn border_right_collapsed(&self, collapsed: bool) -> CssPixels {if collapsed {- self.collapsed_border_share(self.border_right.get(), false)+ collapsed_border_share(self.border_right(), false, self.is_collapsed_borders_table_box())} else {- self.border_right.get()+ self.border_right()}}- pub(crate) fn border_top_collapsed(&self, collapsed: bool) -> CssPixels {+ fn border_top_collapsed(&self, collapsed: bool) -> CssPixels {if collapsed {- self.collapsed_border_share(self.border_top.get(), true)+ collapsed_border_share(self.border_top(), true, self.is_collapsed_borders_table_box())} else {- self.border_top.get()+ self.border_top()}}- pub(crate) fn border_bottom_collapsed(&self, collapsed: bool) -> CssPixels {+ fn border_bottom_collapsed(&self, collapsed: bool) -> CssPixels {if collapsed {- self.collapsed_border_share(self.border_bottom.get(), false)+ collapsed_border_share(self.border_bottom(), false, self.is_collapsed_borders_table_box())} else {- self.border_bottom.get()+ self.border_bottom()}}- pub(crate) fn border_box_left(&self, collapsed: bool) -> CssPixels {- self.border_left_collapsed(collapsed) + self.padding_left.get()+ fn border_box_left(&self, collapsed: bool) -> CssPixels {+ self.border_left_collapsed(collapsed) + self.padding_left()}- pub(crate) fn border_box_right(&self, collapsed: bool) -> CssPixels {- self.border_right_collapsed(collapsed) + self.padding_right.get()+ fn border_box_right(&self, collapsed: bool) -> CssPixels {+ self.border_right_collapsed(collapsed) + self.padding_right()}- pub(crate) fn border_box_top(&self, collapsed: bool) -> CssPixels {- self.border_top_collapsed(collapsed) + self.padding_top.get()+ fn border_box_top(&self, collapsed: bool) -> CssPixels {+ self.border_top_collapsed(collapsed) + self.padding_top()}- pub(crate) fn border_box_bottom(&self, collapsed: bool) -> CssPixels {- self.border_bottom_collapsed(collapsed) + self.padding_bottom.get()+ fn border_box_bottom(&self, collapsed: bool) -> CssPixels {+ self.border_bottom_collapsed(collapsed) + self.padding_bottom()}- pub(crate) fn horizontal_margin_border_padding(&self) -> CssPixels {- self.margin_left.get()- + self.border_left.get()- + self.padding_left.get()- + self.padding_right.get()- + self.border_right.get()- + self.margin_right.get()+ fn horizontal_margin_border_padding(&self) -> CssPixels {+ self.margin_left()+ + self.border_left()+ + self.padding_left()+ + self.padding_right()+ + self.border_right()+ + self.margin_right()}- pub(crate) fn border_box_inline_size(&self, collapsed: bool) -> CssPixels {- self.border_box_left(collapsed) + self.content_inline_size.get() + self.border_box_right(collapsed)+ fn border_box_inline_size(&self, collapsed: bool) -> CssPixels {+ self.border_box_left(collapsed) + self.content_inline_size() + self.border_box_right(collapsed)}- pub(crate) fn border_box_block_size(&self, collapsed: bool) -> CssPixels {- self.border_box_top(collapsed) + self.content_block_size.get() + self.border_box_bottom(collapsed)+ fn border_box_block_size(&self, collapsed: bool) -> CssPixels {+ self.border_box_top(collapsed) + self.content_block_size() + self.border_box_bottom(collapsed)}- pub(crate) fn margin_box_bottom(&self, collapsed: bool) -> CssPixels {- self.margin_bottom.get() + self.border_box_bottom(collapsed)+ fn margin_box_bottom(&self, collapsed: bool) -> CssPixels {+ self.margin_bottom() + self.border_box_bottom(collapsed)}- pub(crate) fn margin_box_top(&self, collapsed: bool) -> CssPixels {- self.margin_top.get() + self.border_box_top(collapsed)+ fn margin_box_top(&self, collapsed: bool) -> CssPixels {+ self.margin_top() + self.border_box_top(collapsed)}- pub(crate) fn margin_box_inline_size(&self, collapsed: bool) -> CssPixels {- self.margin_left.get()+ fn margin_box_inline_size(&self, collapsed: bool) -> CssPixels {+ self.margin_left()+ self.border_box_left(collapsed)- + self.content_inline_size.get()+ + self.content_inline_size()+ self.border_box_right(collapsed)- + self.margin_right.get()+ + self.margin_right()}- pub(crate) fn margin_box_block_size(&self, collapsed: bool) -> CssPixels {- self.margin_top.get()+ fn margin_box_block_size(&self, collapsed: bool) -> CssPixels {+ self.margin_top()+ self.border_box_top(collapsed)- + self.content_block_size.get()+ + self.content_block_size()+ self.margin_box_bottom(collapsed)}+}- pub(crate) fn available_inner_space_or_constraints_from(&self, outer: AvailableSpace) -> AvailableSpace {- use AvailableSize;-- let mut inline_size = if self.has_definite_inline_size.get() {- AvailableSize::definite(self.content_inline_size.get())- } else {- AvailableSize::Indefinite- };- let block_size = if self.has_definite_block_size.get() {- AvailableSize::definite(self.content_block_size.get())- } else {- AvailableSize::Indefinite- };- if inline_size == AvailableSize::Indefinite- && matches!(outer.inline_size, AvailableSize::MinContent | AvailableSize::MaxContent)- {- inline_size = outer.inline_size;- }- AvailableSpace {- inline_size,- block_size,+macro_rules! impl_box_metric_cells {+ ($type:ty, $read:ident) => {+ impl BoxMetricCells for $type {+ impl_box_metric_cells!(@getters $read;+ 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,+ uses_collapsing_borders_model: bool,+ is_collapsed_borders_table_box: bool,+ );}- }+ };+ (@getters cell; $($name:ident: $value:ty,)+) => {+ $(+ #[inline]+ fn $name(&self) -> $value {+ self.$name.get()+ }+ )++ };+ (@getters value; $($name:ident: $value:ty,)+) => {+ $(+ #[inline]+ fn $name(&self) -> $value {+ self.$name+ }+ )++ };}+impl_box_metric_cells!(UsedValues, cell);+impl_box_metric_cells!(RootInputCells, value);+/// 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.