Skip to content
Permalink
Browse files

style: Reformat recent changes.

  • Loading branch information...
emilio committed Apr 11, 2019
1 parent 7c4f9bb commit 8c004c08580287172585169807ed36933ad674f8
Showing with 572 additions and 213 deletions.
  1. +10 −3 components/selectors/parser.rs
  2. +7 −3 components/style/error_reporting.rs
  3. +5 −1 components/style/font_metrics.rs
  4. +3 −3 components/style/gecko/wrapper.rs
  5. +5 −1 components/style/gecko_string_cache/mod.rs
  6. +1 −1 components/style/stylesheets/rule_parser.rs
  7. +12 −1 components/style/values/computed/angle.rs
  8. +3 −1 components/style/values/computed/box.rs
  9. +32 −18 components/style/values/computed/font.rs
  10. +3 −3 components/style/values/computed/length.rs
  11. +3 −1 components/style/values/computed/mod.rs
  12. +10 −2 components/style/values/generics/border.rs
  13. +1 −1 components/style/values/generics/color.rs
  14. +9 −1 components/style/values/generics/counters.rs
  15. +13 −2 components/style/values/generics/grid.rs
  16. +35 −7 components/style/values/generics/image.rs
  17. +11 −1 components/style/values/generics/mod.rs
  18. +5 −6 components/style/values/generics/text.rs
  19. +18 −2 components/style/values/generics/transform.rs
  20. +20 −2 components/style/values/generics/ui.rs
  21. +22 −3 components/style/values/mod.rs
  22. +4 −2 components/style/values/resolved/mod.rs
  23. +84 −7 components/style/values/specified/align.rs
  24. +10 −1 components/style/values/specified/background.rs
  25. +9 −1 components/style/values/specified/border.rs
  26. +32 −38 components/style/values/specified/box.rs
  27. +3 −1 components/style/values/specified/color.rs
  28. +39 −9 components/style/values/specified/font.rs
  29. +3 −3 components/style/values/specified/length.rs
  30. +28 −3 components/style/values/specified/list.rs
  31. +9 −1 components/style/values/specified/mod.rs
  32. +20 −2 components/style/values/specified/position.rs
  33. +18 −2 components/style/values/specified/svg.rs
  34. +1 −3 components/style/values/specified/text.rs
  35. +9 −1 components/style/values/specified/ui.rs
  36. +13 −13 components/style_derive/to_animated_value.rs
  37. +18 −27 components/style_derive/to_computed_value.rs
  38. +16 −16 components/style_derive/to_resolved_value.rs
  39. +26 −12 components/to_shmem/lib.rs
  40. +2 −8 components/to_shmem_derive/to_shmem.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>),
@@ -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.
@@ -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
@@ -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"
),
})
}
}
@@ -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))
}
@@ -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;
@@ -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 {
@@ -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.
@@ -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);

@@ -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>;
@@ -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),
@@ -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`.
@@ -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;
@@ -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.
@@ -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`)
Oops, something went wrong.

0 comments on commit 8c004c0

Please sign in to comment.
You can’t perform that action at this time.