Truly independent web browser
LibWeb: Tell a run through its input that its root keeps its geometry
Aliaksandr Kalenik0500113f7f91
diff --git a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rsindex a5dac70bee4..2918da6aff5 100644--- a/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs+++ b/Libraries/LibWeb/Rust/src/layout/fc_run_cache.rs@@ -216,6 +216,7 @@ fn sizing_directives_match_ignoring_unobserved(math_stretch_size_constraint,maximum_inline_size_resolved_by_caller,root_is_measured_for_its_content_block_size,+ root_keeps_its_committed_geometry,} = *a;forced_content_inline_size == b.forced_content_inline_size&& forced_content_block_size == b.forced_content_block_size@@ -233,6 +234,7 @@ fn sizing_directives_match_ignoring_unobserved(&& math_stretch_size_constraint == b.math_stretch_size_constraint&& maximum_inline_size_resolved_by_caller == b.maximum_inline_size_resolved_by_caller&& root_is_measured_for_its_content_block_size == b.root_is_measured_for_its_content_block_size+ && root_keeps_its_committed_geometry == b.root_keeps_its_committed_geometry&& match (flex_self_block_size_resolution_space,b.flex_self_block_size_resolution_space,diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex 4805afb1bcc..098df56192d 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -2068,6 +2068,10 @@ fn execute_formatting_context_run(fragmentainer: Option<std::rc::Rc<fragmentation::FragmentainerContext>>,) -> RunOutputs {assert!(!box_.is_invalid());+ assert_eq!(+ input.sizing.root_keeps_its_committed_geometry, root_cells.has_content_offset,+ "only a root that keeps its committed geometry is placed before its run"+ );let parent_owns_root_input_cells = parent_owns_root_input_cells(&callbacks, box_, &input);let checks_root_input_cells_its_parent_owns =parent_owns_root_input_cells && (cfg!(debug_assertions) || run_repeatability::verification_is_enabled());@@ -2471,6 +2475,7 @@ fn enter_own_frame(.treat_block_axis_percentage_insets_as_auto_beyond_root,forced_content_inline_size: body_input.sizing.forced_content_inline_size,forced_content_block_size: body_input.sizing.forced_content_block_size,+ root_keeps_its_committed_geometry: input.sizing.root_keeps_its_committed_geometry,..RootSizingDirectives::default()};std::mem::swap(@@ -3459,7 +3464,7 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {.expect("partial relayout root must have committed geometry"),);let fragments = run.fragments.as_deref().expect("partial relayout must build fragments");- let input = LayoutInput::new(+ let mut input = LayoutInput::new(AvailableSpace {inline_size: AvailableSize::definite(root_used.content_inline_size.get()),block_size: AvailableSize::definite(root_used.content_block_size.get()),@@ -3469,6 +3474,7 @@ fn layout_subtree_with_frozen_root_geometry(run: &FormattingContextRun<'_>) {ContainingBlockConstraints::default(),ParticipationInParentFormattingContext::Root,);+ input.sizing.root_keeps_its_committed_geometry = true;let facts = NodeFacts::new(callbacks, root);debug_assert!(facts.is_svg_svg_box());diff --git a/Libraries/LibWeb/Rust/src/layout/geometry.rs b/Libraries/LibWeb/Rust/src/layout/geometry.rsindex 537af4d9716..b44faf6002d 100644--- a/Libraries/LibWeb/Rust/src/layout/geometry.rs+++ b/Libraries/LibWeb/Rust/src/layout/geometry.rs@@ -347,6 +347,9 @@ pub(crate) struct RootSizingDirectives {// Input-only: MathML layout lays out an embellished operator with the size its core operator should stretch to// cover.pub(crate) math_stretch_size_constraint: Option<MathStretchSizeConstraint>,+ // Input-only: a partial relayout lays out the contents of its root inside the geometry the root committed, which+ // the run keeps as it is.+ pub(crate) root_keeps_its_committed_geometry: bool,}/// The size that MathML layout asks the core operator of an embellished operator to stretch to cover.diff --git a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rsindex 91c4ab80e8c..4d64b2ec091 100644--- a/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs+++ b/Libraries/LibWeb/Rust/src/layout/run_repeatability.rs@@ -73,10 +73,9 @@ fn unobserved_own_block_size_verification_is_enabled() -> bool {}fn run_is_verified_at_other_unobserved_root_inputs(- root_cells: used_values::RootInputCells,own_block_size: formatting_context::OwnBlockSizeObservation,) -> bool {- own_block_size == formatting_context::OwnBlockSizeObservation::Unobserved && !root_cells.has_content_offset+ own_block_size == formatting_context::OwnBlockSizeObservation::Unobserved}fn root_inputs_at_other_own_block_sizes(@@ -85,7 +84,7 @@ fn root_inputs_at_other_own_block_sizes(own_block_size: formatting_context::OwnBlockSizeObservation,automatic_content_block_size: CssPixels,) -> Vec<(used_values::RootInputCells, LayoutInput)> {- if !run_is_verified_at_other_unobserved_root_inputs(root_cells, own_block_size) {+ if !run_is_verified_at_other_unobserved_root_inputs(own_block_size) {return Vec::new();}let mut other_definite_own_block_sizes = Vec::new();@@ -119,7 +118,7 @@ fn root_cells_at_other_block_margins(root_cells: used_values::RootInputCells,own_block_size: formatting_context::OwnBlockSizeObservation,) -> Option<used_values::RootInputCells> {- run_is_verified_at_other_unobserved_root_inputs(root_cells, own_block_size).then(|| used_values::RootInputCells {+ run_is_verified_at_other_unobserved_root_inputs(own_block_size).then(|| used_values::RootInputCells {margin_top: root_cells.margin_top + CssPixels::from_integer(30),margin_bottom: root_cells.margin_bottom - CssPixels::from_integer(20),..root_cellsdiff --git a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rsindex 3f9d1697995..dc73b2136c6 100644--- a/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/svg_formatting_context.rs@@ -1899,7 +1899,10 @@ impl<'pass> SvgFormattingContext<'pass> {let used = &used_pointer;self.commit_svg_element_facts(self.run.box_, facts, attributes);- if facts.is_document_element && !facts.document_is_decoded_svg && !used.has_content_offset.get() {+ if facts.is_document_element+ && !facts.document_is_decoded_svg+ && !input.sizing.root_keeps_its_committed_geometry+ {// Overwrite the content width/height with the styled node width/height (from <svg width height ...>)//// NOTE: If a height had not been provided by the svg element, it was set to the height of the container