2020-07-19 23:01:53 -07:00
|
|
|
/*
|
2021-04-22 16:53:07 -07:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2020-07-19 23:01:53 -07:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-19 23:01:53 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2023-07-20 20:58:13 +01:00
|
|
|
#include <LibWeb/DOM/Document.h>
|
2020-07-23 09:44:42 -07:00
|
|
|
#include <LibWeb/DOM/Element.h>
|
2024-10-29 11:07:02 +01:00
|
|
|
#include <LibWeb/HTML/HTMLOrSVGElement.h>
|
2024-07-09 20:59:00 +01:00
|
|
|
#include <LibWeb/SVG/SVGAnimatedString.h>
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2020-07-23 09:44:42 -07:00
|
|
|
namespace Web::SVG {
|
2020-07-19 23:01:53 -07:00
|
|
|
|
2024-07-09 20:20:05 +01:00
|
|
|
class SVGElement
|
|
|
|
|
: public DOM::Element
|
2024-10-29 11:07:02 +01:00
|
|
|
, public HTML::GlobalEventHandlers
|
|
|
|
|
, public HTML::HTMLOrSVGElement<SVGElement> {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(SVGElement, DOM::Element);
|
2020-10-02 20:57:28 +01:00
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
public:
|
2021-08-05 10:26:09 +02:00
|
|
|
virtual bool requires_svg_container() const override { return true; }
|
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<SVGAnimatedString> class_name();
|
|
|
|
|
GC::Ptr<SVGSVGElement> owner_svg_element();
|
2024-07-09 20:59:00 +01:00
|
|
|
|
2024-12-24 17:16:10 +09:00
|
|
|
bool should_include_in_accessibility_tree() const;
|
|
|
|
|
virtual Optional<ARIA::Role> default_role() const override;
|
|
|
|
|
|
2020-07-26 17:47:26 +02:00
|
|
|
protected:
|
2022-02-18 21:00:52 +01:00
|
|
|
SVGElement(DOM::Document&, DOM::QualifiedName);
|
2021-09-26 15:24:41 +01:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2022-08-28 13:42:07 +02:00
|
|
|
virtual void visit_edges(Cell::Visitor&) override;
|
|
|
|
|
|
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;
|
2025-01-11 17:37:08 +00:00
|
|
|
virtual WebIDL::ExceptionOr<void> cloned(DOM::Node&, bool) const override;
|
2024-10-29 13:27:01 +01:00
|
|
|
virtual void children_changed() override;
|
|
|
|
|
virtual void inserted() override;
|
|
|
|
|
virtual void removed_from(Node*) override;
|
|
|
|
|
|
2023-05-30 21:23:52 +01:00
|
|
|
void update_use_elements_that_reference_this();
|
|
|
|
|
void remove_from_use_element_that_reference_this();
|
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<SVGAnimatedLength> svg_animated_length_for_property(CSS::PropertyID) const;
|
2024-04-01 00:40:26 +01:00
|
|
|
|
2023-05-24 05:41:55 +02:00
|
|
|
private:
|
2024-07-09 20:20:05 +01:00
|
|
|
// ^HTML::GlobalEventHandlers
|
2024-11-15 04:01:23 +13:00
|
|
|
virtual GC::Ptr<DOM::EventTarget> global_event_handlers_to_event_target(FlyString const&) override { return *this; }
|
2024-07-09 20:20:05 +01:00
|
|
|
|
2023-05-24 05:41:55 +02:00
|
|
|
virtual bool is_svg_element() const final { return true; }
|
2024-07-09 20:59:00 +01:00
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ptr<SVGAnimatedString> m_class_name_animated_string;
|
2020-07-19 23:01:53 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
2023-05-24 05:41:55 +02:00
|
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
|
|
|
|
|
|
template<>
|
|
|
|
|
inline bool Node::fast_is<SVG::SVGElement>() const { return is_svg_element(); }
|
|
|
|
|
|
|
|
|
|
}
|