mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
style: Compute and store SVG unitless length as a factor number.
Servo-side changes from [bug 1367327] https://bugzilla.mozilla.org/show_bug.cgi?id=1367327.
This commit is contained in:
parent
ebb3dd8787
commit
800433aacb
2 changed files with 46 additions and 7 deletions
|
@ -3994,7 +3994,7 @@ clip-path
|
|||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="InheritedSVG"
|
||||
skip_longhands="paint-order stroke-dasharray"
|
||||
skip_longhands="paint-order stroke-dasharray stroke-dashoffset stroke-width"
|
||||
skip_additionals="*">
|
||||
pub fn set_paint_order(&mut self, v: longhands::paint_order::computed_value::T) {
|
||||
use self::longhands::paint_order;
|
||||
|
@ -4062,6 +4062,46 @@ clip-path
|
|||
}
|
||||
longhands::stroke_dasharray::computed_value::T(vec)
|
||||
}
|
||||
|
||||
pub fn set_stroke_dashoffset(&mut self, v: longhands::stroke_dashoffset::computed_value::T) {
|
||||
match v {
|
||||
Either::First(number) => self.gecko.mStrokeDashoffset.set_value(CoordDataValue::Factor(number)),
|
||||
Either::Second(lop) => self.gecko.mStrokeDashoffset.set(lop),
|
||||
}
|
||||
}
|
||||
|
||||
${impl_coord_copy('stroke_dashoffset', 'mStrokeDashoffset')}
|
||||
|
||||
pub fn clone_stroke_dashoffset(&self) -> longhands::stroke_dashoffset::computed_value::T {
|
||||
use values::computed::LengthOrPercentage;
|
||||
match self.gecko.mStrokeDashoffset.as_value() {
|
||||
CoordDataValue::Factor(number) => Either::First(number),
|
||||
CoordDataValue::Coord(coord) => Either::Second(LengthOrPercentage::Length(Au(coord))),
|
||||
CoordDataValue::Percent(p) => Either::Second(LengthOrPercentage::Percentage(p)),
|
||||
CoordDataValue::Calc(calc) => Either::Second(LengthOrPercentage::Calc(calc.into())),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_stroke_width(&mut self, v: longhands::stroke_width::computed_value::T) {
|
||||
match v {
|
||||
Either::First(number) => self.gecko.mStrokeWidth.set_value(CoordDataValue::Factor(number)),
|
||||
Either::Second(lop) => self.gecko.mStrokeWidth.set(lop),
|
||||
}
|
||||
}
|
||||
|
||||
${impl_coord_copy('stroke_width', 'mStrokeWidth')}
|
||||
|
||||
pub fn clone_stroke_width(&self) -> longhands::stroke_width::computed_value::T {
|
||||
use values::computed::LengthOrPercentage;
|
||||
match self.gecko.mStrokeWidth.as_value() {
|
||||
CoordDataValue::Factor(number) => Either::First(number),
|
||||
CoordDataValue::Coord(coord) => Either::Second(LengthOrPercentage::Length(Au(coord))),
|
||||
CoordDataValue::Percent(p) => Either::Second(LengthOrPercentage::Percentage(p)),
|
||||
CoordDataValue::Calc(calc) => Either::Second(LengthOrPercentage::Calc(calc.into())),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="Color"
|
||||
|
|
|
@ -66,9 +66,9 @@ ${helpers.predefined_type(
|
|||
spec="https://www.w3.org/TR/SVG2/painting.html#SpecifyingStrokePaint")}
|
||||
|
||||
${helpers.predefined_type(
|
||||
"stroke-width", "LengthOrPercentage",
|
||||
"computed::LengthOrPercentage::one()",
|
||||
"parse_numbers_are_pixels_non_negative",
|
||||
"stroke-width", "LengthOrPercentageOrNumber",
|
||||
"Either::First(1.0)",
|
||||
"parse_non_negative",
|
||||
products="gecko",
|
||||
animation_value_type="ComputedValue",
|
||||
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeWidth")}
|
||||
|
@ -103,9 +103,8 @@ ${helpers.predefined_type("stroke-dasharray",
|
|||
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing")}
|
||||
|
||||
${helpers.predefined_type(
|
||||
"stroke-dashoffset", "LengthOrPercentage",
|
||||
"computed::LengthOrPercentage::zero()",
|
||||
"parse_numbers_are_pixels",
|
||||
"stroke-dashoffset", "LengthOrPercentageOrNumber",
|
||||
"Either::First(0.0)",
|
||||
products="gecko",
|
||||
animation_value_type="ComputedValue",
|
||||
spec="https://www.w3.org/TR/SVG2/painting.html#StrokeDashing")}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue