mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 05:57:41 +00:00
LibWeb: Stop making ComputedValues::stroke_width() optional
This defaults to 1px and should always have some kind of value.
This commit is contained in:
parent
5cdcd135ab
commit
af51095fe2
2 changed files with 13 additions and 15 deletions
|
@ -308,7 +308,7 @@ public:
|
|||
Optional<SVGPaint> 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<LengthPercentage> 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<SVGPaint> stroke;
|
||||
float fill_opacity { InitialValues::fill_opacity() };
|
||||
float stroke_opacity { InitialValues::stroke_opacity() };
|
||||
Optional<LengthPercentage> stroke_width;
|
||||
LengthPercentage stroke_width { Length::make_px(1) };
|
||||
|
||||
Vector<ShadowData> text_shadow;
|
||||
} m_inherited;
|
||||
|
|
|
@ -202,7 +202,7 @@ Optional<float> 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()) {
|
||||
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;
|
||||
|
@ -214,9 +214,7 @@ Optional<float> SVGGraphicsElement::stroke_width() const
|
|||
}
|
||||
}
|
||||
auto scaled_viewport_size = (viewport_width + viewport_height) * 0.5;
|
||||
return width->to_px(*layout_node(), scaled_viewport_size).to_double();
|
||||
}
|
||||
return {};
|
||||
return width.to_px(*layout_node(), scaled_viewport_size).to_double();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue