Fixes to pass tidy.

This commit is contained in:
Bobby Holley 2017-02-07 22:56:01 -08:00
parent 8915e53cee
commit a69eed6956
4 changed files with 14 additions and 12 deletions

View file

@ -1,12 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::borrow::Borrow;
use bloom::BloomFilter;
use parser::{CaseSensitivity, Combinator, ComplexSelector, LocalName};
use parser::{SimpleSelector, Selector, SelectorImpl};
use std::borrow::Borrow;
use tree::Element;
/// The reason why we're doing selector matching.
@ -240,8 +238,8 @@ fn can_fast_reject<E>(mut selector: &ComplexSelector<E::Impl>,
for ss in selector.compound_selector.iter() {
match *ss {
SimpleSelector::LocalName(LocalName { ref name, ref lower_name }) => {
if !bf.might_contain(name)
&& !bf.might_contain(lower_name) {
if !bf.might_contain(name) &&
!bf.might_contain(lower_name) {
return Some(SelectorMatchingResult::NotMatchedGlobally);
}
},
@ -320,7 +318,8 @@ fn matches_complex_selector_internal<E>(selector: &ComplexSelector<E::Impl>,
// If the failure status is NotMatchedAndRestartFromClosestDescendant
// and combinator is Combinator::LaterSibling, give up this Combinator::LaterSibling matching
// and restart from the closest descendant combinator.
(SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant, Combinator::LaterSibling) => return result,
(SelectorMatchingResult::NotMatchedAndRestartFromClosestDescendant, Combinator::LaterSibling)
=> return result,
// The Combinator::Descendant combinator and the status is
// NotMatchedAndRestartFromClosestLaterSibling or
@ -436,7 +435,8 @@ fn matches_simple_selector<E>(
relation_if!(matches_last_child(element, reason), AFFECTED_BY_CHILD_INDEX)
}
SimpleSelector::OnlyChild => {
relation_if!(matches_first_child(element, reason) && matches_last_child(element, reason), AFFECTED_BY_CHILD_INDEX)
relation_if!(matches_first_child(element, reason) &&
matches_last_child(element, reason), AFFECTED_BY_CHILD_INDEX)
}
SimpleSelector::Root => {
// We never share styles with an element with no parent, so no point

View file

@ -574,7 +574,7 @@ impl From<Specificity> for u32 {
fn specificity<Impl>(complex_selector: &ComplexSelector<Impl>,
pseudo_element: Option<&Impl::PseudoElement>)
-> u32
where Impl: SelectorImpl {
where Impl: SelectorImpl {
let mut specificity = complex_selector_specificity(complex_selector);
if pseudo_element.is_some() {
specificity.element_selectors += 1;
@ -670,7 +670,7 @@ fn parse_complex_selector_and_pseudo_element<P, Impl>(
where P: Parser<Impl=Impl>, Impl: SelectorImpl
{
let (first, mut pseudo_element) = parse_compound_selector(parser, input)?;
let mut complex = ComplexSelector{ compound_selector: first, next: None };
let mut complex = ComplexSelector { compound_selector: first, next: None };
'outer_loop: while pseudo_element.is_none() {
let combinator;
@ -1123,11 +1123,11 @@ fn parse_simple_pseudo_class<P, Impl>(parser: &P, name: Cow<str>) -> Result<Simp
// NB: pub module in order to access the DummyParser
#[cfg(test)]
pub mod tests {
use cssparser::{Parser as CssParser, ToCss, serialize_identifier};
use std::borrow::Cow;
use std::collections::HashMap;
use std::fmt;
use std::sync::Arc;
use cssparser::{Parser as CssParser, ToCss, serialize_identifier};
use super::*;
#[derive(PartialEq, Clone, Debug, Hash, Eq)]
@ -1219,7 +1219,7 @@ pub mod tests {
self.default_ns.clone()
}
fn namespace_for_prefix(&self, prefix: &String) -> Option<String> {
fn namespace_for_prefix(&self, prefix: &str) -> Option<String> {
self.ns_prefixes.get(prefix).cloned()
}
}

View file

@ -86,7 +86,6 @@ impl<T> MatchAttr for T where T: MatchAttrGeneric, T::Impl: SelectorImpl<AttrVal
fn match_attr_dash(&self, attr: &AttrSelector<Self::Impl>, value: &String) -> bool {
self.match_attr(attr, |attr_value| {
// The attribute must start with the pattern.
if !attr_value.starts_with(value) {
return false

View file

@ -50,6 +50,9 @@ files = [
"./tests/wpt/mozilla/tests/css/fonts",
"./tests/wpt/mozilla/tests/css/pre_with_tab.html",
"./tests/wpt/mozilla/tests/mozilla/textarea_placeholder.html",
# Tidy complains about taking &String instead of &str, but they aren't
# equivalent given the way the traits are set up.
"./components/selectors/tree.rs",
]
# Directories that are ignored for the non-WPT tidy check.
directories = [