summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorSigmund Lahn <s@lahn.no>2023-04-24 22:38:50 +0200
committerAndreas Kling <kling@serenityos.org>2023-04-25 09:33:35 +0200
commitf2f14ad9bd9c18a1a1ab517343c706b43737761e (patch)
tree26952a3790c63bdff8e6e5059b5b188fc1e2daaa /Userland/Libraries
parent5e7c838160f67774d633120ee3ed8df7f9e9261c (diff)
downloadserenity-f2f14ad9bd9c18a1a1ab517343c706b43737761e.zip
LibWeb+WebContent: Make document background and Viewport transparent
This means iframes are transparent by default (as in firefox/chrome). Painting the outermost canvas background is moved to the PageHost.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp10
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h2
-rw-r--r--Userland/Libraries/LibWeb/Layout/Viewport.cpp1
-rw-r--r--Userland/Libraries/LibWeb/Painting/PaintableBox.cpp2
4 files changed, 7 insertions, 8 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index 8d270c21e2..0aa1394a3e 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -722,7 +722,7 @@ void Document::tear_down_layout_tree()
m_layout_root = nullptr;
}
-Color Document::background_color(Gfx::Palette const& palette) const
+Color Document::background_color() const
{
// CSS2 says we should use the HTML element's background color unless it's transparent...
if (auto* html_element = this->html_element(); html_element && html_element->layout_node()) {
@@ -734,12 +734,12 @@ Color Document::background_color(Gfx::Palette const& palette) const
// ...in which case we use the BODY element's background color.
if (auto* body_element = body(); body_element && body_element->layout_node()) {
auto color = body_element->layout_node()->computed_values().background_color();
- if (color.alpha())
- return color;
+ return color;
}
- // If both HTML and BODY are transparent, we fall back to the system's "base" palette color.
- return palette.base();
+ // By default, the document is transparent.
+ // The outermost canvas is colored by the PageHost.
+ return Color::Transparent;
}
Vector<CSS::BackgroundLayerData> const* Document::background_layers() const
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index 6af28868cf..e12b88e3c4 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -179,7 +179,7 @@ public:
Page* page();
Page const* page() const;
- Color background_color(Gfx::Palette const&) const;
+ Color background_color() const;
Vector<CSS::BackgroundLayerData> const* background_layers() const;
Color link_color() const;
diff --git a/Userland/Libraries/LibWeb/Layout/Viewport.cpp b/Userland/Libraries/LibWeb/Layout/Viewport.cpp
index 2a92837ebe..1326f5a30b 100644
--- a/Userland/Libraries/LibWeb/Layout/Viewport.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Viewport.cpp
@@ -55,7 +55,6 @@ void Viewport::build_stacking_context_tree()
void Viewport::paint_all_phases(PaintContext& context)
{
build_stacking_context_tree_if_needed();
- context.painter().fill_rect(context.enclosing_device_rect(paintable_box()->absolute_rect()).to_type<int>(), document().background_color(context.palette()));
context.painter().translate(-context.device_viewport_rect().location().to_type<int>());
paintable_box()->stacking_context()->paint(context);
}
diff --git a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
index deb95630dd..75d5659d7e 100644
--- a/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
+++ b/Userland/Libraries/LibWeb/Painting/PaintableBox.cpp
@@ -257,7 +257,7 @@ void PaintableBox::paint_background(PaintContext& context) const
// user agents must instead propagate the computed values of the background properties from that element’s first HTML BODY child element.
if (document().html_element()->should_use_body_background_properties()) {
background_layers = document().background_layers();
- background_color = document().background_color(context.palette());
+ background_color = document().background_color();
}
} else {
background_rect = absolute_padding_box_rect();