Skip to content

Commit

Permalink
style: Reformat recent changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Mar 13, 2019
1 parent 9a8cee2 commit 5aeab7a
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 53 deletions.
6 changes: 1 addition & 5 deletions components/style/custom_properties.rs
Expand Up @@ -515,11 +515,7 @@ impl<'a> CustomPropertiesBuilder<'a> {
}

/// Cascade a given custom property declaration.
pub fn cascade(
&mut self,
declaration: &'a CustomDeclaration,
origin: Origin,
) {
pub fn cascade(&mut self, declaration: &'a CustomDeclaration, origin: Origin) {
let CustomDeclaration {
ref name,
ref value,
Expand Down
17 changes: 9 additions & 8 deletions components/style/gecko/media_queries.rs
Expand Up @@ -116,10 +116,7 @@ impl Device {
};

unsafe {
bindings::Gecko_AnimationNameMayBeReferencedFromStyle(
pc,
name.as_atom().as_ptr(),
)
bindings::Gecko_AnimationNameMayBeReferencedFromStyle(pc, name.as_atom().as_ptr())
}
}

Expand Down Expand Up @@ -169,7 +166,12 @@ impl Device {
#[inline]
pub fn pres_context(&self) -> Option<&structs::nsPresContext> {
unsafe {
self.document().mPresShell.as_ref()?.mPresContext.mRawPtr.as_ref()
self.document()
.mPresShell
.as_ref()?
.mPresContext
.mRawPtr
.as_ref()
}
}

Expand Down Expand Up @@ -268,9 +270,8 @@ impl Device {
if doc.mIsBeingUsedAsImage() {
return true;
}
let document_color_use = unsafe {
structs::StaticPrefs_sVarCache_browser_display_document_color_use
};
let document_color_use =
unsafe { structs::StaticPrefs_sVarCache_browser_display_document_color_use };
let prefs = self.pref_sheet_prefs();
match document_color_use {
1 => true,
Expand Down
3 changes: 1 addition & 2 deletions components/style/gecko/wrapper.rs
Expand Up @@ -1246,8 +1246,7 @@ impl<'le> TElement for GeckoElement<'le> {
}

fn owner_doc_matches_for_testing(&self, device: &Device) -> bool {
self.as_node().owner_doc().0 as *const structs::Document ==
device.document() as *const _
self.as_node().owner_doc().0 as *const structs::Document == device.document() as *const _
}

fn style_attribute(&self) -> Option<ArcBorrow<Locked<PropertyDeclarationBlock>>> {
Expand Down
2 changes: 1 addition & 1 deletion components/style/gecko_bindings/sugar/ns_style_coord.rs
Expand Up @@ -5,8 +5,8 @@
//! Rust helpers for Gecko's `nsStyleCoord`.

use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs::{nsStyleCoord, nsStyleCoord_Calc, nsStyleCoord_CalcValue};
use crate::gecko_bindings::structs::nsStyleSides;
use crate::gecko_bindings::structs::{nsStyleCoord, nsStyleCoord_Calc, nsStyleCoord_CalcValue};
use crate::gecko_bindings::structs::{nsStyleUnion, nsStyleUnit, nscoord};
use std::mem;

Expand Down
8 changes: 3 additions & 5 deletions components/style/rule_tree/mod.rs
Expand Up @@ -11,7 +11,7 @@ use crate::applicable_declarations::ApplicableDeclarationList;
use crate::gecko::selector_parser::PseudoElement;
use crate::properties::{Importance, LonghandIdSet, PropertyDeclarationBlock};
use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
use crate::stylesheets::{StyleRule, Origin};
use crate::stylesheets::{Origin, StyleRule};
use crate::thread_state;
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
Expand Down Expand Up @@ -663,10 +663,8 @@ impl CascadeLevel {
#[inline]
pub fn origin(&self) -> Origin {
match *self {
CascadeLevel::UAImportant |
CascadeLevel::UANormal => Origin::UserAgent,
CascadeLevel::UserImportant |
CascadeLevel::UserNormal => Origin::User,
CascadeLevel::UAImportant | CascadeLevel::UANormal => Origin::UserAgent,
CascadeLevel::UserImportant | CascadeLevel::UserNormal => Origin::User,
CascadeLevel::PresHints |
CascadeLevel::InnerShadowNormal |
CascadeLevel::SameTreeAuthorNormal |
Expand Down
6 changes: 5 additions & 1 deletion components/style/stylesheets/origin.rs
Expand Up @@ -76,7 +76,11 @@ impl OriginSet {
/// See the `OriginSet` documentation for information about the order
/// origins are iterated.
pub fn iter(&self) -> OriginSetIterator {
OriginSetIterator { set: *self, cur: 0, rev: false }
OriginSetIterator {
set: *self,
cur: 0,
rev: false,
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/style/values/animated/svg.rs
Expand Up @@ -8,7 +8,7 @@ use super::{Animate, Procedure, ToAnimatedZero};
use crate::properties::animated_properties::ListAnimation;
use crate::values::animated::color::Color as AnimatedColor;
use crate::values::computed::url::ComputedUrl;
use crate::values::distance::{SquaredDistance, ComputeSquaredDistance};
use crate::values::distance::{ComputeSquaredDistance, SquaredDistance};
use crate::values::generics::svg::{SVGPaint, SVGStrokeDashArray};

/// Animated SVGPaint.
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/computed/mod.rs
Expand Up @@ -76,7 +76,7 @@ pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind};
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
pub use self::table::XSpan;
pub use self::text::{InitialLetter, LetterSpacing, LineHeight};
pub use self::text::{OverflowWrap, TextOverflow, WordSpacing, WordBreak};
pub use self::text::{OverflowWrap, TextOverflow, WordBreak, WordSpacing};
pub use self::text::{TextAlign, TextEmphasisPosition, TextEmphasisStyle};
pub use self::time::Time;
pub use self::transform::{Rotate, Scale, Transform, TransformOperation};
Expand Down
4 changes: 1 addition & 3 deletions components/style/values/computed/svg.rs
Expand Up @@ -57,9 +57,7 @@ impl SVGWidth {
/// `1px`.
pub fn one() -> Self {
use crate::values::generics::NonNegative;
generic::SVGLength::LengthPercentage(
NonNegative(LengthPercentage::one()),
)
generic::SVGLength::LengthPercentage(NonNegative(LengthPercentage::one()))
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/style/values/computed/text.rs
Expand Up @@ -18,9 +18,9 @@ use crate::Zero;
use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};

pub use crate::values::specified::{OverflowWrap, WordBreak};
pub use crate::values::specified::TextAlignKeyword as TextAlign;
pub use crate::values::specified::TextEmphasisPosition;
pub use crate::values::specified::{OverflowWrap, WordBreak};

/// A computed value for the `initial-letter` property.
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
Expand Down
4 changes: 1 addition & 3 deletions components/style/values/computed/transform.rs
Expand Up @@ -592,9 +592,7 @@ impl Translate {
/// Convert Translate to TransformOperation.
pub fn from_transform_operation(operation: &TransformOperation) -> Translate {
match *operation {
generic::TransformOperation::Translate(tx, ty) => {
generic::Translate::Translate(tx, ty)
},
generic::TransformOperation::Translate(tx, ty) => generic::Translate::Translate(tx, ty),
generic::TransformOperation::Translate3D(tx, ty, tz) => {
generic::Translate::Translate3D(tx, ty, tz)
},
Expand Down
14 changes: 13 additions & 1 deletion components/style/values/generics/mod.rs
Expand Up @@ -215,7 +215,19 @@ pub struct GreaterThanOrEqualToOne<T>(pub T);

/// A clip rect for clip and image-region
#[allow(missing_docs)]
#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
#[derive(
Clone,
ComputeSquaredDistance,
Copy,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToCss,
)]
#[css(function = "rect", comma)]
pub struct ClipRect<LengthOrAuto> {
pub top: LengthOrAuto,
Expand Down
4 changes: 1 addition & 3 deletions components/style/values/generics/text.rs
Expand Up @@ -29,9 +29,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,
)]
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)]
pub enum Spacing<Value> {
/// `normal`
Normal,
Expand Down
19 changes: 16 additions & 3 deletions components/style/values/generics/transform.rs
Expand Up @@ -137,7 +137,10 @@ where
SkewY(Angle),
/// translate(x, y) or translate(x)
#[css(comma, function)]
Translate(LengthPercentage, #[css(skip_if = "Zero::is_zero")] LengthPercentage),
Translate(
LengthPercentage,
#[css(skip_if = "Zero::is_zero")] LengthPercentage,
),
/// translateX(x)
#[css(function = "translateX")]
TranslateX(LengthPercentage),
Expand Down Expand Up @@ -637,7 +640,14 @@ impl<Number: ToCss + PartialEq> ToCss for Scale<Number> {
}

#[derive(
Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToAnimatedZero, ToComputedValue, ToCss
Clone,
Debug,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToAnimatedZero,
ToComputedValue,
ToCss,
)]
/// A value of the `translate` property
///
Expand All @@ -660,7 +670,10 @@ where
/// 'none'
None,
/// '<length-percentage>' or '<length-percentage> <length-percentage>'
Translate(LengthPercentage, #[css(skip_if = "Zero::is_zero")] LengthPercentage),
Translate(
LengthPercentage,
#[css(skip_if = "Zero::is_zero")] LengthPercentage,
),
/// '<length-percentage> <length-percentage> <length>'
Translate3D(LengthPercentage, LengthPercentage, Length),
}
Expand Down
7 changes: 6 additions & 1 deletion components/style/values/specified/mod.rs
Expand Up @@ -652,7 +652,12 @@ impl ClipRect {
left = parse_argument(context, input, allow_quirks)?;
}

Ok(ClipRect { top, right, bottom, left })
Ok(ClipRect {
top,
right,
bottom,
left,
})
})
}
}
Expand Down
17 changes: 6 additions & 11 deletions components/style/values/specified/svg.rs
Expand Up @@ -6,9 +6,9 @@

use crate::parser::{Parse, ParserContext};
use crate::values::generics::svg as generic;
use crate::values::specified::AllowQuirks;
use crate::values::specified::color::Color;
use crate::values::specified::url::SpecifiedUrl;
use crate::values::specified::AllowQuirks;
use crate::values::specified::LengthPercentage;
use crate::values::specified::{NonNegativeLengthPercentage, Opacity};
use crate::values::CustomIdent;
Expand Down Expand Up @@ -52,10 +52,9 @@ macro_rules! parse_svg_length {
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParseError<'i>> {
if let Ok(lp) = input.try(|i| {
<$lp>::parse_quirky(context, i, AllowQuirks::Always)
}) {
return Ok(generic::SVGLength::LengthPercentage(lp))
if let Ok(lp) = input.try(|i| <$lp>::parse_quirky(context, i, AllowQuirks::Always))
{
return Ok(generic::SVGLength::LengthPercentage(lp));
}

try_match_ident_ignore_ascii_case! { input,
Expand All @@ -65,7 +64,7 @@ macro_rules! parse_svg_length {
}
}
}
}
};
}

parse_svg_length!(SVGLength, LengthPercentage);
Expand All @@ -78,11 +77,7 @@ impl Parse for SVGStrokeDashArray {
) -> Result<Self, ParseError<'i>> {
if let Ok(values) = input.try(|i| {
CommaWithSpace::parse(i, |i| {
NonNegativeLengthPercentage::parse_quirky(
context,
i,
AllowQuirks::Always,
)
NonNegativeLengthPercentage::parse_quirky(context, i, AllowQuirks::Always)
})
}) {
return Ok(generic::SVGStrokeDashArray::Values(values));
Expand Down
6 changes: 3 additions & 3 deletions components/style_derive/cg.rs
Expand Up @@ -70,9 +70,9 @@ pub fn propagate_clauses_to_output_type(
for bound in extra_bounds {
let ty = bound.bounded_ty;
let bounds = bound.bounds;
where_clause.predicates.push(
parse_quote!(<#ty as #trait_path>::#trait_output: #bounds),
)
where_clause
.predicates
.push(parse_quote!(<#ty as #trait_path>::#trait_output: #bounds))
}
}

Expand Down

0 comments on commit 5aeab7a

Please sign in to comment.