2022-04-10 19:05:12 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-04-10 19:05:12 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2024-03-27 00:13:16 +00:00
|
|
|
#include <LibWeb/SVG/AttributeParser.h>
|
2022-04-10 19:05:12 +02:00
|
|
|
#include <LibWeb/SVG/SVGElement.h>
|
2025-01-08 14:44:00 +11:00
|
|
|
#include <LibWeb/SVG/SVGGraphicsElement.h>
|
2024-03-27 00:13:16 +00:00
|
|
|
#include <LibWeb/SVG/SVGViewport.h>
|
2022-04-10 19:05:12 +02:00
|
|
|
|
|
|
|
|
namespace Web::SVG {
|
|
|
|
|
|
2025-01-08 14:44:00 +11:00
|
|
|
class SVGClipPathElement final : public SVGGraphicsElement
|
2024-03-27 00:13:16 +00:00
|
|
|
, public SVGViewport {
|
2025-01-08 14:44:00 +11:00
|
|
|
WEB_PLATFORM_OBJECT(SVGClipPathElement, SVGGraphicsElement);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(SVGClipPathElement);
|
2022-04-10 19:05:12 +02:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2022-04-10 19:05:12 +02:00
|
|
|
virtual ~SVGClipPathElement();
|
|
|
|
|
|
2024-03-27 00:13:16 +00:00
|
|
|
virtual Optional<ViewBox> view_box() const override
|
|
|
|
|
{
|
|
|
|
|
// Same trick as SVGMaskElement.
|
|
|
|
|
if (clip_path_units() == MaskContentUnits::ObjectBoundingBox)
|
|
|
|
|
return ViewBox { 0, 0, 1, 1 };
|
|
|
|
|
return {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual Optional<PreserveAspectRatio> preserve_aspect_ratio() const override
|
|
|
|
|
{
|
|
|
|
|
return PreserveAspectRatio { PreserveAspectRatio::Align::None, {} };
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-14 08:14:16 -05:00
|
|
|
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
2024-03-27 00:13:16 +00:00
|
|
|
|
|
|
|
|
ClipPathUnits clip_path_units() const
|
|
|
|
|
{
|
|
|
|
|
return m_clip_path_units.value_or(ClipPathUnits::UserSpaceOnUse);
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-20 16:35:12 +01:00
|
|
|
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
2022-08-28 13:42:07 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
SVGClipPathElement(DOM::Document&, DOM::QualifiedName);
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2024-03-27 00:13:16 +00:00
|
|
|
|
|
|
|
|
Optional<ClipPathUnits> m_clip_path_units = {};
|
2022-04-10 19:05:12 +02:00
|
|
|
};
|
2025-05-13 07:06:33 -04:00
|
|
|
|
2022-04-10 19:05:12 +02:00
|
|
|
}
|