mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 12:20:00 +01:00
LibWeb/SVG: Prefer href to xlink:href attribute on images
This commit is contained in:
parent
93a35895ae
commit
4dd538e708
|
|
@ -14,6 +14,7 @@
|
|||
#include <LibWeb/HTML/PotentialCORSRequest.h>
|
||||
#include <LibWeb/HTML/SharedResourceRequest.h>
|
||||
#include <LibWeb/Layout/SVGImageBox.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
#include <LibWeb/SVG/SVGDecodedImageData.h>
|
||||
|
||||
|
|
@ -60,7 +61,19 @@ void SVGImageElement::attribute_changed(FlyString const& name, Optional<String>
|
|||
auto parsed_value = AttributeParser::parse_coordinate(value.value_or(String {}));
|
||||
MUST(height()->base_val()->set_value(parsed_value.value_or(0)));
|
||||
} else if (name == SVG::AttributeNames::href) {
|
||||
process_the_url(value);
|
||||
// https://svgwg.org/svg2-draft/linking.html#XLinkRefAttrs
|
||||
// For backwards compatibility, elements with an ‘href’ attribute also recognize an ‘href’ attribute in the
|
||||
// XLink namespace. If the element is in the XLink namespace, it does not recognize an ‘href’ attribute in the
|
||||
// SVG namespace. When the ‘href’ attribute is present in both the XLink namespace and without a namespace, the
|
||||
// value of the attribute without a namespace shall be used. The attribute in the XLink namespace shall be ignored.
|
||||
if (namespace_ == Namespace::XLink && has_attribute_ns({}, name))
|
||||
return;
|
||||
|
||||
auto href = value;
|
||||
if (!namespace_.has_value() && !href.has_value())
|
||||
href = get_attribute_ns(SVG::AttributeNames::href, Namespace::XLink);
|
||||
|
||||
process_the_url(href);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
3
Tests/LibWeb/Ref/data/50x50-red.svg
Normal file
3
Tests/LibWeb/Ref/data/50x50-red.svg
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50">
|
||||
<rect fill="red" width="50" height="50"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 114 B |
4
Tests/LibWeb/Ref/expected/svg/image-xlink-href-ref.html
Normal file
4
Tests/LibWeb/Ref/expected/svg/image-xlink-href-ref.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<svg>
|
||||
<rect width="100" height="100" fill="green"></rect>
|
||||
</svg>
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="match" href="../../expected/svg/image-xlink-href-ref.html" />
|
||||
<svg>
|
||||
<image id="test" href="../../data/50x50-green.svg" xlink:href="../../data/50x50-red.svg" width="100" height="100" />
|
||||
</svg>
|
||||
5
Tests/LibWeb/Ref/input/svg/image-xlink-href.html
Normal file
5
Tests/LibWeb/Ref/input/svg/image-xlink-href.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<link rel="match" href="../../expected/svg/image-xlink-href-ref.html" />
|
||||
<svg>
|
||||
<image id="test" xlink:href="../../data/50x50-green.svg" width="100" height="100" />
|
||||
</svg>
|
||||
Loading…
Reference in New Issue
Block a user