Truly independent web browser
LibWeb: Note percentage dependencies where the run resolves them
Aliaksandr Kalenik339643d0792a
diff --git a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/formatting_context.rsindex fcef823b222..c9ebd5b481a 100644--- a/Libraries/LibWeb/Rust/src/layout/formatting_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/formatting_context.rs@@ -2762,14 +2762,18 @@ pub(crate) fn propagate_percentage_block_size_dependency_to_containing_block(if !child_depends_on_percentage_block_size && !relative_block_insets_resolve_against_containing_block {return;}- let containing_block = callbacks.in_flow_containing_block(child);- let containing_block_or_run_root_that_forwarded_the_basis =- if !containing_block.is_invalid() && records.holds_box(containing_block) {- containing_block- } else {- records.root()- };- records.note_descendant_depends_on_percentage_block_size(containing_block_or_run_root_that_forwarded_the_basis);+ // NB: The nearest box at or above the containing block whose dependency this run resolves hears of it, which is+ // the run root where the containing block lies above it.+ let mut box_resolving_the_dependency = callbacks.in_flow_containing_block(child);+ while !box_resolving_the_dependency.is_invalid()+ && !records.resolves_percentage_block_size_dependency_of(box_resolving_the_dependency)+ {+ box_resolving_the_dependency = callbacks.parent(box_resolving_the_dependency);+ }+ if box_resolving_the_dependency.is_invalid() {+ box_resolving_the_dependency = records.root();+ }+ records.note_descendant_depends_on_percentage_block_size(box_resolving_the_dependency);}/// The layout of a child: its outcome, the fragments its placement takes, and the child's box as its layout left it,diff --git a/Libraries/LibWeb/Rust/src/layout/run_records.rs b/Libraries/LibWeb/Rust/src/layout/run_records.rsindex 80fb380063a..1aa6bac57d0 100644--- a/Libraries/LibWeb/Rust/src/layout/run_records.rs+++ b/Libraries/LibWeb/Rust/src/layout/run_records.rs@@ -601,11 +601,6 @@ impl<'arena> RunRecords<'arena> {}}- /// Whether this run holds `node`: lays it out itself, or keeps a child laid out by a run of its own.- pub(crate) fn holds_box(&self, node: Node) -> bool {- self.is_root_with_record(node) || self.held_boxes.borrow().contains_key(&node)- }-#[track_caller]fn panic_for_box_not_held(&self, node: Node) -> ! {panic!(@@ -655,6 +650,15 @@ impl<'arena> RunRecords<'arena> {});}+ /// Whether this run resolves the percentage block size dependency of `node`: the run root, or a box whose layout is+ /// in progress.+ pub(crate) fn resolves_percentage_block_size_dependency_of(&self, node: Node) -> bool {+ self.percentage_block_size_dependencies_in_progress+ .borrow()+ .iter()+ .any(|(tracked, _)| *tracked == node)+ }+/// Notes that a box `containing_block` contains depends on the block size its percentages resolve against./// Nothing resolves the dependency of a box that is neither the run root nor in progress, so the note is dropped for/// such a box.diff --git a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs b/Libraries/LibWeb/Rust/src/layout/sizing_context.rsindex 791805f6301..d3f74bb11e0 100644--- a/Libraries/LibWeb/Rust/src/layout/sizing_context.rs+++ b/Libraries/LibWeb/Rust/src/layout/sizing_context.rs@@ -1315,8 +1315,7 @@ impl<'pass, 'container> SizingContext<'pass, 'container> {let style = self.style(node);let in_quirks_mode = facts.document_in_quirks_mode();let svg_root_forwards_quirks_basis = facts.is_svg_svg_box() && in_quirks_mode;- let forwards_block_basis_as_anonymous_box =- self.records.holds_box(node) && self.forwards_percentage_bases_as_anonymous_box(node);+ let forwards_block_basis_as_anonymous_box = self.forwards_percentage_bases_as_anonymous_box(node);let forwards_quirks_basis_as_auto_height_block_container = in_quirks_mode&& !facts.is_viewport()&& !facts.is_table_cell()