Truly independent web browser
LibWeb: Group the box sides of a layout fragment into BoxSides
Aliaksandr Kalenik9d38e2622195
diff --git a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rsindex 29a308cf482..0873f9a7135 100644--- a/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/block_formatting_context.rs@@ -6380,8 +6380,10 @@ impl<'pass> BlockFormattingContext<'pass> {let has_line_clamp_point = self.line_clamp_point_found.get();if has_line_clamp_point || self.clamped_content_is_scrollable_overflow {run.update_fragment_payloads_of(self.run.box_, |payloads| {- payloads.has_line_clamp_point = has_line_clamp_point;- payloads.clamped_content_is_scrollable_overflow = self.clamped_content_is_scrollable_overflow;+ payloads.line_clamp = fragment_tree::LineClampFacts {+ has_line_clamp_point,+ clamped_content_is_scrollable_overflow: self.clamped_content_is_scrollable_overflow,+ };});}}diff --git a/Libraries/LibWeb/Rust/src/layout/commit.rs b/Libraries/LibWeb/Rust/src/layout/commit.rsindex aaa67a831e4..d0f9d36c0ae 100644--- a/Libraries/LibWeb/Rust/src/layout/commit.rs+++ b/Libraries/LibWeb/Rust/src/layout/commit.rs@@ -235,7 +235,7 @@ impl<'tree> Commit<'_, 'tree> {self.out_of_flow_boxes.push((node, inputs.clone()));}let (containing_block_fragment, line_index_offset) = holder.placement_of(link);- if link.fragment.continues_from_previous_fragment || link.fragment.continues_in_next_fragment {+ if link.fragment.breaks.box_is_broken() {self.meet_broken_box(link, containing_block_fragment, line_index_offset, holder);return;}diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rsindex d642ea88877..b34df6ac47b 100644--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs@@ -274,8 +274,8 @@ impl FcRunCacheEntry {if std::sync::Arc::ptr_eq(committed, &root.fragment) {return true;}- committed.content_inline_size == content_inline_size- && (committed.content_block_size == content_block_size+ committed.sides.content_size.width == content_inline_size+ && (committed.sides.content_size.height == content_block_size|| self.outputs.inputs_never_observed.own_block_size== formatting_context::OwnBlockSizeObservation::Unobserved)&& same_allocation(diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_overflow.rs b/Libraries/LibWeb/Rust/src/layout/fragment_overflow.rsindex 0083941a7a7..28c1a3fc36e 100644--- a/Libraries/LibWeb/Rust/src/layout/fragment_overflow.rs+++ b/Libraries/LibWeb/Rust/src/layout/fragment_overflow.rs@@ -29,39 +29,24 @@ pub(crate) struct FragmentScrollableOverflow {}pub(crate) fn physical_content_size(fragment: &Fragment, frame: Frame) -> FfiCssPixelSize {- frame.size_to_physical(fragment.content_inline_size, fragment.content_block_size)+ let size = fragment.sides.content_size;+ frame.size_to_physical(size.width, size.height)}pub(crate) fn physical_padding(fragment: &Fragment, frame: Frame) -> FfiPixelBox {- sides_to_physical(- frame,- FfiPixelBox {- top: fragment.padding_top,- right: fragment.padding_right,- bottom: fragment.padding_bottom,- left: fragment.padding_left,- },- )+ sides_to_physical(frame, fragment.sides.padding.into())}fn physical_border(fragment: &Fragment, frame: Frame) -> FfiPixelBox {- sides_to_physical(- frame,- FfiPixelBox {- top: fragment.border_top,- right: fragment.border_right,- bottom: fragment.border_bottom,- left: fragment.border_left,- },- )+ sides_to_physical(frame, fragment.sides.border.into())}fn physical_border_box_edges(fragment: &Fragment, frame: Frame) -> FfiPixelBox {let border = physical_border(fragment, frame);- if !fragment.uses_collapsing_borders_model {+ if !fragment.sides.collapsing.uses_collapsing_borders_model() {return border;}- let is_table_box = fragment.is_collapsed_borders_table_box;+ let is_table_box = fragment.sides.collapsing.is_collapsed_borders_table_box();FfiPixelBox {top: used_values::collapsed_border_share(border.top, true, is_table_box),right: used_values::collapsed_border_share(border.right, false, is_table_box),@@ -120,8 +105,8 @@ impl ContainedBoxesRelativeToContainerPaddingBox {CssPixelRect::new(link.committed_offset.x,link.committed_offset.y,- fragment.content_inline_size,- fragment.content_block_size,+ fragment.sides.content_size.width,+ fragment.sides.content_size.height,),container.content_size,)@@ -232,8 +217,8 @@ fn hidden_content_is_scrollable_overflow(let mut ancestor = arena.node_parent_if_live(hidden_box);while let Some(node) = ancestor {if node == fragment_being_built.node {- if fragment_being_built.has_line_clamp_point {- return fragment_being_built.clamped_content_is_scrollable_overflow;+ if fragment_being_built.line_clamp.has_line_clamp_point {+ return fragment_being_built.line_clamp.clamped_content_is_scrollable_overflow;}} else if let Some(keeps_clamped_content) = line_clamp_container_keeps_clamped_content_scrollable(arena, node) {return keeps_clamped_content;@@ -330,8 +315,9 @@ pub(crate) fn scrollable_overflow_of<'link>(}let box_is_scroll_container = node_facts::kind_and_style_make_scroll_container(kind, style);+ let line_clamp = fragment.line_clamp;let line_clamp_clip =- (fragment.has_line_clamp_point && !fragment.clamped_content_is_scrollable_overflow).then(|| {+ (line_clamp.has_line_clamp_point && !line_clamp.clamped_content_is_scrollable_overflow).then(|| {Frame::of(style.map_or(writing_mode::HORIZONTAL_TB, |style| style.writing_mode())).half_plane_before_block_end(own.content_size).translated_by(own.content_box.location())@@ -893,13 +879,13 @@ mod tests {arena.insert_child(container, child, NodeSlotId::INVALID);let mut container_link = FragmentLink::for_test(container);let fragment = std::sync::Arc::get_mut(&mut container_link.fragment).unwrap();- fragment.content_inline_size = CssPixels::from_integer(100);- fragment.content_block_size = CssPixels::from_integer(200);- fragment.padding_bottom = CssPixels::from_integer(10);+ fragment.sides.content_size.width = CssPixels::from_integer(100);+ fragment.sides.content_size.height = CssPixels::from_integer(200);+ fragment.sides.padding.bottom = CssPixels::from_integer(10);let mut child_link = FragmentLink::for_test(child);let fragment = std::sync::Arc::get_mut(&mut child_link.fragment).unwrap();- fragment.content_inline_size = CssPixels::from_integer(20);- fragment.content_block_size = CssPixels::from_integer(20);+ fragment.sides.content_size.width = CssPixels::from_integer(20);+ fragment.sides.content_size.height = CssPixels::from_integer(20);child_link.committed_offset.y = CssPixels::from_integer(180).into();child_link.containing_block = container;let overflow = scrollable_overflow_of(diff --git a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rsindex e5aed8a2b7e..718f771e47f 100644--- a/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs+++ b/Libraries/LibWeb/Rust/src/layout/fragment_tree.rs@@ -8,21 +8,69 @@ use super::*;use crate::layout::used_values::CommittedSvgFacts;use smallvec::SmallVec;+/// Which border model a box follows, and in the collapsing borders model, whether the box is the table box or a cell:+/// the two own different parts of the collapsed borders at their edges (see `used_values::collapsed_border_share`).+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+pub(crate) enum CollapsingBorders {+ #[default]+ Separate,+ CollapsedCell,+ CollapsedTableBox,+}++impl CollapsingBorders {+ pub(crate) fn of(uses_collapsing_borders_model: bool, is_collapsed_borders_table_box: bool) -> Self {+ match (uses_collapsing_borders_model, is_collapsed_borders_table_box) {+ (false, _) => Self::Separate,+ (true, false) => Self::CollapsedCell,+ (true, true) => Self::CollapsedTableBox,+ }+ }++ pub(crate) fn uses_collapsing_borders_model(self) -> bool {+ self != Self::Separate+ }++ pub(crate) fn is_collapsed_borders_table_box(self) -> bool {+ self == Self::CollapsedTableBox+ }+}++/// The content size, borders and paddings a fragment shows of its box.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+pub(crate) struct BoxSides {+ pub(crate) content_size: FfiCssPixelSize,+ pub(crate) border: geometry::Sides,+ pub(crate) padding: geometry::Sides,+ pub(crate) collapsing: CollapsingBorders,+}++/// Whether fragmentation broke the box, so that its fragment continues one in an earlier fragmentainer, or continues+/// in a later one.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+pub(crate) struct BreakFacts {+ pub(crate) continues_from_previous: bool,+ pub(crate) continues_in_next: bool,+}++impl BreakFacts {+ pub(crate) fn box_is_broken(self) -> bool {+ self.continues_from_previous || self.continues_in_next+ }+}++/// For a line-clamp container: whether its contents hold the clamp point, and whether what follows the clamp point+/// still counts as scrollable overflow.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+pub(crate) struct LineClampFacts {+ pub(crate) has_line_clamp_point: bool,+ pub(crate) clamped_content_is_scrollable_overflow: bool,+}+pub(crate) struct Fragment {pub(crate) identity: u64,pub(crate) node: crate::layout::node_data::NodeSlotId,- pub(crate) content_inline_size: CssPixels,- pub(crate) content_block_size: CssPixels,- pub(crate) border_left: CssPixels,- pub(crate) border_right: CssPixels,- pub(crate) border_top: CssPixels,- pub(crate) border_bottom: CssPixels,- pub(crate) padding_left: CssPixels,- pub(crate) padding_right: CssPixels,- pub(crate) padding_top: CssPixels,- pub(crate) padding_bottom: CssPixels,- pub(crate) uses_collapsing_borders_model: bool,- pub(crate) is_collapsed_borders_table_box: bool,+ pub(crate) sides: BoxSides,pub(crate) collapsed_table_borders: Option<std::sync::Arc<table_formatting_context::OwnedCollapsedTableBorders>>,pub(crate) line_data: Option<std::sync::Arc<inline_content::InlineContent>>,pub(crate) grid_layout_data: Option<std::sync::Arc<grid_formatting_context::GridLayoutData>>,@@ -34,10 +82,8 @@ pub(crate) struct Fragment {pub(crate) svg: Option<Box<CommittedSvgFacts>>,pub(crate) computed_svg_path: Option<std::sync::Arc<libgfx_rust::path::Path>>,pub(crate) svg_text_character_cells: Option<std::sync::Arc<Vec<svg_formatting_context::FfiSvgTextCharacterCell>>>,- pub(crate) has_line_clamp_point: bool,- pub(crate) clamped_content_is_scrollable_overflow: bool,- pub(crate) continues_from_previous_fragment: bool,- pub(crate) continues_in_next_fragment: bool,+ pub(crate) line_clamp: LineClampFacts,+ pub(crate) breaks: BreakFacts,pub(crate) scrollable_overflow: fragment_overflow::FragmentScrollableOverflow,pub(crate) holds_links_of_outer_containing_blocks: bool,pub(crate) children: Vec<FragmentLink>,@@ -124,18 +170,7 @@ impl Fragment {Self {identity: self.identity,node: self.node,- content_inline_size: self.content_inline_size,- content_block_size: self.content_block_size,- border_left: self.border_left,- border_right: self.border_right,- border_top: self.border_top,- border_bottom: self.border_bottom,- padding_left: self.padding_left,- padding_right: self.padding_right,- padding_top: self.padding_top,- padding_bottom: self.padding_bottom,- uses_collapsing_borders_model: self.uses_collapsing_borders_model,- is_collapsed_borders_table_box: self.is_collapsed_borders_table_box,+ sides: self.sides,collapsed_table_borders: self.collapsed_table_borders.clone(),line_data: self.line_data.clone(),grid_layout_data: self.grid_layout_data.clone(),@@ -146,10 +181,8 @@ impl Fragment {svg: self.svg.clone(),computed_svg_path: self.computed_svg_path.clone(),svg_text_character_cells: self.svg_text_character_cells.clone(),- has_line_clamp_point: self.has_line_clamp_point,- clamped_content_is_scrollable_overflow: self.clamped_content_is_scrollable_overflow,- continues_from_previous_fragment: self.continues_from_previous_fragment,- continues_in_next_fragment: self.continues_in_next_fragment,+ line_clamp: self.line_clamp,+ breaks: self.breaks,scrollable_overflow,holds_links_of_outer_containing_blocks: self.holds_links_of_outer_containing_blocks,children,@@ -180,18 +213,7 @@ impl Fragment {fn has_same_box_properties_comparing_payloads(&self, previous: &Fragment, payloads: PayloadComparison) -> bool {self.node == previous.node- && self.content_inline_size == previous.content_inline_size- && self.content_block_size == previous.content_block_size- && self.border_left == previous.border_left- && self.border_right == previous.border_right- && self.border_top == previous.border_top- && self.border_bottom == previous.border_bottom- && self.padding_left == previous.padding_left- && self.padding_right == previous.padding_right- && self.padding_top == previous.padding_top- && self.padding_bottom == previous.padding_bottom- && self.uses_collapsing_borders_model == previous.uses_collapsing_borders_model- && self.is_collapsed_borders_table_box == previous.is_collapsed_borders_table_box+ && self.sides == previous.sides&& payloads.matches(self.collapsed_table_borders.as_ref(),previous.collapsed_table_borders.as_ref(),@@ -207,10 +229,8 @@ impl Fragment {self.svg_text_character_cells.as_ref(),previous.svg_text_character_cells.as_ref(),)- && self.has_line_clamp_point == previous.has_line_clamp_point- && self.clamped_content_is_scrollable_overflow == previous.clamped_content_is_scrollable_overflow- && self.continues_from_previous_fragment == previous.continues_from_previous_fragment- && self.continues_in_next_fragment == previous.continues_in_next_fragment+ && self.line_clamp == previous.line_clamp+ && self.breaks == previous.breaks}pub(crate) fn has_same_child_placements(&self, previous: &Fragment) -> bool {@@ -240,18 +260,7 @@ impl FragmentLink {fragment: std::sync::Arc::new(Fragment {identity: 1,node,- content_inline_size: CssPixels::default(),- content_block_size: CssPixels::default(),- border_left: CssPixels::default(),- border_right: CssPixels::default(),- border_top: CssPixels::default(),- border_bottom: CssPixels::default(),- padding_left: CssPixels::default(),- padding_right: CssPixels::default(),- padding_top: CssPixels::default(),- padding_bottom: CssPixels::default(),- uses_collapsing_borders_model: false,- is_collapsed_borders_table_box: false,+ sides: BoxSides::default(),collapsed_table_borders: None,line_data: None,grid_layout_data: None,@@ -262,10 +271,8 @@ impl FragmentLink {svg: None,computed_svg_path: None,svg_text_character_cells: None,- has_line_clamp_point: false,- clamped_content_is_scrollable_overflow: false,- continues_from_previous_fragment: false,- continues_in_next_fragment: false,+ line_clamp: LineClampFacts::default(),+ breaks: BreakFacts::default(),scrollable_overflow: Default::default(),holds_links_of_outer_containing_blocks: false,children: Vec::new(),@@ -630,10 +637,7 @@ fn previously_committed_fragment_where(candidate: &Fragment,matches: impl FnOnce(&Fragment, &Fragment) -> bool,) -> Option<std::sync::Arc<Fragment>> {- if candidate.continues_from_previous_fragment- || candidate.continues_in_next_fragment- || !pass.has_committed_fragment_link(candidate.node)- {+ if candidate.breaks.box_is_broken() || !pass.has_committed_fragment_link(candidate.node) {return None;}pass.arena()@@ -656,10 +660,7 @@ pub(crate) struct FragmentPayloads {pub(crate) svg: CommittedSvgFacts,pub(crate) computed_svg_path: Option<std::sync::Arc<libgfx_rust::path::Path>>,pub(crate) svg_text_character_cells: Option<std::sync::Arc<Vec<svg_formatting_context::FfiSvgTextCharacterCell>>>,- /// For a line-clamp container: whether its contents hold the clamp point, and whether what follows the clamp- /// point still counts as scrollable overflow.- pub(crate) has_line_clamp_point: bool,- pub(crate) clamped_content_is_scrollable_overflow: bool,+ pub(crate) line_clamp: LineClampFacts,}impl FragmentPayloads {@@ -674,8 +675,7 @@ impl FragmentPayloads {svg: fragment.svg.as_deref().copied().unwrap_or_default(),computed_svg_path: fragment.computed_svg_path.clone(),svg_text_character_cells: fragment.svg_text_character_cells.clone(),- has_line_clamp_point: fragment.has_line_clamp_point,- clamped_content_is_scrollable_overflow: fragment.clamped_content_is_scrollable_overflow,+ line_clamp: fragment.line_clamp,}}}@@ -690,19 +690,8 @@ pub(crate) struct FragmentGeometry {impl FragmentGeometry {pub(crate) fn shows_box_of_fragment(&self, fragment: &Fragment) -> bool {- let cells = &self.cells;- same_allocation(self.line_data.as_ref(), fragment.line_data.as_ref())- && fragment.content_inline_size == cells.content_inline_size- && fragment.content_block_size == cells.content_block_size- && fragment.border_left == cells.border_left- && fragment.border_right == cells.border_right- && fragment.border_top == cells.border_top- && fragment.border_bottom == cells.border_bottom- && fragment.padding_left == cells.padding_left- && fragment.padding_right == cells.padding_right- && fragment.padding_top == cells.padding_top- && fragment.padding_bottom == cells.padding_bottom- && fragment.uses_collapsing_borders_model == cells.uses_collapsing_borders_model+ fragment.sides == self.cells.box_sides()+ && same_allocation(self.line_data.as_ref(), fragment.line_data.as_ref())}}@@ -725,10 +714,9 @@ fn snapshot_fragment(svg,computed_svg_path,svg_text_character_cells,- has_line_clamp_point,- clamped_content_is_scrollable_overflow,+ line_clamp,} = payloads.map(|payloads| *payloads).unwrap_or_default();- if has_line_clamp_point && !fragment_facts.continues_in_next_fragment {+ if line_clamp.has_line_clamp_point && !fragment_facts.continues_in_next_fragment {line_clamp_edge::clip_floats_at_block_end_content_edge(pass,node,@@ -741,18 +729,7 @@ fn snapshot_fragment(let mut fragment = Fragment {identity: 0,node,- content_inline_size: cells.content_inline_size,- content_block_size: cells.content_block_size,- border_left: cells.border_left,- border_right: cells.border_right,- border_top: cells.border_top,- border_bottom: cells.border_bottom,- padding_left: cells.padding_left,- padding_right: cells.padding_right,- padding_top: cells.padding_top,- padding_bottom: cells.padding_bottom,- uses_collapsing_borders_model: cells.uses_collapsing_borders_model,- is_collapsed_borders_table_box: cells.is_collapsed_borders_table_box,+ sides: cells.box_sides(),collapsed_table_borders,line_data,grid_layout_data,@@ -763,10 +740,11 @@ fn snapshot_fragment(svg: (svg != CommittedSvgFacts::default()).then(|| Box::new(svg)),computed_svg_path,svg_text_character_cells,- has_line_clamp_point,- clamped_content_is_scrollable_overflow,- continues_from_previous_fragment: fragment_facts.continues_from_previous_fragment,- continues_in_next_fragment: fragment_facts.continues_in_next_fragment,+ line_clamp,+ breaks: BreakFacts {+ continues_from_previous: fragment_facts.continues_from_previous_fragment,+ continues_in_next: fragment_facts.continues_in_next_fragment,+ },scrollable_overflow: Default::default(),holds_links_of_outer_containing_blocks: fragment_overflow::holds_links_of_outer_containing_blocks(node, &children,@@ -821,8 +799,8 @@ fn fragment_of_placed_box(};let shows_box_as_placed = children.is_empty()&& geometry.shows_box_of_fragment(&arrived)- && arrived.continues_from_previous_fragment == fragment_facts.continues_from_previous_fragment- && arrived.continues_in_next_fragment == fragment_facts.continues_in_next_fragment;+ && arrived.breaks.continues_from_previous == fragment_facts.continues_from_previous_fragment+ && arrived.breaks.continues_in_next == fragment_facts.continues_in_next_fragment;if shows_box_as_placed {return arrived;}diff --git a/Libraries/LibWeb/Rust/src/layout/geometry.rs b/Libraries/LibWeb/Rust/src/layout/geometry.rsindex b53eaa241eb..3878eac6f9f 100644--- a/Libraries/LibWeb/Rust/src/layout/geometry.rs+++ b/Libraries/LibWeb/Rust/src/layout/geometry.rs@@ -49,6 +49,15 @@ const FRAME_SIDES_IN_PHYSICAL_PLANE: [[u8; 4]; 5] = [/// The frame side that each physical side lies on, indexed by the physical side.const PHYSICAL_SIDES_IN_FRAME: [[u8; 4]; 5] = [[0, 1, 2, 3], [3, 0, 1, 2], [3, 2, 1, 0], [3, 0, 1, 2], [1, 2, 3, 0]];+/// The widths of the sides of a box, such as its borders or paddings, in a frame or in the physical plane.+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]+pub(crate) struct Sides {+ pub(crate) top: CssPixels,+ pub(crate) right: CssPixels,+ pub(crate) bottom: CssPixels,+ pub(crate) left: CssPixels,+}+/// The frame of a writing mode.#[derive(Clone, Copy, Debug, PartialEq, Eq)]pub(crate) struct Frame(u8);diff --git a/Libraries/LibWeb/Rust/src/layout/line_clamp_edge.rs b/Libraries/LibWeb/Rust/src/layout/line_clamp_edge.rsindex ebc001490ad..0ab0fac3712 100644--- a/Libraries/LibWeb/Rust/src/layout/line_clamp_edge.rs+++ b/Libraries/LibWeb/Rust/src/layout/line_clamp_edge.rs@@ -96,8 +96,8 @@ impl ClampEdgeWalk<'_, '_> {CssPixelRect::new(link.committed_offset.x,link.committed_offset.y,- fragment.content_inline_size,- fragment.content_block_size,+ fragment.sides.content_size.width,+ fragment.sides.content_size.height,),FfiCssPixelSize {width: containing_block.width,@@ -120,7 +120,7 @@ impl ClampEdgeWalk<'_, '_> {// NB: Line clamping does not reach into a box that establishes a formatting context of its own, and a nested// line-clamp container clips the floats in its formatting context at its own edge.- if fragment.has_line_clamp_point+ if fragment.line_clamp.has_line_clamp_point|| formatting_context::formatting_context_type_created_by_box(NodeFacts::new(self.pass, fragment.node)).is_some(){diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rsindex ae7a614f8b0..5877f9b6d64 100644--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs@@ -203,6 +203,32 @@ impl RootInputCells {self.resolve_vertical_box_model(style, basis);}+ /// The content size, borders and paddings the fragment of the box shows.+ pub(crate) fn box_sides(&self) -> fragment_tree::BoxSides {+ fragment_tree::BoxSides {+ content_size: FfiCssPixelSize {+ width: self.content_inline_size,+ height: self.content_block_size,+ },+ border: geometry::Sides {+ top: self.border_top,+ right: self.border_right,+ bottom: self.border_bottom,+ left: self.border_left,+ },+ padding: geometry::Sides {+ top: self.padding_top,+ right: self.padding_right,+ bottom: self.padding_bottom,+ left: self.padding_left,+ },+ collapsing: fragment_tree::CollapsingBorders::of(+ self.uses_collapsing_borders_model,+ self.is_collapsed_borders_table_box,+ ),+ }+ }+/// The sizes and box sides `link` and its fragment show, with both sizes definite.pub(crate) fn of_committed_fragment_link(link: &fragment_tree::FragmentLink) -> Self {let mut cells = Self {@@ -215,21 +241,21 @@ impl RootInputCells {/// Takes the sizes and box sides `link` and its fragment show.pub(crate) fn take_box_metrics_of_committed_link(&mut self, link: &fragment_tree::FragmentLink) {- let fragment = &link.fragment;- self.set_content_inline_size(fragment.content_inline_size);- self.set_content_block_size(fragment.content_block_size);+ let sides = &link.fragment.sides;+ self.set_content_inline_size(sides.content_size.width);+ self.set_content_block_size(sides.content_size.height);self.margin_left = link.margin_left;self.margin_right = link.margin_right;self.margin_top = link.margin_top;self.margin_bottom = link.margin_bottom;- self.border_left = fragment.border_left;- self.border_right = fragment.border_right;- self.border_top = fragment.border_top;- self.border_bottom = fragment.border_bottom;- self.padding_left = fragment.padding_left;- self.padding_right = fragment.padding_right;- self.padding_top = fragment.padding_top;- self.padding_bottom = fragment.padding_bottom;+ self.border_left = sides.border.left;+ self.border_right = sides.border.right;+ self.border_top = sides.border.top;+ self.border_bottom = sides.border.bottom;+ self.padding_left = sides.padding.left;+ self.padding_right = sides.padding.right;+ self.padding_top = sides.padding.top;+ self.padding_bottom = sides.padding.bottom;}/// The cells, with the sizes, size constraints and box sides they hold in frame `from` read in frame `to` instead.diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_build.rs b/Libraries/LibWeb/Rust/src/painting/paintable_build.rsindex df7e9471754..4a5e0e7a649 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_build.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_build.rs@@ -236,7 +236,8 @@ impl<'a> PaintableCommit<'a> {) -> ReplacedCommittedFragmentLink {let fragment = &link.fragment;let frame = link.frame;- let new_content_size = frame.size_to_physical(fragment.content_inline_size, fragment.content_block_size);+ let new_content_size =+ frame.size_to_physical(fragment.sides.content_size.width, fragment.sides.content_size.height);let new_offset: used_values::FfiCssPixelPoint = if frame.is_physical() {link.committed_offset} else {@@ -247,8 +248,8 @@ impl<'a> PaintableCommit<'a> {CssPixelRect::new(link.committed_offset.x,link.committed_offset.y,- fragment.content_inline_size,- fragment.content_block_size,+ fragment.sides.content_size.width,+ fragment.sides.content_size.height,),).location()@@ -290,8 +291,8 @@ impl<'a> PaintableCommit<'a> {(old_link.fragment.identity,frame.size_to_physical(- old_link.fragment.content_inline_size,- old_link.fragment.content_block_size,+ old_link.fragment.sides.content_size.width,+ old_link.fragment.sides.content_size.height,),)})diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_data.rs b/Libraries/LibWeb/Rust/src/painting/paintable_data.rsindex a96cfd874a4..005905e2a83 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_data.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_data.rs@@ -32,6 +32,17 @@ pub struct FfiPixelBox {pub left: CssPixels,}+impl From<crate::layout::geometry::Sides> for FfiPixelBox {+ fn from(sides: crate::layout::geometry::Sides) -> Self {+ Self {+ top: sides.top,+ right: sides.right,+ bottom: sides.bottom,+ left: sides.left,+ }+ }+}+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]#[repr(C)]pub struct FfiOverflowData {diff --git a/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs b/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rsindex 8e243489612..e60dae70627 100644--- a/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs+++ b/Libraries/LibWeb/Rust/src/painting/paintable_geometry.rs@@ -44,8 +44,8 @@ fn link_content_rect(link: &crate::layout::fragment_tree::FragmentLink) -> CssPiCssPixelRect::new(link.committed_offset.x,link.committed_offset.y,- link.fragment.content_inline_size,- link.fragment.content_block_size,+ link.fragment.sides.content_size.width,+ link.fragment.sides.content_size.height,)}@@ -83,7 +83,8 @@ pub(crate) fn committed_content_size(arena: &impl GeometryRead, slot: NodeSlotIdlet frame = data.frame();arena.with_committed_fragment_link(slot, |link| {link.map_or_else(used_values::FfiCssPixelSize::default, |link| {- frame.size_to_physical(link.fragment.content_inline_size, link.fragment.content_block_size)+ let size = link.fragment.sides.content_size;+ frame.size_to_physical(size.width, size.height)})})}@@ -120,27 +121,11 @@ pub(crate) fn committed_margin(arena: &impl GeometryRead, slot: NodeSlotId) -> F}fn border_of(fragment: &crate::layout::fragment_tree::Fragment, frame: Frame) -> FfiPixelBox {- sides_to_physical(- frame,- FfiPixelBox {- top: fragment.border_top,- right: fragment.border_right,- bottom: fragment.border_bottom,- left: fragment.border_left,- },- )+ sides_to_physical(frame, fragment.sides.border.into())}fn padding_of(fragment: &crate::layout::fragment_tree::Fragment, frame: Frame) -> FfiPixelBox {- sides_to_physical(- frame,- FfiPixelBox {- top: fragment.padding_top,- right: fragment.padding_right,- bottom: fragment.padding_bottom,- left: fragment.padding_left,- },- )+ sides_to_physical(frame, fragment.sides.padding.into())}pub(crate) fn committed_border(arena: &impl GeometryRead, slot: NodeSlotId) -> FfiPixelBox {@@ -176,7 +161,7 @@ pub(crate) fn committed_inset(arena: &impl GeometryRead, slot: NodeSlotId) -> Ffpub(crate) fn committed_uses_collapsing_borders_model(arena: &impl GeometryRead, slot: NodeSlotId) -> bool {arena.with_committed_fragment_link(slot, |link| {- link.is_some_and(|link| link.fragment.uses_collapsing_borders_model)+ link.is_some_and(|link| link.fragment.sides.collapsing.uses_collapsing_borders_model())})}@@ -445,8 +430,8 @@ pub(crate) fn absolute_fragment_rect(arena: &impl GeometryRead, slot: NodeSlotIdCssPixelRect::new(link.committed_offset.x,link.committed_offset.y,- link.fragment.content_inline_size,- link.fragment.content_block_size,+ link.fragment.sides.content_size.width,+ link.fragment.sides.content_size.height,),fragment.containing_block_fragment,)@@ -472,7 +457,7 @@ fn with_later_box_fragment<R>(pub(crate) fn unbroken_content_size(arena: &impl GeometryRead, slot: NodeSlotId) -> used_values::FfiCssPixelSize {let mut size = committed_content_size(arena, slot);for fragment in arena.committed_side_data(slot).box_fragments() {- size.height += fragment.link.fragment.content_block_size;+ size.height += fragment.link.fragment.sides.content_size.height;}size}@@ -489,8 +474,8 @@ pub(crate) fn unbroken_box_model(if let Some(last) = arena.committed_side_data(slot).box_fragments().last() {let fragment = &last.link.fragment;margin.bottom = last.link.margin_bottom;- padding.bottom = fragment.padding_bottom;- border.bottom = fragment.border_bottom;+ padding.bottom = fragment.sides.padding.bottom;+ border.bottom = fragment.sides.border.bottom;}(margin, padding, border)}@@ -534,10 +519,10 @@ pub(crate) fn committed_fragment_border(arena: &impl GeometryRead, slot: NodeSlopub(crate) fn committed_fragment_present_edges(arena: &impl GeometryRead, slot: NodeSlotId, index: usize) -> u8 {let edges_of = |fragment: &crate::layout::fragment_tree::Fragment| {let mut edges = PIECE_EDGE_LEFT | PIECE_EDGE_RIGHT;- if !fragment.continues_from_previous_fragment {+ if !fragment.breaks.continues_from_previous {edges |= PIECE_EDGE_TOP;}- if !fragment.continues_in_next_fragment {+ if !fragment.breaks.continues_in_next {edges |= PIECE_EDGE_BOTTOM;}edges@@ -677,8 +662,10 @@ pub(crate) fn first_fragment_padding_box_rect(arena: &impl GeometryRead, slot: Npub(crate) fn committed_border_box_edges(arena: &impl GeometryRead, slot: NodeSlotId) -> FfiPixelBox {let border = committed_border(arena, slot);let Some(is_table_box) = arena.with_committed_fragment_link(slot, |link| {- link.filter(|link| link.fragment.uses_collapsing_borders_model)- .map(|link| link.fragment.is_collapsed_borders_table_box)+ let collapsing = link?.fragment.sides.collapsing;+ collapsing+ .uses_collapsing_borders_model()+ .then(|| collapsing.is_collapsed_borders_table_box())}) else {return border;};diff --git a/Libraries/LibWeb/Rust/src/render_state.rs b/Libraries/LibWeb/Rust/src/render_state.rsindex de2b68e9508..530711d11e1 100644--- a/Libraries/LibWeb/Rust/src/render_state.rs+++ b/Libraries/LibWeb/Rust/src/render_state.rs@@ -1286,8 +1286,8 @@ mod tests {// The viewport's fragment holds scrollable overflow it no longer has, and a read settles it first since.let mut link = crate::layout::fragment_tree::FragmentLink::for_test(viewport);let fragment = std::sync::Arc::get_mut(&mut link.fragment).unwrap();- fragment.content_inline_size = crate::css::css_pixels::CssPixels::from_integer(100);- fragment.content_block_size = crate::css::css_pixels::CssPixels::from_integer(100);+ fragment.sides.content_size.width = crate::css::css_pixels::CssPixels::from_integer(100);+ fragment.sides.content_size.height = crate::css::css_pixels::CssPixels::from_integer(100);fragment.scrollable_overflow.has_scrollable_overflow = true;arena.set_committed_fragment_link(viewport, link, None);arena.request_fragment_overflow_recalculation(viewport);