1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:07:34 +00:00

LibWeb: Make tiled backgrounds scroll with content

Previously the page background was always draw relative to the viewport
instead of following with the content. This should eventually become
an opt-in mode (via CSS "background-attachment") but for now let's have
the default behavior be that backgrounds scroll with content.

Also take this opportunity to move the background painting code from
the two web views to a shared location in InitialContainingBlockBox.
This commit is contained in:
Andreas Kling 2021-03-07 13:46:20 +01:00
parent 6c087480cf
commit 7f9f916470
4 changed files with 21 additions and 15 deletions

View file

@ -84,14 +84,6 @@ void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target)
return;
}
painter.fill_rect(bitmap_rect, layout_root->document().background_color(palette()));
if (auto background_bitmap = layout_root->document().background_image()) {
painter.draw_tiled_bitmap(bitmap_rect, *background_bitmap);
}
painter.translate(-content_rect.x(), -content_rect.y());
Web::PaintContext context(painter, palette(), content_rect.top_left());
context.set_should_show_line_box_borders(m_should_show_line_box_borders);
context.set_viewport_rect(content_rect);