Skip to content

Commit 1b87881

Browse files
committed
LibWeb: Fill PageHost root with document background color
This makes Acid3 have a background color again. Regressed with f2f14ad.
1 parent f4d8a24 commit 1b87881

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

Userland/Services/WebContent/PageHost.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ Web::Layout::Viewport* PageHost::layout_root()
108108
return document->layout_node();
109109
}
110110

111+
Gfx::Color PageHost::background_color() const
112+
{
113+
auto document = page().top_level_browsing_context().active_document();
114+
if (!document)
115+
return Gfx::Color::Transparent;
116+
return document->background_color();
117+
}
118+
111119
void PageHost::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& target)
112120
{
113121
Gfx::Painter painter(target);
@@ -116,7 +124,11 @@ void PageHost::paint(Web::DevicePixelRect const& content_rect, Gfx::Bitmap& targ
116124
if (auto* document = page().top_level_browsing_context().active_document())
117125
document->update_layout();
118126

119-
painter.fill_rect(bitmap_rect, palette().base());
127+
auto background_color = this->background_color();
128+
129+
if (background_color.alpha() < 255)
130+
painter.clear_rect(bitmap_rect, palette().base());
131+
painter.fill_rect(bitmap_rect, background_color);
120132

121133
auto* layout_root = this->layout_root();
122134
if (!layout_root) {

Userland/Services/WebContent/PageHost.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class PageHost final : public Web::PageClient {
4949
void confirm_closed(bool accepted);
5050
void prompt_closed(Optional<String> response);
5151

52+
[[nodiscard]] Gfx::Color background_color() const;
53+
5254
private:
5355
// ^PageClient
5456
virtual bool is_connection_open() const override;

0 commit comments

Comments
 (0)