mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Update rustc to revision 3dcd2157403163789aaf21a9ab3c4d30a7c6494d.
This commit is contained in:
parent
b8900782b0
commit
466faac2a5
223 changed files with 4414 additions and 4105 deletions
|
@ -9,7 +9,7 @@ use sync::Arc;
|
|||
use cssparser::ast::*;
|
||||
use cssparser::{tokenize, parse_nth};
|
||||
|
||||
use selector_matching::{StylesheetOrigin, UserAgentOrigin};
|
||||
use selector_matching::StylesheetOrigin;
|
||||
use string_cache::{Atom, Namespace};
|
||||
|
||||
use namespaces::NamespaceMap;
|
||||
|
@ -114,8 +114,8 @@ pub struct AttrSelector {
|
|||
|
||||
#[deriving(Eq, PartialEq, Clone, Hash)]
|
||||
pub enum NamespaceConstraint {
|
||||
AnyNamespace,
|
||||
SpecificNamespace(Namespace),
|
||||
Any,
|
||||
Specific(Namespace),
|
||||
}
|
||||
|
||||
|
||||
|
@ -162,21 +162,37 @@ fn compute_specificity(mut selector: &CompoundSelector,
|
|||
specificity: &mut Specificity) {
|
||||
for simple_selector in simple_selectors.iter() {
|
||||
match simple_selector {
|
||||
&LocalNameSelector(..) => specificity.element_selectors += 1,
|
||||
&IDSelector(..) => specificity.id_selectors += 1,
|
||||
&ClassSelector(..)
|
||||
| &AttrExists(..) | &AttrEqual(..) | &AttrIncludes(..) | &AttrDashMatch(..)
|
||||
| &AttrPrefixMatch(..) | &AttrSubstringMatch(..) | &AttrSuffixMatch(..)
|
||||
| &AnyLink | &Link | &Visited | &Hover | &Disabled | &Enabled
|
||||
| &FirstChild | &LastChild | &OnlyChild | &Root | &Checked | &Indeterminate
|
||||
// | &Empty | &Lang(*)
|
||||
| &NthChild(..) | &NthLastChild(..)
|
||||
| &NthOfType(..) | &NthLastOfType(..)
|
||||
| &FirstOfType | &LastOfType | &OnlyOfType | &ServoNonzeroBorder
|
||||
=> specificity.class_like_selectors += 1,
|
||||
&NamespaceSelector(..) => (),
|
||||
&Negation(ref negated)
|
||||
=> simple_selectors_specificity(negated.as_slice(), specificity),
|
||||
&SimpleSelector::LocalNameSelector(..) =>
|
||||
specificity.element_selectors += 1,
|
||||
&SimpleSelector::IDSelector(..) =>
|
||||
specificity.id_selectors += 1,
|
||||
&SimpleSelector::ClassSelector(..) |
|
||||
&SimpleSelector::AttrExists(..) |
|
||||
&SimpleSelector::AttrEqual(..) |
|
||||
&SimpleSelector::AttrIncludes(..) |
|
||||
&SimpleSelector::AttrDashMatch(..) |
|
||||
&SimpleSelector::AttrPrefixMatch(..) |
|
||||
&SimpleSelector::AttrSubstringMatch(..) |
|
||||
&SimpleSelector::AttrSuffixMatch(..) |
|
||||
&SimpleSelector::AnyLink | &SimpleSelector::Link |
|
||||
&SimpleSelector::Visited | &SimpleSelector::Hover |
|
||||
&SimpleSelector::Disabled | &SimpleSelector::Enabled |
|
||||
&SimpleSelector::FirstChild | &SimpleSelector::LastChild |
|
||||
&SimpleSelector::OnlyChild | &SimpleSelector::Root |
|
||||
&SimpleSelector::Checked |
|
||||
&SimpleSelector::Indeterminate |
|
||||
// &SimpleSelector::Empty | &SimpleSelector::Lang(*) |
|
||||
&SimpleSelector::NthChild(..) |
|
||||
&SimpleSelector::NthLastChild(..) |
|
||||
&SimpleSelector::NthOfType(..) |
|
||||
&SimpleSelector::NthLastOfType(..) |
|
||||
&SimpleSelector::FirstOfType | &SimpleSelector::LastOfType |
|
||||
&SimpleSelector::OnlyOfType |
|
||||
&SimpleSelector::ServoNonzeroBorder =>
|
||||
specificity.class_like_selectors += 1,
|
||||
&SimpleSelector::NamespaceSelector(..) => (),
|
||||
&SimpleSelector::Negation(ref negated) =>
|
||||
simple_selectors_specificity(negated.as_slice(), specificity),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -201,12 +217,14 @@ fn parse_type_selector<I: Iterator<ComponentValue>>(
|
|||
Some((namespace, local_name)) => {
|
||||
let mut simple_selectors = vec!();
|
||||
match namespace {
|
||||
SpecificNamespace(ns) => simple_selectors.push(NamespaceSelector(ns)),
|
||||
AnyNamespace => (),
|
||||
NamespaceConstraint::Specific(ns) => {
|
||||
simple_selectors.push(SimpleSelector::NamespaceSelector(ns))
|
||||
},
|
||||
NamespaceConstraint::Any => (),
|
||||
}
|
||||
match local_name {
|
||||
Some(name) => {
|
||||
simple_selectors.push(LocalNameSelector(LocalName {
|
||||
simple_selectors.push(SimpleSelector::LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice(name.as_slice()),
|
||||
lower_name: Atom::from_slice(name.into_ascii_lower().as_slice())
|
||||
}))
|
||||
|
@ -220,8 +238,8 @@ fn parse_type_selector<I: Iterator<ComponentValue>>(
|
|||
|
||||
|
||||
enum SimpleSelectorParseResult {
|
||||
SimpleSelectorResult(SimpleSelector),
|
||||
PseudoElementResult(PseudoElement),
|
||||
SimpleSelector(SimpleSelector),
|
||||
PseudoElement(PseudoElement),
|
||||
}
|
||||
|
||||
|
||||
|
@ -233,8 +251,8 @@ fn parse_qualified_name<I: Iterator<ComponentValue>>(
|
|||
-> Result<Option<(NamespaceConstraint, Option<String>)>, ()> {
|
||||
let default_namespace = |local_name| {
|
||||
let namespace = match namespaces.default {
|
||||
Some(ref ns) => SpecificNamespace(ns.clone()),
|
||||
None => AnyNamespace,
|
||||
Some(ref ns) => NamespaceConstraint::Specific(ns.clone()),
|
||||
None => NamespaceConstraint::Any,
|
||||
};
|
||||
Ok(Some((namespace, local_name)))
|
||||
};
|
||||
|
@ -264,24 +282,24 @@ fn parse_qualified_name<I: Iterator<ComponentValue>>(
|
|||
None => return Err(()), // Undeclared namespace prefix
|
||||
Some(ref ns) => (*ns).clone(),
|
||||
};
|
||||
explicit_namespace(iter, SpecificNamespace(namespace))
|
||||
explicit_namespace(iter, NamespaceConstraint::Specific(namespace))
|
||||
},
|
||||
_ if in_attr_selector => Ok(Some(
|
||||
(SpecificNamespace(ns!("")), Some(value)))),
|
||||
(NamespaceConstraint::Specific(ns!("")), Some(value)))),
|
||||
_ => default_namespace(Some(value)),
|
||||
}
|
||||
},
|
||||
Some(&Delim('*')) => {
|
||||
iter.next(); // Consume '*'
|
||||
match iter.peek() {
|
||||
Some(&Delim('|')) => explicit_namespace(iter, AnyNamespace),
|
||||
Some(&Delim('|')) => explicit_namespace(iter, NamespaceConstraint::Any),
|
||||
_ => {
|
||||
if !in_attr_selector { default_namespace(None) }
|
||||
else { Err(()) }
|
||||
},
|
||||
}
|
||||
},
|
||||
Some(&Delim('|')) => explicit_namespace(iter, SpecificNamespace(ns!(""))),
|
||||
Some(&Delim('|')) => explicit_namespace(iter, NamespaceConstraint::Specific(ns!(""))),
|
||||
_ => Ok(None),
|
||||
}
|
||||
}
|
||||
|
@ -302,20 +320,37 @@ fn parse_attribute_selector(content: Vec<ComponentValue>, namespaces: &Namespace
|
|||
skip_whitespace(iter);
|
||||
// TODO: deal with empty value or value containing whitespace (see spec)
|
||||
let result = match iter.next() {
|
||||
None => AttrExists(attr), // [foo]
|
||||
Some(Delim('=')) => AttrEqual(
|
||||
attr, try!(parse_attribute_value(iter)),
|
||||
try!(parse_attribute_flags(iter))), // [foo=bar]
|
||||
Some(IncludeMatch) => AttrIncludes(attr, try!(parse_attribute_value(iter))), // [foo~=bar]
|
||||
// [foo]
|
||||
None => SimpleSelector::AttrExists(attr),
|
||||
|
||||
// [foo=bar]
|
||||
Some(Delim('=')) =>
|
||||
SimpleSelector::AttrEqual(attr, try!(parse_attribute_value(iter)),
|
||||
try!(parse_attribute_flags(iter))),
|
||||
|
||||
// [foo~=bar]
|
||||
Some(IncludeMatch) =>
|
||||
SimpleSelector::AttrIncludes(attr, try!(parse_attribute_value(iter))),
|
||||
|
||||
// [foo|=bar]
|
||||
Some(DashMatch) => {
|
||||
let value = try!(parse_attribute_value(iter));
|
||||
let dashing_value = format!("{}-", value);
|
||||
AttrDashMatch(attr, value, dashing_value) // [foo|=bar]
|
||||
SimpleSelector::AttrDashMatch(attr, value, dashing_value)
|
||||
},
|
||||
Some(PrefixMatch) => AttrPrefixMatch(attr, try!(parse_attribute_value(iter))), // [foo^=bar]
|
||||
|
||||
// [foo^=bar]
|
||||
Some(PrefixMatch) =>
|
||||
SimpleSelector::AttrPrefixMatch(attr, try!(parse_attribute_value(iter))),
|
||||
|
||||
// [foo*=bar]
|
||||
Some(SubstringMatch) => AttrSubstringMatch(attr, try!(parse_attribute_value(iter))),
|
||||
Some(SuffixMatch) => AttrSuffixMatch(attr, try!(parse_attribute_value(iter))), // [foo$=bar]
|
||||
Some(SubstringMatch) =>
|
||||
SimpleSelector::AttrSubstringMatch(attr, try!(parse_attribute_value(iter))),
|
||||
|
||||
// [foo$=bar]
|
||||
Some(SuffixMatch) =>
|
||||
SimpleSelector::AttrSuffixMatch(attr, try!(parse_attribute_value(iter))),
|
||||
|
||||
_ => return Err(())
|
||||
};
|
||||
skip_whitespace(iter);
|
||||
|
@ -336,9 +371,9 @@ fn parse_attribute_flags<I: Iterator<ComponentValue>>(iter: &mut Iter<I>)
|
|||
-> Result<CaseSensitivity, ()> {
|
||||
skip_whitespace(iter);
|
||||
match iter.next() {
|
||||
None => Ok(CaseSensitive),
|
||||
None => Ok(CaseSensitivity::CaseSensitive),
|
||||
Some(Ident(ref value)) if value.as_slice().eq_ignore_ascii_case("i")
|
||||
=> Ok(CaseInsensitive),
|
||||
=> Ok(CaseSensitivity::CaseInsensitive),
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
|
@ -388,11 +423,11 @@ fn parse_selector<I>(context: &ParserContext, iter: &mut Iter<I>, namespaces: &N
|
|||
let combinator = match iter.peek() {
|
||||
None => break, // EOF
|
||||
Some(&Comma) => break,
|
||||
Some(&Delim('>')) => { iter.next(); Child },
|
||||
Some(&Delim('+')) => { iter.next(); NextSibling },
|
||||
Some(&Delim('~')) => { iter.next(); LaterSibling },
|
||||
Some(&Delim('>')) => { iter.next(); Combinator::Child },
|
||||
Some(&Delim('+')) => { iter.next(); Combinator::NextSibling },
|
||||
Some(&Delim('~')) => { iter.next(); Combinator::LaterSibling },
|
||||
Some(_) => {
|
||||
if any_whitespace { Descendant }
|
||||
if any_whitespace { Combinator::Descendant }
|
||||
else { return Err(()) }
|
||||
}
|
||||
};
|
||||
|
@ -417,14 +452,14 @@ fn parse_negation(context: &ParserContext,
|
|||
-> Result<SimpleSelector,()> {
|
||||
let iter = &mut arguments.into_iter().peekable();
|
||||
match try!(parse_type_selector(iter, namespaces)) {
|
||||
Some(type_selector) => Ok(Negation(type_selector)),
|
||||
Some(type_selector) => Ok(SimpleSelector::Negation(type_selector)),
|
||||
None => {
|
||||
match try!(parse_one_simple_selector(context,
|
||||
iter,
|
||||
namespaces,
|
||||
/* inside_negation = */ true)) {
|
||||
Some(SimpleSelectorResult(simple_selector)) => {
|
||||
Ok(Negation(vec![simple_selector]))
|
||||
Some(SimpleSelectorParseResult::SimpleSelector(simple_selector)) => {
|
||||
Ok(SimpleSelector::Negation(vec![simple_selector]))
|
||||
}
|
||||
_ => Err(())
|
||||
}
|
||||
|
@ -455,8 +490,8 @@ fn parse_simple_selectors<I>(context: &ParserContext,
|
|||
namespaces,
|
||||
/* inside_negation = */ false)) {
|
||||
None => break,
|
||||
Some(SimpleSelectorResult(s)) => { simple_selectors.push(s); empty = false },
|
||||
Some(PseudoElementResult(p)) => { pseudo_element = Some(p); empty = false; break },
|
||||
Some(SimpleSelectorParseResult::SimpleSelector(s)) => { simple_selectors.push(s); empty = false },
|
||||
Some(SimpleSelectorParseResult::PseudoElement(p)) => { pseudo_element = Some(p); empty = false; break },
|
||||
}
|
||||
}
|
||||
if empty {
|
||||
|
@ -475,10 +510,10 @@ fn parse_functional_pseudo_class(context: &ParserContext,
|
|||
-> Result<SimpleSelector,()> {
|
||||
match name.as_slice().to_ascii_lower().as_slice() {
|
||||
// "lang" => parse_lang(arguments),
|
||||
"nth-child" => parse_nth(arguments.as_slice()).map(|(a, b)| NthChild(a, b)),
|
||||
"nth-last-child" => parse_nth(arguments.as_slice()).map(|(a, b)| NthLastChild(a, b)),
|
||||
"nth-of-type" => parse_nth(arguments.as_slice()).map(|(a, b)| NthOfType(a, b)),
|
||||
"nth-last-of-type" => parse_nth(arguments.as_slice()).map(|(a, b)| NthLastOfType(a, b)),
|
||||
"nth-child" => parse_nth(arguments.as_slice()).map(|(a, b)| SimpleSelector::NthChild(a, b)),
|
||||
"nth-last-child" => parse_nth(arguments.as_slice()).map(|(a, b)| SimpleSelector::NthLastChild(a, b)),
|
||||
"nth-of-type" => parse_nth(arguments.as_slice()).map(|(a, b)| SimpleSelector::NthOfType(a, b)),
|
||||
"nth-last-of-type" => parse_nth(arguments.as_slice()).map(|(a, b)| SimpleSelector::NthLastOfType(a, b)),
|
||||
"not" => {
|
||||
if inside_negation {
|
||||
Err(())
|
||||
|
@ -503,21 +538,21 @@ fn parse_one_simple_selector<I>(context: &ParserContext,
|
|||
where I: Iterator<ComponentValue> {
|
||||
match iter.peek() {
|
||||
Some(&IDHash(_)) => match iter.next() {
|
||||
Some(IDHash(id)) => Ok(Some(SimpleSelectorResult(
|
||||
IDSelector(Atom::from_slice(id.as_slice()))))),
|
||||
Some(IDHash(id)) => Ok(Some(SimpleSelectorParseResult::SimpleSelector(
|
||||
SimpleSelector::IDSelector(Atom::from_slice(id.as_slice()))))),
|
||||
_ => panic!("Implementation error, this should not happen."),
|
||||
},
|
||||
Some(&Delim('.')) => {
|
||||
iter.next();
|
||||
match iter.next() {
|
||||
Some(Ident(class)) => Ok(Some(SimpleSelectorResult(
|
||||
ClassSelector(Atom::from_slice(class.as_slice()))))),
|
||||
Some(Ident(class)) => Ok(Some(SimpleSelectorParseResult::SimpleSelector(
|
||||
SimpleSelector::ClassSelector(Atom::from_slice(class.as_slice()))))),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
Some(&SquareBracketBlock(_)) => match iter.next() {
|
||||
Some(SquareBracketBlock(content))
|
||||
=> Ok(Some(SimpleSelectorResult(try!(parse_attribute_selector(content, namespaces))))),
|
||||
=> Ok(Some(SimpleSelectorParseResult::SimpleSelector(try!(parse_attribute_selector(content, namespaces))))),
|
||||
_ => panic!("Implementation error, this should not happen."),
|
||||
},
|
||||
Some(&Colon) => {
|
||||
|
@ -528,18 +563,18 @@ fn parse_one_simple_selector<I>(context: &ParserContext,
|
|||
match name.as_slice().to_ascii_lower().as_slice() {
|
||||
// Supported CSS 2.1 pseudo-elements only.
|
||||
// ** Do not add to this list! **
|
||||
"before" => Ok(Some(PseudoElementResult(Before))),
|
||||
"after" => Ok(Some(PseudoElementResult(After))),
|
||||
// "first-line" => PseudoElementResult(FirstLine),
|
||||
// "first-letter" => PseudoElementResult(FirstLetter),
|
||||
"before" => Ok(Some(SimpleSelectorParseResult::PseudoElement(PseudoElement::Before))),
|
||||
"after" => Ok(Some(SimpleSelectorParseResult::PseudoElement(PseudoElement::After))),
|
||||
// "first-line" => SimpleSelectorParseResult::PseudoElement(FirstLine),
|
||||
// "first-letter" => SimpleSelectorParseResult::PseudoElement(FirstLetter),
|
||||
_ => Err(())
|
||||
}
|
||||
},
|
||||
Ok(result) => Ok(Some(SimpleSelectorResult(result))),
|
||||
Ok(result) => Ok(Some(SimpleSelectorParseResult::SimpleSelector(result))),
|
||||
},
|
||||
Some(Function(name, arguments))
|
||||
=> {
|
||||
Ok(Some(SimpleSelectorResult(try!(parse_functional_pseudo_class(
|
||||
Ok(Some(SimpleSelectorParseResult::SimpleSelector(try!(parse_functional_pseudo_class(
|
||||
context,
|
||||
name,
|
||||
arguments,
|
||||
|
@ -549,7 +584,7 @@ fn parse_one_simple_selector<I>(context: &ParserContext,
|
|||
Some(Colon) => {
|
||||
match iter.next() {
|
||||
Some(Ident(name))
|
||||
=> Ok(Some(PseudoElementResult(try!(parse_pseudo_element(name))))),
|
||||
=> Ok(Some(SimpleSelectorParseResult::PseudoElement(try!(parse_pseudo_element(name))))),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
@ -562,23 +597,23 @@ fn parse_one_simple_selector<I>(context: &ParserContext,
|
|||
|
||||
fn parse_simple_pseudo_class(context: &ParserContext, name: &str) -> Result<SimpleSelector,()> {
|
||||
match name.to_ascii_lower().as_slice() {
|
||||
"any-link" => Ok(AnyLink),
|
||||
"link" => Ok(Link),
|
||||
"visited" => Ok(Visited),
|
||||
"hover" => Ok(Hover),
|
||||
"disabled" => Ok(Disabled),
|
||||
"enabled" => Ok(Enabled),
|
||||
"checked" => Ok(Checked),
|
||||
"indeterminate" => Ok(Indeterminate),
|
||||
"first-child" => Ok(FirstChild),
|
||||
"last-child" => Ok(LastChild),
|
||||
"only-child" => Ok(OnlyChild),
|
||||
"root" => Ok(Root),
|
||||
"first-of-type" => Ok(FirstOfType),
|
||||
"last-of-type" => Ok(LastOfType),
|
||||
"only-of-type" => Ok(OnlyOfType),
|
||||
"-servo-nonzero-border" if context.origin == UserAgentOrigin => Ok(ServoNonzeroBorder),
|
||||
// "empty" => Ok(Empty),
|
||||
"any-link" => Ok(SimpleSelector::AnyLink),
|
||||
"link" => Ok(SimpleSelector::Link),
|
||||
"visited" => Ok(SimpleSelector::Visited),
|
||||
"hover" => Ok(SimpleSelector::Hover),
|
||||
"disabled" => Ok(SimpleSelector::Disabled),
|
||||
"enabled" => Ok(SimpleSelector::Enabled),
|
||||
"checked" => Ok(SimpleSelector::Checked),
|
||||
"indeterminate" => Ok(SimpleSelector::Indeterminate),
|
||||
"first-child" => Ok(SimpleSelector::FirstChild),
|
||||
"last-child" => Ok(SimpleSelector::LastChild),
|
||||
"only-child" => Ok(SimpleSelector::OnlyChild),
|
||||
"root" => Ok(SimpleSelector::Root),
|
||||
"first-of-type" => Ok(SimpleSelector::FirstOfType),
|
||||
"last-of-type" => Ok(SimpleSelector::LastOfType),
|
||||
"only-of-type" => Ok(SimpleSelector::OnlyOfType),
|
||||
"-servo-nonzero-border" if context.origin == StylesheetOrigin::UserAgent => Ok(SimpleSelector::ServoNonzeroBorder),
|
||||
// "empty" => Ok(Empty),
|
||||
_ => Err(())
|
||||
}
|
||||
}
|
||||
|
@ -586,8 +621,8 @@ fn parse_simple_pseudo_class(context: &ParserContext, name: &str) -> Result<Simp
|
|||
fn parse_pseudo_element(name: String) -> Result<PseudoElement, ()> {
|
||||
match name.as_slice().to_ascii_lower().as_slice() {
|
||||
// All supported pseudo-elements
|
||||
"before" => Ok(Before),
|
||||
"after" => Ok(After),
|
||||
"before" => Ok(PseudoElement::Before),
|
||||
"after" => Ok(PseudoElement::After),
|
||||
// "first-line" => Some(FirstLine),
|
||||
// "first-letter" => Some(FirstLetter),
|
||||
_ => Err(())
|
||||
|
@ -634,9 +669,11 @@ mod tests {
|
|||
use sync::Arc;
|
||||
use cssparser;
|
||||
use namespaces::NamespaceMap;
|
||||
use selector_matching::AuthorOrigin;
|
||||
use selector_matching::StylesheetOrigin;
|
||||
use string_cache::Atom;
|
||||
use super::*;
|
||||
use super::SimpleSelector::*;
|
||||
use super::PseudoElement::*;
|
||||
|
||||
fn parse(input: &str) -> Result<Vec<Selector>, ()> {
|
||||
parse_ns(input, &NamespaceMap::new())
|
||||
|
@ -644,7 +681,7 @@ mod tests {
|
|||
|
||||
fn parse_ns(input: &str, namespaces: &NamespaceMap) -> Result<Vec<Selector>, ()> {
|
||||
let context = ParserContext {
|
||||
origin: AuthorOrigin,
|
||||
origin: StylesheetOrigin::Author,
|
||||
};
|
||||
parse_selector_list(&context, cssparser::tokenize(input).map(|(v, _)| v), namespaces)
|
||||
}
|
||||
|
@ -658,7 +695,7 @@ mod tests {
|
|||
assert!(parse("") == Err(()))
|
||||
assert!(parse("EeÉ") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalName {
|
||||
simple_selectors: vec!(SimpleSelector::LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice("EeÉ"),
|
||||
lower_name: Atom::from_slice("eeÉ") })),
|
||||
next: None,
|
||||
|
@ -668,7 +705,7 @@ mod tests {
|
|||
})))
|
||||
assert!(parse(".foo") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(ClassSelector(Atom::from_slice("foo"))),
|
||||
simple_selectors: vec!(SimpleSelector::ClassSelector(Atom::from_slice("foo"))),
|
||||
next: None,
|
||||
}),
|
||||
pseudo_element: None,
|
||||
|
@ -676,7 +713,7 @@ mod tests {
|
|||
})))
|
||||
assert!(parse("#bar") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(IDSelector(Atom::from_slice("bar"))),
|
||||
simple_selectors: vec!(SimpleSelector::IDSelector(Atom::from_slice("bar"))),
|
||||
next: None,
|
||||
}),
|
||||
pseudo_element: None,
|
||||
|
@ -684,11 +721,11 @@ mod tests {
|
|||
})))
|
||||
assert!(parse("e.foo#bar") == Ok(vec!(Selector {
|
||||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalName {
|
||||
simple_selectors: vec!(SimpleSelector::LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice("e"),
|
||||
lower_name: Atom::from_slice("e") }),
|
||||
ClassSelector(Atom::from_slice("foo")),
|
||||
IDSelector(Atom::from_slice("bar"))),
|
||||
SimpleSelector::ClassSelector(Atom::from_slice("foo")),
|
||||
SimpleSelector::IDSelector(Atom::from_slice("bar"))),
|
||||
next: None,
|
||||
}),
|
||||
pseudo_element: None,
|
||||
|
@ -698,12 +735,12 @@ mod tests {
|
|||
compound_selectors: Arc::new(CompoundSelector {
|
||||
simple_selectors: vec!(IDSelector(Atom::from_slice("bar"))),
|
||||
next: Some((box CompoundSelector {
|
||||
simple_selectors: vec!(LocalNameSelector(LocalName {
|
||||
simple_selectors: vec!(SimpleSelector::LocalNameSelector(LocalName {
|
||||
name: Atom::from_slice("e"),
|
||||
lower_name: Atom::from_slice("e") }),
|
||||
ClassSelector(Atom::from_slice("foo"))),
|
||||
SimpleSelector::ClassSelector(Atom::from_slice("foo"))),
|
||||
next: None,
|
||||
}, Descendant)),
|
||||
}, Combinator::Descendant)),
|
||||
}),
|
||||
pseudo_element: None,
|
||||
specificity: specificity(1, 1, 1),
|
||||
|
@ -716,7 +753,7 @@ mod tests {
|
|||
simple_selectors: vec!(AttrExists(AttrSelector {
|
||||
name: Atom::from_slice("Foo"),
|
||||
lower_name: Atom::from_slice("foo"),
|
||||
namespace: SpecificNamespace(ns!("")),
|
||||
namespace: NamespaceConstraint::Specific(ns!("")),
|
||||
})),
|
||||
next: None,
|
||||
}),
|
||||
|
@ -731,7 +768,7 @@ mod tests {
|
|||
simple_selectors: vec!(AttrExists(AttrSelector {
|
||||
name: Atom::from_slice("Foo"),
|
||||
lower_name: Atom::from_slice("foo"),
|
||||
namespace: SpecificNamespace(ns!("")),
|
||||
namespace: NamespaceConstraint::Specific(ns!("")),
|
||||
})),
|
||||
next: None,
|
||||
}),
|
||||
|
@ -769,7 +806,7 @@ mod tests {
|
|||
name: atom!("div"),
|
||||
lower_name: atom!("div") })),
|
||||
next: None,
|
||||
}, Descendant)),
|
||||
}, Combinator::Descendant)),
|
||||
}),
|
||||
pseudo_element: Some(After),
|
||||
specificity: specificity(0, 0, 2),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue