Truly independent web browser
LibWeb: Project the orthogonal flow scratch root as cells
Aliaksandr Kalenikaf7aa0ec58c5
diff --git a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rsindex cb190894b98..4718fc4bdd3 100644--- a/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs+++ b/Libraries/LibWeb/Rust/src/layout/intrinsic_sizing.rs@@ -640,15 +640,11 @@ pub(super) fn content_sizes_of_orthogonal_flow(run.sizing().measurement_root_observes_percentage_inline_basis(node)});let available_inline_size_in_own_frame = scope.available_block_size();- let root = scope.root_cells().materialize_record();- root.move_box_metrics_to_frame(callbacks.frame, own_frame);- let inline_size = if root.has_definite_inline_size.get() {- root.content_inline_size.get()+ let mut root_cells = scope.root_cells().in_frame(callbacks.frame, own_frame);+ let inline_size = if root_cells.has_definite_inline_size {+ root_cells.content_inline_size} else {- let scope_in_own_frame = ContentSizingScope {- node,- root_cells: used_values::RootInputCells::capture(&root),- };+ let scope_in_own_frame = ContentSizingScope { node, root_cells };scope_in_own_frame.enter(callbacks_in_own_frame, |run| {run.sizing().orthogonal_flow_inline_size(node,@@ -660,8 +656,8 @@ pub(super) fn content_sizes_of_orthogonal_flow()})};- root.set_content_inline_size(inline_size);- root.has_definite_block_size.set(false);+ root_cells.set_content_inline_size(inline_size);+ root_cells.has_definite_block_size = false;let mut input = LayoutInput::new(AvailableSpace {inline_size: AvailableSize::definite(inline_size),@@ -674,12 +670,8 @@ pub(super) fn content_sizes_of_orthogonal_flow(formatting_context::independent_formatting_context_type(node, &callbacks_in_own_frame),formatting_context::FormattingContextType::Flex | formatting_context::FormattingContextType::Grid);- let result = formatting_context::lay_out_measurement_root_for_its_result(- callbacks_in_own_frame,- node,- used_values::RootInputCells::capture(&root),- input,- );+ let result =+ formatting_context::lay_out_measurement_root_for_its_result(callbacks_in_own_frame, node, root_cells, input);let size = result.automatic_content_block_size;sizing_context::ContentInlineSizes {sizes: sizing_context::ContentSizes { min: size, max: size },diff --git a/Libraries/LibWeb/Rust/src/layout/used_values.rs b/Libraries/LibWeb/Rust/src/layout/used_values.rsindex f4363b6581e..3048dbf4a02 100644--- a/Libraries/LibWeb/Rust/src/layout/used_values.rs+++ b/Libraries/LibWeb/Rust/src/layout/used_values.rs@@ -478,6 +478,40 @@ impl RootInputCells {self.apply_to_record(&record);record}++ /// The cells, with the sizes, size constraints and box sides they hold in frame `from` read in frame `to` instead.+ pub(crate) fn in_frame(mut self, from: geometry::Frame, to: geometry::Frame) -> Self {+ if from == to {+ return self;+ }+ [self.margin_top, self.margin_right, self.margin_bottom, self.margin_left] = from.sides_in(+ [self.margin_top, self.margin_right, self.margin_bottom, self.margin_left],+ to,+ );+ [self.border_top, self.border_right, self.border_bottom, self.border_left] = from.sides_in(+ [self.border_top, self.border_right, self.border_bottom, self.border_left],+ to,+ );+ [+ self.padding_top,+ self.padding_right,+ self.padding_bottom,+ self.padding_left,+ ] = from.sides_in(+ [+ self.padding_top,+ self.padding_right,+ self.padding_bottom,+ self.padding_left,+ ],+ to,+ );+ if from.is_orthogonal_to(to) {+ std::mem::swap(&mut self.content_inline_size, &mut self.content_block_size);+ std::mem::swap(&mut self.has_definite_inline_size, &mut self.has_definite_block_size);+ }+ self+ }}#[derive(Clone, Copy, Debug, PartialEq, Eq)]@@ -501,58 +535,8 @@ impl UsedValuesCellState {/// The state, with the sizes, size constraints and box sides it holds in frame `from` read in frame `to` instead.pub(crate) fn in_frame(mut self, from: geometry::Frame, to: geometry::Frame) -> Self {- if from == to {- return self;- }- let inputs = &mut self.inputs;- [- inputs.margin_top,- inputs.margin_right,- inputs.margin_bottom,- inputs.margin_left,- ] = from.sides_in(- [- inputs.margin_top,- inputs.margin_right,- inputs.margin_bottom,- inputs.margin_left,- ],- to,- );- [- inputs.border_top,- inputs.border_right,- inputs.border_bottom,- inputs.border_left,- ] = from.sides_in(- [- inputs.border_top,- inputs.border_right,- inputs.border_bottom,- inputs.border_left,- ],- to,- );- [- inputs.padding_top,- inputs.padding_right,- inputs.padding_bottom,- inputs.padding_left,- ] = from.sides_in(- [- inputs.padding_top,- inputs.padding_right,- inputs.padding_bottom,- inputs.padding_left,- ],- to,- );+ self.inputs = self.inputs.in_frame(from, to);if from.is_orthogonal_to(to) {- std::mem::swap(&mut inputs.content_inline_size, &mut inputs.content_block_size);- std::mem::swap(- &mut inputs.has_definite_inline_size,- &mut inputs.has_definite_block_size,- );self.baselines = DerivedBaselines::default();}self