LibHTML: Implement basic tiled background image support

It's now possible to set a page background image via <body background>.
Also, HtmlView now officially handles rendering the body element's
background (color, image or both.) LayoutBox is responsible for all
other background rendering.

Note that it's not yet possible to use CSS background-image properties
directly, since we can't parse them yet. :^)
This commit is contained in:
Andreas Kling 2019-10-19 11:49:46 +02:00
parent 96f10c8de2
commit 5a34225999
Notes: sideshowbarker 2024-07-19 11:38:31 +09:00
11 changed files with 101 additions and 7 deletions

View file

@ -25,6 +25,10 @@ HtmlView::HtmlView(GWidget* parent)
, m_main_frame(Frame::create())
{
main_frame().on_set_needs_display = [this](auto& content_rect) {
if (content_rect.is_empty()) {
update();
return;
}
Rect adjusted_rect = content_rect;
adjusted_rect.set_location(to_widget_position(content_rect.location()));
update(adjusted_rect);
@ -118,6 +122,10 @@ void HtmlView::paint_event(GPaintEvent& event)
painter.fill_rect(event.rect(), m_document->background_color());
if (auto background_bitmap = m_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());