diff --git a/components/style/counter_style/mod.rs b/components/style/counter_style/mod.rs index 9e2bc096e2d..72ccbd94634 100644 --- a/components/style/counter_style/mod.rs +++ b/components/style/counter_style/mod.rs @@ -474,10 +474,7 @@ pub struct CounterRange { /// Empty represents 'auto' #[derive(Clone, Debug, ToShmem, ToCss)] #[css(comma)] -pub struct CounterRanges( - #[css(iterable, if_empty = "auto")] - pub crate::OwnedSlice, -); +pub struct CounterRanges(#[css(iterable, if_empty = "auto")] pub crate::OwnedSlice); /// A bound found in `CounterRanges`. #[derive(Clone, Copy, Debug, ToCss, ToShmem)] @@ -503,13 +500,9 @@ impl Parse for CounterRanges { let ranges = input.parse_comma_separated(|input| { let start = parse_bound(context, input)?; let end = parse_bound(context, input)?; - if let (CounterBound::Integer(start), CounterBound::Integer(end)) = - (start, end) - { + if let (CounterBound::Integer(start), CounterBound::Integer(end)) = (start, end) { if start > end { - return Err( - input.new_custom_error(StyleParseErrorKind::UnspecifiedError) - ); + return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)); } } Ok(CounterRange { start, end }) diff --git a/components/style/gecko/profiler.rs b/components/style/gecko/profiler.rs index 92ad068284e..1f25dde04e7 100644 --- a/components/style/gecko/profiler.rs +++ b/components/style/gecko/profiler.rs @@ -62,9 +62,8 @@ pub fn profiler_is_active() -> bool { use std::mem; use std::sync::atomic::{AtomicU32, Ordering}; - let active_and_features: &AtomicU32 = unsafe { - mem::transmute(&detail::RacyFeatures_sActiveAndFeatures) - }; + let active_and_features: &AtomicU32 = + unsafe { mem::transmute(&detail::RacyFeatures_sActiveAndFeatures) }; (active_and_features.load(Ordering::Relaxed) & detail::RacyFeatures_Active) != 0 } diff --git a/components/style/macros.rs b/components/style/macros.rs index 1ab2fe0720e..229e864977a 100644 --- a/components/style/macros.rs +++ b/components/style/macros.rs @@ -112,9 +112,8 @@ macro_rules! define_keyword_type { #[macro_export] macro_rules! profiler_label { ($label_type:ident) => { - let mut _profiler_label: $crate::gecko_bindings::structs::AutoProfilerLabel = unsafe { - ::std::mem::uninitialized() - }; + let mut _profiler_label: $crate::gecko_bindings::structs::AutoProfilerLabel = + unsafe { ::std::mem::uninitialized() }; let _profiler_label = if $crate::gecko::profiler::profiler_is_active() { unsafe { Some($crate::gecko::profiler::AutoProfilerLabel::new( @@ -125,12 +124,12 @@ macro_rules! profiler_label { } else { None }; - } + }; } /// No-op when the Gecko profiler is not available. #[cfg(not(feature = "gecko_profiler"))] #[macro_export] macro_rules! profiler_label { - ($label_type:ident) => {} + ($label_type:ident) => {}; } diff --git a/components/style/rule_collector.rs b/components/style/rule_collector.rs index 2e8ffe5d858..360b8101ef1 100644 --- a/components/style/rule_collector.rs +++ b/components/style/rule_collector.rs @@ -105,8 +105,7 @@ where MatchingMode::Normal => element.rule_hash_target(), }; - let matches_user_and_author_rules = - rule_hash_target.matches_user_and_author_rules(); + let matches_user_and_author_rules = rule_hash_target.matches_user_and_author_rules(); // Gecko definitely has pseudo-elements with style attributes, like // ::-moz-color-swatch. diff --git a/components/style/values/animated/mod.rs b/components/style/values/animated/mod.rs index 23c314a57a4..40edbce73ff 100644 --- a/components/style/values/animated/mod.rs +++ b/components/style/values/animated/mod.rs @@ -10,7 +10,7 @@ use crate::properties::PropertyId; use crate::values::computed::length::LengthPercentage; -use crate::values::computed::url::{ComputedUrl, ComputedImageUrl}; +use crate::values::computed::url::{ComputedImageUrl, ComputedUrl}; use crate::values::computed::Angle as ComputedAngle; use crate::values::computed::Image; use crate::values::specified::SVGPathData; diff --git a/components/style/values/computed/border.rs b/components/style/values/computed/border.rs index 908fd1436ac..abdc28ad848 100644 --- a/components/style/values/computed/border.rs +++ b/components/style/values/computed/border.rs @@ -7,10 +7,10 @@ use crate::values::computed::length::{NonNegativeLength, NonNegativeLengthPercentage}; use crate::values::computed::{NonNegativeNumber, NonNegativeNumberOrPercentage}; use crate::values::generics::border::BorderCornerRadius as GenericBorderCornerRadius; -use crate::values::generics::border::GenericBorderImageSideWidth; use crate::values::generics::border::BorderImageSlice as GenericBorderImageSlice; use crate::values::generics::border::BorderRadius as GenericBorderRadius; use crate::values::generics::border::BorderSpacing as GenericBorderSpacing; +use crate::values::generics::border::GenericBorderImageSideWidth; use crate::values::generics::rect::Rect; use crate::values::generics::size::Size2D; use crate::values::generics::NonNegative; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index add2ad1a40a..06579238e77 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -455,10 +455,7 @@ where #[inline] fn from_computed_value(computed: &Self::ComputedValue) -> Self { - computed - .iter() - .map(T::from_computed_value) - .collect() + computed.iter().map(T::from_computed_value).collect() } } diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index 87f4403057f..ba0e320865a 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -240,16 +240,24 @@ where #[allow(missing_docs)] #[css(comma, function = "interpolatematrix")] InterpolateMatrix { - from_list: GenericTransform>, - to_list: GenericTransform>, + from_list: GenericTransform< + GenericTransformOperation, + >, + to_list: GenericTransform< + GenericTransformOperation, + >, progress: computed::Percentage, }, /// A intermediate type for accumulation of mismatched transform lists. #[allow(missing_docs)] #[css(comma, function = "accumulatematrix")] AccumulateMatrix { - from_list: GenericTransform>, - to_list: GenericTransform>, + from_list: GenericTransform< + GenericTransformOperation, + >, + to_list: GenericTransform< + GenericTransformOperation, + >, count: Integer, }, } diff --git a/components/style/values/specified/list.rs b/components/style/values/specified/list.rs index 566b84bbb16..0519053b902 100644 --- a/components/style/values/specified/list.rs +++ b/components/style/values/specified/list.rs @@ -140,9 +140,7 @@ impl Parse for Quotes { loop { let location = input.current_source_location(); let opening = match input.next() { - Ok(&Token::QuotedString(ref value)) => { - value.as_ref().to_owned().into() - }, + Ok(&Token::QuotedString(ref value)) => value.as_ref().to_owned().into(), Ok(t) => return Err(location.new_unexpected_token_error(t.clone())), Err(_) => break, }; diff --git a/components/style/values/specified/svg.rs b/components/style/values/specified/svg.rs index 88604924deb..578870a4a91 100644 --- a/components/style/values/specified/svg.rs +++ b/components/style/values/specified/svg.rs @@ -298,11 +298,7 @@ impl Parse for MozContextProperties { return Ok(Self::default()); } - let ident = CustomIdent::from_ident( - location, - ident, - &["all", "none", "auto"], - )?; + let ident = CustomIdent::from_ident(location, ident, &["all", "none", "auto"])?; if ident.0 == atom!("fill") { bits.insert(ContextPropertyBits::FILL); diff --git a/components/style/values/specified/text.rs b/components/style/values/specified/text.rs index 165462c8175..188eb18f720 100644 --- a/components/style/values/specified/text.rs +++ b/components/style/values/specified/text.rs @@ -162,9 +162,9 @@ impl Parse for TextOverflowSide { )) } }, - Token::QuotedString(ref v) => Ok(TextOverflowSide::String( - v.as_ref().to_owned().into(), - )), + Token::QuotedString(ref v) => { + Ok(TextOverflowSide::String(v.as_ref().to_owned().into())) + }, ref t => Err(location.new_unexpected_token_error(t.clone())), } } diff --git a/components/style/values/specified/transform.rs b/components/style/values/specified/transform.rs index 4c083e896a2..e942cf13085 100644 --- a/components/style/values/specified/transform.rs +++ b/components/style/values/specified/transform.rs @@ -45,180 +45,184 @@ impl Transform { return Ok(generic::Transform::none()); } - Ok(generic::Transform(Space::parse(input, |input| { - let function = input.expect_function()?.clone(); - input.parse_nested_block(|input| { - let location = input.current_source_location(); - let result = match_ignore_ascii_case! { &function, - "matrix" => { - let a = Number::parse(context, input)?; - input.expect_comma()?; - let b = Number::parse(context, input)?; - input.expect_comma()?; - let c = Number::parse(context, input)?; - input.expect_comma()?; - let d = Number::parse(context, input)?; - input.expect_comma()?; - // Standard matrix parsing. - let e = Number::parse(context, input)?; - input.expect_comma()?; - let f = Number::parse(context, input)?; - Ok(generic::TransformOperation::Matrix(Matrix { a, b, c, d, e, f })) - }, - "matrix3d" => { - let m11 = Number::parse(context, input)?; - input.expect_comma()?; - let m12 = Number::parse(context, input)?; - input.expect_comma()?; - let m13 = Number::parse(context, input)?; - input.expect_comma()?; - let m14 = Number::parse(context, input)?; - input.expect_comma()?; - let m21 = Number::parse(context, input)?; - input.expect_comma()?; - let m22 = Number::parse(context, input)?; - input.expect_comma()?; - let m23 = Number::parse(context, input)?; - input.expect_comma()?; - let m24 = Number::parse(context, input)?; - input.expect_comma()?; - let m31 = Number::parse(context, input)?; - input.expect_comma()?; - let m32 = Number::parse(context, input)?; - input.expect_comma()?; - let m33 = Number::parse(context, input)?; - input.expect_comma()?; - let m34 = Number::parse(context, input)?; - input.expect_comma()?; - // Standard matrix3d parsing. - let m41 = Number::parse(context, input)?; - input.expect_comma()?; - let m42 = Number::parse(context, input)?; - input.expect_comma()?; - let m43 = Number::parse(context, input)?; - input.expect_comma()?; - let m44 = Number::parse(context, input)?; - Ok(generic::TransformOperation::Matrix3D(Matrix3D { - m11, m12, m13, m14, - m21, m22, m23, m24, - m31, m32, m33, m34, - m41, m42, m43, m44, - })) - }, - "translate" => { - let sx = specified::LengthPercentage::parse(context, input)?; - if input.try(|input| input.expect_comma()).is_ok() { - let sy = specified::LengthPercentage::parse(context, input)?; - Ok(generic::TransformOperation::Translate(sx, sy)) - } else { - Ok(generic::TransformOperation::Translate(sx, Zero::zero())) - } - }, - "translatex" => { - let tx = specified::LengthPercentage::parse(context, input)?; - Ok(generic::TransformOperation::TranslateX(tx)) - }, - "translatey" => { - let ty = specified::LengthPercentage::parse(context, input)?; - Ok(generic::TransformOperation::TranslateY(ty)) - }, - "translatez" => { - let tz = specified::Length::parse(context, input)?; - Ok(generic::TransformOperation::TranslateZ(tz)) - }, - "translate3d" => { - let tx = specified::LengthPercentage::parse(context, input)?; - input.expect_comma()?; - let ty = specified::LengthPercentage::parse(context, input)?; - input.expect_comma()?; - let tz = specified::Length::parse(context, input)?; - Ok(generic::TransformOperation::Translate3D(tx, ty, tz)) - }, - "scale" => { - let sx = Number::parse(context, input)?; - if input.try(|input| input.expect_comma()).is_ok() { + Ok(generic::Transform( + Space::parse(input, |input| { + let function = input.expect_function()?.clone(); + input.parse_nested_block(|input| { + let location = input.current_source_location(); + let result = match_ignore_ascii_case! { &function, + "matrix" => { + let a = Number::parse(context, input)?; + input.expect_comma()?; + let b = Number::parse(context, input)?; + input.expect_comma()?; + let c = Number::parse(context, input)?; + input.expect_comma()?; + let d = Number::parse(context, input)?; + input.expect_comma()?; + // Standard matrix parsing. + let e = Number::parse(context, input)?; + input.expect_comma()?; + let f = Number::parse(context, input)?; + Ok(generic::TransformOperation::Matrix(Matrix { a, b, c, d, e, f })) + }, + "matrix3d" => { + let m11 = Number::parse(context, input)?; + input.expect_comma()?; + let m12 = Number::parse(context, input)?; + input.expect_comma()?; + let m13 = Number::parse(context, input)?; + input.expect_comma()?; + let m14 = Number::parse(context, input)?; + input.expect_comma()?; + let m21 = Number::parse(context, input)?; + input.expect_comma()?; + let m22 = Number::parse(context, input)?; + input.expect_comma()?; + let m23 = Number::parse(context, input)?; + input.expect_comma()?; + let m24 = Number::parse(context, input)?; + input.expect_comma()?; + let m31 = Number::parse(context, input)?; + input.expect_comma()?; + let m32 = Number::parse(context, input)?; + input.expect_comma()?; + let m33 = Number::parse(context, input)?; + input.expect_comma()?; + let m34 = Number::parse(context, input)?; + input.expect_comma()?; + // Standard matrix3d parsing. + let m41 = Number::parse(context, input)?; + input.expect_comma()?; + let m42 = Number::parse(context, input)?; + input.expect_comma()?; + let m43 = Number::parse(context, input)?; + input.expect_comma()?; + let m44 = Number::parse(context, input)?; + Ok(generic::TransformOperation::Matrix3D(Matrix3D { + m11, m12, m13, m14, + m21, m22, m23, m24, + m31, m32, m33, m34, + m41, m42, m43, m44, + })) + }, + "translate" => { + let sx = specified::LengthPercentage::parse(context, input)?; + if input.try(|input| input.expect_comma()).is_ok() { + let sy = specified::LengthPercentage::parse(context, input)?; + Ok(generic::TransformOperation::Translate(sx, sy)) + } else { + Ok(generic::TransformOperation::Translate(sx, Zero::zero())) + } + }, + "translatex" => { + let tx = specified::LengthPercentage::parse(context, input)?; + Ok(generic::TransformOperation::TranslateX(tx)) + }, + "translatey" => { + let ty = specified::LengthPercentage::parse(context, input)?; + Ok(generic::TransformOperation::TranslateY(ty)) + }, + "translatez" => { + let tz = specified::Length::parse(context, input)?; + Ok(generic::TransformOperation::TranslateZ(tz)) + }, + "translate3d" => { + let tx = specified::LengthPercentage::parse(context, input)?; + input.expect_comma()?; + let ty = specified::LengthPercentage::parse(context, input)?; + input.expect_comma()?; + let tz = specified::Length::parse(context, input)?; + Ok(generic::TransformOperation::Translate3D(tx, ty, tz)) + }, + "scale" => { + let sx = Number::parse(context, input)?; + if input.try(|input| input.expect_comma()).is_ok() { + let sy = Number::parse(context, input)?; + Ok(generic::TransformOperation::Scale(sx, sy)) + } else { + Ok(generic::TransformOperation::Scale(sx, sx)) + } + }, + "scalex" => { + let sx = Number::parse(context, input)?; + Ok(generic::TransformOperation::ScaleX(sx)) + }, + "scaley" => { let sy = Number::parse(context, input)?; - Ok(generic::TransformOperation::Scale(sx, sy)) - } else { - Ok(generic::TransformOperation::Scale(sx, sx)) - } - }, - "scalex" => { - let sx = Number::parse(context, input)?; - Ok(generic::TransformOperation::ScaleX(sx)) - }, - "scaley" => { - let sy = Number::parse(context, input)?; - Ok(generic::TransformOperation::ScaleY(sy)) - }, - "scalez" => { - let sz = Number::parse(context, input)?; - Ok(generic::TransformOperation::ScaleZ(sz)) - }, - "scale3d" => { - let sx = Number::parse(context, input)?; - input.expect_comma()?; - let sy = Number::parse(context, input)?; - input.expect_comma()?; - let sz = Number::parse(context, input)?; - Ok(generic::TransformOperation::Scale3D(sx, sy, sz)) - }, - "rotate" => { - let theta = specified::Angle::parse_with_unitless(context, input)?; - Ok(generic::TransformOperation::Rotate(theta)) - }, - "rotatex" => { - let theta = specified::Angle::parse_with_unitless(context, input)?; - Ok(generic::TransformOperation::RotateX(theta)) - }, - "rotatey" => { - let theta = specified::Angle::parse_with_unitless(context, input)?; - Ok(generic::TransformOperation::RotateY(theta)) - }, - "rotatez" => { - let theta = specified::Angle::parse_with_unitless(context, input)?; - Ok(generic::TransformOperation::RotateZ(theta)) - }, - "rotate3d" => { - let ax = Number::parse(context, input)?; - input.expect_comma()?; - let ay = Number::parse(context, input)?; - input.expect_comma()?; - let az = Number::parse(context, input)?; - input.expect_comma()?; - let theta = specified::Angle::parse_with_unitless(context, input)?; - // TODO(gw): Check that the axis can be normalized. - Ok(generic::TransformOperation::Rotate3D(ax, ay, az, theta)) - }, - "skew" => { - let ax = specified::Angle::parse_with_unitless(context, input)?; - if input.try(|input| input.expect_comma()).is_ok() { - let ay = specified::Angle::parse_with_unitless(context, input)?; - Ok(generic::TransformOperation::Skew(ax, ay)) - } else { - Ok(generic::TransformOperation::Skew(ax, Zero::zero())) - } - }, - "skewx" => { - let theta = specified::Angle::parse_with_unitless(context, input)?; - Ok(generic::TransformOperation::SkewX(theta)) - }, - "skewy" => { - let theta = specified::Angle::parse_with_unitless(context, input)?; - Ok(generic::TransformOperation::SkewY(theta)) - }, - "perspective" => { - let d = specified::Length::parse_non_negative(context, input)?; - Ok(generic::TransformOperation::Perspective(d)) - }, - _ => Err(()), - }; - result.map_err(|()| { - location - .new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone())) + Ok(generic::TransformOperation::ScaleY(sy)) + }, + "scalez" => { + let sz = Number::parse(context, input)?; + Ok(generic::TransformOperation::ScaleZ(sz)) + }, + "scale3d" => { + let sx = Number::parse(context, input)?; + input.expect_comma()?; + let sy = Number::parse(context, input)?; + input.expect_comma()?; + let sz = Number::parse(context, input)?; + Ok(generic::TransformOperation::Scale3D(sx, sy, sz)) + }, + "rotate" => { + let theta = specified::Angle::parse_with_unitless(context, input)?; + Ok(generic::TransformOperation::Rotate(theta)) + }, + "rotatex" => { + let theta = specified::Angle::parse_with_unitless(context, input)?; + Ok(generic::TransformOperation::RotateX(theta)) + }, + "rotatey" => { + let theta = specified::Angle::parse_with_unitless(context, input)?; + Ok(generic::TransformOperation::RotateY(theta)) + }, + "rotatez" => { + let theta = specified::Angle::parse_with_unitless(context, input)?; + Ok(generic::TransformOperation::RotateZ(theta)) + }, + "rotate3d" => { + let ax = Number::parse(context, input)?; + input.expect_comma()?; + let ay = Number::parse(context, input)?; + input.expect_comma()?; + let az = Number::parse(context, input)?; + input.expect_comma()?; + let theta = specified::Angle::parse_with_unitless(context, input)?; + // TODO(gw): Check that the axis can be normalized. + Ok(generic::TransformOperation::Rotate3D(ax, ay, az, theta)) + }, + "skew" => { + let ax = specified::Angle::parse_with_unitless(context, input)?; + if input.try(|input| input.expect_comma()).is_ok() { + let ay = specified::Angle::parse_with_unitless(context, input)?; + Ok(generic::TransformOperation::Skew(ax, ay)) + } else { + Ok(generic::TransformOperation::Skew(ax, Zero::zero())) + } + }, + "skewx" => { + let theta = specified::Angle::parse_with_unitless(context, input)?; + Ok(generic::TransformOperation::SkewX(theta)) + }, + "skewy" => { + let theta = specified::Angle::parse_with_unitless(context, input)?; + Ok(generic::TransformOperation::SkewY(theta)) + }, + "perspective" => { + let d = specified::Length::parse_non_negative(context, input)?; + Ok(generic::TransformOperation::Perspective(d)) + }, + _ => Err(()), + }; + result.map_err(|()| { + location.new_custom_error(StyleParseErrorKind::UnexpectedFunction( + function.clone(), + )) + }) }) - }) - })?.into())) + })? + .into(), + )) } } diff --git a/components/style_traits/arc_slice.rs b/components/style_traits/arc_slice.rs index be50e21c0bb..6a151e3dc5a 100644 --- a/components/style_traits/arc_slice.rs +++ b/components/style_traits/arc_slice.rs @@ -5,9 +5,9 @@ //! A thin atomically-reference-counted slice. use servo_arc::ThinArc; -use std::{iter, mem}; use std::ops::Deref; use std::ptr::NonNull; +use std::{iter, mem}; /// A canary that we stash in ArcSlices. ///