summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Flynn <trflynn89@pm.me>2022-03-25 13:39:52 -0400
committerAndreas Kling <kling@serenityos.org>2022-03-25 20:11:04 +0100
commite5db67d6ddc0e3284ba46d13f1d3f1fe23817d18 (patch)
tree2f8d95cd6357cfc5a2c847ec23061a00eec1dfee
parenta5ea0666930870b3d37f31e349893d378ef2eee5 (diff)
downloadserenity-e5db67d6ddc0e3284ba46d13f1d3f1fe23817d18.zip
LibWeb: Attach BackgroundAttachment::Fixed to the window view port
This fixes the placement of several background images on Acid2, most notably the background of the eyes and the red rectangle near the bottom of the head.
-rw-r--r--Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp
index 7ff6166b8b..8e9d20818d 100644
--- a/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp
+++ b/Userland/Libraries/LibWeb/Painting/BackgroundPainting.cpp
@@ -6,12 +6,14 @@
*/
#include <LibGfx/Painter.h>
+#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/Node.h>
#include <LibWeb/Painting/BackgroundPainting.h>
#include <LibWeb/Painting/PaintContext.h>
namespace Web::Painting {
+// https://www.w3.org/TR/css-backgrounds-3/#backgrounds
void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMetrics const& layout_node, Gfx::IntRect const& border_rect, Color background_color, Vector<CSS::BackgroundLayerData> const* background_layers, BorderRadiusData const& border_radius)
{
auto& painter = context.painter();
@@ -57,10 +59,18 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
painter.save();
painter.add_clip_rect(clip_rect);
- // FIXME: Attachment
+ Gfx::IntRect background_positioning_area;
- // Origin
- auto background_positioning_area = get_box(layer.origin);
+ // Attachment and Origin
+ switch (layer.attachment) {
+ case CSS::BackgroundAttachment::Fixed:
+ background_positioning_area = layout_node.root().browsing_context().viewport_rect();
+ break;
+ case CSS::BackgroundAttachment::Local:
+ case CSS::BackgroundAttachment::Scroll:
+ background_positioning_area = get_box(layer.origin);
+ break;
+ }
// Size
Gfx::IntRect image_rect;