/src/serenity/Userland/Libraries/LibWeb/SVG/SVGClipPathElement.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2022, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/SVG/AttributeParser.h> |
10 | | #include <LibWeb/SVG/SVGElement.h> |
11 | | #include <LibWeb/SVG/SVGViewport.h> |
12 | | |
13 | | namespace Web::SVG { |
14 | | |
15 | | class SVGClipPathElement final : public SVGElement |
16 | | , public SVGViewport { |
17 | | WEB_PLATFORM_OBJECT(SVGClipPathElement, SVGElement); |
18 | | JS_DECLARE_ALLOCATOR(SVGClipPathElement); |
19 | | |
20 | | public: |
21 | | virtual ~SVGClipPathElement(); |
22 | | |
23 | | virtual Optional<ViewBox> view_box() const override |
24 | 0 | { |
25 | | // Same trick as SVGMaskElement. |
26 | 0 | if (clip_path_units() == MaskContentUnits::ObjectBoundingBox) |
27 | 0 | return ViewBox { 0, 0, 1, 1 }; |
28 | 0 | return {}; |
29 | 0 | } |
30 | | |
31 | | virtual Optional<PreserveAspectRatio> preserve_aspect_ratio() const override |
32 | 0 | { |
33 | 0 | return PreserveAspectRatio { PreserveAspectRatio::Align::None, {} }; |
34 | 0 | } |
35 | | |
36 | | virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value) override; |
37 | | |
38 | | ClipPathUnits clip_path_units() const |
39 | 0 | { |
40 | 0 | return m_clip_path_units.value_or(ClipPathUnits::UserSpaceOnUse); |
41 | 0 | } |
42 | | |
43 | | virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; |
44 | | |
45 | | private: |
46 | | SVGClipPathElement(DOM::Document&, DOM::QualifiedName); |
47 | | virtual void initialize(JS::Realm&) override; |
48 | | |
49 | | Optional<ClipPathUnits> m_clip_path_units = {}; |
50 | | }; |
51 | | |
52 | | } |