2022-03-10 14:02:25 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2022, Andreas Kling <andreas@ladybird.org>
|
2022-03-10 14:02:25 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/Layout/ImageBox.h>
|
2022-03-24 16:06:43 +01:00
|
|
|
#include <LibWeb/Layout/SVGSVGBox.h>
|
2025-02-02 15:55:26 +01:00
|
|
|
#include <LibWeb/Painting/DisplayListRecorder.h>
|
2022-03-10 14:02:25 +01:00
|
|
|
#include <LibWeb/Painting/SVGPaintable.h>
|
2023-09-10 14:10:55 +01:00
|
|
|
#include <LibWeb/SVG/SVGMaskElement.h>
|
2022-03-10 14:02:25 +01:00
|
|
|
|
|
|
|
|
namespace Web::Painting {
|
|
|
|
|
|
|
|
|
|
SVGPaintable::SVGPaintable(Layout::SVGBox const& layout_box)
|
2022-03-18 22:13:26 +01:00
|
|
|
: PaintableBox(layout_box)
|
2022-03-10 14:02:25 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Layout::SVGBox const& SVGPaintable::layout_box() const
|
|
|
|
|
{
|
2022-03-10 15:50:57 +01:00
|
|
|
return static_cast<Layout::SVGBox const&>(layout_node());
|
2022-03-10 14:02:25 +01:00
|
|
|
}
|
|
|
|
|
|
2022-10-31 19:46:55 +00:00
|
|
|
CSSPixelRect SVGPaintable::compute_absolute_rect() const
|
2022-03-24 16:06:43 +01:00
|
|
|
{
|
|
|
|
|
if (auto* svg_svg_box = layout_box().first_ancestor_of_type<Layout::SVGSVGBox>()) {
|
2023-08-15 15:42:38 +02:00
|
|
|
CSSPixelRect rect { offset(), content_size() };
|
2024-03-01 15:30:44 +01:00
|
|
|
for (Layout::Box const* ancestor = svg_svg_box; ancestor; ancestor = ancestor->containing_block())
|
2023-08-15 15:42:38 +02:00
|
|
|
rect.translate_by(ancestor->paintable_box()->offset());
|
2022-03-24 16:06:43 +01:00
|
|
|
return rect;
|
|
|
|
|
}
|
|
|
|
|
return PaintableBox::compute_absolute_rect();
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-18 16:21:09 +01:00
|
|
|
ShouldAntiAlias SVGPaintable::should_anti_alias() const
|
|
|
|
|
{
|
|
|
|
|
auto shape_rendering = computed_values().shape_rendering();
|
|
|
|
|
if (first_is_one_of(shape_rendering, CSS::ShapeRendering::Optimizespeed, CSS::ShapeRendering::Crispedges))
|
|
|
|
|
return ShouldAntiAlias::No;
|
|
|
|
|
return ShouldAntiAlias::Yes;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-10 14:02:25 +01:00
|
|
|
}
|