From a69eed69564f44e047e8340b95de9a23c9717307 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 7 Feb 2017 22:56:01 -0800 Subject: [PATCH] Fixes to pass tidy. --- components/selectors/matching.rs | 14 +++++++------- components/selectors/parser.rs | 8 ++++---- components/selectors/tree.rs | 1 - servo-tidy.toml | 3 +++ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs index 72d3a21ebf2..e4c13bf83fb 100644 --- a/components/selectors/matching.rs +++ b/components/selectors/matching.rs @@ -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(mut selector: &ComplexSelector, 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(selector: &ComplexSelector, // 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( 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 diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs index a3862265bda..d5cae30042f 100644 --- a/components/selectors/parser.rs +++ b/components/selectors/parser.rs @@ -574,7 +574,7 @@ impl From for u32 { fn specificity(complex_selector: &ComplexSelector, 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( where P: Parser, 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(parser: &P, name: Cow) -> Result Option { + fn namespace_for_prefix(&self, prefix: &str) -> Option { self.ns_prefixes.get(prefix).cloned() } } diff --git a/components/selectors/tree.rs b/components/selectors/tree.rs index 0ef48b4eec3..850b58a6b2c 100644 --- a/components/selectors/tree.rs +++ b/components/selectors/tree.rs @@ -86,7 +86,6 @@ impl MatchAttr for T where T: MatchAttrGeneric, T::Impl: SelectorImpl, value: &String) -> bool { self.match_attr(attr, |attr_value| { - // The attribute must start with the pattern. if !attr_value.starts_with(value) { return false diff --git a/servo-tidy.toml b/servo-tidy.toml index b42cc23b619..6c0b63f6951 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -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 = [