1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 23:38:12 +00:00

LibWeb: Treat width/height on <svg> element as HTML dimension values

This might not be entirely correct, but neither was using the completely
ad-hoc parse_html_length(), and this is the last user of that API so
let's move off of it.
This commit is contained in:
Andreas Kling 2022-03-26 14:20:05 +01:00
parent e96b3315ad
commit 7df62c64b7

View file

@ -28,14 +28,14 @@ RefPtr<Layout::Node> SVGSVGElement::create_layout_node(NonnullRefPtr<CSS::StyleP
void SVGSVGElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
// Width defaults to 100%
if (auto width_value = parse_html_length(document(), attribute("width"))) {
if (auto width_value = parse_dimension_value(attribute(SVG::AttributeNames::width))) {
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
} else {
style.set_property(CSS::PropertyID::Width, CSS::PercentageStyleValue::create(CSS::Percentage { 100 }));
}
// Height defaults to 100%
if (auto height_value = parse_html_length(document(), attribute("height"))) {
if (auto height_value = parse_dimension_value(attribute(SVG::AttributeNames::width))) {
style.set_property(CSS::PropertyID::Height, height_value.release_nonnull());
} else {
style.set_property(CSS::PropertyID::Height, CSS::PercentageStyleValue::create(CSS::Percentage { 100 }));