mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibWeb: Factor out "process the URL" AO for SVGUseElement
This commit is contained in:
parent
5151f94d39
commit
ab70932681
Notes:
github-actions[bot]
2024-08-05 09:28:11 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/ab70932681c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/873 Reviewed-by: https://github.com/tcl3
2 changed files with 12 additions and 3 deletions
|
@ -60,12 +60,19 @@ void SVGUseElement::attribute_changed(FlyString const& name, Optional<String> co
|
|||
} else if (name == SVG::AttributeNames::y) {
|
||||
m_y = AttributeParser::parse_coordinate(value.value_or(String {}));
|
||||
} else if (name == SVG::AttributeNames::href || name == "xlink:href"_fly_string) {
|
||||
m_referenced_id = parse_id_from_href(value.value_or(String {}));
|
||||
|
||||
clone_element_tree_as_our_shadow_tree(referenced_element());
|
||||
// When the ‘href’ attribute is set (or, in the absence of an ‘href’ attribute, an ‘xlink:href’ attribute), the user agent must process the URL.
|
||||
process_the_url(value);
|
||||
}
|
||||
}
|
||||
|
||||
// https://www.w3.org/TR/SVG2/linking.html#processingURL
|
||||
void SVGUseElement::process_the_url(Optional<String> const& href)
|
||||
{
|
||||
m_referenced_id = parse_id_from_href(href.value_or(String {}));
|
||||
|
||||
clone_element_tree_as_our_shadow_tree(referenced_element());
|
||||
}
|
||||
|
||||
Optional<FlyString> SVGUseElement::parse_id_from_href(StringView href)
|
||||
{
|
||||
auto id_seperator = href.find('#');
|
||||
|
|
|
@ -51,6 +51,8 @@ private:
|
|||
|
||||
virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
|
||||
|
||||
void process_the_url(Optional<String> const& href);
|
||||
|
||||
static Optional<FlyString> parse_id_from_href(StringView);
|
||||
|
||||
JS::GCPtr<DOM::Element> referenced_element();
|
||||
|
|
Loading…
Reference in a new issue