diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2016-11-21 19:11:35 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2016-11-22 14:50:21 +0100 |
commit | 82b13d50e356ff3fc0eb90b49258be321c7ea795 (patch) | |
tree | c7dee14c45289bb2b77a5e046defc0a2031587ad /components/script/dom | |
parent | a89ba50180532bc652db7ff649f252ffdca33177 (diff) | |
download | servo-82b13d50e356ff3fc0eb90b49258be321c7ea795.tar.gz servo-82b13d50e356ff3fc0eb90b49258be321c7ea795.zip |
Update to selectors 0.15
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/element.rs | 16 | ||||
-rw-r--r-- | components/script/dom/node.rs | 13 |
2 files changed, 14 insertions, 15 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index f162a1b56a0..a725bc83f42 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -73,7 +73,7 @@ use html5ever_atoms::{Prefix, LocalName, Namespace, QualName}; use parking_lot::RwLock; use selectors::matching::{ElementFlags, MatchingReason, matches}; use selectors::matching::{HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS}; -use selectors::parser::{AttrSelector, NamespaceConstraint, parse_author_origin_selector_list_from_str}; +use selectors::parser::{AttrSelector, NamespaceConstraint}; use servo_atoms::Atom; use std::ascii::AsciiExt; use std::borrow::Cow; @@ -92,7 +92,7 @@ use style::properties::{DeclaredValue, Importance}; use style::properties::{PropertyDeclaration, PropertyDeclarationBlock, parse_style_attribute}; use style::properties::longhands::{background_image, border_spacing, font_family, font_size, overflow_x}; use style::restyle_hints::RESTYLE_SELF; -use style::selector_parser::{NonTSPseudoClass, RestyleDamage, ServoSelectorImpl}; +use style::selector_parser::{NonTSPseudoClass, RestyleDamage, ServoSelectorImpl, SelectorParser}; use style::sink::Push; use style::stylist::ApplicableDeclarationBlock; use style::values::CSSFloat; @@ -1885,10 +1885,10 @@ impl ElementMethods for Element { // https://dom.spec.whatwg.org/#dom-element-matches fn Matches(&self, selectors: DOMString) -> Fallible<bool> { - match parse_author_origin_selector_list_from_str(&selectors) { + match SelectorParser::parse_author_origin_no_namespace(&selectors) { Err(()) => Err(Error::Syntax), - Ok(ref selectors) => { - Ok(matches(selectors, &Root::from_ref(self), None, MatchingReason::Other)) + Ok(selectors) => { + Ok(matches(&selectors.0, &Root::from_ref(self), None, MatchingReason::Other)) } } } @@ -1900,13 +1900,13 @@ impl ElementMethods for Element { // https://dom.spec.whatwg.org/#dom-element-closest fn Closest(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> { - match parse_author_origin_selector_list_from_str(&selectors) { + match SelectorParser::parse_author_origin_no_namespace(&selectors) { Err(()) => Err(Error::Syntax), - Ok(ref selectors) => { + Ok(selectors) => { let root = self.upcast::<Node>(); for element in root.inclusive_ancestors() { if let Some(element) = Root::downcast::<Element>(element) { - if matches(selectors, &element, None, MatchingReason::Other) { + if matches(&selectors.0, &element, None, MatchingReason::Other) { return Ok(Some(element)); } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 251d459335e..b128a4506b6 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -72,7 +72,6 @@ use script_layout_interface::message::Msg; use script_traits::UntrustedNodeAddress; use selectors::matching::{MatchingReason, matches}; use selectors::parser::Selector; -use selectors::parser::parse_author_origin_selector_list_from_str; use servo_url::ServoUrl; use std::borrow::ToOwned; use std::cell::{Cell, UnsafeCell}; @@ -83,7 +82,7 @@ use std::mem; use std::ops::Range; use std::sync::Arc; use style::dom::OpaqueNode; -use style::selector_parser::ServoSelectorImpl; +use style::selector_parser::{ServoSelectorImpl, SelectorParser}; use style::stylesheets::Stylesheet; use style::thread_state; use uuid::Uuid; @@ -690,13 +689,13 @@ impl Node { // https://dom.spec.whatwg.org/#dom-parentnode-queryselector pub fn query_selector(&self, selectors: DOMString) -> Fallible<Option<Root<Element>>> { // Step 1. - match parse_author_origin_selector_list_from_str(&selectors) { + match SelectorParser::parse_author_origin_no_namespace(&selectors) { // Step 2. Err(()) => Err(Error::Syntax), // Step 3. - Ok(ref selectors) => { + Ok(selectors) => { Ok(self.traverse_preorder().filter_map(Root::downcast).find(|element| { - matches(selectors, element, None, MatchingReason::Other) + matches(&selectors.0, element, None, MatchingReason::Other) })) } } @@ -709,7 +708,7 @@ impl Node { pub fn query_selector_iter(&self, selectors: DOMString) -> Fallible<QuerySelectorIterator> { // Step 1. - match parse_author_origin_selector_list_from_str(&selectors) { + match SelectorParser::parse_author_origin_no_namespace(&selectors) { // Step 2. Err(()) => Err(Error::Syntax), // Step 3. @@ -717,7 +716,7 @@ impl Node { let mut descendants = self.traverse_preorder(); // Skip the root of the tree. assert!(&*descendants.next().unwrap() == self); - Ok(QuerySelectorIterator::new(descendants, selectors)) + Ok(QuerySelectorIterator::new(descendants, selectors.0)) } } } |