diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-04-11 22:12:41 +0200 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-04-12 12:20:14 +0200 |
commit | 8c004c08580287172585169807ed36933ad674f8 (patch) | |
tree | 36b6b6288ee034ec688e2678f29f6c2445ebc548 | |
parent | 7c4f9bbf494387c2046d614f5d8769b7ce7eed67 (diff) | |
download | servo-8c004c08580287172585169807ed36933ad674f8.tar.gz servo-8c004c08580287172585169807ed36933ad674f8.zip |
style: Reformat recent changes.
40 files changed, 572 insertions, 213 deletions
diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index 765c0d842c1..0515eaca193 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -223,7 +223,9 @@ pub trait Parser<'i> { #[derive(Clone, Debug, Eq, PartialEq, ToShmem)] #[shmem(no_bounds)] -pub struct SelectorList<Impl: SelectorImpl>(#[shmem(field_bound)] pub SmallVec<[Selector<Impl>; 1]>); +pub struct SelectorList<Impl: SelectorImpl>( + #[shmem(field_bound)] pub SmallVec<[Selector<Impl>; 1]>, +); impl<Impl: SelectorImpl> SelectorList<Impl> { /// Parse a comma-separated list of Selectors. @@ -510,7 +512,9 @@ pub fn namespace_empty_string<Impl: SelectorImpl>() -> Impl::NamespaceUrl { /// handle it in to_css to make it invisible to serialization. #[derive(Clone, Eq, PartialEq, ToShmem)] #[shmem(no_bounds)] -pub struct Selector<Impl: SelectorImpl>(#[shmem(field_bound)] ThinArc<SpecificityAndFlags, Component<Impl>>); +pub struct Selector<Impl: SelectorImpl>( + #[shmem(field_bound)] ThinArc<SpecificityAndFlags, Component<Impl>>, +); impl<Impl: SelectorImpl> Selector<Impl> { #[inline] @@ -834,7 +838,10 @@ pub enum Component<Impl: SelectorImpl> { ExplicitAnyNamespace, ExplicitNoNamespace, DefaultNamespace(#[shmem(field_bound)] Impl::NamespaceUrl), - Namespace(#[shmem(field_bound)] Impl::NamespacePrefix, #[shmem(field_bound)] Impl::NamespaceUrl), + Namespace( + #[shmem(field_bound)] Impl::NamespacePrefix, + #[shmem(field_bound)] Impl::NamespaceUrl, + ), ExplicitUniversalType, LocalName(LocalName<Impl>), diff --git a/components/style/error_reporting.rs b/components/style/error_reporting.rs index 9d54f62e318..04677c26041 100644 --- a/components/style/error_reporting.rs +++ b/components/style/error_reporting.rs @@ -6,18 +6,22 @@ #![deny(missing_docs)] +use crate::selector_parser::SelectorImpl; use crate::stylesheets::UrlExtraData; use cssparser::{BasicParseErrorKind, ParseErrorKind, SourceLocation, Token}; +use selectors::SelectorList; use std::fmt; use style_traits::ParseError; -use crate::selector_parser::{SelectorImpl}; -use selectors::SelectorList; /// Errors that can be encountered while parsing CSS. #[derive(Debug)] pub enum ContextualParseError<'a> { /// A property declaration was not recognized. - UnsupportedPropertyDeclaration(&'a str, ParseError<'a>, Option<&'a SelectorList<SelectorImpl>>), + UnsupportedPropertyDeclaration( + &'a str, + ParseError<'a>, + Option<&'a SelectorList<SelectorImpl>>, + ), /// A font face descriptor was not recognized. UnsupportedFontFaceDescriptor(&'a str, ParseError<'a>), /// A font feature values descriptor was not recognized. diff --git a/components/style/font_metrics.rs b/components/style/font_metrics.rs index ab2468e5439..a45ebc297d9 100644 --- a/components/style/font_metrics.rs +++ b/components/style/font_metrics.rs @@ -43,7 +43,11 @@ pub trait FontMetricsProvider { } /// Get default size of a given language and generic family. - fn get_size(&self, font_name: &Atom, font_family: crate::values::computed::font::GenericFontFamily) -> Au; + fn get_size( + &self, + font_name: &Atom, + font_family: crate::values::computed::font::GenericFontFamily, + ) -> Au; /// Construct from a shared style context fn create_from(context: &SharedStyleContext) -> Self diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index a1f06a679d9..0fa354fb139 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -1108,9 +1108,9 @@ impl structs::FontSizePrefs { GenericFontFamily::Monospace => self.mDefaultMonospaceSize, GenericFontFamily::Cursive => self.mDefaultCursiveSize, GenericFontFamily::Fantasy => self.mDefaultFantasySize, - GenericFontFamily::MozEmoji => { - unreachable!("Should never get here, since this doesn't (yet) appear on font family") - }, + GenericFontFamily::MozEmoji => unreachable!( + "Should never get here, since this doesn't (yet) appear on font family" + ), }) } } diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs index f4c875cb7ad..d71d192166a 100644 --- a/components/style/gecko_string_cache/mod.rs +++ b/components/style/gecko_string_cache/mod.rs @@ -126,7 +126,11 @@ impl Borrow<WeakAtom> for Atom { impl ToShmem for Atom { fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> ManuallyDrop<Self> { - assert!(self.is_static(), "ToShmem failed for Atom: must be a static atom: {}", self); + assert!( + self.is_static(), + "ToShmem failed for Atom: must be a static atom: {}", + self + ); ManuallyDrop::new(Atom(self.0)) } diff --git a/components/style/stylesheets/rule_parser.rs b/components/style/stylesheets/rule_parser.rs index 33190c578b4..a3ec24174ed 100644 --- a/components/style/stylesheets/rule_parser.rs +++ b/components/style/stylesheets/rule_parser.rs @@ -9,7 +9,7 @@ use crate::error_reporting::ContextualParseError; use crate::font_face::parse_font_face_block; use crate::media_queries::MediaList; use crate::parser::{Parse, ParserContext}; -use crate::properties::{parse_property_declaration_list}; +use crate::properties::parse_property_declaration_list; use crate::selector_parser::{SelectorImpl, SelectorParser}; use crate::shared_lock::{Locked, SharedRwLock}; use crate::str::starts_with_ignore_ascii_case; diff --git a/components/style/values/computed/angle.rs b/components/style/values/computed/angle.rs index 1ce1a7fd34d..cdbc0006941 100644 --- a/components/style/values/computed/angle.rs +++ b/components/style/values/computed/angle.rs @@ -14,7 +14,18 @@ use style_traits::{CssWriter, ToCss}; /// A computed angle in degrees. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Add, Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToAnimatedZero, ToResolvedValue)] +#[derive( + Add, + Animate, + Clone, + Copy, + Debug, + MallocSizeOf, + PartialEq, + PartialOrd, + ToAnimatedZero, + ToResolvedValue, +)] pub struct Angle(CSSFloat); impl ToCss for Angle { diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index c7a3ba7e36e..4cd16b1cd9e 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -15,7 +15,9 @@ pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat}; pub use crate::values::specified::box_::{Contain, Display, Overflow}; pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox, OverscrollBehavior}; -pub use crate::values::specified::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType}; +pub use crate::values::specified::box_::{ + ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType, +}; pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange}; /// A computed value for the `vertical-align` property. diff --git a/components/style/values/computed/font.rs b/components/style/values/computed/font.rs index 152bbcc0d4b..001b8444a30 100644 --- a/components/style/values/computed/font.rs +++ b/components/style/values/computed/font.rs @@ -40,7 +40,9 @@ pub use crate::values::specified::font::{XLang, XTextZoom}; /// https://drafts.csswg.org/css-fonts-4/#propdef-font-weight /// /// This is effectively just a `Number`. -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] +#[derive( + Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue, +)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct FontWeight(pub Number); @@ -190,7 +192,9 @@ impl FontFamily { /// Get default font family as `serif` which is a generic font-family pub fn serif() -> Self { FontFamily { - families: FontFamilyList::new(Box::new([SingleFontFamily::Generic(GenericFontFamily::Serif)])), + families: FontFamilyList::new(Box::new([SingleFontFamily::Generic( + GenericFontFamily::Serif, + )])), is_system_font: false, } } @@ -427,8 +431,10 @@ impl PartialEq for FontFamilyList { return false; } for (a, b) in self_list.mNames.iter().zip(other_list.mNames.iter()) { - if a.mSyntax != b.mSyntax || a.mName.mRawPtr != b.mName.mRawPtr || - a.mGeneric != b.mGeneric { + if a.mSyntax != b.mSyntax || + a.mName.mRawPtr != b.mName.mRawPtr || + a.mGeneric != b.mGeneric + { return false; } } @@ -459,19 +465,15 @@ impl FontFamilyList { for family in families.iter() { match *family { - SingleFontFamily::FamilyName(ref f) => { - unsafe { - bindings::Gecko_nsTArray_FontFamilyName_AppendNamed( - names, - f.name.as_ptr(), - f.syntax, - ); - } + SingleFontFamily::FamilyName(ref f) => unsafe { + bindings::Gecko_nsTArray_FontFamilyName_AppendNamed( + names, + f.name.as_ptr(), + f.syntax, + ); }, - SingleFontFamily::Generic(family) => { - unsafe { - bindings::Gecko_nsTArray_FontFamilyName_AppendGeneric(names, family); - } + SingleFontFamily::Generic(family) => unsafe { + bindings::Gecko_nsTArray_FontFamilyName_AppendGeneric(names, family); }, } } @@ -547,7 +549,17 @@ impl<'a> Iterator for FontFamilyNameIter<'a> { } /// Preserve the readability of text when font fallback occurs -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] +#[derive( + Animate, + Clone, + ComputeSquaredDistance, + Copy, + Debug, + MallocSizeOf, + PartialEq, + ToCss, + ToResolvedValue, +)] pub enum FontSizeAdjust { #[animation(error)] /// None variant @@ -831,7 +843,9 @@ impl ToCss for FontStyle { /// A value for the font-stretch property per: /// /// https://drafts.csswg.org/css-fonts-4/#propdef-font-stretch -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] +#[derive( + Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue, +)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct FontStretch(pub NonNegativePercentage); diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 1e1fedd41bf..f43befbbaf0 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -10,8 +10,7 @@ use crate::values::computed::NonNegativeNumber; use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; use crate::values::generics::length as generics; use crate::values::generics::length::{ - GenericLengthPercentageOrNormal, GenericLengthOrNumber, - GenericMaxSize, GenericSize, + GenericLengthOrNumber, GenericLengthPercentageOrNormal, GenericMaxSize, GenericSize, }; use crate::values::generics::NonNegative; use crate::values::specified::length::ViewportPercentageLength; @@ -783,7 +782,8 @@ impl From<NonNegativeLength> for Au { } /// Either a computed NonNegativeLengthPercentage or the `normal` keyword. -pub type NonNegativeLengthPercentageOrNormal = GenericLengthPercentageOrNormal<NonNegativeLengthPercentage>; +pub type NonNegativeLengthPercentageOrNormal = + GenericLengthPercentageOrNormal<NonNegativeLengthPercentage>; /// Either a non-negative `<length>` or a `<number>`. pub type NonNegativeLengthOrNumber = GenericLengthOrNumber<NonNegativeLength, NonNegativeNumber>; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 72de7f2238e..3b32f8fecd7 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -535,7 +535,9 @@ impl From<GreaterThanOrEqualToOneNumber> for CSSFloat { } #[allow(missing_docs)] -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] +#[derive( + Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue, +)] #[repr(C, u8)] pub enum NumberOrPercentage { Percentage(Percentage), diff --git a/components/style/values/generics/border.rs b/components/style/values/generics/border.rs index fb6f1537662..ec0ab1c4b07 100644 --- a/components/style/values/generics/border.rs +++ b/components/style/values/generics/border.rs @@ -75,7 +75,11 @@ pub use self::GenericBorderImageSlice as BorderImageSlice; ToShmem, )] #[repr(C)] -pub struct GenericBorderCornerRadius<L>(#[css(field_bound)] #[shmem(field_bound)] pub Size2D<L>); +pub struct GenericBorderCornerRadius<L>( + #[css(field_bound)] + #[shmem(field_bound)] + pub Size2D<L>, +); pub use self::GenericBorderCornerRadius as BorderCornerRadius; @@ -114,7 +118,11 @@ impl<L: Zero> Zero for BorderCornerRadius<L> { ToShmem, )] #[repr(transparent)] -pub struct BorderSpacing<L>(#[css(field_bound)] #[shmem(field_bound)] pub Size2D<L>); +pub struct BorderSpacing<L>( + #[css(field_bound)] + #[shmem(field_bound)] + pub Size2D<L>, +); impl<L> BorderSpacing<L> { /// Trivially create a `BorderCornerRadius`. diff --git a/components/style/values/generics/color.rs b/components/style/values/generics/color.rs index 5aa287baadf..b4f2e7445ea 100644 --- a/components/style/values/generics/color.rs +++ b/components/style/values/generics/color.rs @@ -40,7 +40,7 @@ pub enum GenericColor<RGBA> { color: RGBA, /// The ratios of mixing between numeric and currentcolor. ratios: ComplexColorRatios, - } + }, } pub use self::GenericColor as Color; diff --git a/components/style/values/generics/counters.rs b/components/style/values/generics/counters.rs index 9da5b9140d9..17ac687a670 100644 --- a/components/style/values/generics/counters.rs +++ b/components/style/values/generics/counters.rs @@ -15,7 +15,15 @@ use std::ops::Deref; /// A name / value pair for counters. #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub struct CounterPair<Integer> { /// The name of the counter. diff --git a/components/style/values/generics/grid.rs b/components/style/values/generics/grid.rs index 17af16e5167..393e570f066 100644 --- a/components/style/values/generics/grid.rs +++ b/components/style/values/generics/grid.rs @@ -379,7 +379,9 @@ where /// The initial argument of the `repeat` function. /// /// <https://drafts.csswg.org/css-grid/#typedef-track-repeat> -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem, +)] pub enum RepeatCount<Integer> { /// A positive integer. This is allowed only for `<track-repeat>` and `<fixed-repeat>` Number(Integer), @@ -414,7 +416,16 @@ impl Parse for RepeatCount<specified::Integer> { /// /// It can also hold `repeat()` function parameters, which expands into the respective /// values in its computed form. -#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, +)] #[css(function = "repeat")] pub struct TrackRepeat<L, I> { /// The number of times for the value to be repeated (could also be `auto-fit` or `auto-fill`) diff --git a/components/style/values/generics/image.rs b/components/style/values/generics/image.rs index 59fc260f93a..a7fa6da9337 100644 --- a/components/style/values/generics/image.rs +++ b/components/style/values/generics/image.rs @@ -16,7 +16,9 @@ use style_traits::{CssWriter, ToCss}; /// An [image]. /// /// [image]: https://drafts.csswg.org/css-images/#image-values -#[derive(Clone, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] +#[derive( + Clone, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, +)] pub enum Image<Gradient, MozImageRect, ImageUrl> { /// A `<url()>` image. Url(ImageUrl), @@ -73,7 +75,9 @@ pub enum GradientKind<LineDirection, Length, LengthPercentage, Position, Angle> } /// A radial gradient's ending shape. -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem, +)] pub enum EndingShape<Length, LengthPercentage> { /// A circular gradient. Circle(Circle<Length>), @@ -91,7 +95,9 @@ pub enum Circle<Length> { } /// An ellipse shape. -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem, +)] pub enum Ellipse<LengthPercentage> { /// An ellipse pair of radii. Radii(LengthPercentage, LengthPercentage), @@ -103,7 +109,17 @@ pub enum Ellipse<LengthPercentage> { #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive( - Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + Parse, + PartialEq, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub enum ShapeExtent { ClosestSide, @@ -116,7 +132,9 @@ pub enum ShapeExtent { /// A gradient item. /// <https://drafts.csswg.org/css-images-4/#color-stop-syntax> -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem, +)] pub enum GradientItem<Color, LengthPercentage> { /// A color stop. ColorStop(ColorStop<Color, LengthPercentage>), @@ -126,7 +144,9 @@ pub enum GradientItem<Color, LengthPercentage> { /// A color stop. /// <https://drafts.csswg.org/css-images/#typedef-color-stop-list> -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem, +)] pub struct ColorStop<Color, LengthPercentage> { /// The color of this stop. pub color: Color, @@ -170,7 +190,15 @@ impl ToCss for PaintWorklet { #[allow(missing_docs)] #[css(comma, function)] #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub struct MozImageRect<NumberOrPercentage, MozImageRectUrl> { pub url: MozImageRectUrl, diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index e5bb9fa727f..d735e3bbdef 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -44,7 +44,17 @@ pub mod url; #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive( - Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + Parse, + PartialEq, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub enum SymbolsType { Cyclic, diff --git a/components/style/values/generics/text.rs b/components/style/values/generics/text.rs index 6324e7dfba8..a09260aa7e4 100644 --- a/components/style/values/generics/text.rs +++ b/components/style/values/generics/text.rs @@ -38,9 +38,7 @@ impl<N, I> InitialLetter<N, I> { } /// A generic spacing value for the `letter-spacing` and `word-spacing` properties. -#[derive( - Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem, -)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)] pub enum Spacing<Value> { /// `normal` Normal, @@ -75,9 +73,10 @@ impl<Value> Spacing<Value> { #[cfg(feature = "gecko")] fn line_height_moz_block_height_enabled(context: &ParserContext) -> bool { use crate::gecko_bindings::structs; - context.in_ua_sheet() || unsafe { - structs::StaticPrefs_sVarCache_layout_css_line_height_moz_block_height_content_enabled - } + context.in_ua_sheet() || + unsafe { + structs::StaticPrefs_sVarCache_layout_css_line_height_moz_block_height_content_enabled + } } /// A generic value for the `line-height` property. diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index bfa59c60fb2..6c6374db941 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -132,7 +132,15 @@ fn is_same<N: PartialEq>(x: &N, y: &N) -> bool { } #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] /// A single operation in the list of a `transform` value pub enum TransformOperation<Angle, Number, Length, Integer, LengthPercentage> @@ -239,7 +247,15 @@ where } #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] /// A value of the `transform` property pub struct Transform<T>(#[css(if_empty = "none", iterable)] pub Vec<T>); diff --git a/components/style/values/generics/ui.rs b/components/style/values/generics/ui.rs index 444c9a561d1..945f60fb5dd 100644 --- a/components/style/values/generics/ui.rs +++ b/components/style/values/generics/ui.rs @@ -11,7 +11,16 @@ use values::specified::ui::CursorKind; /// A generic value for the `cursor` property. /// /// https://drafts.csswg.org/css-ui/#cursor -#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, +)] pub struct Cursor<Image> { /// The parsed images for the cursor. pub images: Box<[Image]>, @@ -44,7 +53,16 @@ impl<Image: ToCss> ToCss for Cursor<Image> { } /// A generic value for item of `image cursors`. -#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, +)] pub struct CursorImage<ImageUrl, Number> { /// The url to parse images from. pub url: ImageUrl, diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs index 89f0de816f2..e2da4984084 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -96,7 +96,15 @@ where /// Convenience void type to disable some properties and values through types. #[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))] #[derive( - Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss, ToResolvedValue, + Clone, + Copy, + Debug, + PartialEq, + SpecifiedValueInfo, + ToAnimatedValue, + ToComputedValue, + ToCss, + ToResolvedValue, )] pub enum Impossible {} @@ -155,7 +163,16 @@ impl<A: Debug, B: Debug> Debug for Either<A, B> { /// <https://drafts.csswg.org/css-values-4/#custom-idents> #[derive( - Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, + Clone, + Debug, + Eq, + Hash, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, )] pub struct CustomIdent(pub Atom); @@ -193,7 +210,9 @@ impl ToCss for CustomIdent { } /// <https://drafts.csswg.org/css-animations/#typedef-keyframes-name> -#[derive(Clone, Debug, MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] +#[derive( + Clone, Debug, MallocSizeOf, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, +)] pub enum KeyframesName { /// <custom-ident> Ident(CustomIdent), diff --git a/components/style/values/resolved/mod.rs b/components/style/values/resolved/mod.rs index 33609cbd89d..7877ed71a0b 100644 --- a/components/style/values/resolved/mod.rs +++ b/components/style/values/resolved/mod.rs @@ -5,9 +5,9 @@ //! Resolved values. These are almost always computed values, but in some cases //! there are used values. +use crate::properties::ComputedValues; use cssparser; use smallvec::SmallVec; -use crate::properties::ComputedValues; mod color; @@ -182,7 +182,9 @@ where #[inline] fn to_resolved_value(self, context: &Context) -> Self::ResolvedValue { - Vec::from(self).to_resolved_value(context).into_boxed_slice() + Vec::from(self) + .to_resolved_value(context) + .into_boxed_slice() } #[inline] diff --git a/components/style/values/specified/align.rs b/components/style/values/specified/align.rs index 20f801d13b2..7c2ecda19a4 100644 --- a/components/style/values/specified/align.rs +++ b/components/style/values/specified/align.rs @@ -134,7 +134,18 @@ pub enum AxisDirection { /// Shared value for the `align-content` and `justify-content` properties. /// /// <https://drafts.csswg.org/css-align/#content-distribution> -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + PartialEq, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct ContentDistribution { primary: AlignFlags, @@ -247,7 +258,18 @@ impl ContentDistribution { /// Value for the `align-content` property. /// /// <https://drafts.csswg.org/css-align/#propdef-align-content> -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + PartialEq, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] pub struct AlignContent(pub ContentDistribution); impl Parse for AlignContent { @@ -287,7 +309,18 @@ impl From<AlignContent> for u16 { /// Value for the `justify-content` property. /// /// <https://drafts.csswg.org/css-align/#propdef-justify-content> -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + PartialEq, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] pub struct JustifyContent(pub ContentDistribution); impl Parse for JustifyContent { @@ -325,7 +358,18 @@ impl From<JustifyContent> for u16 { } /// <https://drafts.csswg.org/css-align/#self-alignment> -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + PartialEq, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] pub struct SelfAlignment(pub AlignFlags); impl SelfAlignment { @@ -385,7 +429,18 @@ impl SelfAlignment { /// The specified value of the align-self property. /// /// <https://drafts.csswg.org/css-align/#propdef-align-self> -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + PartialEq, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] pub struct AlignSelf(pub SelfAlignment); impl Parse for AlignSelf { @@ -423,7 +478,18 @@ impl From<AlignSelf> for u8 { /// The specified value of the justify-self property. /// /// <https://drafts.csswg.org/css-align/#propdef-justify-self> -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + PartialEq, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] pub struct JustifySelf(pub SelfAlignment); impl Parse for JustifySelf { @@ -461,7 +527,18 @@ impl From<JustifySelf> for u8 { /// Value of the `align-items` property /// /// <https://drafts.csswg.org/css-align/#propdef-align-items> -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + PartialEq, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] pub struct AlignItems(pub AlignFlags); impl AlignItems { diff --git a/components/style/values/specified/background.rs b/components/style/values/specified/background.rs index f087695db52..e7cb98a6ae9 100644 --- a/components/style/values/specified/background.rs +++ b/components/style/values/specified/background.rs @@ -64,7 +64,16 @@ pub enum BackgroundRepeatKeyword { /// axes. /// /// https://drafts.csswg.org/css-backgrounds/#the-background-repeat -#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, +)] pub struct BackgroundRepeat(pub BackgroundRepeatKeyword, pub BackgroundRepeatKeyword); impl BackgroundRepeat { diff --git a/components/style/values/specified/border.rs b/components/style/values/specified/border.rs index c05217fab0c..59f2f7aa284 100644 --- a/components/style/values/specified/border.rs +++ b/components/style/values/specified/border.rs @@ -265,7 +265,15 @@ pub enum BorderImageRepeatKeyword { /// /// https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat #[derive( - Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, + Clone, + Copy, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, )] pub struct BorderImageRepeat(pub BorderImageRepeatKeyword, pub BorderImageRepeatKeyword); diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index c003bf966bb..c90c270c59f 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -468,12 +468,17 @@ impl Parse for ScrollSnapType { _context: &ParserContext, input: &mut Parser<'i, 't>, ) -> Result<Self, ParseError<'i>> { - if input.try(|input| input.expect_ident_matching("none")).is_ok() { + if input + .try(|input| input.expect_ident_matching("none")) + .is_ok() + { return Ok(ScrollSnapType::none()); } let axis = ScrollSnapAxis::parse(input)?; - let strictness = input.try(ScrollSnapStrictness::parse).unwrap_or(ScrollSnapStrictness::Proximity); + let strictness = input + .try(ScrollSnapStrictness::parse) + .unwrap_or(ScrollSnapStrictness::Proximity); Ok(Self { axis, strictness }) } } @@ -524,7 +529,16 @@ pub enum ScrollSnapAlignKeyword { /// https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-align #[allow(missing_docs)] #[derive( - Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, )] #[repr(C)] pub struct ScrollSnapAlign { @@ -637,7 +651,15 @@ pub enum OverflowClipBox { } #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] /// Provides a rendering hint to the user agent, /// stating what kinds of changes the author expects @@ -940,7 +962,9 @@ pub type Perspective = GenericPerspective<NonNegativeLength>; /// A given transition property, that is either `All`, a longhand or shorthand /// property, or an unsupported or custom property. -#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem)] +#[derive( + Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue, ToResolvedValue, ToShmem, +)] pub enum TransitionProperty { /// A shorthand. Shorthand(ShorthandId), @@ -1035,17 +1059,7 @@ impl TransitionProperty { #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive( - Clone, - Copy, - Debug, - Eq, - Hash, - MallocSizeOf, - Parse, - PartialEq, - SpecifiedValueInfo, - ToCss, - ToShmem, + Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem, )] /// https://drafts.csswg.org/css-box/#propdef-float pub enum Float { @@ -1060,17 +1074,7 @@ pub enum Float { #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive( - Clone, - Copy, - Debug, - Eq, - Hash, - MallocSizeOf, - Parse, - PartialEq, - SpecifiedValueInfo, - ToCss, - ToShmem, + Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem, )] /// https://drafts.csswg.org/css-box/#propdef-clear pub enum Clear { @@ -1087,17 +1091,7 @@ pub enum Clear { #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive( - Clone, - Copy, - Debug, - Eq, - Hash, - MallocSizeOf, - Parse, - PartialEq, - SpecifiedValueInfo, - ToCss, - ToShmem, + Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem, )] pub enum Resize { None, diff --git a/components/style/values/specified/color.rs b/components/style/values/specified/color.rs index 25e7af6b98b..375a7d23d49 100644 --- a/components/style/values/specified/color.rs +++ b/components/style/values/specified/color.rs @@ -407,7 +407,9 @@ impl ToComputedValue for MozFontSmoothingBackgroundColor { type ComputedValue = RGBA; fn to_computed_value(&self, context: &Context) -> RGBA { - self.0.to_computed_value(context).to_rgba(RGBA::transparent()) + self.0 + .to_computed_value(context) + .to_rgba(RGBA::transparent()) } fn from_computed_value(computed: &RGBA) -> Self { diff --git a/components/style/values/specified/font.rs b/components/style/values/specified/font.rs index 809ffe77498..f02d44124a2 100644 --- a/components/style/values/specified/font.rs +++ b/components/style/values/specified/font.rs @@ -368,9 +368,7 @@ pub enum FontStretch { } /// A keyword value for `font-stretch`. -#[derive( - Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem, -)] +#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)] #[allow(missing_docs)] pub enum FontStretchKeyword { Normal, @@ -532,7 +530,9 @@ impl FontFamily { /// Parse a specified font-family value pub fn parse_specified<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { let values = input.parse_comma_separated(SingleFontFamily::parse)?; - Ok(FontFamily::Values(FontFamilyList::new(values.into_boxed_slice()))) + Ok(FontFamily::Values(FontFamilyList::new( + values.into_boxed_slice(), + ))) } } @@ -995,7 +995,9 @@ bitflags! { } } -#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToResolvedValue, ToShmem, +)] /// Set of variant alternates pub enum VariantAlternates { /// Enables display of stylistic alternates @@ -1020,7 +1022,9 @@ pub enum VariantAlternates { HistoricalForms, } -#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToResolvedValue, ToShmem, +)] /// List of Variant Alternates pub struct VariantAlternatesList( #[css(if_empty = "normal", iterable)] pub Box<[VariantAlternates]>, @@ -1858,7 +1862,15 @@ impl Parse for FontFeatureSettings { } #[derive( - Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, + Clone, + Copy, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, )] /// Whether user agents are allowed to synthesize bold or oblique font faces /// when a font family lacks bold or italic faces @@ -2178,7 +2190,15 @@ impl Parse for XTextZoom { } #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] /// Internal property that reflects the lang attribute pub struct XLang(#[css(skip)] pub Atom); @@ -2267,7 +2287,17 @@ impl Parse for MozScriptLevel { } #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[derive(Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Copy, + Debug, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] /// Specifies the multiplier to be used to adjust font size /// due to changes in scriptlevel. /// diff --git a/components/style/values/specified/length.rs b/components/style/values/specified/length.rs index a6beef91ee5..5bb01955956 100644 --- a/components/style/values/specified/length.rs +++ b/components/style/values/specified/length.rs @@ -13,8 +13,7 @@ use crate::properties::computed_value_flags::ComputedValueFlags; use crate::values::computed::{self, CSSPixelLength, Context}; use crate::values::generics::length as generics; use crate::values::generics::length::{ - GenericLengthPercentageOrNormal, GenericLengthOrNumber, - GenericMaxSize, GenericSize, + GenericLengthOrNumber, GenericLengthPercentageOrNormal, GenericMaxSize, GenericSize, }; use crate::values::generics::NonNegative; use crate::values::specified::calc::CalcNode; @@ -958,7 +957,8 @@ impl NonNegativeLengthPercentageOrAuto { pub type NonNegativeLengthPercentage = NonNegative<LengthPercentage>; /// Either a NonNegativeLengthPercentage or the `normal` keyword. -pub type NonNegativeLengthPercentageOrNormal = GenericLengthPercentageOrNormal<NonNegativeLengthPercentage>; +pub type NonNegativeLengthPercentageOrNormal = + GenericLengthPercentageOrNormal<NonNegativeLengthPercentage>; impl From<NoCalcLength> for NonNegativeLengthPercentage { #[inline] diff --git a/components/style/values/specified/list.rs b/components/style/values/specified/list.rs index 5a95a9bd7f7..8c1e9fa2ad4 100644 --- a/components/style/values/specified/list.rs +++ b/components/style/values/specified/list.rs @@ -16,7 +16,16 @@ use style_traits::{ParseError, StyleParseErrorKind}; /// Specified and computed `list-style-type` property. #[cfg(feature = "gecko")] #[derive( - Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + Eq, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub enum ListStyleType { /// <counter-style> | none @@ -77,7 +86,15 @@ impl Parse for ListStyleType { /// A quote pair. #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub struct QuotePair { /// The opening quote. @@ -89,7 +106,15 @@ pub struct QuotePair { /// Specified and computed `quotes` property. #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub struct Quotes( #[css(iterable, if_empty = "none")] diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 5c9e413cb09..64a76ccc582 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -709,7 +709,15 @@ impl AllowQuirks { /// /// `[namespace? `|`]? ident` #[derive( - Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, + Clone, + Debug, + Eq, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, )] #[css(function)] pub struct Attr { diff --git a/components/style/values/specified/position.rs b/components/style/values/specified/position.rs index d3c39b4f582..f75af3f5585 100644 --- a/components/style/values/specified/position.rs +++ b/components/style/values/specified/position.rs @@ -571,7 +571,17 @@ impl From<GridAutoFlow> for u8 { } } -#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem)] +#[derive( + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] /// https://drafts.csswg.org/css-grid/#named-grid-area pub struct TemplateAreas { /// `named area` containing for each template area @@ -678,7 +688,15 @@ impl Parse for TemplateAreas { /// Arc type for `Arc<TemplateAreas>` #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub struct TemplateAreasArc(#[ignore_malloc_size_of = "Arc"] pub Arc<TemplateAreas>); diff --git a/components/style/values/specified/svg.rs b/components/style/values/specified/svg.rs index b78b11f2ffa..dd4990782a0 100644 --- a/components/style/values/specified/svg.rs +++ b/components/style/values/specified/svg.rs @@ -129,7 +129,15 @@ const PAINT_ORDER_MASK: u8 = 0b11; /// Higher priority values, i.e. the values specified first, /// will be painted first (and may be covered by paintings of lower priority) #[derive( - Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, + Clone, + Copy, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, )] pub struct SVGPaintOrder(pub u8); @@ -238,7 +246,15 @@ impl ToCss for SVGPaintOrder { /// Specified MozContextProperties value. /// Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties) #[derive( - Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, + Clone, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, )] pub struct MozContextProperties(pub CustomIdent); diff --git a/components/style/values/specified/text.rs b/components/style/values/specified/text.rs index 44df9a4c38e..9d4c6ae649c 100644 --- a/components/style/values/specified/text.rs +++ b/components/style/values/specified/text.rs @@ -512,9 +512,7 @@ impl TextEmphasisKeywordValue { } /// Fill mode for the text-emphasis-style property -#[derive( - Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem, -)] +#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)] pub enum TextEmphasisFillMode { /// `filled` Filled, diff --git a/components/style/values/specified/ui.rs b/components/style/values/specified/ui.rs index 52afa0fb256..0cc20d960c6 100644 --- a/components/style/values/specified/ui.rs +++ b/components/style/values/specified/ui.rs @@ -57,7 +57,15 @@ impl Parse for CursorImage { /// Specified value of `-moz-force-broken-image-icon` #[derive( - Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, + Clone, + Copy, + Debug, + MallocSizeOf, + PartialEq, + SpecifiedValueInfo, + ToComputedValue, + ToResolvedValue, + ToShmem, )] pub struct MozForceBrokenImageIcon(pub bool); diff --git a/components/style_derive/to_animated_value.rs b/components/style_derive/to_animated_value.rs index ac231be3452..51a73cbf4e1 100644 --- a/components/style_derive/to_animated_value.rs +++ b/components/style_derive/to_animated_value.rs @@ -10,20 +10,20 @@ use to_computed_value; pub fn derive(input: DeriveInput) -> TokenStream { let trait_impl = |from_body, to_body| { quote! { - #[inline] - fn from_animated_value(animated: Self::AnimatedValue) -> Self { - match animated { - #from_body - } - } + #[inline] + fn from_animated_value(animated: Self::AnimatedValue) -> Self { + match animated { + #from_body + } + } - #[inline] - fn to_animated_value(self) -> Self::AnimatedValue { - match self { - #to_body - } - } - } + #[inline] + fn to_animated_value(self) -> Self::AnimatedValue { + match self { + #to_body + } + } + } }; // TODO(emilio): Consider optimizing away non-generic cases as well? diff --git a/components/style_derive/to_computed_value.rs b/components/style_derive/to_computed_value.rs index 6010b7483cb..ed6e07a2f5a 100644 --- a/components/style_derive/to_computed_value.rs +++ b/components/style_derive/to_computed_value.rs @@ -55,10 +55,7 @@ pub fn derive_to_value( let (to_body, from_body) = { let params = input.generics.type_params().collect::<Vec<_>>(); for param in ¶ms { - cg::add_predicate( - &mut where_clause, - parse_quote!(#param: #trait_path), - ); + cg::add_predicate(&mut where_clause, parse_quote!(#param: #trait_path)); } let to_body = cg::fmap_match(&input, bind_style, |binding| { @@ -80,20 +77,14 @@ pub fn derive_to_value( } call_to(&binding) }); - let from_body = cg::fmap_match(&input, bind_style, |binding| { - call_from(&binding) - }); + let from_body = cg::fmap_match(&input, bind_style, |binding| call_from(&binding)); (to_body, from_body) }; input.generics.where_clause = where_clause; let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); - let computed_value_type = cg::fmap_trait_output( - &input, - &trait_path, - &output_type_name, - ); + let computed_value_type = cg::fmap_trait_output(&input, &trait_path, &output_type_name); let impl_ = trait_impl(from_body, to_body); @@ -109,21 +100,21 @@ pub fn derive_to_value( pub fn derive(input: DeriveInput) -> TokenStream { let trait_impl = |from_body, to_body| { quote! { - #[inline] - fn from_computed_value(computed: &Self::ComputedValue) -> Self { - match *computed { - #from_body - } - } - - #[allow(unused_variables)] - #[inline] - fn to_computed_value(&self, context: &crate::values::computed::Context) -> Self::ComputedValue { - match *self { - #to_body - } - } - } + #[inline] + fn from_computed_value(computed: &Self::ComputedValue) -> Self { + match *computed { + #from_body + } + } + + #[allow(unused_variables)] + #[inline] + fn to_computed_value(&self, context: &crate::values::computed::Context) -> Self::ComputedValue { + match *self { + #to_body + } + } + } }; let non_generic_implementation = || { diff --git a/components/style_derive/to_resolved_value.rs b/components/style_derive/to_resolved_value.rs index 70d3f71876f..040cda954a8 100644 --- a/components/style_derive/to_resolved_value.rs +++ b/components/style_derive/to_resolved_value.rs @@ -11,23 +11,23 @@ use to_computed_value; pub fn derive(input: DeriveInput) -> TokenStream { let trait_impl = |from_body, to_body| { quote! { - #[inline] - fn from_resolved_value(resolved: Self::ResolvedValue) -> Self { - match resolved { - #from_body - } - } + #[inline] + fn from_resolved_value(resolved: Self::ResolvedValue) -> Self { + match resolved { + #from_body + } + } - #[inline] - fn to_resolved_value( - self, - context: &crate::values::resolved::Context, - ) -> Self::ResolvedValue { - match self { - #to_body - } - } - } + #[inline] + fn to_resolved_value( + self, + context: &crate::values::resolved::Context, + ) -> Self::ResolvedValue { + match self { + #to_body + } + } + } }; let non_generic_implementation = || { diff --git a/components/to_shmem/lib.rs b/components/to_shmem/lib.rs index db6efe20895..59fc2afb546 100644 --- a/components/to_shmem/lib.rs +++ b/components/to_shmem/lib.rs @@ -24,17 +24,17 @@ use smallvec::{Array, SmallVec}; use std::alloc::Layout; #[cfg(debug_assertions)] use std::any::TypeId; -use std::isize; #[cfg(debug_assertions)] use std::collections::HashSet; use std::ffi::CString; +use std::isize; use std::marker::PhantomData; use std::mem::{self, ManuallyDrop}; use std::num::Wrapping; use std::ops::Range; +use std::os::raw::c_char; #[cfg(debug_assertions)] use std::os::raw::c_void; -use std::os::raw::c_char; use std::ptr::{self, NonNull}; use std::slice; use std::str; @@ -166,7 +166,7 @@ impl SharedMemoryBuilder { // Reserve space for the padding. let start = self.index.checked_add(padding).unwrap(); - assert!(start <= std::isize::MAX as usize); // for the cast below + assert!(start <= std::isize::MAX as usize); // for the cast below // Reserve space for the value. let end = start.checked_add(layout.size()).unwrap(); @@ -205,7 +205,22 @@ macro_rules! impl_trivial_to_shmem { )*}; } -impl_trivial_to_shmem!((), bool, f32, f64, i8, i16, i32, i64, u8, u16, u32, u64, isize, usize); +impl_trivial_to_shmem!( + (), + bool, + f32, + f64, + i8, + i16, + i32, + i64, + u8, + u16, + u32, + u64, + isize, + usize +); impl_trivial_to_shmem!(cssparser::RGBA); impl_trivial_to_shmem!(cssparser::SourceLocation); @@ -424,7 +439,9 @@ impl<T: 'static + ToShmem> ToShmem for Arc<T> { #[cfg(debug_assertions)] assert!( !builder.shared_values.contains(&self.heap_ptr()) || - builder.allowed_duplication_types.contains(&TypeId::of::<T>()), + builder + .allowed_duplication_types + .contains(&TypeId::of::<T>()), "ToShmem failed for Arc<T>: encountered a value of type T with multiple references \ and which has not been explicitly allowed with an add_allowed_duplication_type call", ); @@ -463,11 +480,7 @@ impl<H: 'static + ToShmem, T: 'static + ToShmem> ToShmem for ThinArc<H, T> { // Make a clone of the Arc-owned header and slice values with all of // their heap allocations placed in the shared memory buffer. let header = self.header.header.to_shmem(builder); - let values: Vec<ManuallyDrop<T>> = self - .slice - .iter() - .map(|v| v.to_shmem(builder)) - .collect(); + let values: Vec<ManuallyDrop<T>> = self.slice.iter().map(|v| v.to_shmem(builder)).collect(); // Create a new ThinArc with the shared value and have it place // its ArcInner in the shared memory buffer. @@ -499,10 +512,11 @@ impl ToShmem for SmallBitVec { let src = vs.as_ptr() as *const usize; ptr::copy(src, dest, len); - let dest_slice = Box::from_raw(slice::from_raw_parts_mut(dest, len) as *mut [usize]); + let dest_slice = + Box::from_raw(slice::from_raw_parts_mut(dest, len) as *mut [usize]); InternalStorage::Spilled(dest_slice) } - } + }, InternalStorage::Inline(x) => InternalStorage::Inline(x), }; ManuallyDrop::new(unsafe { SmallBitVec::from_storage(storage) }) diff --git a/components/to_shmem_derive/to_shmem.rs b/components/to_shmem_derive/to_shmem.rs index 5021476aad4..1335ef4eea6 100644 --- a/components/to_shmem_derive/to_shmem.rs +++ b/components/to_shmem_derive/to_shmem.rs @@ -12,10 +12,7 @@ pub fn derive(mut input: syn::DeriveInput) -> TokenStream { let attrs = cg::parse_input_attrs::<ShmemInputAttrs>(&input); if !attrs.no_bounds { for param in input.generics.type_params() { - cg::add_predicate( - &mut where_clause, - parse_quote!(#param: ::to_shmem::ToShmem), - ); + cg::add_predicate(&mut where_clause, parse_quote!(#param: ::to_shmem::ToShmem)); } } for variant in Structure::new(&input).variants() { @@ -23,10 +20,7 @@ pub fn derive(mut input: syn::DeriveInput) -> TokenStream { let attrs = cg::parse_field_attrs::<ShmemFieldAttrs>(&binding.ast()); if attrs.field_bound { let ty = &binding.ast().ty; - cg::add_predicate( - &mut where_clause, - parse_quote!(#ty: ::to_shmem::ToShmem), - ) + cg::add_predicate(&mut where_clause, parse_quote!(#ty: ::to_shmem::ToShmem)) } } } |