Run rustfmt on selectors, servo_arc, and style.

This was generated with:

./mach cargo fmt --package selectors &&
./mach cargo fmt --package servo_arc &&
./mach cargo fmt --package style

Using rustfmt 0.4.1-nightly (a4462d1 2018-03-26)
This commit is contained in:
Bobby Holley 2018-04-10 17:35:15 -07:00
parent f7ae1a37e3
commit c99bcdd4b8
181 changed files with 9981 additions and 7933 deletions

View file

@ -5,7 +5,7 @@
//! Gecko-specific bits for selector-parsing.
use cssparser::{BasicParseError, BasicParseErrorKind, Parser};
use cssparser::{ToCss, Token, CowRcStr, SourceLocation};
use cssparser::{CowRcStr, SourceLocation, ToCss, Token};
use element_state::{DocumentState, ElementState};
use gecko_bindings::structs;
use gecko_bindings::structs::RawServoSelectorList;
@ -13,7 +13,7 @@ use gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI};
use invalidation::element::document_state::InvalidationMatchingData;
use selector_parser::{Direction, SelectorParser};
use selectors::SelectorList;
use selectors::parser::{self as selector_parser, Selector, Visit, SelectorParseErrorKind};
use selectors::parser::{self as selector_parser, Selector, SelectorParseErrorKind, Visit};
use selectors::visitor::SelectorVisitor;
use std::fmt;
use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace};
@ -65,7 +65,10 @@ macro_rules! pseudo_class_name {
apply_non_ts_list!(pseudo_class_name);
impl ToCss for NonTSPseudoClass {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
where
W: fmt::Write,
{
use cssparser::CssStringWriter;
use std::fmt::Write;
macro_rules! pseudo_class_serialize {
@ -133,7 +136,6 @@ impl Visit for NonTSPseudoClass {
}
}
impl NonTSPseudoClass {
/// Parses the name and returns a non-ts-pseudo-class if succeeds.
/// None otherwise. It doesn't check whether the pseudo-class is enabled
@ -154,8 +156,12 @@ impl NonTSPseudoClass {
/// Returns true if this pseudo-class has any of the given flags set.
fn has_any_flag(&self, flags: NonTSPseudoClassFlag) -> bool {
macro_rules! check_flag {
(_) => (false);
($flags:ident) => (NonTSPseudoClassFlag::$flags.intersects(flags));
(_) => {
false
};
($flags:ident) => {
NonTSPseudoClassFlag::$flags.intersects(flags)
};
}
macro_rules! pseudo_class_check_is_enabled_in {
(bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*],
@ -178,11 +184,14 @@ impl NonTSPseudoClass {
match *self {
// For pseudo-classes with pref, the availability in content
// depends on the pref.
NonTSPseudoClass::Fullscreen =>
unsafe { mozilla::StaticPrefs_sVarCache_full_screen_api_unprefix_enabled },
NonTSPseudoClass::Fullscreen => unsafe {
mozilla::StaticPrefs_sVarCache_full_screen_api_unprefix_enabled
},
// Otherwise, a pseudo-class is enabled in content when it
// doesn't have any enabled flag.
_ => !self.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
_ => !self.has_any_flag(
NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME,
),
}
}
@ -190,16 +199,21 @@ impl NonTSPseudoClass {
///
/// We intentionally skip the link-related ones.
pub fn is_safe_user_action_state(&self) -> bool {
matches!(*self, NonTSPseudoClass::Hover |
NonTSPseudoClass::Active |
NonTSPseudoClass::Focus)
matches!(
*self,
NonTSPseudoClass::Hover | NonTSPseudoClass::Active | NonTSPseudoClass::Focus
)
}
/// Get the state flag associated with a pseudo-class, if any.
pub fn state_flag(&self) -> ElementState {
macro_rules! flag {
(_) => (ElementState::empty());
($state:ident) => (ElementState::$state);
(_) => {
ElementState::empty()
};
($state:ident) => {
ElementState::$state
};
}
macro_rules! pseudo_class_state {
(bare: [$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*],
@ -229,7 +243,7 @@ impl NonTSPseudoClass {
/// revalidation.
pub fn needs_cache_revalidation(&self) -> bool {
self.state_flag().is_empty() &&
!matches!(*self,
!matches!(*self,
// :-moz-any is handled by the revalidation visitor walking
// the things inside it; it does not need to cause
// revalidation on its own.
@ -261,10 +275,11 @@ impl NonTSPseudoClass {
/// Returns true if the evaluation of the pseudo-class depends on the
/// element's attributes.
pub fn is_attr_based(&self) -> bool {
matches!(*self,
NonTSPseudoClass::MozTableBorderNonzero |
NonTSPseudoClass::MozBrowserFrame |
NonTSPseudoClass::Lang(..))
matches!(
*self,
NonTSPseudoClass::MozTableBorderNonzero | NonTSPseudoClass::MozBrowserFrame |
NonTSPseudoClass::Lang(..)
)
}
}
@ -297,22 +312,19 @@ impl ::selectors::SelectorImpl for SelectorImpl {
}
impl<'a> SelectorParser<'a> {
fn is_pseudo_class_enabled(
&self,
pseudo_class: &NonTSPseudoClass,
) -> bool {
fn is_pseudo_class_enabled(&self, pseudo_class: &NonTSPseudoClass) -> bool {
if pseudo_class.is_enabled_in_content() {
return true;
}
if self.in_user_agent_stylesheet() &&
pseudo_class.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS)
pseudo_class.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_UA_SHEETS)
{
return true;
}
if self.chrome_rules_enabled() &&
pseudo_class.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_CHROME)
pseudo_class.has_any_flag(NonTSPseudoClassFlag::PSEUDO_CLASS_ENABLED_IN_CHROME)
{
return true;
}
@ -320,10 +332,7 @@ impl<'a> SelectorParser<'a> {
return false;
}
fn is_pseudo_element_enabled(
&self,
pseudo_element: &PseudoElement,
) -> bool {
fn is_pseudo_element_enabled(&self, pseudo_element: &PseudoElement) -> bool {
if pseudo_element.enabled_in_content() {
return true;
}
@ -359,8 +368,7 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
fn pseudo_element_allows_single_colon(name: &str) -> bool {
// FIXME: -moz-tree check should probably be ascii-case-insensitive.
::selectors::parser::is_css2_pseudo_element(name) ||
name.starts_with("-moz-tree-")
::selectors::parser::is_css2_pseudo_element(name) || name.starts_with("-moz-tree-")
}
fn parse_non_ts_pseudo_class(
@ -373,7 +381,11 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
return Ok(pseudo_class);
}
}
Err(location.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)))
Err(
location.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(
name,
)),
)
}
fn parse_non_ts_functional_pseudo_class<'t>(
@ -420,7 +432,11 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
if self.is_pseudo_class_enabled(&pseudo_class) {
Ok(pseudo_class)
} else {
Err(parser.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)))
Err(
parser.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(
name,
)),
)
}
}
@ -435,9 +451,11 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
}
}
Err(location.new_custom_error(
SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)
))
Err(
location.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(
name,
)),
)
}
fn parse_functional_pseudo_element<'t>(
@ -456,7 +474,10 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
Ok(&Token::Ident(ref ident)) => args.push(Atom::from(ident.as_ref())),
Ok(&Token::Comma) => {},
Ok(t) => return Err(location.new_unexpected_token_error(t.clone())),
Err(BasicParseError { kind: BasicParseErrorKind::EndOfInput, .. }) => break,
Err(BasicParseError {
kind: BasicParseErrorKind::EndOfInput,
..
}) => break,
_ => unreachable!("Parser::next() shouldn't return any other error"),
}
}
@ -465,9 +486,11 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
return Ok(pseudo);
}
}
Err(parser.new_custom_error(
SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)
))
Err(
parser.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(
name,
)),
)
}
fn default_namespace(&self) -> Option<Namespace> {
@ -484,7 +507,8 @@ impl SelectorImpl {
/// `fun` on it.
#[inline]
pub fn each_eagerly_cascaded_pseudo_element<F>(mut fun: F)
where F: FnMut(PseudoElement),
where
F: FnMut(PseudoElement),
{
for pseudo in &EAGER_PSEUDOS {
fun(pseudo.clone())