style: Reformat recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-04-11 22:12:41 +02:00
parent 7c4f9bbf49
commit 8c004c0858
40 changed files with 571 additions and 212 deletions

View file

@ -223,7 +223,9 @@ pub trait Parser<'i> {
#[derive(Clone, Debug, Eq, PartialEq, ToShmem)] #[derive(Clone, Debug, Eq, PartialEq, ToShmem)]
#[shmem(no_bounds)] #[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> { impl<Impl: SelectorImpl> SelectorList<Impl> {
/// Parse a comma-separated list of Selectors. /// 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. /// handle it in to_css to make it invisible to serialization.
#[derive(Clone, Eq, PartialEq, ToShmem)] #[derive(Clone, Eq, PartialEq, ToShmem)]
#[shmem(no_bounds)] #[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> { impl<Impl: SelectorImpl> Selector<Impl> {
#[inline] #[inline]
@ -834,7 +838,10 @@ pub enum Component<Impl: SelectorImpl> {
ExplicitAnyNamespace, ExplicitAnyNamespace,
ExplicitNoNamespace, ExplicitNoNamespace,
DefaultNamespace(#[shmem(field_bound)] Impl::NamespaceUrl), 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, ExplicitUniversalType,
LocalName(LocalName<Impl>), LocalName(LocalName<Impl>),

View file

@ -6,18 +6,22 @@
#![deny(missing_docs)] #![deny(missing_docs)]
use crate::selector_parser::SelectorImpl;
use crate::stylesheets::UrlExtraData; use crate::stylesheets::UrlExtraData;
use cssparser::{BasicParseErrorKind, ParseErrorKind, SourceLocation, Token}; use cssparser::{BasicParseErrorKind, ParseErrorKind, SourceLocation, Token};
use selectors::SelectorList;
use std::fmt; use std::fmt;
use style_traits::ParseError; use style_traits::ParseError;
use crate::selector_parser::{SelectorImpl};
use selectors::SelectorList;
/// Errors that can be encountered while parsing CSS. /// Errors that can be encountered while parsing CSS.
#[derive(Debug)] #[derive(Debug)]
pub enum ContextualParseError<'a> { pub enum ContextualParseError<'a> {
/// A property declaration was not recognized. /// 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. /// A font face descriptor was not recognized.
UnsupportedFontFaceDescriptor(&'a str, ParseError<'a>), UnsupportedFontFaceDescriptor(&'a str, ParseError<'a>),
/// A font feature values descriptor was not recognized. /// A font feature values descriptor was not recognized.

View file

@ -43,7 +43,11 @@ pub trait FontMetricsProvider {
} }
/// Get default size of a given language and generic family. /// 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 /// Construct from a shared style context
fn create_from(context: &SharedStyleContext) -> Self fn create_from(context: &SharedStyleContext) -> Self

View file

@ -1108,9 +1108,9 @@ impl structs::FontSizePrefs {
GenericFontFamily::Monospace => self.mDefaultMonospaceSize, GenericFontFamily::Monospace => self.mDefaultMonospaceSize,
GenericFontFamily::Cursive => self.mDefaultCursiveSize, GenericFontFamily::Cursive => self.mDefaultCursiveSize,
GenericFontFamily::Fantasy => self.mDefaultFantasySize, GenericFontFamily::Fantasy => self.mDefaultFantasySize,
GenericFontFamily::MozEmoji => { GenericFontFamily::MozEmoji => unreachable!(
unreachable!("Should never get here, since this doesn't (yet) appear on font family") "Should never get here, since this doesn't (yet) appear on font family"
}, ),
}) })
} }
} }

View file

@ -126,7 +126,11 @@ impl Borrow<WeakAtom> for Atom {
impl ToShmem for Atom { impl ToShmem for Atom {
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> ManuallyDrop<Self> { 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)) ManuallyDrop::new(Atom(self.0))
} }

View file

@ -9,7 +9,7 @@ use crate::error_reporting::ContextualParseError;
use crate::font_face::parse_font_face_block; use crate::font_face::parse_font_face_block;
use crate::media_queries::MediaList; use crate::media_queries::MediaList;
use crate::parser::{Parse, ParserContext}; 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::selector_parser::{SelectorImpl, SelectorParser};
use crate::shared_lock::{Locked, SharedRwLock}; use crate::shared_lock::{Locked, SharedRwLock};
use crate::str::starts_with_ignore_ascii_case; use crate::str::starts_with_ignore_ascii_case;

View file

@ -14,7 +14,18 @@ use style_traits::{CssWriter, ToCss};
/// A computed angle in degrees. /// A computed angle in degrees.
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[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); pub struct Angle(CSSFloat);
impl ToCss for Angle { impl ToCss for Angle {

View file

@ -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_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
pub use crate::values::specified::box_::{Contain, Display, Overflow}; pub use crate::values::specified::box_::{Contain, Display, Overflow};
pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox, OverscrollBehavior}; 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}; pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
/// A computed value for the `vertical-align` property. /// A computed value for the `vertical-align` property.

View file

@ -40,7 +40,9 @@ pub use crate::values::specified::font::{XLang, XTextZoom};
/// https://drafts.csswg.org/css-fonts-4/#propdef-font-weight /// https://drafts.csswg.org/css-fonts-4/#propdef-font-weight
/// ///
/// This is effectively just a `Number`. /// 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))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub struct FontWeight(pub Number); pub struct FontWeight(pub Number);
@ -190,7 +192,9 @@ impl FontFamily {
/// Get default font family as `serif` which is a generic font-family /// Get default font family as `serif` which is a generic font-family
pub fn serif() -> Self { pub fn serif() -> Self {
FontFamily { FontFamily {
families: FontFamilyList::new(Box::new([SingleFontFamily::Generic(GenericFontFamily::Serif)])), families: FontFamilyList::new(Box::new([SingleFontFamily::Generic(
GenericFontFamily::Serif,
)])),
is_system_font: false, is_system_font: false,
} }
} }
@ -427,8 +431,10 @@ impl PartialEq for FontFamilyList {
return false; return false;
} }
for (a, b) in self_list.mNames.iter().zip(other_list.mNames.iter()) { for (a, b) in self_list.mNames.iter().zip(other_list.mNames.iter()) {
if a.mSyntax != b.mSyntax || a.mName.mRawPtr != b.mName.mRawPtr || if a.mSyntax != b.mSyntax ||
a.mGeneric != b.mGeneric { a.mName.mRawPtr != b.mName.mRawPtr ||
a.mGeneric != b.mGeneric
{
return false; return false;
} }
} }
@ -459,19 +465,15 @@ impl FontFamilyList {
for family in families.iter() { for family in families.iter() {
match *family { match *family {
SingleFontFamily::FamilyName(ref f) => { SingleFontFamily::FamilyName(ref f) => unsafe {
unsafe { bindings::Gecko_nsTArray_FontFamilyName_AppendNamed(
bindings::Gecko_nsTArray_FontFamilyName_AppendNamed( names,
names, f.name.as_ptr(),
f.name.as_ptr(), f.syntax,
f.syntax, );
);
}
}, },
SingleFontFamily::Generic(family) => { SingleFontFamily::Generic(family) => unsafe {
unsafe { bindings::Gecko_nsTArray_FontFamilyName_AppendGeneric(names, family);
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 /// 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 { pub enum FontSizeAdjust {
#[animation(error)] #[animation(error)]
/// None variant /// None variant
@ -831,7 +843,9 @@ impl ToCss for FontStyle {
/// A value for the font-stretch property per: /// A value for the font-stretch property per:
/// ///
/// https://drafts.csswg.org/css-fonts-4/#propdef-font-stretch /// 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))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub struct FontStretch(pub NonNegativePercentage); pub struct FontStretch(pub NonNegativePercentage);

View file

@ -10,8 +10,7 @@ use crate::values::computed::NonNegativeNumber;
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance}; use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
use crate::values::generics::length as generics; use crate::values::generics::length as generics;
use crate::values::generics::length::{ use crate::values::generics::length::{
GenericLengthPercentageOrNormal, GenericLengthOrNumber, GenericLengthOrNumber, GenericLengthPercentageOrNormal, GenericMaxSize, GenericSize,
GenericMaxSize, GenericSize,
}; };
use crate::values::generics::NonNegative; use crate::values::generics::NonNegative;
use crate::values::specified::length::ViewportPercentageLength; use crate::values::specified::length::ViewportPercentageLength;
@ -783,7 +782,8 @@ impl From<NonNegativeLength> for Au {
} }
/// Either a computed NonNegativeLengthPercentage or the `normal` keyword. /// 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>`. /// Either a non-negative `<length>` or a `<number>`.
pub type NonNegativeLengthOrNumber = GenericLengthOrNumber<NonNegativeLength, NonNegativeNumber>; pub type NonNegativeLengthOrNumber = GenericLengthOrNumber<NonNegativeLength, NonNegativeNumber>;

View file

@ -535,7 +535,9 @@ impl From<GreaterThanOrEqualToOneNumber> for CSSFloat {
} }
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] #[derive(
Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue,
)]
#[repr(C, u8)] #[repr(C, u8)]
pub enum NumberOrPercentage { pub enum NumberOrPercentage {
Percentage(Percentage), Percentage(Percentage),

View file

@ -75,7 +75,11 @@ pub use self::GenericBorderImageSlice as BorderImageSlice;
ToShmem, ToShmem,
)] )]
#[repr(C)] #[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; pub use self::GenericBorderCornerRadius as BorderCornerRadius;
@ -114,7 +118,11 @@ impl<L: Zero> Zero for BorderCornerRadius<L> {
ToShmem, ToShmem,
)] )]
#[repr(transparent)] #[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> { impl<L> BorderSpacing<L> {
/// Trivially create a `BorderCornerRadius`. /// Trivially create a `BorderCornerRadius`.

View file

@ -40,7 +40,7 @@ pub enum GenericColor<RGBA> {
color: RGBA, color: RGBA,
/// The ratios of mixing between numeric and currentcolor. /// The ratios of mixing between numeric and currentcolor.
ratios: ComplexColorRatios, ratios: ComplexColorRatios,
} },
} }
pub use self::GenericColor as Color; pub use self::GenericColor as Color;

View file

@ -15,7 +15,15 @@ use std::ops::Deref;
/// A name / value pair for counters. /// A name / value pair for counters.
#[derive( #[derive(
Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] )]
pub struct CounterPair<Integer> { pub struct CounterPair<Integer> {
/// The name of the counter. /// The name of the counter.

View file

@ -379,7 +379,9 @@ where
/// The initial argument of the `repeat` function. /// The initial argument of the `repeat` function.
/// ///
/// <https://drafts.csswg.org/css-grid/#typedef-track-repeat> /// <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> { pub enum RepeatCount<Integer> {
/// A positive integer. This is allowed only for `<track-repeat>` and `<fixed-repeat>` /// A positive integer. This is allowed only for `<track-repeat>` and `<fixed-repeat>`
Number(Integer), Number(Integer),
@ -414,7 +416,16 @@ impl Parse for RepeatCount<specified::Integer> {
/// ///
/// It can also hold `repeat()` function parameters, which expands into the respective /// It can also hold `repeat()` function parameters, which expands into the respective
/// values in its computed form. /// 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")] #[css(function = "repeat")]
pub struct TrackRepeat<L, I> { pub struct TrackRepeat<L, I> {
/// The number of times for the value to be repeated (could also be `auto-fit` or `auto-fill`) /// The number of times for the value to be repeated (could also be `auto-fit` or `auto-fill`)

View file

@ -16,7 +16,9 @@ use style_traits::{CssWriter, ToCss};
/// An [image]. /// An [image].
/// ///
/// [image]: https://drafts.csswg.org/css-images/#image-values /// [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> { pub enum Image<Gradient, MozImageRect, ImageUrl> {
/// A `<url()>` image. /// A `<url()>` image.
Url(ImageUrl), Url(ImageUrl),
@ -73,7 +75,9 @@ pub enum GradientKind<LineDirection, Length, LengthPercentage, Position, Angle>
} }
/// A radial gradient's ending shape. /// 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> { pub enum EndingShape<Length, LengthPercentage> {
/// A circular gradient. /// A circular gradient.
Circle(Circle<Length>), Circle(Circle<Length>),
@ -91,7 +95,9 @@ pub enum Circle<Length> {
} }
/// An ellipse shape. /// 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> { pub enum Ellipse<LengthPercentage> {
/// An ellipse pair of radii. /// An ellipse pair of radii.
Radii(LengthPercentage, LengthPercentage), Radii(LengthPercentage, LengthPercentage),
@ -103,7 +109,17 @@ pub enum Ellipse<LengthPercentage> {
#[allow(missing_docs)] #[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive( #[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 { pub enum ShapeExtent {
ClosestSide, ClosestSide,
@ -116,7 +132,9 @@ pub enum ShapeExtent {
/// A gradient item. /// A gradient item.
/// <https://drafts.csswg.org/css-images-4/#color-stop-syntax> /// <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> { pub enum GradientItem<Color, LengthPercentage> {
/// A color stop. /// A color stop.
ColorStop(ColorStop<Color, LengthPercentage>), ColorStop(ColorStop<Color, LengthPercentage>),
@ -126,7 +144,9 @@ pub enum GradientItem<Color, LengthPercentage> {
/// A color stop. /// A color stop.
/// <https://drafts.csswg.org/css-images/#typedef-color-stop-list> /// <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> { pub struct ColorStop<Color, LengthPercentage> {
/// The color of this stop. /// The color of this stop.
pub color: Color, pub color: Color,
@ -170,7 +190,15 @@ impl ToCss for PaintWorklet {
#[allow(missing_docs)] #[allow(missing_docs)]
#[css(comma, function)] #[css(comma, function)]
#[derive( #[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 struct MozImageRect<NumberOrPercentage, MozImageRectUrl> {
pub url: MozImageRectUrl, pub url: MozImageRectUrl,

View file

@ -44,7 +44,17 @@ pub mod url;
#[allow(missing_docs)] #[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive( #[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 { pub enum SymbolsType {
Cyclic, Cyclic,

View file

@ -38,9 +38,7 @@ impl<N, I> InitialLetter<N, I> {
} }
/// A generic spacing value for the `letter-spacing` and `word-spacing` properties. /// A generic spacing value for the `letter-spacing` and `word-spacing` properties.
#[derive( #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem,
)]
pub enum Spacing<Value> { pub enum Spacing<Value> {
/// `normal` /// `normal`
Normal, Normal,
@ -75,9 +73,10 @@ impl<Value> Spacing<Value> {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn line_height_moz_block_height_enabled(context: &ParserContext) -> bool { fn line_height_moz_block_height_enabled(context: &ParserContext) -> bool {
use crate::gecko_bindings::structs; use crate::gecko_bindings::structs;
context.in_ua_sheet() || unsafe { context.in_ua_sheet() ||
structs::StaticPrefs_sVarCache_layout_css_line_height_moz_block_height_content_enabled unsafe {
} structs::StaticPrefs_sVarCache_layout_css_line_height_moz_block_height_content_enabled
}
} }
/// A generic value for the `line-height` property. /// A generic value for the `line-height` property.

View file

@ -132,7 +132,15 @@ fn is_same<N: PartialEq>(x: &N, y: &N) -> bool {
} }
#[derive( #[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 /// A single operation in the list of a `transform` value
pub enum TransformOperation<Angle, Number, Length, Integer, LengthPercentage> pub enum TransformOperation<Angle, Number, Length, Integer, LengthPercentage>
@ -239,7 +247,15 @@ where
} }
#[derive( #[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 /// A value of the `transform` property
pub struct Transform<T>(#[css(if_empty = "none", iterable)] pub Vec<T>); pub struct Transform<T>(#[css(if_empty = "none", iterable)] pub Vec<T>);

View file

@ -11,7 +11,16 @@ use values::specified::ui::CursorKind;
/// A generic value for the `cursor` property. /// A generic value for the `cursor` property.
/// ///
/// https://drafts.csswg.org/css-ui/#cursor /// 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> { pub struct Cursor<Image> {
/// The parsed images for the cursor. /// The parsed images for the cursor.
pub images: Box<[Image]>, pub images: Box<[Image]>,
@ -44,7 +53,16 @@ impl<Image: ToCss> ToCss for Cursor<Image> {
} }
/// A generic value for item of `image cursors`. /// 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> { pub struct CursorImage<ImageUrl, Number> {
/// The url to parse images from. /// The url to parse images from.
pub url: ImageUrl, pub url: ImageUrl,

View file

@ -96,7 +96,15 @@ where
/// Convenience void type to disable some properties and values through types. /// Convenience void type to disable some properties and values through types.
#[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, MallocSizeOf, Serialize))]
#[derive( #[derive(
Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss, ToResolvedValue, Clone,
Copy,
Debug,
PartialEq,
SpecifiedValueInfo,
ToAnimatedValue,
ToComputedValue,
ToCss,
ToResolvedValue,
)] )]
pub enum Impossible {} 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> /// <https://drafts.csswg.org/css-values-4/#custom-idents>
#[derive( #[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); pub struct CustomIdent(pub Atom);
@ -193,7 +210,9 @@ impl ToCss for CustomIdent {
} }
/// <https://drafts.csswg.org/css-animations/#typedef-keyframes-name> /// <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 { pub enum KeyframesName {
/// <custom-ident> /// <custom-ident>
Ident(CustomIdent), Ident(CustomIdent),

View file

@ -5,9 +5,9 @@
//! Resolved values. These are almost always computed values, but in some cases //! Resolved values. These are almost always computed values, but in some cases
//! there are used values. //! there are used values.
use crate::properties::ComputedValues;
use cssparser; use cssparser;
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::properties::ComputedValues;
mod color; mod color;
@ -182,7 +182,9 @@ where
#[inline] #[inline]
fn to_resolved_value(self, context: &Context) -> Self::ResolvedValue { 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] #[inline]

View file

@ -134,7 +134,18 @@ pub enum AxisDirection {
/// Shared value for the `align-content` and `justify-content` properties. /// Shared value for the `align-content` and `justify-content` properties.
/// ///
/// <https://drafts.csswg.org/css-align/#content-distribution> /// <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))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub struct ContentDistribution { pub struct ContentDistribution {
primary: AlignFlags, primary: AlignFlags,
@ -247,7 +258,18 @@ impl ContentDistribution {
/// Value for the `align-content` property. /// Value for the `align-content` property.
/// ///
/// <https://drafts.csswg.org/css-align/#propdef-align-content> /// <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); pub struct AlignContent(pub ContentDistribution);
impl Parse for AlignContent { impl Parse for AlignContent {
@ -287,7 +309,18 @@ impl From<AlignContent> for u16 {
/// Value for the `justify-content` property. /// Value for the `justify-content` property.
/// ///
/// <https://drafts.csswg.org/css-align/#propdef-justify-content> /// <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); pub struct JustifyContent(pub ContentDistribution);
impl Parse for JustifyContent { impl Parse for JustifyContent {
@ -325,7 +358,18 @@ impl From<JustifyContent> for u16 {
} }
/// <https://drafts.csswg.org/css-align/#self-alignment> /// <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); pub struct SelfAlignment(pub AlignFlags);
impl SelfAlignment { impl SelfAlignment {
@ -385,7 +429,18 @@ impl SelfAlignment {
/// The specified value of the align-self property. /// The specified value of the align-self property.
/// ///
/// <https://drafts.csswg.org/css-align/#propdef-align-self> /// <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); pub struct AlignSelf(pub SelfAlignment);
impl Parse for AlignSelf { impl Parse for AlignSelf {
@ -423,7 +478,18 @@ impl From<AlignSelf> for u8 {
/// The specified value of the justify-self property. /// The specified value of the justify-self property.
/// ///
/// <https://drafts.csswg.org/css-align/#propdef-justify-self> /// <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); pub struct JustifySelf(pub SelfAlignment);
impl Parse for JustifySelf { impl Parse for JustifySelf {
@ -461,7 +527,18 @@ impl From<JustifySelf> for u8 {
/// Value of the `align-items` property /// Value of the `align-items` property
/// ///
/// <https://drafts.csswg.org/css-align/#propdef-align-items> /// <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); pub struct AlignItems(pub AlignFlags);
impl AlignItems { impl AlignItems {

View file

@ -64,7 +64,16 @@ pub enum BackgroundRepeatKeyword {
/// axes. /// axes.
/// ///
/// https://drafts.csswg.org/css-backgrounds/#the-background-repeat /// 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); pub struct BackgroundRepeat(pub BackgroundRepeatKeyword, pub BackgroundRepeatKeyword);
impl BackgroundRepeat { impl BackgroundRepeat {

View file

@ -265,7 +265,15 @@ pub enum BorderImageRepeatKeyword {
/// ///
/// https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat /// https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat
#[derive( #[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); pub struct BorderImageRepeat(pub BorderImageRepeatKeyword, pub BorderImageRepeatKeyword);

View file

@ -468,12 +468,17 @@ impl Parse for ScrollSnapType {
_context: &ParserContext, _context: &ParserContext,
input: &mut Parser<'i, 't>, input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> { ) -> 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()); return Ok(ScrollSnapType::none());
} }
let axis = ScrollSnapAxis::parse(input)?; 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 }) Ok(Self { axis, strictness })
} }
} }
@ -524,7 +529,16 @@ pub enum ScrollSnapAlignKeyword {
/// https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-align /// https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-align
#[allow(missing_docs)] #[allow(missing_docs)]
#[derive( #[derive(
Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, Clone,
Copy,
Debug,
Eq,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] )]
#[repr(C)] #[repr(C)]
pub struct ScrollSnapAlign { pub struct ScrollSnapAlign {
@ -637,7 +651,15 @@ pub enum OverflowClipBox {
} }
#[derive( #[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, /// Provides a rendering hint to the user agent,
/// stating what kinds of changes the author expects /// 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 /// A given transition property, that is either `All`, a longhand or shorthand
/// property, or an unsupported or custom property. /// 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 { pub enum TransitionProperty {
/// A shorthand. /// A shorthand.
Shorthand(ShorthandId), Shorthand(ShorthandId),
@ -1035,17 +1059,7 @@ impl TransitionProperty {
#[allow(missing_docs)] #[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive( #[derive(
Clone, Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem,
Copy,
Debug,
Eq,
Hash,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToCss,
ToShmem,
)] )]
/// https://drafts.csswg.org/css-box/#propdef-float /// https://drafts.csswg.org/css-box/#propdef-float
pub enum Float { pub enum Float {
@ -1060,17 +1074,7 @@ pub enum Float {
#[allow(missing_docs)] #[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive( #[derive(
Clone, Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem,
Copy,
Debug,
Eq,
Hash,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToCss,
ToShmem,
)] )]
/// https://drafts.csswg.org/css-box/#propdef-clear /// https://drafts.csswg.org/css-box/#propdef-clear
pub enum Clear { pub enum Clear {
@ -1087,17 +1091,7 @@ pub enum Clear {
#[allow(missing_docs)] #[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive( #[derive(
Clone, Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem,
Copy,
Debug,
Eq,
Hash,
MallocSizeOf,
Parse,
PartialEq,
SpecifiedValueInfo,
ToCss,
ToShmem,
)] )]
pub enum Resize { pub enum Resize {
None, None,

View file

@ -407,7 +407,9 @@ impl ToComputedValue for MozFontSmoothingBackgroundColor {
type ComputedValue = RGBA; type ComputedValue = RGBA;
fn to_computed_value(&self, context: &Context) -> 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 { fn from_computed_value(computed: &RGBA) -> Self {

View file

@ -368,9 +368,7 @@ pub enum FontStretch {
} }
/// A keyword value for `font-stretch`. /// A keyword value for `font-stretch`.
#[derive( #[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem,
)]
#[allow(missing_docs)] #[allow(missing_docs)]
pub enum FontStretchKeyword { pub enum FontStretchKeyword {
Normal, Normal,
@ -532,7 +530,9 @@ impl FontFamily {
/// Parse a specified font-family value /// Parse a specified font-family value
pub fn parse_specified<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> { pub fn parse_specified<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
let values = input.parse_comma_separated(SingleFontFamily::parse)?; 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 /// Set of variant alternates
pub enum VariantAlternates { pub enum VariantAlternates {
/// Enables display of stylistic alternates /// Enables display of stylistic alternates
@ -1020,7 +1022,9 @@ pub enum VariantAlternates {
HistoricalForms, HistoricalForms,
} }
#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToResolvedValue, ToShmem)] #[derive(
Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToResolvedValue, ToShmem,
)]
/// List of Variant Alternates /// List of Variant Alternates
pub struct VariantAlternatesList( pub struct VariantAlternatesList(
#[css(if_empty = "normal", iterable)] pub Box<[VariantAlternates]>, #[css(if_empty = "normal", iterable)] pub Box<[VariantAlternates]>,
@ -1858,7 +1862,15 @@ impl Parse for FontFeatureSettings {
} }
#[derive( #[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 /// Whether user agents are allowed to synthesize bold or oblique font faces
/// when a font family lacks bold or italic faces /// when a font family lacks bold or italic faces
@ -2178,7 +2190,15 @@ impl Parse for XTextZoom {
} }
#[derive( #[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 /// Internal property that reflects the lang attribute
pub struct XLang(#[css(skip)] pub Atom); pub struct XLang(#[css(skip)] pub Atom);
@ -2267,7 +2287,17 @@ impl Parse for MozScriptLevel {
} }
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] #[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 /// Specifies the multiplier to be used to adjust font size
/// due to changes in scriptlevel. /// due to changes in scriptlevel.
/// ///

View file

@ -13,8 +13,7 @@ use crate::properties::computed_value_flags::ComputedValueFlags;
use crate::values::computed::{self, CSSPixelLength, Context}; use crate::values::computed::{self, CSSPixelLength, Context};
use crate::values::generics::length as generics; use crate::values::generics::length as generics;
use crate::values::generics::length::{ use crate::values::generics::length::{
GenericLengthPercentageOrNormal, GenericLengthOrNumber, GenericLengthOrNumber, GenericLengthPercentageOrNormal, GenericMaxSize, GenericSize,
GenericMaxSize, GenericSize,
}; };
use crate::values::generics::NonNegative; use crate::values::generics::NonNegative;
use crate::values::specified::calc::CalcNode; use crate::values::specified::calc::CalcNode;
@ -958,7 +957,8 @@ impl NonNegativeLengthPercentageOrAuto {
pub type NonNegativeLengthPercentage = NonNegative<LengthPercentage>; pub type NonNegativeLengthPercentage = NonNegative<LengthPercentage>;
/// Either a NonNegativeLengthPercentage or the `normal` keyword. /// Either a NonNegativeLengthPercentage or the `normal` keyword.
pub type NonNegativeLengthPercentageOrNormal = GenericLengthPercentageOrNormal<NonNegativeLengthPercentage>; pub type NonNegativeLengthPercentageOrNormal =
GenericLengthPercentageOrNormal<NonNegativeLengthPercentage>;
impl From<NoCalcLength> for NonNegativeLengthPercentage { impl From<NoCalcLength> for NonNegativeLengthPercentage {
#[inline] #[inline]

View file

@ -16,7 +16,16 @@ use style_traits::{ParseError, StyleParseErrorKind};
/// Specified and computed `list-style-type` property. /// Specified and computed `list-style-type` property.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
#[derive( #[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, Clone,
Debug,
Eq,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] )]
pub enum ListStyleType { pub enum ListStyleType {
/// <counter-style> | none /// <counter-style> | none
@ -77,7 +86,15 @@ impl Parse for ListStyleType {
/// A quote pair. /// A quote pair.
#[derive( #[derive(
Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] )]
pub struct QuotePair { pub struct QuotePair {
/// The opening quote. /// The opening quote.
@ -89,7 +106,15 @@ pub struct QuotePair {
/// Specified and computed `quotes` property. /// Specified and computed `quotes` property.
#[derive( #[derive(
Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] )]
pub struct Quotes( pub struct Quotes(
#[css(iterable, if_empty = "none")] #[css(iterable, if_empty = "none")]

View file

@ -709,7 +709,15 @@ impl AllowQuirks {
/// ///
/// `[namespace? `|`]? ident` /// `[namespace? `|`]? ident`
#[derive( #[derive(
Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, Clone,
Debug,
Eq,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] )]
#[css(function)] #[css(function)]
pub struct Attr { pub struct Attr {

View file

@ -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 /// https://drafts.csswg.org/css-grid/#named-grid-area
pub struct TemplateAreas { pub struct TemplateAreas {
/// `named area` containing for each template area /// `named area` containing for each template area
@ -678,7 +688,15 @@ impl Parse for TemplateAreas {
/// Arc type for `Arc<TemplateAreas>` /// Arc type for `Arc<TemplateAreas>`
#[derive( #[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>); pub struct TemplateAreasArc(#[ignore_malloc_size_of = "Arc"] pub Arc<TemplateAreas>);

View file

@ -129,7 +129,15 @@ const PAINT_ORDER_MASK: u8 = 0b11;
/// Higher priority values, i.e. the values specified first, /// Higher priority values, i.e. the values specified first,
/// will be painted first (and may be covered by paintings of lower priority) /// will be painted first (and may be covered by paintings of lower priority)
#[derive( #[derive(
Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, Clone,
Copy,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] )]
pub struct SVGPaintOrder(pub u8); pub struct SVGPaintOrder(pub u8);
@ -238,7 +246,15 @@ impl ToCss for SVGPaintOrder {
/// Specified MozContextProperties value. /// Specified MozContextProperties value.
/// Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties) /// Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-context-properties)
#[derive( #[derive(
Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss, ToResolvedValue, ToShmem, Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)] )]
pub struct MozContextProperties(pub CustomIdent); pub struct MozContextProperties(pub CustomIdent);

View file

@ -512,9 +512,7 @@ impl TextEmphasisKeywordValue {
} }
/// Fill mode for the text-emphasis-style property /// Fill mode for the text-emphasis-style property
#[derive( #[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem,
)]
pub enum TextEmphasisFillMode { pub enum TextEmphasisFillMode {
/// `filled` /// `filled`
Filled, Filled,

View file

@ -57,7 +57,15 @@ impl Parse for CursorImage {
/// Specified value of `-moz-force-broken-image-icon` /// Specified value of `-moz-force-broken-image-icon`
#[derive( #[derive(
Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToResolvedValue, ToShmem, Clone,
Copy,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem,
)] )]
pub struct MozForceBrokenImageIcon(pub bool); pub struct MozForceBrokenImageIcon(pub bool);

View file

@ -10,20 +10,20 @@ use to_computed_value;
pub fn derive(input: DeriveInput) -> TokenStream { pub fn derive(input: DeriveInput) -> TokenStream {
let trait_impl = |from_body, to_body| { let trait_impl = |from_body, to_body| {
quote! { quote! {
#[inline] #[inline]
fn from_animated_value(animated: Self::AnimatedValue) -> Self { fn from_animated_value(animated: Self::AnimatedValue) -> Self {
match animated { match animated {
#from_body #from_body
} }
} }
#[inline] #[inline]
fn to_animated_value(self) -> Self::AnimatedValue { fn to_animated_value(self) -> Self::AnimatedValue {
match self { match self {
#to_body #to_body
} }
} }
} }
}; };
// TODO(emilio): Consider optimizing away non-generic cases as well? // TODO(emilio): Consider optimizing away non-generic cases as well?

View file

@ -55,10 +55,7 @@ pub fn derive_to_value(
let (to_body, from_body) = { let (to_body, from_body) = {
let params = input.generics.type_params().collect::<Vec<_>>(); let params = input.generics.type_params().collect::<Vec<_>>();
for param in &params { for param in &params {
cg::add_predicate( cg::add_predicate(&mut where_clause, parse_quote!(#param: #trait_path));
&mut where_clause,
parse_quote!(#param: #trait_path),
);
} }
let to_body = cg::fmap_match(&input, bind_style, |binding| { let to_body = cg::fmap_match(&input, bind_style, |binding| {
@ -80,20 +77,14 @@ pub fn derive_to_value(
} }
call_to(&binding) call_to(&binding)
}); });
let from_body = cg::fmap_match(&input, bind_style, |binding| { let from_body = cg::fmap_match(&input, bind_style, |binding| call_from(&binding));
call_from(&binding)
});
(to_body, from_body) (to_body, from_body)
}; };
input.generics.where_clause = where_clause; input.generics.where_clause = where_clause;
let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl(); let (impl_generics, ty_generics, where_clause) = input.generics.split_for_impl();
let computed_value_type = cg::fmap_trait_output( let computed_value_type = cg::fmap_trait_output(&input, &trait_path, &output_type_name);
&input,
&trait_path,
&output_type_name,
);
let impl_ = trait_impl(from_body, to_body); let impl_ = trait_impl(from_body, to_body);
@ -109,21 +100,21 @@ pub fn derive_to_value(
pub fn derive(input: DeriveInput) -> TokenStream { pub fn derive(input: DeriveInput) -> TokenStream {
let trait_impl = |from_body, to_body| { let trait_impl = |from_body, to_body| {
quote! { quote! {
#[inline] #[inline]
fn from_computed_value(computed: &Self::ComputedValue) -> Self { fn from_computed_value(computed: &Self::ComputedValue) -> Self {
match *computed { match *computed {
#from_body #from_body
} }
} }
#[allow(unused_variables)] #[allow(unused_variables)]
#[inline] #[inline]
fn to_computed_value(&self, context: &crate::values::computed::Context) -> Self::ComputedValue { fn to_computed_value(&self, context: &crate::values::computed::Context) -> Self::ComputedValue {
match *self { match *self {
#to_body #to_body
} }
} }
} }
}; };
let non_generic_implementation = || { let non_generic_implementation = || {

View file

@ -11,23 +11,23 @@ use to_computed_value;
pub fn derive(input: DeriveInput) -> TokenStream { pub fn derive(input: DeriveInput) -> TokenStream {
let trait_impl = |from_body, to_body| { let trait_impl = |from_body, to_body| {
quote! { quote! {
#[inline] #[inline]
fn from_resolved_value(resolved: Self::ResolvedValue) -> Self { fn from_resolved_value(resolved: Self::ResolvedValue) -> Self {
match resolved { match resolved {
#from_body #from_body
} }
} }
#[inline] #[inline]
fn to_resolved_value( fn to_resolved_value(
self, self,
context: &crate::values::resolved::Context, context: &crate::values::resolved::Context,
) -> Self::ResolvedValue { ) -> Self::ResolvedValue {
match self { match self {
#to_body #to_body
} }
} }
} }
}; };
let non_generic_implementation = || { let non_generic_implementation = || {

View file

@ -24,17 +24,17 @@ use smallvec::{Array, SmallVec};
use std::alloc::Layout; use std::alloc::Layout;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use std::any::TypeId; use std::any::TypeId;
use std::isize;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use std::collections::HashSet; use std::collections::HashSet;
use std::ffi::CString; use std::ffi::CString;
use std::isize;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem::{self, ManuallyDrop}; use std::mem::{self, ManuallyDrop};
use std::num::Wrapping; use std::num::Wrapping;
use std::ops::Range; use std::ops::Range;
use std::os::raw::c_char;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use std::os::raw::c_void; use std::os::raw::c_void;
use std::os::raw::c_char;
use std::ptr::{self, NonNull}; use std::ptr::{self, NonNull};
use std::slice; use std::slice;
use std::str; use std::str;
@ -166,7 +166,7 @@ impl SharedMemoryBuilder {
// Reserve space for the padding. // Reserve space for the padding.
let start = self.index.checked_add(padding).unwrap(); 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. // Reserve space for the value.
let end = start.checked_add(layout.size()).unwrap(); 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::RGBA);
impl_trivial_to_shmem!(cssparser::SourceLocation); impl_trivial_to_shmem!(cssparser::SourceLocation);
@ -424,7 +439,9 @@ impl<T: 'static + ToShmem> ToShmem for Arc<T> {
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
assert!( assert!(
!builder.shared_values.contains(&self.heap_ptr()) || !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 \ "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", 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 // Make a clone of the Arc-owned header and slice values with all of
// their heap allocations placed in the shared memory buffer. // their heap allocations placed in the shared memory buffer.
let header = self.header.header.to_shmem(builder); let header = self.header.header.to_shmem(builder);
let values: Vec<ManuallyDrop<T>> = self let values: Vec<ManuallyDrop<T>> = self.slice.iter().map(|v| v.to_shmem(builder)).collect();
.slice
.iter()
.map(|v| v.to_shmem(builder))
.collect();
// Create a new ThinArc with the shared value and have it place // Create a new ThinArc with the shared value and have it place
// its ArcInner in the shared memory buffer. // its ArcInner in the shared memory buffer.
@ -499,10 +512,11 @@ impl ToShmem for SmallBitVec {
let src = vs.as_ptr() as *const usize; let src = vs.as_ptr() as *const usize;
ptr::copy(src, dest, len); 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::Spilled(dest_slice)
} }
} },
InternalStorage::Inline(x) => InternalStorage::Inline(x), InternalStorage::Inline(x) => InternalStorage::Inline(x),
}; };
ManuallyDrop::new(unsafe { SmallBitVec::from_storage(storage) }) ManuallyDrop::new(unsafe { SmallBitVec::from_storage(storage) })

View file

@ -12,10 +12,7 @@ pub fn derive(mut input: syn::DeriveInput) -> TokenStream {
let attrs = cg::parse_input_attrs::<ShmemInputAttrs>(&input); let attrs = cg::parse_input_attrs::<ShmemInputAttrs>(&input);
if !attrs.no_bounds { if !attrs.no_bounds {
for param in input.generics.type_params() { for param in input.generics.type_params() {
cg::add_predicate( cg::add_predicate(&mut where_clause, parse_quote!(#param: ::to_shmem::ToShmem));
&mut where_clause,
parse_quote!(#param: ::to_shmem::ToShmem),
);
} }
} }
for variant in Structure::new(&input).variants() { 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()); let attrs = cg::parse_field_attrs::<ShmemFieldAttrs>(&binding.ast());
if attrs.field_bound { if attrs.field_bound {
let ty = &binding.ast().ty; let ty = &binding.ast().ty;
cg::add_predicate( cg::add_predicate(&mut where_clause, parse_quote!(#ty: ::to_shmem::ToShmem))
&mut where_clause,
parse_quote!(#ty: ::to_shmem::ToShmem),
)
} }
} }
} }