Skip to content
Permalink
Browse files

style: Rustfmt recent changes.

  • Loading branch information...
emilio committed May 5, 2019
1 parent deba73a commit 57874ae90a69c7e0af6e604d570674256afbecf7
@@ -270,8 +270,7 @@ where
Component::Combinator(..) => {
unreachable!("Found combinator in simple selectors vector?");
},
Component::Part(..) |
Component::PseudoElement(..) | Component::LocalName(..) => {
Component::Part(..) | Component::PseudoElement(..) | Component::LocalName(..) => {
specificity.element_selectors += 1
},
Component::Slotted(ref selector) => {
@@ -30,10 +30,14 @@ pub trait PseudoElement: Sized + ToCss {

/// Whether the pseudo-element supports a given state selector to the right
/// of it.
fn accepts_state_pseudo_classes(&self) -> bool { false }
fn accepts_state_pseudo_classes(&self) -> bool {
false
}

/// Whether this pseudo-element is valid after a ::slotted(..) pseudo.
fn valid_after_slotted(&self) -> bool { false }
fn valid_after_slotted(&self) -> bool {
false
}
}

/// A trait that represents a pseudo-class.
@@ -116,7 +120,10 @@ impl SelectorParsingState {

#[inline]
fn allows_non_functional_pseudo_classes(self) -> bool {
!self.intersects(SelectorParsingState::AFTER_SLOTTED | SelectorParsingState::AFTER_NON_STATEFUL_PSEUDO_ELEMENT)
!self.intersects(
SelectorParsingState::AFTER_SLOTTED |
SelectorParsingState::AFTER_NON_STATEFUL_PSEUDO_ELEMENT,
)
}

#[inline]
@@ -1221,9 +1228,7 @@ impl ToCss for Combinator {
Combinator::Descendant => dest.write_str(" "),
Combinator::NextSibling => dest.write_str(" + "),
Combinator::LaterSibling => dest.write_str(" ~ "),
Combinator::PseudoElement |
Combinator::Part |
Combinator::SlotAssignment => Ok(()),
Combinator::PseudoElement | Combinator::Part | Combinator::SlotAssignment => Ok(()),
}
}
}
@@ -1979,11 +1984,10 @@ where

let mut state = SelectorParsingState::empty();
loop {
let parse_result =
match parse_one_simple_selector(parser, input, state)? {
None => break,
Some(result) => result,
};
let parse_result = match parse_one_simple_selector(parser, input, state)? {
None => break,
Some(result) => result,
};

empty = false;

@@ -2034,9 +2038,7 @@ where
Impl: SelectorImpl,
{
if !state.allows_functional_pseudo_classes() {
return Err(input.new_custom_error(
SelectorParseErrorKind::InvalidState
));
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
}
debug_assert!(state.allows_tree_structural_pseudo_classes());
match_ignore_ascii_case! { &name,
@@ -2102,7 +2104,7 @@ where
Err(..) => {
input.reset(&start);
return Ok(None);
}
},
};

Ok(Some(match token {
@@ -2122,7 +2124,7 @@ where
Token::Ident(ref class) => class,
ref t => {
let e = SelectorParseErrorKind::ClassNeedsIdent(t.clone());
return Err(location.new_custom_error(e))
return Err(location.new_custom_error(e));
},
};
let class = Component::Class(class.as_ref().into());
@@ -2149,16 +2151,17 @@ where
return Err(input.new_custom_error(e));
},
};
let is_pseudo_element =
!is_single_colon || is_css2_pseudo_element(&name);
let is_pseudo_element = !is_single_colon || is_css2_pseudo_element(&name);
if is_pseudo_element {
if state.intersects(SelectorParsingState::AFTER_PSEUDO_ELEMENT) {
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
}
let pseudo_element = if is_functional {
if P::parse_part(parser) && name.eq_ignore_ascii_case("part") {
if !state.allows_part() {
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
return Err(
input.new_custom_error(SelectorParseErrorKind::InvalidState)
);
}
let name = input.parse_nested_block(|input| {
Ok(input.expect_ident()?.as_ref().into())
@@ -2167,7 +2170,9 @@ where
}
if P::parse_slotted(parser) && name.eq_ignore_ascii_case("slotted") {
if !state.allows_slotted() {
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
return Err(
input.new_custom_error(SelectorParseErrorKind::InvalidState)
);
}
let selector = input.parse_nested_block(|input| {
parse_inner_compound_selector(parser, input)
@@ -2181,7 +2186,9 @@ where
P::parse_pseudo_element(parser, location, name)?
};

if state.intersects(SelectorParsingState::AFTER_SLOTTED) && !pseudo_element.valid_after_slotted() {
if state.intersects(SelectorParsingState::AFTER_SLOTTED) &&
!pseudo_element.valid_after_slotted()
{
return Err(input.new_custom_error(SelectorParseErrorKind::InvalidState));
}
SimpleSelectorParseResult::PseudoElement(pseudo_element)
@@ -2198,7 +2205,7 @@ where
},
_ => {
input.reset(&start);
return Ok(None)
return Ok(None);
},
}))
}
@@ -2234,7 +2241,9 @@ where
}

let pseudo_class = P::parse_non_ts_pseudo_class(parser, location, name)?;
if state.intersects(SelectorParsingState::AFTER_PSEUDO_ELEMENT) && !pseudo_class.is_user_action_state() {
if state.intersects(SelectorParsingState::AFTER_PSEUDO_ELEMENT) &&
!pseudo_class.is_user_action_state()
{
return Err(location.new_custom_error(SelectorParseErrorKind::InvalidState));
}
Ok(Component::NonTSPseudoClass(pseudo_class))
@@ -2266,9 +2275,13 @@ pub mod tests {
impl parser::PseudoElement for PseudoElement {
type Impl = DummySelectorImpl;

fn accepts_state_pseudo_classes(&self) -> bool { true }
fn accepts_state_pseudo_classes(&self) -> bool {
true
}

fn valid_after_slotted(&self) -> bool { true }
fn valid_after_slotted(&self) -> bool {
true
}
}

impl parser::NonTSPseudoClass for PseudoClass {
@@ -110,10 +110,7 @@ pub trait Element: Sized + Clone + Debug {
case_sensitivity: CaseSensitivity,
) -> bool;

fn is_part(
&self,
name: &<Self::Impl as SelectorImpl>::PartName,
) -> bool;
fn is_part(&self, name: &<Self::Impl as SelectorImpl>::PartName) -> bool;

/// Returns whether this element matches `:empty`.
///
@@ -49,8 +49,8 @@ use selectors::NthIndexCache;
use servo_arc::{Arc, ArcBorrow};
use smallbitvec::SmallBitVec;
use smallvec::SmallVec;
use std::{mem, ops};
use std::sync::Mutex;
use std::{mem, ops};
use style_traits::viewport::ViewportConstraints;

/// The type of the stylesheets that the stylist contains.
@@ -271,12 +271,8 @@ impl DocumentCascadeData {
let origin_sheets = flusher.origin_sheets(Origin::UserAgent);
let _unused_cascade_datas = {
let mut ua_cache = UA_CASCADE_DATA_CACHE.lock().unwrap();
self.user_agent = ua_cache.lookup(
origin_sheets,
device,
quirks_mode,
guards.ua_or_user,
)?;
self.user_agent =
ua_cache.lookup(origin_sheets, device, quirks_mode, guards.ua_or_user)?;
debug!("User agent data cache size {:?}", ua_cache.len());
ua_cache.take_unused()
};
@@ -86,8 +86,8 @@ pub use self::transform::{TransformOrigin, TransformStyle, Translate};
#[cfg(feature = "gecko")]
pub use self::ui::CursorImage;
pub use self::ui::{Cursor, MozForceBrokenImageIcon, UserSelect};
pub use super::specified::{BorderStyle, TextDecorationLine};
pub use super::specified::TextTransform;
pub use super::specified::{BorderStyle, TextDecorationLine};
pub use super::{Auto, Either, None_};
pub use app_units::Au;

@@ -19,9 +19,9 @@ use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};

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

/// A computed value for the `initial-letter` property.
pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
@@ -280,7 +280,9 @@ impl Parse for VerticalAlign {
return Ok(GenericVerticalAlign::Length(lp));
}

Ok(GenericVerticalAlign::Keyword(VerticalAlignKeyword::parse(input)?))
Ok(GenericVerticalAlign::Keyword(VerticalAlignKeyword::parse(
input,
)?))
}
}

@@ -510,13 +510,16 @@ impl Gradient {
items.sort_by(|a, b| {
match (a, b) {
(
&generic::GradientItem::ComplexColorStop { position: ref a_position, .. },
&generic::GradientItem::ComplexColorStop { position: ref b_position, .. },
&generic::GradientItem::ComplexColorStop {
position: ref a_position,
..
},
&generic::GradientItem::ComplexColorStop {
position: ref b_position,
..
},
) => match (a_position, b_position) {
(
&LengthPercentage::Percentage(a),
&LengthPercentage::Percentage(b),
) => {
(&LengthPercentage::Percentage(a), &LengthPercentage::Percentage(b)) => {
return a.0.partial_cmp(&b.0).unwrap_or(Ordering::Equal);
},
_ => {},
@@ -786,7 +789,7 @@ impl LineDirection {
#[cfg(feature = "gecko")]
{
// `-moz-` prefixed linear gradient can be both Angle and Position.
if *compat_mode == CompatMode::Moz && !simple_moz_gradient(){
if *compat_mode == CompatMode::Moz && !simple_moz_gradient() {
let position = i.try(|i| LegacyPosition::parse(context, i)).ok();
if _angle.is_none() {
_angle = i.try(|i| Angle::parse(context, i)).ok();
@@ -961,10 +964,13 @@ impl GradientItem {
if let Ok(multi_position) = input.try(|i| LengthPercentage::parse(context, i)) {
let stop_color = stop.color.clone();
items.push(stop.into_item());
items.push(ColorStop {
color: stop_color,
position: Some(multi_position),
}.into_item());
items.push(
ColorStop {
color: stop_color,
position: Some(multi_position),
}
.into_item(),
);
} else {
items.push(stop.into_item());
}
@@ -80,10 +80,10 @@ pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind};
pub use self::svg::{SVGPaintOrder, SVGStrokeDashArray, SVGWidth};
pub use self::svg_path::SVGPathData;
pub use self::table::XSpan;
pub use self::text::TextTransform;
pub use self::text::{InitialLetter, LetterSpacing, LineHeight, TextAlign};
pub use self::text::{OverflowWrap, TextEmphasisPosition, TextEmphasisStyle, WordBreak};
pub use self::text::{TextAlignKeyword, TextDecorationLine, TextOverflow, WordSpacing};
pub use self::text::TextTransform;
pub use self::time::Time;
pub use self::transform::{Rotate, Scale, Transform};
pub use self::transform::{TransformOrigin, TransformStyle, Translate};
@@ -361,7 +361,8 @@ impl TextDecorationLine {
SpecifiedValueInfo,
ToComputedValue,
ToResolvedValue,
ToShmem)]
ToShmem,
)]
#[repr(C)]
/// Specified value of the text-transform property, stored in two parts:
/// the case-related transforms (mutually exclusive, only one may be in effect), and others (non-exclusive).
@@ -468,7 +469,8 @@ impl ToCss for TextTransform {
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem)]
ToShmem,
)]
#[repr(C)]
/// Specified keyword values for case transforms in the text-transform property. (These are exclusive.)
pub enum TextTransformCase {
@@ -563,7 +565,9 @@ pub enum TextAlignKeyword {
}

/// Specified value of text-align property.
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
#[derive(
Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, ToCss, ToShmem,
)]
pub enum TextAlign {
/// Keyword value of text-align property.
Keyword(TextAlignKeyword),

0 comments on commit 57874ae

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