Skip to content

Truly independent web browser

LibWeb: Paint the root background over the viewport box's overflow

Andreas Klingaefa654701d6
diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/background_resolution.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/background_resolution.rs
index 6462fdeb24e..bee2998ae48 100644
--- a/Libraries/LibWeb/Rust/src/painting/record/paint/background_resolution.rs
+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/background_resolution.rs
@@ -864,15 +864,18 @@ pub(crate) fn has_background_to_paint(
})
}
-/// The root background covers the viewport and the root's scrollable overflow. Moving the
-/// viewport inside that area does not change the recorded background; growing it does.
+/// The root background covers the viewport and everything it can scroll to. Moving the viewport
+/// inside that area does not change the recorded background; growing it does.
pub(crate) fn root_background_canvas_rect(
arena: &impl PaintRead,
root: NodeSlotId,
viewport_rect: CssPixelRect,
) -> CssPixelRect {
let mut rect = viewport_rect;
- if let Some(overflow_rect) = crate::painting::paintable_geometry::scrollable_overflow_rect(arena, root) {
+ // NB: The overflow of the viewport box, not of the root: a box positioned against the initial containing block
+ // is overflow of the viewport alone, and the compositor scrolls to it without a new recording.
+ let viewport = arena.node_parent_if_live(root).unwrap_or(root);
+ if let Some(overflow_rect) = crate::painting::paintable_geometry::scrollable_overflow_rect(arena, viewport) {
rect.unite(overflow_rect);
}
rect
diff --git a/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs b/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs
index efda7644456..e33d0c02286 100644
--- a/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs
+++ b/Libraries/LibWeb/Rust/src/painting/scrollable_overflow.rs
@@ -124,7 +124,7 @@ impl LayoutNodeArena {
node,
PaintDamage::SCROLL_METADATA | PaintDamage::DRAW_OVERLAY | PaintDamage::HIT_OVERLAY,
);
- // The root background covers the viewport united with the root's overflow.
+ // The root background covers the viewport united with the overflow of the viewport box.
if self.node_kind_if_live(node) == Some(NodeKind::Viewport)
&& let Some(source) = self.paint_state().root_background_source
{
diff --git a/Tests/LibWeb/Text/expected/display_list/root-background-absolutely-positioned-overflow.txt b/Tests/LibWeb/Text/expected/display_list/root-background-absolutely-positioned-overflow.txt
index 01e02d7f73e..a6a173ddd59 100644
--- a/Tests/LibWeb/Text/expected/display_list/root-background-absolutely-positioned-overflow.txt
+++ b/Tests/LibWeb/Text/expected/display_list/root-background-absolutely-positioned-overflow.txt
@@ -7,6 +7,6 @@ AccumulatedVisualContext Tree:
DisplayList:
CompositorScrollNode@s0/e0 scroll_node_index=s1 parent_scroll_node_index=s0 scrollport_rect=[0,0 800x600] min_scroll_offset=[0,0] max_scroll_offset=[0,2400] is_viewport=true
-DrawRepeatedTile@s1/e0 dst_rect=[0,0 50x50] clip_rect=[0,0 800x613] tile_size=[50x50] tile_step=[50x50] scaling_mode=Bilinear inline_clips=[clip=[0,0 800x613]]
+DrawRepeatedTile@s1/e0 dst_rect=[0,0 50x50] clip_rect=[0,0 800x3000] tile_size=[50x50] tile_step=[50x50] scaling_mode=Bilinear inline_clips=[clip=[0,0 800x3000]]
PaintLinearGradient@s1/e0 rect=[0,0 50x50]