style: Rustfmt recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2020-06-04 02:02:50 +02:00
parent 69c7077b3d
commit 762abbaf9f
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
19 changed files with 163 additions and 101 deletions

View file

@ -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
}

View file

@ -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;
@ -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 {
@ -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);
@ -384,7 +391,7 @@ impl<'a> SelectorDependencyCollector<'a> {
Err(err) => {
*self.alloc_error = Some(err);
return false;
}
},
}
}
@ -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 {
@ -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,
@ -483,7 +490,7 @@ impl<'a> SelectorVisitor for SelectorDependencyCollector<'a> {
Err(err) => {
*self.alloc_error = Some(err);
return false;
}
},
}
},
Component::NonTSPseudoClass(ref pc) => {

View file

@ -177,13 +177,10 @@ pub struct Invalidation<'a> {
impl<'a> Invalidation<'a> {
/// Create a new invalidation for matching a dependency.
pub fn new(
dependency: &'a Dependency,
scope: Option<OpaqueElement>,
) -> Self {
pub fn new(dependency: &'a Dependency, scope: Option<OpaqueElement>) -> Self {
debug_assert!(
dependency.selector_offset == dependency.selector.len() + 1 ||
dependency.invalidation_kind() != DependencyInvalidationKind::Element,
dependency.invalidation_kind() != DependencyInvalidationKind::Element,
"No point to this, if the dependency matched the element we should just invalidate it"
);
Self {
@ -206,7 +203,11 @@ impl<'a> Invalidation<'a> {
// for the weird pseudos in <input type="number">.
//
// We should be able to do better here!
match self.dependency.selector.combinator_at_parse_order(self.offset - 1) {
match self
.dependency
.selector
.combinator_at_parse_order(self.offset - 1)
{
Combinator::Descendant | Combinator::LaterSibling | Combinator::PseudoElement => true,
Combinator::Part |
Combinator::SlotAssignment |
@ -220,7 +221,11 @@ impl<'a> Invalidation<'a> {
return InvalidationKind::Descendant(DescendantInvalidationKind::Dom);
}
match self.dependency.selector.combinator_at_parse_order(self.offset - 1) {
match self
.dependency
.selector
.combinator_at_parse_order(self.offset - 1)
{
Combinator::Child | Combinator::Descendant | Combinator::PseudoElement => {
InvalidationKind::Descendant(DescendantInvalidationKind::Dom)
},
@ -238,7 +243,11 @@ impl<'a> fmt::Debug for Invalidation<'a> {
use cssparser::ToCss;
f.write_str("Invalidation(")?;
for component in self.dependency.selector.iter_raw_parse_order_from(self.offset) {
for component in self
.dependency
.selector
.iter_raw_parse_order_from(self.offset)
{
if matches!(*component, Component::Combinator(..)) {
break;
}
@ -816,9 +825,11 @@ where
let mut cur_dependency = invalidation.dependency;
loop {
cur_dependency = match cur_dependency.parent {
None => return SingleInvalidationResult {
invalidated_self: true,
matched: true,
None => {
return SingleInvalidationResult {
invalidated_self: true,
matched: true,
}
},
Some(ref p) => &**p,
};
@ -828,11 +839,14 @@ where
// The inner selector changed, now check if the full
// previous part of the selector did, before keeping
// checking for descendants.
if !self.processor.check_outer_dependency(cur_dependency, self.element) {
if !self
.processor
.check_outer_dependency(cur_dependency, self.element)
{
return SingleInvalidationResult {
invalidated_self: false,
matched: false,
}
};
}
if cur_dependency.invalidation_kind() == DependencyInvalidationKind::Element {
@ -840,24 +854,21 @@ where
}
debug!(" > Generating invalidation");
break Invalidation::new(cur_dependency, invalidation.scope)
break Invalidation::new(cur_dependency, invalidation.scope);
}
},
CompoundSelectorMatchingResult::Matched {
next_combinator_offset,
} => {
Invalidation {
dependency: invalidation.dependency,
scope: invalidation.scope,
offset: next_combinator_offset + 1,
matched_by_any_previous: false,
}
} => Invalidation {
dependency: invalidation.dependency,
scope: invalidation.scope,
offset: next_combinator_offset + 1,
matched_by_any_previous: false,
},
};
debug_assert_ne!(
next_invalidation.offset,
0,
next_invalidation.offset, 0,
"Rightmost selectors shouldn't generate more invalidations",
);
@ -886,7 +897,9 @@ where
c.maybe_allowed_after_pseudo_element(),
"Someone seriously messed up selector parsing: \
{:?} at offset {:?}: {:?}",
next_invalidation.dependency, next_invalidation.offset, c,
next_invalidation.dependency,
next_invalidation.offset,
c,
);
None

View file

@ -254,7 +254,9 @@ where
);
}
let mut attributes_changed = false;
snapshot.each_attr_changed(|_| { attributes_changed = true; });
snapshot.each_attr_changed(|_| {
attributes_changed = true;
});
if attributes_changed {
debug!(
" > attributes changed, old: {}",
@ -436,7 +438,12 @@ where
/// Check whether a dependency should be taken into account.
#[inline]
fn check_dependency(&mut self, dependency: &Dependency) -> bool {
check_dependency(dependency, &self.element, &self.wrapper, &mut self.matching_context)
check_dependency(
dependency,
&self.element,
&self.wrapper,
&mut self.matching_context,
)
}
fn scan_dependency(&mut self, dependency: &'selectors Dependency) {
@ -472,10 +479,8 @@ where
debug_assert_ne!(dependency.selector_offset, 0);
debug_assert_ne!(dependency.selector_offset, dependency.selector.len());
let invalidation = Invalidation::new(
&dependency,
self.matching_context.current_host.clone(),
);
let invalidation =
Invalidation::new(&dependency, self.matching_context.current_host.clone());
match invalidation_kind {
DependencyInvalidationKind::Element => unreachable!(),