diff --git a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp index 53d1b4967a..fedb8dd723 100644 --- a/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp +++ b/Userland/Libraries/LibWeb/Layout/SVGSVGBox.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include +#include #include #include #include @@ -27,14 +27,14 @@ void SVGSVGBox::prepare_for_replaced_layout() if (dom_node().has_attribute(HTML::AttributeNames::width) && dom_node().has_attribute(HTML::AttributeNames::height)) { Optional w; Optional h; - if (auto width = HTML::parse_dimension_value(dom_node().attribute(HTML::AttributeNames::width))) { - if (width->has_length()) - w = width->to_length().to_px(*this); - } - if (auto height = HTML::parse_dimension_value(dom_node().attribute(HTML::AttributeNames::height))) { - if (height->has_length()) - h = height->to_length().to_px(*this); - } + auto parsing_context = CSS::Parser::ParsingContext { document() }; + auto width = parse_css_value(parsing_context, dom_node().attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width); + if (!width.is_null() && width->has_length()) + w = width->to_length().to_px(*this); + + auto height = parse_css_value(parsing_context, dom_node().attribute((HTML::AttributeNames::height)), CSS::PropertyID::Height); + if (!height.is_null() && height->has_length()) + h = height->to_length().to_px(*this); if (w.has_value() && h.has_value()) { set_intrinsic_width(*w); set_intrinsic_height(*h); diff --git a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp index 6ad9d19c36..ccaa0a79c5 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGForeignObjectElement.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -63,11 +63,11 @@ JS::GCPtr SVGForeignObjectElement::create_layout_node(NonnullRefPt void SVGForeignObjectElement::apply_presentational_hints(CSS::StyleProperties& style) const { Base::apply_presentational_hints(style); - - if (auto width_value = HTML::parse_dimension_value(attribute(SVG::AttributeNames::width))) + auto parsing_context = CSS::Parser::ParsingContext { document() }; + if (auto width_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::width), CSS::PropertyID::Width)) style.set_property(CSS::PropertyID::Width, width_value.release_nonnull()); - if (auto height_value = HTML::parse_dimension_value(attribute(SVG::AttributeNames::height))) + if (auto height_value = parse_css_value(parsing_context, attribute(Web::HTML::AttributeNames::height), CSS::PropertyID::Height)) style.set_property(CSS::PropertyID::Height, height_value.release_nonnull()); } diff --git a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp index 897aa64d09..302a98c70e 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGSVGElement.cpp @@ -5,7 +5,6 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include #include #include #include @@ -38,7 +37,8 @@ JS::GCPtr SVGSVGElement::create_layout_node(NonnullRefPtr