mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
commit
1f342638c4
7 changed files with 53 additions and 58 deletions
|
@ -559,10 +559,10 @@ impl<'ln> MatchMethods for LayoutNode<'ln> {
|
||||||
|
|
||||||
|
|
||||||
// In terms of `SimpleSelector`s, these two functions will insert and remove:
|
// In terms of `SimpleSelector`s, these two functions will insert and remove:
|
||||||
// - `LocalNameSelector`
|
// - `SimpleSelector::LocalName`
|
||||||
// - `NamepaceSelector`
|
// - `SimpleSelector::Namepace`
|
||||||
// - `IDSelector`
|
// - `SimpleSelector::ID`
|
||||||
// - `ClassSelector`
|
// - `SimpleSelector::Class`
|
||||||
|
|
||||||
fn insert_into_bloom_filter(&self, bf: &mut BloomFilter) {
|
fn insert_into_bloom_filter(&self, bf: &mut BloomFilter) {
|
||||||
// Only elements are interesting.
|
// Only elements are interesting.
|
||||||
|
|
|
@ -39,7 +39,7 @@ impl TableCellFlow {
|
||||||
-> TableCellFlow {
|
-> TableCellFlow {
|
||||||
TableCellFlow {
|
TableCellFlow {
|
||||||
block_flow: BlockFlow::from_node_and_fragment(node, fragment),
|
block_flow: BlockFlow::from_node_and_fragment(node, fragment),
|
||||||
column_span: node.get_unsigned_integer_attribute(UnsignedIntegerAttribute::ColSpanUnsignedIntegerAttribute)
|
column_span: node.get_unsigned_integer_attribute(UnsignedIntegerAttribute::ColSpan)
|
||||||
.unwrap_or(1),
|
.unwrap_or(1),
|
||||||
visible: visible,
|
visible: visible,
|
||||||
}
|
}
|
||||||
|
|
|
@ -594,7 +594,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
|
||||||
fn has_nonzero_border(self) -> bool {
|
fn has_nonzero_border(self) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
match self.element
|
match self.element
|
||||||
.get_unsigned_integer_attribute_for_layout(UnsignedIntegerAttribute::BorderUnsignedIntegerAttribute) {
|
.get_unsigned_integer_attribute_for_layout(UnsignedIntegerAttribute::Border) {
|
||||||
None | Some(0) => false,
|
None | Some(0) => false,
|
||||||
_ => true,
|
_ => true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,7 +369,7 @@ impl RawLayoutElementHelpers for Element {
|
||||||
attribute: UnsignedIntegerAttribute)
|
attribute: UnsignedIntegerAttribute)
|
||||||
-> Option<u32> {
|
-> Option<u32> {
|
||||||
match attribute {
|
match attribute {
|
||||||
UnsignedIntegerAttribute::BorderUnsignedIntegerAttribute => {
|
UnsignedIntegerAttribute::Border => {
|
||||||
if self.is_htmltableelement() {
|
if self.is_htmltableelement() {
|
||||||
let this: &HTMLTableElement = mem::transmute(self);
|
let this: &HTMLTableElement = mem::transmute(self);
|
||||||
this.get_border()
|
this.get_border()
|
||||||
|
@ -379,7 +379,7 @@ impl RawLayoutElementHelpers for Element {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UnsignedIntegerAttribute::ColSpanUnsignedIntegerAttribute => {
|
UnsignedIntegerAttribute::ColSpan => {
|
||||||
if self.is_htmltablecellelement() {
|
if self.is_htmltablecellelement() {
|
||||||
let this: &HTMLTableCellElement = mem::transmute(self);
|
let this: &HTMLTableCellElement = mem::transmute(self);
|
||||||
this.get_colspan()
|
this.get_colspan()
|
||||||
|
@ -397,7 +397,7 @@ impl RawLayoutElementHelpers for Element {
|
||||||
unsafe fn get_simple_color_attribute_for_layout(&self, attribute: SimpleColorAttribute)
|
unsafe fn get_simple_color_attribute_for_layout(&self, attribute: SimpleColorAttribute)
|
||||||
-> Option<RGBA> {
|
-> Option<RGBA> {
|
||||||
match attribute {
|
match attribute {
|
||||||
SimpleColorAttribute::BgColorSimpleColorAttribute => {
|
SimpleColorAttribute::BgColor => {
|
||||||
if self.is_htmlbodyelement() {
|
if self.is_htmlbodyelement() {
|
||||||
let this: &HTMLBodyElement = mem::transmute(self);
|
let this: &HTMLBodyElement = mem::transmute(self);
|
||||||
this.get_background_color()
|
this.get_background_color()
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
//! Legacy presentational attributes defined in the HTML5 specification: `<td width>`,
|
//! Legacy presentational attributes defined in the HTML5 specification: `<td width>`,
|
||||||
//! `<input size>`, and so forth.
|
//! `<input size>`, and so forth.
|
||||||
|
|
||||||
use self::UnsignedIntegerAttribute::*;
|
|
||||||
use self::SimpleColorAttribute::*;
|
|
||||||
|
|
||||||
use node::{TElement, TElementAttributes, TNode};
|
use node::{TElement, TElementAttributes, TNode};
|
||||||
use properties::DeclaredValue::SpecifiedValue;
|
use properties::DeclaredValue::SpecifiedValue;
|
||||||
use properties::PropertyDeclaration::*;
|
use properties::PropertyDeclaration::*;
|
||||||
|
@ -36,15 +33,15 @@ pub enum IntegerAttribute {
|
||||||
/// Legacy presentational attributes that take a nonnegative integer as defined in HTML5 § 2.4.4.2.
|
/// Legacy presentational attributes that take a nonnegative integer as defined in HTML5 § 2.4.4.2.
|
||||||
pub enum UnsignedIntegerAttribute {
|
pub enum UnsignedIntegerAttribute {
|
||||||
/// `<td border>`
|
/// `<td border>`
|
||||||
BorderUnsignedIntegerAttribute,
|
Border,
|
||||||
/// `<td colspan>`
|
/// `<td colspan>`
|
||||||
ColSpanUnsignedIntegerAttribute,
|
ColSpan,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Legacy presentational attributes that take a simple color as defined in HTML5 § 2.4.6.
|
/// Legacy presentational attributes that take a simple color as defined in HTML5 § 2.4.6.
|
||||||
pub enum SimpleColorAttribute {
|
pub enum SimpleColorAttribute {
|
||||||
/// `<body bgcolor>`
|
/// `<body bgcolor>`
|
||||||
BgColorSimpleColorAttribute,
|
BgColor,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extension methods for `Stylist` that cause rules to be synthesized for legacy attributes.
|
/// Extension methods for `Stylist` that cause rules to be synthesized for legacy attributes.
|
||||||
|
@ -210,7 +207,7 @@ impl PresentationalHintSynthesis for Stylist {
|
||||||
TElementAttributes,
|
TElementAttributes,
|
||||||
V: VecLike<
|
V: VecLike<
|
||||||
DeclarationBlock> {
|
DeclarationBlock> {
|
||||||
match element.get_simple_color_attribute(BgColorSimpleColorAttribute) {
|
match element.get_simple_color_attribute(SimpleColorAttribute::BgColor) {
|
||||||
None => {}
|
None => {}
|
||||||
Some(color) => {
|
Some(color) => {
|
||||||
matching_rules_list.vec_push(DeclarationBlock::from_declaration(
|
matching_rules_list.vec_push(DeclarationBlock::from_declaration(
|
||||||
|
@ -229,7 +226,7 @@ impl PresentationalHintSynthesis for Stylist {
|
||||||
E: TElement<'a> +
|
E: TElement<'a> +
|
||||||
TElementAttributes,
|
TElementAttributes,
|
||||||
V: VecLike<DeclarationBlock> {
|
V: VecLike<DeclarationBlock> {
|
||||||
match element.get_unsigned_integer_attribute(BorderUnsignedIntegerAttribute) {
|
match element.get_unsigned_integer_attribute(UnsignedIntegerAttribute::Border) {
|
||||||
None => {}
|
None => {}
|
||||||
Some(length) => {
|
Some(length) => {
|
||||||
let width_value = specified::Length::Au(Au::from_px(length as int));
|
let width_value = specified::Length::Au(Au::from_px(length as int));
|
||||||
|
|
|
@ -222,7 +222,7 @@ impl SelectorMap {
|
||||||
match *ss {
|
match *ss {
|
||||||
// TODO(pradeep): Implement case-sensitivity based on the document type and quirks
|
// TODO(pradeep): Implement case-sensitivity based on the document type and quirks
|
||||||
// mode.
|
// mode.
|
||||||
SimpleSelector::IDSelector(ref id) => return Some(id.clone()),
|
SimpleSelector::ID(ref id) => return Some(id.clone()),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,7 +236,7 @@ impl SelectorMap {
|
||||||
match *ss {
|
match *ss {
|
||||||
// TODO(pradeep): Implement case-sensitivity based on the document type and quirks
|
// TODO(pradeep): Implement case-sensitivity based on the document type and quirks
|
||||||
// mode.
|
// mode.
|
||||||
SimpleSelector::ClassSelector(ref class) => return Some(class.clone()),
|
SimpleSelector::Class(ref class) => return Some(class.clone()),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -248,7 +248,7 @@ impl SelectorMap {
|
||||||
let simple_selector_sequence = &rule.selector.simple_selectors;
|
let simple_selector_sequence = &rule.selector.simple_selectors;
|
||||||
for ss in simple_selector_sequence.iter() {
|
for ss in simple_selector_sequence.iter() {
|
||||||
match *ss {
|
match *ss {
|
||||||
SimpleSelector::LocalNameSelector(ref name) => {
|
SimpleSelector::LocalName(ref name) => {
|
||||||
return Some(name.clone())
|
return Some(name.clone())
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -665,23 +665,23 @@ fn can_fast_reject<'a,E,N>(mut selector: &CompoundSelector,
|
||||||
|
|
||||||
for ss in selector.simple_selectors.iter() {
|
for ss in selector.simple_selectors.iter() {
|
||||||
match *ss {
|
match *ss {
|
||||||
SimpleSelector::LocalNameSelector(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);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SimpleSelector::NamespaceSelector(ref namespace) => {
|
SimpleSelector::Namespace(ref namespace) => {
|
||||||
if !bf.might_contain(namespace) {
|
if !bf.might_contain(namespace) {
|
||||||
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SimpleSelector::IDSelector(ref id) => {
|
SimpleSelector::ID(ref id) => {
|
||||||
if !bf.might_contain(id) {
|
if !bf.might_contain(id) {
|
||||||
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
SimpleSelector::ClassSelector(ref class) => {
|
SimpleSelector::Class(ref class) => {
|
||||||
if !bf.might_contain(class) {
|
if !bf.might_contain(class) {
|
||||||
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
return Some(SelectorMatchingResult::NotMatchedGlobally);
|
||||||
}
|
}
|
||||||
|
@ -830,25 +830,25 @@ pub fn matches_simple_selector<'a,E,N>(selector: &SimpleSelector,
|
||||||
-> bool
|
-> bool
|
||||||
where E: TElement<'a>, N: TNode<'a,E> {
|
where E: TElement<'a>, N: TNode<'a,E> {
|
||||||
match *selector {
|
match *selector {
|
||||||
SimpleSelector::LocalNameSelector(LocalName { ref name, ref lower_name }) => {
|
SimpleSelector::LocalName(LocalName { ref name, ref lower_name }) => {
|
||||||
let name = if element.is_html_element_in_html_document() { lower_name } else { name };
|
let name = if element.is_html_element_in_html_document() { lower_name } else { name };
|
||||||
let element = element.as_element();
|
let element = element.as_element();
|
||||||
element.get_local_name() == name
|
element.get_local_name() == name
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleSelector::NamespaceSelector(ref namespace) => {
|
SimpleSelector::Namespace(ref namespace) => {
|
||||||
let element = element.as_element();
|
let element = element.as_element();
|
||||||
element.get_namespace() == namespace
|
element.get_namespace() == namespace
|
||||||
}
|
}
|
||||||
// TODO: case-sensitivity depends on the document type and quirks mode
|
// TODO: case-sensitivity depends on the document type and quirks mode
|
||||||
SimpleSelector::IDSelector(ref id) => {
|
SimpleSelector::ID(ref id) => {
|
||||||
*shareable = false;
|
*shareable = false;
|
||||||
let element = element.as_element();
|
let element = element.as_element();
|
||||||
element.get_id().map_or(false, |attr| {
|
element.get_id().map_or(false, |attr| {
|
||||||
attr == *id
|
attr == *id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
SimpleSelector::ClassSelector(ref class) => {
|
SimpleSelector::Class(ref class) => {
|
||||||
let element = element.as_element();
|
let element = element.as_element();
|
||||||
element.has_class(class)
|
element.has_class(class)
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,10 +52,10 @@ pub enum Combinator {
|
||||||
|
|
||||||
#[deriving(Eq, PartialEq, Clone, Hash)]
|
#[deriving(Eq, PartialEq, Clone, Hash)]
|
||||||
pub enum SimpleSelector {
|
pub enum SimpleSelector {
|
||||||
IDSelector(Atom),
|
ID(Atom),
|
||||||
ClassSelector(Atom),
|
Class(Atom),
|
||||||
LocalNameSelector(LocalName),
|
LocalName(LocalName),
|
||||||
NamespaceSelector(Namespace),
|
Namespace(Namespace),
|
||||||
|
|
||||||
// Attribute selectors
|
// Attribute selectors
|
||||||
AttrExists(AttrSelector), // [foo]
|
AttrExists(AttrSelector), // [foo]
|
||||||
|
@ -162,11 +162,11 @@ fn compute_specificity(mut selector: &CompoundSelector,
|
||||||
specificity: &mut Specificity) {
|
specificity: &mut Specificity) {
|
||||||
for simple_selector in simple_selectors.iter() {
|
for simple_selector in simple_selectors.iter() {
|
||||||
match simple_selector {
|
match simple_selector {
|
||||||
&SimpleSelector::LocalNameSelector(..) =>
|
&SimpleSelector::LocalName(..) =>
|
||||||
specificity.element_selectors += 1,
|
specificity.element_selectors += 1,
|
||||||
&SimpleSelector::IDSelector(..) =>
|
&SimpleSelector::ID(..) =>
|
||||||
specificity.id_selectors += 1,
|
specificity.id_selectors += 1,
|
||||||
&SimpleSelector::ClassSelector(..) |
|
&SimpleSelector::Class(..) |
|
||||||
&SimpleSelector::AttrExists(..) |
|
&SimpleSelector::AttrExists(..) |
|
||||||
&SimpleSelector::AttrEqual(..) |
|
&SimpleSelector::AttrEqual(..) |
|
||||||
&SimpleSelector::AttrIncludes(..) |
|
&SimpleSelector::AttrIncludes(..) |
|
||||||
|
@ -190,7 +190,7 @@ fn compute_specificity(mut selector: &CompoundSelector,
|
||||||
&SimpleSelector::OnlyOfType |
|
&SimpleSelector::OnlyOfType |
|
||||||
&SimpleSelector::ServoNonzeroBorder =>
|
&SimpleSelector::ServoNonzeroBorder =>
|
||||||
specificity.class_like_selectors += 1,
|
specificity.class_like_selectors += 1,
|
||||||
&SimpleSelector::NamespaceSelector(..) => (),
|
&SimpleSelector::Namespace(..) => (),
|
||||||
&SimpleSelector::Negation(ref negated) =>
|
&SimpleSelector::Negation(ref negated) =>
|
||||||
simple_selectors_specificity(negated.as_slice(), specificity),
|
simple_selectors_specificity(negated.as_slice(), specificity),
|
||||||
}
|
}
|
||||||
|
@ -218,13 +218,13 @@ fn parse_type_selector<I: Iterator<ComponentValue>>(
|
||||||
let mut simple_selectors = vec!();
|
let mut simple_selectors = vec!();
|
||||||
match namespace {
|
match namespace {
|
||||||
NamespaceConstraint::Specific(ns) => {
|
NamespaceConstraint::Specific(ns) => {
|
||||||
simple_selectors.push(SimpleSelector::NamespaceSelector(ns))
|
simple_selectors.push(SimpleSelector::Namespace(ns))
|
||||||
},
|
},
|
||||||
NamespaceConstraint::Any => (),
|
NamespaceConstraint::Any => (),
|
||||||
}
|
}
|
||||||
match local_name {
|
match local_name {
|
||||||
Some(name) => {
|
Some(name) => {
|
||||||
simple_selectors.push(SimpleSelector::LocalNameSelector(LocalName {
|
simple_selectors.push(SimpleSelector::LocalName(LocalName {
|
||||||
name: Atom::from_slice(name.as_slice()),
|
name: Atom::from_slice(name.as_slice()),
|
||||||
lower_name: Atom::from_slice(name.into_ascii_lower().as_slice())
|
lower_name: Atom::from_slice(name.into_ascii_lower().as_slice())
|
||||||
}))
|
}))
|
||||||
|
@ -539,14 +539,14 @@ fn parse_one_simple_selector<I>(context: &ParserContext,
|
||||||
match iter.peek() {
|
match iter.peek() {
|
||||||
Some(&IDHash(_)) => match iter.next() {
|
Some(&IDHash(_)) => match iter.next() {
|
||||||
Some(IDHash(id)) => Ok(Some(SimpleSelectorParseResult::SimpleSelector(
|
Some(IDHash(id)) => Ok(Some(SimpleSelectorParseResult::SimpleSelector(
|
||||||
SimpleSelector::IDSelector(Atom::from_slice(id.as_slice()))))),
|
SimpleSelector::ID(Atom::from_slice(id.as_slice()))))),
|
||||||
_ => panic!("Implementation error, this should not happen."),
|
_ => panic!("Implementation error, this should not happen."),
|
||||||
},
|
},
|
||||||
Some(&Delim('.')) => {
|
Some(&Delim('.')) => {
|
||||||
iter.next();
|
iter.next();
|
||||||
match iter.next() {
|
match iter.next() {
|
||||||
Some(Ident(class)) => Ok(Some(SimpleSelectorParseResult::SimpleSelector(
|
Some(Ident(class)) => Ok(Some(SimpleSelectorParseResult::SimpleSelector(
|
||||||
SimpleSelector::ClassSelector(Atom::from_slice(class.as_slice()))))),
|
SimpleSelector::Class(Atom::from_slice(class.as_slice()))))),
|
||||||
_ => Err(()),
|
_ => Err(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -672,8 +672,6 @@ mod tests {
|
||||||
use selector_matching::StylesheetOrigin;
|
use selector_matching::StylesheetOrigin;
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
use super::*;
|
use super::*;
|
||||||
use super::SimpleSelector::*;
|
|
||||||
use super::PseudoElement::*;
|
|
||||||
|
|
||||||
fn parse(input: &str) -> Result<Vec<Selector>, ()> {
|
fn parse(input: &str) -> Result<Vec<Selector>, ()> {
|
||||||
parse_ns(input, &NamespaceMap::new())
|
parse_ns(input, &NamespaceMap::new())
|
||||||
|
@ -695,7 +693,7 @@ mod tests {
|
||||||
assert!(parse("") == Err(()))
|
assert!(parse("") == Err(()))
|
||||||
assert!(parse("EeÉ") == Ok(vec!(Selector {
|
assert!(parse("EeÉ") == Ok(vec!(Selector {
|
||||||
compound_selectors: Arc::new(CompoundSelector {
|
compound_selectors: Arc::new(CompoundSelector {
|
||||||
simple_selectors: vec!(SimpleSelector::LocalNameSelector(LocalName {
|
simple_selectors: vec!(SimpleSelector::LocalName(LocalName {
|
||||||
name: Atom::from_slice("EeÉ"),
|
name: Atom::from_slice("EeÉ"),
|
||||||
lower_name: Atom::from_slice("eeÉ") })),
|
lower_name: Atom::from_slice("eeÉ") })),
|
||||||
next: None,
|
next: None,
|
||||||
|
@ -705,7 +703,7 @@ mod tests {
|
||||||
})))
|
})))
|
||||||
assert!(parse(".foo") == Ok(vec!(Selector {
|
assert!(parse(".foo") == Ok(vec!(Selector {
|
||||||
compound_selectors: Arc::new(CompoundSelector {
|
compound_selectors: Arc::new(CompoundSelector {
|
||||||
simple_selectors: vec!(SimpleSelector::ClassSelector(Atom::from_slice("foo"))),
|
simple_selectors: vec!(SimpleSelector::Class(Atom::from_slice("foo"))),
|
||||||
next: None,
|
next: None,
|
||||||
}),
|
}),
|
||||||
pseudo_element: None,
|
pseudo_element: None,
|
||||||
|
@ -713,7 +711,7 @@ mod tests {
|
||||||
})))
|
})))
|
||||||
assert!(parse("#bar") == Ok(vec!(Selector {
|
assert!(parse("#bar") == Ok(vec!(Selector {
|
||||||
compound_selectors: Arc::new(CompoundSelector {
|
compound_selectors: Arc::new(CompoundSelector {
|
||||||
simple_selectors: vec!(SimpleSelector::IDSelector(Atom::from_slice("bar"))),
|
simple_selectors: vec!(SimpleSelector::ID(Atom::from_slice("bar"))),
|
||||||
next: None,
|
next: None,
|
||||||
}),
|
}),
|
||||||
pseudo_element: None,
|
pseudo_element: None,
|
||||||
|
@ -721,11 +719,11 @@ mod tests {
|
||||||
})))
|
})))
|
||||||
assert!(parse("e.foo#bar") == Ok(vec!(Selector {
|
assert!(parse("e.foo#bar") == Ok(vec!(Selector {
|
||||||
compound_selectors: Arc::new(CompoundSelector {
|
compound_selectors: Arc::new(CompoundSelector {
|
||||||
simple_selectors: vec!(SimpleSelector::LocalNameSelector(LocalName {
|
simple_selectors: vec!(SimpleSelector::LocalName(LocalName {
|
||||||
name: Atom::from_slice("e"),
|
name: Atom::from_slice("e"),
|
||||||
lower_name: Atom::from_slice("e") }),
|
lower_name: Atom::from_slice("e") }),
|
||||||
SimpleSelector::ClassSelector(Atom::from_slice("foo")),
|
SimpleSelector::Class(Atom::from_slice("foo")),
|
||||||
SimpleSelector::IDSelector(Atom::from_slice("bar"))),
|
SimpleSelector::ID(Atom::from_slice("bar"))),
|
||||||
next: None,
|
next: None,
|
||||||
}),
|
}),
|
||||||
pseudo_element: None,
|
pseudo_element: None,
|
||||||
|
@ -733,12 +731,12 @@ mod tests {
|
||||||
})))
|
})))
|
||||||
assert!(parse("e.foo #bar") == Ok(vec!(Selector {
|
assert!(parse("e.foo #bar") == Ok(vec!(Selector {
|
||||||
compound_selectors: Arc::new(CompoundSelector {
|
compound_selectors: Arc::new(CompoundSelector {
|
||||||
simple_selectors: vec!(IDSelector(Atom::from_slice("bar"))),
|
simple_selectors: vec!(SimpleSelector::ID(Atom::from_slice("bar"))),
|
||||||
next: Some((box CompoundSelector {
|
next: Some((box CompoundSelector {
|
||||||
simple_selectors: vec!(SimpleSelector::LocalNameSelector(LocalName {
|
simple_selectors: vec!(SimpleSelector::LocalName(LocalName {
|
||||||
name: Atom::from_slice("e"),
|
name: Atom::from_slice("e"),
|
||||||
lower_name: Atom::from_slice("e") }),
|
lower_name: Atom::from_slice("e") }),
|
||||||
SimpleSelector::ClassSelector(Atom::from_slice("foo"))),
|
SimpleSelector::Class(Atom::from_slice("foo"))),
|
||||||
next: None,
|
next: None,
|
||||||
}, Combinator::Descendant)),
|
}, Combinator::Descendant)),
|
||||||
}),
|
}),
|
||||||
|
@ -750,7 +748,7 @@ mod tests {
|
||||||
let mut namespaces = NamespaceMap::new();
|
let mut namespaces = NamespaceMap::new();
|
||||||
assert!(parse_ns("[Foo]", &namespaces) == Ok(vec!(Selector {
|
assert!(parse_ns("[Foo]", &namespaces) == Ok(vec!(Selector {
|
||||||
compound_selectors: Arc::new(CompoundSelector {
|
compound_selectors: Arc::new(CompoundSelector {
|
||||||
simple_selectors: vec!(AttrExists(AttrSelector {
|
simple_selectors: vec!(SimpleSelector::AttrExists(AttrSelector {
|
||||||
name: Atom::from_slice("Foo"),
|
name: Atom::from_slice("Foo"),
|
||||||
lower_name: Atom::from_slice("foo"),
|
lower_name: Atom::from_slice("foo"),
|
||||||
namespace: NamespaceConstraint::Specific(ns!("")),
|
namespace: NamespaceConstraint::Specific(ns!("")),
|
||||||
|
@ -765,7 +763,7 @@ mod tests {
|
||||||
namespaces.default = Some(ns!(MathML));
|
namespaces.default = Some(ns!(MathML));
|
||||||
assert!(parse_ns("[Foo]", &namespaces) == Ok(vec!(Selector {
|
assert!(parse_ns("[Foo]", &namespaces) == Ok(vec!(Selector {
|
||||||
compound_selectors: Arc::new(CompoundSelector {
|
compound_selectors: Arc::new(CompoundSelector {
|
||||||
simple_selectors: vec!(AttrExists(AttrSelector {
|
simple_selectors: vec!(SimpleSelector::AttrExists(AttrSelector {
|
||||||
name: Atom::from_slice("Foo"),
|
name: Atom::from_slice("Foo"),
|
||||||
lower_name: Atom::from_slice("foo"),
|
lower_name: Atom::from_slice("foo"),
|
||||||
namespace: NamespaceConstraint::Specific(ns!("")),
|
namespace: NamespaceConstraint::Specific(ns!("")),
|
||||||
|
@ -779,8 +777,8 @@ mod tests {
|
||||||
assert!(parse_ns("e", &namespaces) == Ok(vec!(Selector {
|
assert!(parse_ns("e", &namespaces) == Ok(vec!(Selector {
|
||||||
compound_selectors: Arc::new(CompoundSelector {
|
compound_selectors: Arc::new(CompoundSelector {
|
||||||
simple_selectors: vec!(
|
simple_selectors: vec!(
|
||||||
NamespaceSelector(ns!(MathML)),
|
SimpleSelector::Namespace(ns!(MathML)),
|
||||||
LocalNameSelector(LocalName {
|
SimpleSelector::LocalName(LocalName {
|
||||||
name: Atom::from_slice("e"),
|
name: Atom::from_slice("e"),
|
||||||
lower_name: Atom::from_slice("e") }),
|
lower_name: Atom::from_slice("e") }),
|
||||||
),
|
),
|
||||||
|
@ -795,20 +793,20 @@ mod tests {
|
||||||
simple_selectors: vec!(),
|
simple_selectors: vec!(),
|
||||||
next: None,
|
next: None,
|
||||||
}),
|
}),
|
||||||
pseudo_element: Some(Before),
|
pseudo_element: Some(PseudoElement::Before),
|
||||||
specificity: specificity(0, 0, 1),
|
specificity: specificity(0, 0, 1),
|
||||||
})))
|
})))
|
||||||
assert!(parse("div :after") == Ok(vec!(Selector {
|
assert!(parse("div :after") == Ok(vec!(Selector {
|
||||||
compound_selectors: Arc::new(CompoundSelector {
|
compound_selectors: Arc::new(CompoundSelector {
|
||||||
simple_selectors: vec!(),
|
simple_selectors: vec!(),
|
||||||
next: Some((box CompoundSelector {
|
next: Some((box CompoundSelector {
|
||||||
simple_selectors: vec!(LocalNameSelector(LocalName {
|
simple_selectors: vec!(SimpleSelector::LocalName(LocalName {
|
||||||
name: atom!("div"),
|
name: atom!("div"),
|
||||||
lower_name: atom!("div") })),
|
lower_name: atom!("div") })),
|
||||||
next: None,
|
next: None,
|
||||||
}, Combinator::Descendant)),
|
}, Combinator::Descendant)),
|
||||||
}),
|
}),
|
||||||
pseudo_element: Some(After),
|
pseudo_element: Some(PseudoElement::After),
|
||||||
specificity: specificity(0, 0, 2),
|
specificity: specificity(0, 0, 2),
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue