mirror of
https://github.com/servo/servo.git
synced 2025-07-25 16:20:36 +01:00
Fixes to pass tidy.
This commit is contained in:
parent
8915e53cee
commit
a69eed6956
4 changed files with 14 additions and 12 deletions
|
@ -1,12 +1,10 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* 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
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
use std::borrow::Borrow;
|
|
||||||
|
|
||||||
use bloom::BloomFilter;
|
use bloom::BloomFilter;
|
||||||
|
|
||||||
use parser::{CaseSensitivity, Combinator, ComplexSelector, LocalName};
|
use parser::{CaseSensitivity, Combinator, ComplexSelector, LocalName};
|
||||||
use parser::{SimpleSelector, Selector, SelectorImpl};
|
use parser::{SimpleSelector, Selector, SelectorImpl};
|
||||||
|
use std::borrow::Borrow;
|
||||||
use tree::Element;
|
use tree::Element;
|
||||||
|
|
||||||
/// The reason why we're doing selector matching.
|
/// 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() {
|
for ss in selector.compound_selector.iter() {
|
||||||
match *ss {
|
match *ss {
|
||||||
SimpleSelector::LocalName(LocalName { ref name, ref lower_name }) => {
|
SimpleSelector::LocalName(LocalName { ref name, ref lower_name }) => {
|
||||||
if !bf.might_contain(name)
|
if !bf.might_contain(name) &&
|
||||||
&& !bf.might_contain(lower_name) {
|
!bf.might_contain(lower_name) {
|
||||||
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -320,7 +318,8 @@ fn matches_complex_selector_internal<E>(selector: &ComplexSelector<E::Impl>,
|
||||||
// If the failure status is NotMatchedAndRestartFromClosestDescendant
|
// If the failure status is NotMatchedAndRestartFromClosestDescendant
|
||||||
// and combinator is Combinator::LaterSibling, give up this Combinator::LaterSibling matching
|
// and combinator is Combinator::LaterSibling, give up this Combinator::LaterSibling matching
|
||||||
// and restart from the closest descendant combinator.
|
// 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
|
// The Combinator::Descendant combinator and the status is
|
||||||
// NotMatchedAndRestartFromClosestLaterSibling or
|
// NotMatchedAndRestartFromClosestLaterSibling or
|
||||||
|
@ -436,7 +435,8 @@ fn matches_simple_selector<E>(
|
||||||
relation_if!(matches_last_child(element, reason), AFFECTED_BY_CHILD_INDEX)
|
relation_if!(matches_last_child(element, reason), AFFECTED_BY_CHILD_INDEX)
|
||||||
}
|
}
|
||||||
SimpleSelector::OnlyChild => {
|
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 => {
|
SimpleSelector::Root => {
|
||||||
// We never share styles with an element with no parent, so no point
|
// We never share styles with an element with no parent, so no point
|
||||||
|
|
|
@ -574,7 +574,7 @@ impl From<Specificity> for u32 {
|
||||||
fn specificity<Impl>(complex_selector: &ComplexSelector<Impl>,
|
fn specificity<Impl>(complex_selector: &ComplexSelector<Impl>,
|
||||||
pseudo_element: Option<&Impl::PseudoElement>)
|
pseudo_element: Option<&Impl::PseudoElement>)
|
||||||
-> u32
|
-> u32
|
||||||
where Impl: SelectorImpl {
|
where Impl: SelectorImpl {
|
||||||
let mut specificity = complex_selector_specificity(complex_selector);
|
let mut specificity = complex_selector_specificity(complex_selector);
|
||||||
if pseudo_element.is_some() {
|
if pseudo_element.is_some() {
|
||||||
specificity.element_selectors += 1;
|
specificity.element_selectors += 1;
|
||||||
|
@ -670,7 +670,7 @@ fn parse_complex_selector_and_pseudo_element<P, Impl>(
|
||||||
where P: Parser<Impl=Impl>, Impl: SelectorImpl
|
where P: Parser<Impl=Impl>, Impl: SelectorImpl
|
||||||
{
|
{
|
||||||
let (first, mut pseudo_element) = parse_compound_selector(parser, input)?;
|
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() {
|
'outer_loop: while pseudo_element.is_none() {
|
||||||
let combinator;
|
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
|
// NB: pub module in order to access the DummyParser
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod tests {
|
pub mod tests {
|
||||||
|
use cssparser::{Parser as CssParser, ToCss, serialize_identifier};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use cssparser::{Parser as CssParser, ToCss, serialize_identifier};
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[derive(PartialEq, Clone, Debug, Hash, Eq)]
|
#[derive(PartialEq, Clone, Debug, Hash, Eq)]
|
||||||
|
@ -1219,7 +1219,7 @@ pub mod tests {
|
||||||
self.default_ns.clone()
|
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()
|
self.ns_prefixes.get(prefix).cloned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
fn match_attr_dash(&self, attr: &AttrSelector<Self::Impl>, value: &String) -> bool {
|
||||||
self.match_attr(attr, |attr_value| {
|
self.match_attr(attr, |attr_value| {
|
||||||
|
|
||||||
// The attribute must start with the pattern.
|
// The attribute must start with the pattern.
|
||||||
if !attr_value.starts_with(value) {
|
if !attr_value.starts_with(value) {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -50,6 +50,9 @@ files = [
|
||||||
"./tests/wpt/mozilla/tests/css/fonts",
|
"./tests/wpt/mozilla/tests/css/fonts",
|
||||||
"./tests/wpt/mozilla/tests/css/pre_with_tab.html",
|
"./tests/wpt/mozilla/tests/css/pre_with_tab.html",
|
||||||
"./tests/wpt/mozilla/tests/mozilla/textarea_placeholder.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 that are ignored for the non-WPT tidy check.
|
||||||
directories = [
|
directories = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue