2023-05-30 21:23:52 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023, Preston Taylor <95388976+PrestonLTaylor@users.noreply.github.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-10-11 10:13:17 -04:00
|
|
|
#include <AK/FlyString.h>
|
2023-05-30 21:23:52 +01:00
|
|
|
#include <LibWeb/DOM/DocumentObserver.h>
|
|
|
|
#include <LibWeb/SVG/SVGAnimatedLength.h>
|
|
|
|
#include <LibWeb/SVG/SVGGraphicsElement.h>
|
2023-11-14 01:03:19 +00:00
|
|
|
#include <LibWeb/SVG/SVGURIReference.h>
|
2023-05-30 21:23:52 +01:00
|
|
|
|
|
|
|
namespace Web::SVG {
|
|
|
|
|
2023-11-14 01:03:19 +00:00
|
|
|
class SVGUseElement final
|
|
|
|
: public SVGGraphicsElement
|
|
|
|
, public SVGURIReferenceMixin<SupportsXLinkHref::Yes> {
|
2023-05-30 21:23:52 +01:00
|
|
|
WEB_PLATFORM_OBJECT(SVGUseElement, SVGGraphicsElement);
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_DECLARE_ALLOCATOR(SVGUseElement);
|
2023-05-30 21:23:52 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~SVGUseElement() override = default;
|
|
|
|
|
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;
|
2023-05-30 21:23:52 +01:00
|
|
|
|
|
|
|
virtual void inserted() override;
|
|
|
|
|
|
|
|
void svg_element_changed(SVGElement&);
|
|
|
|
void svg_element_removed(SVGElement&);
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<SVGAnimatedLength> x() const;
|
|
|
|
GC::Ref<SVGAnimatedLength> y() const;
|
|
|
|
GC::Ref<SVGAnimatedLength> width() const;
|
|
|
|
GC::Ref<SVGAnimatedLength> height() const;
|
2023-05-30 21:23:52 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<SVGElement> instance_root() const;
|
|
|
|
GC::Ptr<SVGElement> animated_instance_root() const;
|
2023-05-30 21:23:52 +01:00
|
|
|
|
2023-08-31 08:58:41 +01:00
|
|
|
virtual Gfx::AffineTransform element_transform() const override;
|
|
|
|
|
2023-05-30 21:23:52 +01:00
|
|
|
private:
|
|
|
|
SVGUseElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-05-30 21:23:52 +01:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
2023-06-23 02:15:03 +03:00
|
|
|
virtual bool is_svg_use_element() const override { return true; }
|
|
|
|
|
2024-12-20 16:35:12 +01:00
|
|
|
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
2023-08-19 19:42:31 +02:00
|
|
|
|
2024-07-27 15:43:56 +12:00
|
|
|
void process_the_url(Optional<String> const& href);
|
|
|
|
|
2023-12-24 15:39:06 +13:00
|
|
|
static Optional<FlyString> parse_id_from_href(StringView);
|
2023-05-30 21:23:52 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<DOM::Element> referenced_element();
|
2023-05-30 21:23:52 +01:00
|
|
|
|
2024-07-28 02:34:05 +12:00
|
|
|
void fetch_the_document(URL::URL const& url);
|
2025-04-07 10:46:22 +00:00
|
|
|
bool is_referenced_element_same_document() const;
|
2024-07-28 02:34:05 +12:00
|
|
|
|
2024-07-28 00:53:52 +12:00
|
|
|
void clone_element_tree_as_our_shadow_tree(Element* to_clone);
|
2024-07-28 00:48:59 +12:00
|
|
|
bool is_valid_reference_element(Element const& reference_element) const;
|
2023-05-30 21:23:52 +01:00
|
|
|
|
|
|
|
Optional<float> m_x;
|
|
|
|
Optional<float> m_y;
|
|
|
|
|
2025-02-15 22:55:46 +13:00
|
|
|
Optional<URL::URL> m_href;
|
2023-05-30 21:23:52 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<DOM::DocumentObserver> m_document_observer;
|
|
|
|
GC::Ptr<HTML::SharedResourceRequest> m_resource_request;
|
2024-07-28 02:34:05 +12:00
|
|
|
Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer;
|
2023-05-30 21:23:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2023-06-23 02:15:03 +03:00
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
|
|
|
|
template<>
|
|
|
|
inline bool Node::fast_is<SVG::SVGUseElement>() const { return is_svg_use_element(); }
|
|
|
|
|
|
|
|
}
|