/src/serenity/Userland/Libraries/LibWeb/Layout/SVGSVGBox.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/Layout/ReplacedBox.h> |
10 | | #include <LibWeb/SVG/SVGSVGElement.h> |
11 | | |
12 | | namespace Web::Layout { |
13 | | |
14 | | class SVGSVGBox final : public ReplacedBox { |
15 | | JS_CELL(SVGSVGBox, ReplacedBox); |
16 | | JS_DECLARE_ALLOCATOR(SVGSVGBox); |
17 | | |
18 | | public: |
19 | | SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, NonnullRefPtr<CSS::StyleProperties>); |
20 | | virtual ~SVGSVGBox() override = default; |
21 | | |
22 | 0 | SVG::SVGSVGElement& dom_node() { return verify_cast<SVG::SVGSVGElement>(ReplacedBox::dom_node()); } |
23 | 0 | SVG::SVGSVGElement const& dom_node() const { return verify_cast<SVG::SVGSVGElement>(ReplacedBox::dom_node()); } |
24 | | |
25 | 0 | virtual bool can_have_children() const override { return true; } |
26 | | |
27 | | virtual JS::GCPtr<Painting::Paintable> create_paintable() const override; |
28 | | |
29 | | virtual void prepare_for_replaced_layout() override; |
30 | | |
31 | | private: |
32 | 0 | virtual bool is_svg_svg_box() const final { return true; } |
33 | | |
34 | | [[nodiscard]] Optional<CSSPixelFraction> calculate_intrinsic_aspect_ratio() const; |
35 | | }; |
36 | | |
37 | | template<> |
38 | 0 | inline bool Node::fast_is<SVGSVGBox>() const { return is_svg_svg_box(); } |
39 | | |
40 | | } |