Skip to content

Commit

Permalink
style: Rustfmt recent changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Jun 4, 2020
1 parent 69c7077 commit 762abba
Show file tree
Hide file tree
Showing 19 changed files with 163 additions and 101 deletions.
54 changes: 32 additions & 22 deletions components/selectors/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ impl SelectorParsingState {

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

#[inline]
Expand Down Expand Up @@ -354,10 +352,9 @@ impl<Impl: SelectorImpl> SelectorList<Impl> {
{
let mut values = SmallVec::new();
loop {
values.push(
input
.parse_until_before(Delimiter::Comma, |input| parse_selector(parser, input, state))?,
);
values.push(input.parse_until_before(Delimiter::Comma, |input| {
parse_selector(parser, input, state)
})?);
match input.next() {
Err(_) => return Ok(SelectorList(values)),
Ok(&Token::Comma) => continue,
Expand All @@ -382,7 +379,11 @@ where
P: Parser<'i, Impl = Impl>,
Impl: SelectorImpl,
{
parse_selector(parser, input, state | SelectorParsingState::DISALLOW_PSEUDOS | SelectorParsingState::DISALLOW_COMBINATORS)
parse_selector(
parser,
input,
state | SelectorParsingState::DISALLOW_PSEUDOS | SelectorParsingState::DISALLOW_COMBINATORS,
)
}

/// Parse a comma separated list of compound selectors.
Expand All @@ -395,7 +396,9 @@ where
Impl: SelectorImpl,
{
input
.parse_comma_separated(|input| parse_inner_compound_selector(parser, input, SelectorParsingState::empty()))
.parse_comma_separated(|input| {
parse_inner_compound_selector(parser, input, SelectorParsingState::empty())
})
.map(|selectors| selectors.into_boxed_slice())
}

Expand Down Expand Up @@ -450,9 +453,7 @@ where
},
// In quirks mode, class and id selectors should match
// case-insensitively, so just avoid inserting them into the filter.
Component::ID(ref id) if quirks_mode != QuirksMode::Quirks => {
id.precomputed_hash()
},
Component::ID(ref id) if quirks_mode != QuirksMode::Quirks => id.precomputed_hash(),
Component::Class(ref class) if quirks_mode != QuirksMode::Quirks => {
class.precomputed_hash()
},
Expand All @@ -466,7 +467,7 @@ where
}
}
continue;
}
},
_ => continue,
};

Expand Down Expand Up @@ -1086,11 +1087,14 @@ impl<Impl: SelectorImpl> Component<Impl> {
pub fn maybe_allowed_after_pseudo_element(&self) -> bool {
match *self {
Component::NonTSPseudoClass(..) => true,
Component::Negation(ref components) => components.iter().all(|c| c.maybe_allowed_after_pseudo_element()),
Component::Is(ref selectors) |
Component::Where(ref selectors) => {
Component::Negation(ref components) => components
.iter()
.all(|c| c.maybe_allowed_after_pseudo_element()),
Component::Is(ref selectors) | Component::Where(ref selectors) => {
selectors.iter().all(|selector| {
selector.iter_raw_match_order().all(|c| c.maybe_allowed_after_pseudo_element())
selector
.iter_raw_match_order()
.all(|c| c.maybe_allowed_after_pseudo_element())
})
},
_ => false,
Expand All @@ -1110,12 +1114,14 @@ impl<Impl: SelectorImpl> Component<Impl> {
*self
);
match *self {
Component::Negation(ref components) => {
!components.iter().all(|c| c.matches_for_stateless_pseudo_element())
},
Component::Negation(ref components) => !components
.iter()
.all(|c| c.matches_for_stateless_pseudo_element()),
Component::Is(ref selectors) | Component::Where(ref selectors) => {
selectors.iter().any(|selector| {
selector.iter_raw_match_order().all(|c| c.matches_for_stateless_pseudo_element())
selector
.iter_raw_match_order()
.all(|c| c.matches_for_stateless_pseudo_element())
})
},
_ => false,
Expand Down Expand Up @@ -2254,7 +2260,11 @@ where
// Pseudo-elements cannot be represented by the matches-any
// pseudo-class; they are not valid within :is().
//
let inner = SelectorList::parse_with_state(parser, input, state | SelectorParsingState::DISALLOW_PSEUDOS)?;
let inner = SelectorList::parse_with_state(
parser,
input,
state | SelectorParsingState::DISALLOW_PSEUDOS,
)?;
Ok(component(inner.0.into_vec().into_boxed_slice()))
}

Expand Down
1 change: 1 addition & 0 deletions components/style/build_gecko.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl BuilderExt for Builder {
// them.
let mut builder = Builder::default()
.rust_target(RustTarget::Stable_1_25)
.size_t_is_usize(true)
.disable_untagged_union();

let rustfmt_path = env::var_os("RUSTFMT")
Expand Down
15 changes: 10 additions & 5 deletions components/style/dom_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

use crate::context::QuirksMode;
use crate::dom::{TDocument, TElement, TNode, TShadowRoot};
use crate::invalidation::element::invalidation_map::Dependency;
use crate::invalidation::element::invalidator::{DescendantInvalidationLists, Invalidation};
use crate::invalidation::element::invalidator::{InvalidationProcessor, InvalidationVector};
use crate::invalidation::element::invalidation_map::Dependency;
use crate::Atom;
use selectors::attr::CaseSensitivity;
use selectors::matching::{self, MatchingContext, MatchingMode};
Expand Down Expand Up @@ -145,7 +145,10 @@ where
}

fn check_outer_dependency(&mut self, _: &Dependency, _: E) -> bool {
debug_assert!(false, "How? We should only have parent-less dependencies here!");
debug_assert!(
false,
"How? We should only have parent-less dependencies here!"
);
true
}

Expand Down Expand Up @@ -647,9 +650,11 @@ pub fn query_selector<E, Q>(
if root_element.is_some() || !invalidation_may_be_useful {
query_selector_slow::<E, Q>(root, selector_list, results, &mut matching_context);
} else {
let dependencies = selector_list.0.iter().map(|selector| {
Dependency::for_full_selector_invalidation(selector.clone())
}).collect::<SmallVec<[_; 5]>>();
let dependencies = selector_list
.0
.iter()
.map(|selector| Dependency::for_full_selector_invalidation(selector.clone()))
.collect::<SmallVec<[_; 5]>>();
let mut processor = QuerySelectorProcessor::<E, Q> {
results,
matching_context,
Expand Down
1 change: 0 additions & 1 deletion components/style/gecko/media_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ pub static MEDIA_FEATURES: [MediaFeatureDescription; 53] = [
keyword_evaluator!(eval_any_hover, Hover),
ParsingRequirements::empty(),
),

// Internal -moz-is-glyph media feature: applies only inside SVG glyphs.
// Internal because it is really only useful in the user agent anyway
// and therefore not worth standardizing.
Expand Down
12 changes: 7 additions & 5 deletions components/style/gecko/pseudo_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,13 @@ impl PseudoElement {
/// Whether this pseudo-element is enabled for all content.
pub fn enabled_in_content(&self) -> bool {
match *self {
PseudoElement::MozFocusOuter => static_prefs::pref!("layout.css.moz-focus-outer.enabled"),
PseudoElement::FileChooserButton => static_prefs::pref!("layout.css.file-chooser-button.enabled"),
_ => {
(self.flags() & structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS_AND_CHROME) == 0
}
PseudoElement::MozFocusOuter => {
static_prefs::pref!("layout.css.moz-focus-outer.enabled")
},
PseudoElement::FileChooserButton => {
static_prefs::pref!("layout.css.file-chooser-button.enabled")
},
_ => (self.flags() & structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS_AND_CHROME) == 0,
}
}

Expand Down
3 changes: 2 additions & 1 deletion components/style/gecko/selector_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {

#[inline]
fn parse_is_and_where(&self) -> bool {
self.in_user_agent_stylesheet() || static_prefs::pref!("layout.css.is-where-selectors.enabled")
self.in_user_agent_stylesheet() ||
static_prefs::pref!("layout.css.is-where-selectors.enabled")
}

#[inline]
Expand Down
4 changes: 2 additions & 2 deletions components/style/gecko_bindings/sugar/ownership.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

//! Helpers for different FFI pointer kinds that Gecko's FFI layer uses.

use gecko_bindings::structs::root::mozilla::detail::CopyablePtr;
use servo_arc::{Arc, RawOffsetArc};
use std::marker::PhantomData;
use std::mem::{forget, transmute};
use std::ops::{Deref, DerefMut};
use std::ptr;
use gecko_bindings::structs::root::mozilla::detail::CopyablePtr;

/// Indicates that a given Servo type has a corresponding Gecko FFI type.
pub unsafe trait HasFFI: Sized + 'static {
Expand Down Expand Up @@ -345,4 +345,4 @@ impl<T> DerefMut for CopyablePtr<T> {
fn deref_mut<'a>(&'a mut self) -> &'a mut T {
&mut self.mPtr
}
}
}
5 changes: 4 additions & 1 deletion components/style/invalidation/element/document_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ where
I: Iterator<Item = &'a CascadeData>,
{
fn check_outer_dependency(&mut self, _: &Dependency, _: E) -> bool {
debug_assert!(false, "how, we should only have parent-less dependencies here!");
debug_assert!(
false,
"how, we should only have parent-less dependencies here!"
);
true
}

Expand Down
23 changes: 15 additions & 8 deletions components/style/invalidation/element/invalidation_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

use crate::context::QuirksMode;
use crate::element_state::{DocumentState, ElementState};
use crate::selector_map::{MaybeCaseInsensitiveHashMap, PrecomputedHashMap, SelectorMap, SelectorMapEntry};
use crate::selector_map::{
MaybeCaseInsensitiveHashMap, PrecomputedHashMap, SelectorMap, SelectorMapEntry,
};
use crate::selector_parser::SelectorImpl;
use crate::{Atom, LocalName, Namespace};
use fallible::FallibleVec;
Expand Down Expand Up @@ -196,7 +198,8 @@ pub struct InvalidationMap {
/// A list of document state dependencies in the rules we represent.
pub document_state_selectors: Vec<DocumentStateDependency>,
/// A map of other attribute affecting selectors.
pub other_attribute_affecting_selectors: PrecomputedHashMap<LocalName, SmallVec<[Dependency; 1]>>,
pub other_attribute_affecting_selectors:
PrecomputedHashMap<LocalName, SmallVec<[Dependency; 1]>>,
}

impl InvalidationMap {
Expand Down Expand Up @@ -331,7 +334,11 @@ impl<'a> SelectorDependencyCollector<'a> {
self.visit_whole_selector_from(iter, 0)
}

fn visit_whole_selector_from(&mut self, mut iter: SelectorIter<SelectorImpl>, mut index: usize) -> bool {
fn visit_whole_selector_from(
&mut self,
mut iter: SelectorIter<SelectorImpl>,
mut index: usize,
) -> bool {
loop {
// Reset the compound state.
self.compound_state = PerCompoundState::new(index);
Expand Down Expand Up @@ -384,7 +391,7 @@ impl<'a> SelectorDependencyCollector<'a> {
Err(err) => {
*self.alloc_error = Some(err);
return false;
}
},
}
}

Expand All @@ -395,8 +402,7 @@ impl<'a> SelectorDependencyCollector<'a> {
// cache them or something.
for &(ref selector, ref selector_offset) in self.parent_selectors.iter() {
debug_assert_ne!(
self.compound_state.offset,
0,
self.compound_state.offset, 0,
"Shouldn't bother creating nested dependencies for the rightmost compound",
);
let new_parent = Dependency {
Expand Down Expand Up @@ -442,7 +448,8 @@ impl<'a> SelectorVisitor for SelectorDependencyCollector<'a> {

index += 1; // account for the combinator.

self.parent_selectors.push((self.selector.clone(), self.compound_state.offset));
self.parent_selectors
.push((self.selector.clone(), self.compound_state.offset));
let mut nested = SelectorDependencyCollector {
map: &mut *self.map,
document_state: &mut *self.document_state,
Expand Down Expand Up @@ -483,7 +490,7 @@ impl<'a> SelectorVisitor for SelectorDependencyCollector<'a> {
Err(err) => {
*self.alloc_error = Some(err);
return false;
}
},
}
},
Component::NonTSPseudoClass(ref pc) => {
Expand Down
Loading

0 comments on commit 762abba

Please sign in to comment.