2024-06-23 17:05:47 +02:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2024, Andreas Kling <andreas@ladybird.org>
|
2024-07-16 12:08:34 +01:00
|
|
|
|
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
|
2024-06-23 17:05:47 +02:00
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2024-06-28 14:51:57 +02:00
|
|
|
|
#include <LibWeb/Bindings/SVGAElementPrototype.h>
|
2024-07-16 12:08:34 +01:00
|
|
|
|
#include <LibWeb/DOM/DOMTokenList.h>
|
2024-06-23 17:05:47 +02:00
|
|
|
|
#include <LibWeb/Layout/SVGGraphicsBox.h>
|
|
|
|
|
#include <LibWeb/SVG/SVGAElement.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::SVG {
|
|
|
|
|
|
|
|
|
|
JS_DEFINE_ALLOCATOR(SVGAElement);
|
|
|
|
|
|
|
|
|
|
SVGAElement::SVGAElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
|
|
|
|
: SVGGraphicsElement(document, move(qualified_name))
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SVGAElement::~SVGAElement() = default;
|
|
|
|
|
|
2024-06-28 14:51:57 +02:00
|
|
|
|
void SVGAElement::initialize(JS::Realm& realm)
|
|
|
|
|
{
|
|
|
|
|
Base::initialize(realm);
|
|
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(SVGAElement);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-16 12:08:34 +01:00
|
|
|
|
void SVGAElement::visit_edges(Cell::Visitor& visitor)
|
|
|
|
|
{
|
|
|
|
|
Base::visit_edges(visitor);
|
2024-07-16 13:43:42 +01:00
|
|
|
|
SVGURIReferenceMixin::visit_edges(visitor);
|
2024-07-16 12:08:34 +01:00
|
|
|
|
visitor.visit(m_rel_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SVGAElement::attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value)
|
|
|
|
|
{
|
|
|
|
|
Base::attribute_changed(name, old_value, value);
|
2024-11-06 18:00:18 +01:00
|
|
|
|
if (name == SVG::AttributeNames::href) {
|
|
|
|
|
invalidate_style(DOM::StyleInvalidationReason::HTMLHyperlinkElementHrefChange);
|
|
|
|
|
}
|
2024-07-16 12:08:34 +01:00
|
|
|
|
if (name == HTML::AttributeNames::rel) {
|
|
|
|
|
if (m_rel_list)
|
|
|
|
|
m_rel_list->associated_attribute_changed(value.value_or(String {}));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-14 18:45:18 +01:00
|
|
|
|
// https://html.spec.whatwg.org/multipage/interaction.html#dom-tabindex
|
|
|
|
|
i32 SVGAElement::default_tab_index_value() const
|
|
|
|
|
{
|
|
|
|
|
// See the base function for the spec comments.
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-16 12:08:34 +01:00
|
|
|
|
// https://svgwg.org/svg2-draft/linking.html#__svg__SVGAElement__relList
|
|
|
|
|
JS::NonnullGCPtr<DOM::DOMTokenList> SVGAElement::rel_list()
|
|
|
|
|
{
|
|
|
|
|
// The relList IDL attribute reflects the ‘rel’ content attribute.
|
|
|
|
|
if (!m_rel_list)
|
|
|
|
|
m_rel_list = DOM::DOMTokenList::create(*this, HTML::AttributeNames::rel);
|
|
|
|
|
return *m_rel_list;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-26 17:42:27 +02:00
|
|
|
|
JS::GCPtr<Layout::Node> SVGAElement::create_layout_node(CSS::StyleProperties style)
|
2024-06-23 17:05:47 +02:00
|
|
|
|
{
|
2024-11-14 06:13:46 +13:00
|
|
|
|
return heap().allocate<Layout::SVGGraphicsBox>(document(), *this, move(style));
|
2024-06-23 17:05:47 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|