/src/serenity/Userland/Libraries/LibWeb/SVG/SVGTextPathElement.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2023, MacDue <macdue@dueutil.tech> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibURL/URL.h> |
8 | | #include <LibWeb/Bindings/SVGTextPathElementPrototype.h> |
9 | | #include <LibWeb/Layout/SVGTextPathBox.h> |
10 | | #include <LibWeb/SVG/AttributeNames.h> |
11 | | #include <LibWeb/SVG/SVGTextPathElement.h> |
12 | | |
13 | | namespace Web::SVG { |
14 | | |
15 | | JS_DEFINE_ALLOCATOR(SVGTextPathElement); |
16 | | |
17 | | SVGTextPathElement::SVGTextPathElement(DOM::Document& document, DOM::QualifiedName qualified_name) |
18 | 0 | : SVGTextContentElement(document, move(qualified_name)) |
19 | 0 | { |
20 | 0 | } |
21 | | |
22 | | JS::GCPtr<SVGGeometryElement const> SVGTextPathElement::path_or_shape() const |
23 | 0 | { |
24 | 0 | auto href = get_attribute(AttributeNames::href); |
25 | 0 | if (!href.has_value()) |
26 | 0 | return {}; |
27 | 0 | auto url = document().url().complete_url(*href); |
28 | 0 | return try_resolve_url_to<SVGGeometryElement const>(url); |
29 | 0 | } |
30 | | |
31 | | void SVGTextPathElement::initialize(JS::Realm& realm) |
32 | 0 | { |
33 | 0 | Base::initialize(realm); |
34 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGTextPathElement); |
35 | 0 | } |
36 | | |
37 | | void SVGTextPathElement::visit_edges(Cell::Visitor& visitor) |
38 | 0 | { |
39 | 0 | Base::visit_edges(visitor); |
40 | 0 | SVGURIReferenceMixin::visit_edges(visitor); |
41 | 0 | } |
42 | | |
43 | | JS::GCPtr<Layout::Node> SVGTextPathElement::create_layout_node(NonnullRefPtr<CSS::StyleProperties> style) |
44 | 0 | { |
45 | 0 | return heap().allocate_without_realm<Layout::SVGTextPathBox>(document(), *this, move(style)); |
46 | 0 | } |
47 | | |
48 | | }; |