diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h index f82ef03521..6218da8daf 100644 --- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h +++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h @@ -308,7 +308,7 @@ public: Optional const& stroke() const { return m_inherited.stroke; } float fill_opacity() const { return m_inherited.fill_opacity; } float stroke_opacity() const { return m_inherited.stroke_opacity; } - Optional const& stroke_width() const { return m_inherited.stroke_width; } + LengthPercentage const& stroke_width() const { return m_inherited.stroke_width; } Color stop_color() const { return m_noninherited.stop_color; } float stop_opacity() const { return m_noninherited.stop_opacity; } @@ -352,7 +352,7 @@ protected: Optional stroke; float fill_opacity { InitialValues::fill_opacity() }; float stroke_opacity { InitialValues::stroke_opacity() }; - Optional stroke_width; + LengthPercentage stroke_width { Length::make_px(1) }; Vector text_shadow; } m_inherited; diff --git a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp index ed2d6c72e2..694819ad13 100644 --- a/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp +++ b/Userland/Libraries/LibWeb/SVG/SVGGraphicsElement.cpp @@ -202,21 +202,19 @@ Optional SVGGraphicsElement::stroke_width() const return {}; // FIXME: Converting to pixels isn't really correct - values should be in "user units" // https://svgwg.org/svg2-draft/coords.html#TermUserUnits - if (auto width = layout_node()->computed_values().stroke_width(); width.has_value()) { - // Resolved relative to the "Scaled viewport size": https://www.w3.org/TR/2017/WD-fill-stroke-3-20170413/#scaled-viewport-size - // FIXME: This isn't right, but it's something. - CSSPixels viewport_width = 0; - CSSPixels viewport_height = 0; - if (auto* svg_svg_element = shadow_including_first_ancestor_of_type()) { - if (auto* svg_svg_layout_node = svg_svg_element->layout_node()) { - viewport_width = svg_svg_layout_node->computed_values().width().to_px(*svg_svg_layout_node, 0); - viewport_height = svg_svg_layout_node->computed_values().height().to_px(*svg_svg_layout_node, 0); - } + auto width = layout_node()->computed_values().stroke_width(); + // Resolved relative to the "Scaled viewport size": https://www.w3.org/TR/2017/WD-fill-stroke-3-20170413/#scaled-viewport-size + // FIXME: This isn't right, but it's something. + CSSPixels viewport_width = 0; + CSSPixels viewport_height = 0; + if (auto* svg_svg_element = shadow_including_first_ancestor_of_type()) { + if (auto* svg_svg_layout_node = svg_svg_element->layout_node()) { + viewport_width = svg_svg_layout_node->computed_values().width().to_px(*svg_svg_layout_node, 0); + viewport_height = svg_svg_layout_node->computed_values().height().to_px(*svg_svg_layout_node, 0); } - auto scaled_viewport_size = (viewport_width + viewport_height) * 0.5; - return width->to_px(*layout_node(), scaled_viewport_size).to_double(); } - return {}; + auto scaled_viewport_size = (viewport_width + viewport_height) * 0.5; + return width.to_px(*layout_node(), scaled_viewport_size).to_double(); } }