Format remaining files

This commit is contained in:
Pyfisch 2018-11-06 13:01:35 +01:00
parent bf47f90da6
commit cb07debcb6
252 changed files with 5944 additions and 3744 deletions

View file

@ -143,7 +143,9 @@ impl<'a> FontSettingTagIter<'a> {
impl<'a> Iterator for FontSettingTagIter<'a> {
type Item = Result<(&'a ComputedVariationValue, &'a ComputedVariationValue), ()>;
fn next(&mut self) -> Option<Result<(&'a ComputedVariationValue, &'a ComputedVariationValue), ()>> {
fn next(
&mut self,
) -> Option<Result<(&'a ComputedVariationValue, &'a ComputedVariationValue), ()>> {
match (
FontSettingTagIter::next_tag(&mut self.a_state),
FontSettingTagIter::next_tag(&mut self.b_state),

View file

@ -23,9 +23,15 @@ impl Animate for CalcLengthOrPercentage {
Ok(Some(this.animate(&other, procedure)?))
};
let length = self.unclamped_length().animate(&other.unclamped_length(), procedure)?;
let length = self
.unclamped_length()
.animate(&other.unclamped_length(), procedure)?;
let percentage = animate_percentage_half(self.percentage, other.percentage)?;
Ok(CalcLengthOrPercentage::with_clamping_mode(length, percentage, self.clamping_mode))
Ok(CalcLengthOrPercentage::with_clamping_mode(
length,
percentage,
self.clamping_mode,
))
}
}

View file

@ -38,16 +38,16 @@ enum PropertyCategory {
impl PropertyCategory {
fn of(id: &PropertyId) -> Self {
match *id {
PropertyId::Shorthand(..) |
PropertyId::ShorthandAlias(..) => PropertyCategory::Shorthand,
PropertyId::Longhand(id) |
PropertyId::LonghandAlias(id, ..) => {
PropertyId::Shorthand(..) | PropertyId::ShorthandAlias(..) => {
PropertyCategory::Shorthand
},
PropertyId::Longhand(id) | PropertyId::LonghandAlias(id, ..) => {
if id.is_logical() {
PropertyCategory::LogicalLonghand
} else {
PropertyCategory::PhysicalLonghand
}
}
},
PropertyId::Custom(..) => PropertyCategory::Custom,
}
}
@ -81,9 +81,9 @@ pub fn compare_property_priority(a: &PropertyId, b: &PropertyId) -> cmp::Orderin
// name.
let subprop_count_a = a.longhands().count();
let subprop_count_b = b.longhands().count();
subprop_count_a.cmp(&subprop_count_b).then_with(|| {
a.idl_name_sort_order().cmp(&b.idl_name_sort_order())
})
subprop_count_a
.cmp(&subprop_count_b)
.then_with(|| a.idl_name_sort_order().cmp(&b.idl_name_sort_order()))
}
/// Animate from one value to another.

View file

@ -32,13 +32,11 @@ fn to_number_or_percentage(
value: &SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number>,
) -> Result<NumberOrPercentage, ()> {
Ok(match *value {
SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref l) => {
match *l {
LengthOrPercentage::Length(ref l) => NumberOrPercentage::Number(l.px()),
LengthOrPercentage::Percentage(ref p) => NumberOrPercentage::Percentage(*p),
LengthOrPercentage::Calc(..) => return Err(()),
}
}
SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref l) => match *l {
LengthOrPercentage::Length(ref l) => NumberOrPercentage::Number(l.px()),
LengthOrPercentage::Percentage(ref p) => NumberOrPercentage::Percentage(*p),
LengthOrPercentage::Calc(..) => return Err(()),
},
SvgLengthOrPercentageOrNumber::Number(ref n) => NumberOrPercentage::Number(*n),
})
}
@ -50,22 +48,15 @@ impl Animate for SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number> {
let other = to_number_or_percentage(other)?;
match (this, other) {
(
NumberOrPercentage::Number(ref this),
NumberOrPercentage::Number(ref other),
) => {
Ok(SvgLengthOrPercentageOrNumber::Number(
this.animate(other, procedure)?
))
},
(NumberOrPercentage::Number(ref this), NumberOrPercentage::Number(ref other)) => Ok(
SvgLengthOrPercentageOrNumber::Number(this.animate(other, procedure)?),
),
(
NumberOrPercentage::Percentage(ref this),
NumberOrPercentage::Percentage(ref other),
) => {
Ok(SvgLengthOrPercentageOrNumber::LengthOrPercentage(
LengthOrPercentage::Percentage(this.animate(other, procedure)?)
))
},
) => Ok(SvgLengthOrPercentageOrNumber::LengthOrPercentage(
LengthOrPercentage::Percentage(this.animate(other, procedure)?),
)),
_ => Err(()),
}
}
@ -73,8 +64,7 @@ impl Animate for SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number> {
impl ComputeSquaredDistance for SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number> {
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
to_number_or_percentage(self)?
.compute_squared_distance(&to_number_or_percentage(other)?)
to_number_or_percentage(self)?.compute_squared_distance(&to_number_or_percentage(other)?)
}
}
@ -105,9 +95,9 @@ where
return Err(());
}
match (self, other) {
(&SVGStrokeDashArray::Values(ref this), &SVGStrokeDashArray::Values(ref other)) => {
Ok(SVGStrokeDashArray::Values(this.animate_repeatable_list(other, procedure)?))
},
(&SVGStrokeDashArray::Values(ref this), &SVGStrokeDashArray::Values(ref other)) => Ok(
SVGStrokeDashArray::Values(this.animate_repeatable_list(other, procedure)?),
),
_ => Err(()),
}
}
@ -135,11 +125,12 @@ where
#[inline]
fn to_animated_zero(&self) -> Result<Self, ()> {
match *self {
SVGStrokeDashArray::Values(ref values) => {
Ok(SVGStrokeDashArray::Values(
values.iter().map(ToAnimatedZero::to_animated_zero).collect::<Result<Vec<_>, _>>()?,
))
}
SVGStrokeDashArray::Values(ref values) => Ok(SVGStrokeDashArray::Values(
values
.iter()
.map(ToAnimatedZero::to_animated_zero)
.collect::<Result<Vec<_>, _>>()?,
)),
SVGStrokeDashArray::ContextValue => Ok(SVGStrokeDashArray::ContextValue),
}
}