1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:28:10 +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

@ -262,14 +262,7 @@ void InProcessWebView::paint_event(GUI::PaintEvent& event)
return;
}
painter.fill_rect(event.rect(), document()->background_color(palette()));
if (auto background_bitmap = document()->background_image()) {
painter.draw_tiled_bitmap(event.rect(), *background_bitmap);
}
painter.translate(frame_thickness(), frame_thickness());
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
PaintContext context(painter, palette(), { horizontal_scrollbar().value(), vertical_scrollbar().value() });
context.set_should_show_line_box_borders(m_should_show_line_box_borders);