diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-05-17 05:40:14 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-17 05:40:14 -0500 |
commit | d8b7013fcddff79a9c879077e1a564d83201359c (patch) | |
tree | 88a16d0317249297479192f769217f69a8b39895 /components/script/dom/node.rs | |
parent | a7b77306f985b79d3b8b4d9b2cb51fa38f45bd39 (diff) | |
parent | 522f8489d6fca474e6aad1d341ee84a99c130738 (diff) | |
download | servo-d8b7013fcddff79a9c879077e1a564d83201359c.tar.gz servo-d8b7013fcddff79a9c879077e1a564d83201359c.zip |
Auto merge of #16900 - emilio:pseudos, r=bholley
Bug 1364850: Move PseudoElement to be just another combinator in selectors. r=bholley
On top of https://github.com/servo/servo/pull/16890.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16900)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 8c8831801ef..1ad28974f3d 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -70,7 +70,7 @@ use script_layout_interface::{LayoutElementType, LayoutNodeType, TrustedNodeAddr use script_layout_interface::message::Msg; use script_traits::DocumentActivity; use script_traits::UntrustedNodeAddress; -use selectors::matching::matches_selector_list; +use selectors::matching::{matches_selector_list, MatchingContext, MatchingMode}; use selectors::parser::SelectorList; use servo_url::ServoUrl; use std::borrow::ToOwned; @@ -346,11 +346,14 @@ impl<'a> Iterator for QuerySelectorIterator { fn next(&mut self) -> Option<Root<Node>> { let selectors = &self.selectors.0; + // TODO(cgaebel): Is it worth it to build a bloom filter here // (instead of passing `None`)? Probably. + let mut ctx = MatchingContext::new(MatchingMode::Normal, None); + self.iterator.by_ref().filter_map(|node| { if let Some(element) = Root::downcast(node) { - if matches_selector_list(selectors, &element, None) { + if matches_selector_list(selectors, &element, &mut ctx) { return Some(Root::upcast(element)); } } @@ -717,8 +720,9 @@ impl Node { Err(()) => Err(Error::Syntax), // Step 3. Ok(selectors) => { + let mut ctx = MatchingContext::new(MatchingMode::Normal, None); Ok(self.traverse_preorder().filter_map(Root::downcast).find(|element| { - matches_selector_list(&selectors.0, element, None) + matches_selector_list(&selectors.0, element, &mut ctx) })) } } |