summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-07-11 12:26:53 +0200
committerAndreas Kling <kling@serenityos.org>2022-07-11 18:57:45 +0200
commit67de1131b9010ffbb2c292e5da772ee11a5f378d (patch)
treef33b12465089aac380c6f565f9444bda2ec53a2e /Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
parent17a6fcfde339bede45ef61913c28d41dbc77da09 (diff)
downloadserenity-67de1131b9010ffbb2c292e5da772ee11a5f378d.zip
LibWeb: Match WebKit and Blink re: absence of width/height on <svg>
Diffstat (limited to 'Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp')
-rw-r--r--Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
index 2980cdceb1..ebd0e709f4 100644
--- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
+++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2020, Matthew Olsson <matthewcolsson@gmail.com>
+ * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -28,17 +29,24 @@ 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 = HTML::parse_dimension_value(attribute(SVG::AttributeNames::width))) {
+ auto width_attribute = attribute(SVG::AttributeNames::width);
+ if (auto width_value = HTML::parse_dimension_value(width_attribute)) {
style.set_property(CSS::PropertyID::Width, width_value.release_nonnull());
- } else {
+ } else if (width_attribute == "") {
+ // If the `width` attribute is an empty string, it defaults to 100%.
+ // This matches WebKit and Blink, but not Firefox. The spec is unclear.
+ // FIXME: Figure out what to do here.
style.set_property(CSS::PropertyID::Width, CSS::PercentageStyleValue::create(CSS::Percentage { 100 }));
}
// Height defaults to 100%
- if (auto height_value = HTML::parse_dimension_value(attribute(SVG::AttributeNames::height))) {
+ auto height_attribute = attribute(SVG::AttributeNames::height);
+ if (auto height_value = HTML::parse_dimension_value(height_attribute)) {
style.set_property(CSS::PropertyID::Height, height_value.release_nonnull());
- } else {
+ } else if (height_attribute == "") {
+ // If the `height` attribute is an empty string, it defaults to 100%.
+ // This matches WebKit and Blink, but not Firefox. The spec is unclear.
+ // FIXME: Figure out what to do here.
style.set_property(CSS::PropertyID::Height, CSS::PercentageStyleValue::create(CSS::Percentage { 100 }));
}
}