mirror of
https://github.com/servo/servo.git
synced 2025-06-19 14:48:59 +01:00
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 -->
This commit is contained in:
commit
d8b7013fcd
19 changed files with 675 additions and 541 deletions
|
@ -86,7 +86,7 @@ use net_traits::request::CorsSettings;
|
|||
use ref_filter_map::ref_filter_map;
|
||||
use script_layout_interface::message::ReflowQueryType;
|
||||
use script_thread::Runnable;
|
||||
use selectors::matching::{ElementSelectorFlags, MatchingContext, matches_selector_list};
|
||||
use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode, matches_selector_list};
|
||||
use selectors::matching::{HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS};
|
||||
use selectors::parser::{AttrSelector, NamespaceConstraint};
|
||||
use servo_atoms::Atom;
|
||||
|
@ -104,7 +104,7 @@ use style::properties::{Importance, PropertyDeclaration, PropertyDeclarationBloc
|
|||
use style::properties::longhands::{self, background_image, border_spacing, font_family, font_size, overflow_x};
|
||||
use style::restyle_hints::RESTYLE_SELF;
|
||||
use style::rule_tree::CascadeLevel;
|
||||
use style::selector_parser::{NonTSPseudoClass, RestyleDamage, SelectorImpl, SelectorParser};
|
||||
use style::selector_parser::{NonTSPseudoClass, PseudoElement, RestyleDamage, SelectorImpl, SelectorParser};
|
||||
use style::shared_lock::{SharedRwLock, Locked};
|
||||
use style::sink::Push;
|
||||
use style::stylearc::Arc;
|
||||
|
@ -2058,7 +2058,8 @@ impl ElementMethods for Element {
|
|||
match SelectorParser::parse_author_origin_no_namespace(&selectors) {
|
||||
Err(()) => Err(Error::Syntax),
|
||||
Ok(selectors) => {
|
||||
Ok(matches_selector_list(&selectors.0, &Root::from_ref(self), None))
|
||||
let mut ctx = MatchingContext::new(MatchingMode::Normal, None);
|
||||
Ok(matches_selector_list(&selectors.0, &Root::from_ref(self), &mut ctx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2076,8 +2077,8 @@ impl ElementMethods for Element {
|
|||
let root = self.upcast::<Node>();
|
||||
for element in root.inclusive_ancestors() {
|
||||
if let Some(element) = Root::downcast::<Element>(element) {
|
||||
if matches_selector_list(&selectors.0, &element, None)
|
||||
{
|
||||
let mut ctx = MatchingContext::new(MatchingMode::Normal, None);
|
||||
if matches_selector_list(&selectors.0, &element, &mut ctx) {
|
||||
return Ok(Some(element));
|
||||
}
|
||||
}
|
||||
|
@ -2386,6 +2387,15 @@ impl<'a> ::selectors::Element for Root<Element> {
|
|||
self.upcast::<Node>().GetParentElement()
|
||||
}
|
||||
|
||||
fn match_pseudo_element(&self,
|
||||
_pseudo: &PseudoElement,
|
||||
_context: &mut MatchingContext)
|
||||
-> bool
|
||||
{
|
||||
false
|
||||
}
|
||||
|
||||
|
||||
fn first_child_element(&self) -> Option<Root<Element>> {
|
||||
self.node.child_elements().next()
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -652,6 +652,14 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> {
|
|||
self.element.namespace()
|
||||
}
|
||||
|
||||
fn match_pseudo_element(&self,
|
||||
_pseudo: &PseudoElement,
|
||||
_context: &mut MatchingContext)
|
||||
-> bool
|
||||
{
|
||||
false
|
||||
}
|
||||
|
||||
fn match_non_ts_pseudo_class<F>(&self,
|
||||
pseudo_class: &NonTSPseudoClass,
|
||||
_: &mut MatchingContext,
|
||||
|
@ -1150,6 +1158,14 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> {
|
|||
self.element.get_namespace()
|
||||
}
|
||||
|
||||
fn match_pseudo_element(&self,
|
||||
_pseudo: &PseudoElement,
|
||||
_context: &mut MatchingContext)
|
||||
-> bool
|
||||
{
|
||||
false
|
||||
}
|
||||
|
||||
fn match_non_ts_pseudo_class<F>(&self,
|
||||
_: &NonTSPseudoClass,
|
||||
_: &mut MatchingContext,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue