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),
}
}

View file

@ -92,6 +92,7 @@ impl ComputeSquaredDistance for Angle {
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
// Use the formula for calculating the distance between angles defined in SVG:
// https://www.w3.org/TR/SVG/animate.html#complexDistances
self.radians64().compute_squared_distance(&other.radians64())
self.radians64()
.compute_squared_distance(&other.radians64())
}
}

View file

@ -207,12 +207,12 @@ impl ToCss for CalcLengthOrPercentage {
if length.px() == 0. && self.clamping_mode.clamp(p.0) == p.0 {
return p.to_css(dest);
}
}
},
None => {
if self.clamping_mode.clamp(length.px()) == length.px() {
return length.to_css(dest);
}
}
},
}
dest.write_str("calc(")?;
@ -950,8 +950,18 @@ pub type NonNegativeLengthOrPercentageOrNormal = Either<NonNegativeLengthOrPerce
/// block-size, and inline-size.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo,
ToComputedValue, ToCss)]
#[derive(
Clone,
Copy,
Debug,
Eq,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
)]
pub enum ExtremumLength {
MozMaxContent,
MozMinContent,

View file

@ -24,7 +24,8 @@ impl Quotes {
"\u{2018}".to_owned().into_boxed_str(),
"\u{2019}".to_owned().into_boxed_str(),
),
].into_boxed_slice(),
]
.into_boxed_slice(),
)
}
}

View file

@ -51,7 +51,7 @@ impl SVGLength {
/// `0px`
pub fn zero() -> Self {
generic::SVGLength::Length(generic::SvgLengthOrPercentageOrNumber::LengthOrPercentage(
LengthOrPercentage::zero()
LengthOrPercentage::zero(),
))
}
}
@ -84,7 +84,7 @@ impl SVGWidth {
pub fn one() -> Self {
use values::generics::NonNegative;
generic::SVGLength::Length(generic::SvgLengthOrPercentageOrNumber::LengthOrPercentage(
NonNegative(LengthOrPercentage::one())
NonNegative(LengthOrPercentage::one()),
))
}
}

View file

@ -307,7 +307,8 @@ where
this.0.animate(&other.0, procedure)?,
this.1.animate(&other.1, procedure)?,
))
}).collect::<Result<Vec<_>, _>>()?;
})
.collect::<Result<Vec<_>, _>>()?;
Ok(Polygon {
fill: self.fill,
coordinates,
@ -333,7 +334,8 @@ where
let d1 = this.0.compute_squared_distance(&other.0)?;
let d2 = this.1.compute_squared_distance(&other.1)?;
Ok(d1 + d2)
}).sum()
})
.sum()
}
}

View file

@ -9,7 +9,9 @@ use parser::ParserContext;
use values::CSSFloat;
/// A generic easing function.
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
#[derive(
Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
)]
#[value_info(ty = "TIMING_FUNCTION")]
#[repr(u8, C)]
pub enum TimingFunction<Integer, Number> {

View file

@ -45,7 +45,7 @@ pub enum MozLength<LengthOrPercentageOrAuto> {
SpecifiedValueInfo,
ToAnimatedZero,
ToComputedValue,
ToCss
ToCss,
)]
pub enum MaxLength<LengthOrPercentageOrNone> {
LengthOrPercentageOrNone(LengthOrPercentageOrNone),

View file

@ -71,8 +71,20 @@ impl<ImageUrl: ToCss, Number: ToCss> ToCss for CursorImage<ImageUrl, Number> {
/// A generic value for `scrollbar-color` property.
///
/// https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
#[derive(
Animate,
Clone,
ComputeSquaredDistance,
Copy,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToCss,
)]
pub enum ScrollbarColor<Color> {
/// `auto`
Auto,
@ -82,7 +94,7 @@ pub enum ScrollbarColor<Color> {
thumb: Color,
/// Second `<color>`, for color of the scrollbar track.
track: Color,
}
},
}
impl<Color> Default for ScrollbarColor<Color> {

View file

@ -152,11 +152,7 @@ impl Parse for Angle {
impl Angle {
/// Parse an `<angle>` value given a value and an unit.
pub fn parse_dimension(
value: CSSFloat,
unit: &str,
was_calc: bool,
) -> Result<Angle, ()> {
pub fn parse_dimension(value: CSSFloat, unit: &str, was_calc: bool) -> Result<Angle, ()> {
let value = match_ignore_ascii_case! { unit,
"deg" => AngleDimension::Deg(value),
"grad" => AngleDimension::Grad(value),
@ -200,7 +196,8 @@ impl Angle {
return input.parse_nested_block(|i| CalcNode::parse_angle(context, i))
},
_ => Err(()),
}.map_err(|()| input.new_unexpected_token_error(token.clone()))
}
.map_err(|()| input.new_unexpected_token_error(token.clone()))
}
}

View file

@ -275,7 +275,8 @@ impl Ellipse {
ShapeRadius::parse(context, i)?,
ShapeRadius::parse(context, i)?,
))
}).unwrap_or_default();
})
.unwrap_or_default();
let position = if input.try(|i| i.expect_ident_matching("at")).is_ok() {
Position::parse(context, input)?
} else {
@ -422,7 +423,8 @@ impl Polygon {
let fill = FillRule::parse(i)?;
i.expect_comma()?; // only eat the comma if there is something before it
Ok(fill)
}).unwrap_or_default();
})
.unwrap_or_default();
let buf = input.parse_comma_separated(|i| {
Ok(PolygonCoord(
@ -459,7 +461,8 @@ impl Path {
let fill = FillRule::parse(i)?;
i.expect_comma()?;
Ok(fill)
}).unwrap_or_default();
})
.unwrap_or_default();
let path = SVGPathData::parse(context, input)?;
Ok(Path { fill, path })
}

View file

@ -92,7 +92,8 @@ impl ToComputedValue for BorderSideWidth {
BorderSideWidth::Medium => Length::from_px(3.).to_computed_value(context),
BorderSideWidth::Thick => Length::from_px(5.).to_computed_value(context),
BorderSideWidth::Length(ref length) => length.to_computed_value(context),
}.into()
}
.into()
}
#[inline]
@ -182,7 +183,8 @@ impl Parse for BorderSpacing {
) -> Result<Self, ParseError<'i>> {
Size::parse_with(context, input, |context, input| {
Length::parse_non_negative_quirky(context, input, AllowQuirks::Yes).map(From::from)
}).map(GenericBorderSpacing)
})
.map(GenericBorderSpacing)
}
}

View file

@ -529,8 +529,7 @@ impl CalcNode {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<CSSInteger, ParseError<'i>> {
Self::parse_number(context, input)
.map(|n| n.round() as CSSInteger)
Self::parse_number(context, input).map(|n| n.round() as CSSInteger)
}
/// Convenience parsing function for `<length> | <percentage>`.

View file

@ -93,7 +93,8 @@ impl Content {
.try(|input| {
input.expect_comma()?;
ListStyleType::parse(input)
}).unwrap_or(ListStyleType::Decimal)
})
.unwrap_or(ListStyleType::Decimal)
}
#[cfg(feature = "gecko")]
@ -102,7 +103,8 @@ impl Content {
.try(|input| {
input.expect_comma()?;
CounterStyleOrNone::parse(context, input)
}).unwrap_or(CounterStyleOrNone::decimal())
})
.unwrap_or(CounterStyleOrNone::decimal())
}
}

View file

@ -74,10 +74,9 @@ impl Parse for TimingFunction {
Ok(GenericTimingFunction::Steps(steps, position))
},
_ => Err(()),
}).map_err(|()| {
location.new_custom_error(
StyleParseErrorKind::UnexpectedFunction(function.clone())
)
})
.map_err(|()| {
location.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone()))
})
})
}

View file

@ -733,7 +733,8 @@ impl ToComputedValue for KeywordSize {
KeywordSize::XLarge => Au::from_px(FONT_MEDIUM_PX) * 3 / 2,
KeywordSize::XXLarge => Au::from_px(FONT_MEDIUM_PX) * 2,
KeywordSize::XXXLarge => Au::from_px(FONT_MEDIUM_PX) * 3,
}.into()
}
.into()
}
#[inline]
@ -837,7 +838,8 @@ impl FontSize {
6 => KeywordSize::XXLarge,
// If value is greater than 7, let it be 7.
_ => KeywordSize::XXXLarge,
}.into(),
}
.into(),
)
}
@ -906,7 +908,8 @@ impl FontSize {
.to_computed_value_zoomed(
context,
FontBaseSize::InheritedStyleButStripEmUnits,
).length_component();
)
.length_component();
info = parent.keyword_info.map(|i| i.compose(ratio, abs.into()));
}
@ -2108,7 +2111,8 @@ impl ToComputedValue for FontLanguageOverride {
String::from_utf8(buf.to_vec()).unwrap()
} else {
unsafe { String::from_utf8_unchecked(buf.to_vec()) }
}.into_boxed_str(),
}
.into_boxed_str(),
)
}
}

View file

@ -189,7 +189,9 @@ impl Image {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Image, ParseError<'i>> {
if let Ok(url) = input.try(|input| SpecifiedImageUrl::parse_with_cors_anonymous(context, input)) {
if let Ok(url) =
input.try(|input| SpecifiedImageUrl::parse_with_cors_anonymous(context, input))
{
return Ok(generic::Image::Url(url));
}
Self::parse(context, input)
@ -1023,7 +1025,8 @@ impl Parse for PaintWorklet {
.try(|input| {
input.expect_comma()?;
input.parse_comma_separated(|input| SpecifiedValue::parse(input))
}).unwrap_or(vec![]);
})
.unwrap_or(vec![]);
Ok(PaintWorklet { name, arguments })
})
}

View file

@ -73,10 +73,12 @@ impl SourceSizeList {
Some(ref v) => v.to_computed_value(context),
None => Length::NoCalc(NoCalcLength::ViewportPercentage(
ViewportPercentageLength::Vw(100.),
)).to_computed_value(context),
))
.to_computed_value(context),
},
}
}).into()
})
.into()
}
}

View file

@ -563,7 +563,6 @@ impl ToAnimatedZero for ArcFlag {
}
}
/// SVG Path parser.
struct PathParser<'a> {
chars: Peekable<Cloned<slice::Iter<'a, u8>>>,

View file

@ -613,30 +613,40 @@ impl TextEmphasisShapeKeyword {
pub fn char(&self, fill: TextEmphasisFillMode) -> &str {
let fill = fill == TextEmphasisFillMode::Filled;
match *self {
TextEmphasisShapeKeyword::Dot => if fill {
"\u{2022}"
} else {
"\u{25e6}"
TextEmphasisShapeKeyword::Dot => {
if fill {
"\u{2022}"
} else {
"\u{25e6}"
}
},
TextEmphasisShapeKeyword::Circle => if fill {
"\u{25cf}"
} else {
"\u{25cb}"
TextEmphasisShapeKeyword::Circle => {
if fill {
"\u{25cf}"
} else {
"\u{25cb}"
}
},
TextEmphasisShapeKeyword::DoubleCircle => if fill {
"\u{25c9}"
} else {
"\u{25ce}"
TextEmphasisShapeKeyword::DoubleCircle => {
if fill {
"\u{25c9}"
} else {
"\u{25ce}"
}
},
TextEmphasisShapeKeyword::Triangle => if fill {
"\u{25b2}"
} else {
"\u{25b3}"
TextEmphasisShapeKeyword::Triangle => {
if fill {
"\u{25b2}"
} else {
"\u{25b3}"
}
},
TextEmphasisShapeKeyword::Sesame => if fill {
"\u{fe45}"
} else {
"\u{fe46}"
TextEmphasisShapeKeyword::Sesame => {
if fill {
"\u{fe45}"
} else {
"\u{fe46}"
}
},
}
}