mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 22:24:08 +03:00
LibWeb: Implement background-attachment: local
This causes the background to scroll along with the element's contents.
This commit is contained in:
parent
ad859a8d0d
commit
8356ff283b
Notes:
sideshowbarker
2024-07-17 00:37:23 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/8356ff283b Pull-request: https://github.com/SerenityOS/serenity/pull/20435
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||||
* Copyright (c) 2021-2022, Sam Atkins <atkinssj@serenityos.org>
|
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||||
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
|
* Copyright (c) 2022, MacDue <macdue@dueutil.tech>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
@ -14,6 +14,7 @@
|
|||||||
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
#include <LibWeb/Painting/BorderRadiusCornerClipper.h>
|
||||||
#include <LibWeb/Painting/GradientPainting.h>
|
#include <LibWeb/Painting/GradientPainting.h>
|
||||||
#include <LibWeb/Painting/PaintContext.h>
|
#include <LibWeb/Painting/PaintContext.h>
|
||||||
|
#include <LibWeb/Painting/PaintableBox.h>
|
||||||
|
|
||||||
namespace Web::Painting {
|
namespace Web::Painting {
|
||||||
|
|
||||||
@ -131,6 +132,15 @@ void paint_background(PaintContext& context, Layout::NodeWithStyleAndBoxModelMet
|
|||||||
background_positioning_area = layout_node.root().browsing_context().viewport_rect();
|
background_positioning_area = layout_node.root().browsing_context().viewport_rect();
|
||||||
break;
|
break;
|
||||||
case CSS::BackgroundAttachment::Local:
|
case CSS::BackgroundAttachment::Local:
|
||||||
|
background_positioning_area = get_box(layer.origin).rect;
|
||||||
|
if (is<Layout::Box>(layout_node)) {
|
||||||
|
auto* paintable_box = static_cast<Layout::Box const&>(layout_node).paintable_box();
|
||||||
|
if (paintable_box) {
|
||||||
|
auto scroll_offset = paintable_box->scroll_offset();
|
||||||
|
background_positioning_area.translate_by(-scroll_offset.x(), -scroll_offset.y());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case CSS::BackgroundAttachment::Scroll:
|
case CSS::BackgroundAttachment::Scroll:
|
||||||
background_positioning_area = get_box(layer.origin).rect;
|
background_positioning_area = get_box(layer.origin).rect;
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user