Truly independent web browser
LibWeb: Place line fragments by their box when measuring overflow
Andreas Kling88b0c1fc2ceb
diff --git a/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs b/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rsindex d0500551c23..a41144a6683 100644--- a/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs+++ b/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs@@ -342,7 +342,13 @@ fn measure_scrollable_overflow_impl(in_flow_and_floated_content_bounds.unite(line_rect);}for fragment in side_data.fragments() {- let mut fragment_rect = text_fragment::absolute_rect(layout_arena, fragment);+ // NB: The box holding the line boxes is the containing block of each of their fragments, and their+ // offsets are relative to it, also for a fragment whose node left the tree since it was laid out.+ debug_assert!(+ text_fragment::containing_block_paintable(layout_arena, fragment)+ .is_none_or(|block| block == box_paintable)+ );+ let mut fragment_rect = text_fragment::rect_in_containing_block(fragment).translated_by(absolute_position);if layout_arena.node_is_in_focused_text_control(fragment.layout_node)&& let Some(style_source_style) =layout_arena.node_style_if_live(text_fragment::style_source(layout_arena, fragment))diff --git a/Libraries/LibWeb/Rust/src/painting/text_fragment.rs b/Libraries/LibWeb/Rust/src/painting/text_fragment.rsindex ce25c188385..91c7c99a1c6 100644--- a/Libraries/LibWeb/Rust/src/painting/text_fragment.rs+++ b/Libraries/LibWeb/Rust/src/painting/text_fragment.rs@@ -32,18 +32,23 @@ pub(crate) fn containing_block_paintable(}pub(crate) fn absolute_rect(layout_arena: &impl PaintRead, fragment: &FragmentRecord) -> CssPixelRect {+ let rect = rect_in_containing_block(fragment);+ match containing_block_paintable(layout_arena, fragment) {+ Some(block) => rect.translated_by(paintable_geometry::absolute_position(layout_arena, block)),+ None => rect,+ }+}++/// The fragment's rect relative to its containing block, which is the box whose line boxes hold it.+pub(crate) fn rect_in_containing_block(fragment: &FragmentRecord) -> CssPixelRect {let (x, y) = fragment.offset();let (width, height) = fragment.size();- let mut rect = CssPixelRect {+ CssPixelRect {x: x + fragment.relpos_delta.x,y: y + fragment.relpos_delta.y,width,height,- };- if let Some(block) = containing_block_paintable(layout_arena, fragment) {- rect = rect.translated_by(paintable_geometry::absolute_position(layout_arena, block));}- rect}pub(crate) fn absolute_line_box_rect(