diff --git a/components/style/dom.rs b/components/style/dom.rs index ed8b52f02ef..1733b580184 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -20,8 +20,8 @@ use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock}; #[cfg(feature = "gecko")] use properties::LonghandId; #[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue; use rule_tree::CascadeLevel; -use selector_parser::{AttrValue, ElementExt}; -use selector_parser::{PseudoClassStringArg, PseudoElement}; +use selector_parser::{AttrValue, PseudoClassStringArg, PseudoElement, SelectorImpl}; +use selectors::Element as SelectorsElement; use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode}; use selectors::sink::Push; use servo_arc::{Arc, ArcBorrow}; @@ -242,8 +242,17 @@ pub trait PresentationalHintsSynthesizer { } /// The element trait, the main abstraction the style crate acts over. -pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + - ElementExt + PresentationalHintsSynthesizer { +pub trait TElement + : Eq + + PartialEq + + Debug + + Hash + + Sized + + Copy + + Clone + + SelectorsElement + + PresentationalHintsSynthesizer +{ /// The concrete node type. type ConcreteNode: TNode; @@ -263,6 +272,11 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone + /// font-size used for rem units. fn owner_doc_matches_for_testing(&self, _: &Device) -> bool { true } + /// Whether this element should match user and author rules. + /// + /// We use this for Native Anonymous Content in Gecko. + fn matches_user_and_author_rules(&self) -> bool { true } + /// Returns the depth of this element in the DOM. fn depth(&self) -> usize { let mut depth = 0; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 052fb627f9e..e259422c629 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -75,7 +75,7 @@ use properties::animated_properties::{AnimationValue, AnimationValueMap}; use properties::animated_properties::TransitionProperty; use properties::style_structs::Font; use rule_tree::CascadeLevel as ServoCascadeLevel; -use selector_parser::{AttrValue, ElementExt, PseudoClassStringArg}; +use selector_parser::{AttrValue, PseudoClassStringArg}; use selectors::{Element, OpaqueElement}; use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator, CaseSensitivity, NamespaceConstraint}; use selectors::matching::{ElementSelectorFlags, MatchingContext}; @@ -1105,6 +1105,11 @@ impl<'le> TElement for GeckoElement<'le> { self.flags() & (NODE_IS_NATIVE_ANONYMOUS as u32) != 0 } + #[inline] + fn matches_user_and_author_rules(&self) -> bool { + !self.is_in_native_anonymous_subtree() + } + fn implemented_pseudo_element(&self) -> Option { if !self.is_native_anonymous() { return None; @@ -2069,10 +2074,3 @@ impl<'a> NamespaceConstraintHelpers for NamespaceConstraint<&'a Namespace> { } } } - -impl<'le> ElementExt for GeckoElement<'le> { - #[inline] - fn matches_user_and_author_rules(&self) -> bool { - !self.is_in_native_anonymous_subtree() - } -} diff --git a/components/style/selector_parser.rs b/components/style/selector_parser.rs index 316f360daf8..85b4d09d758 100644 --- a/components/style/selector_parser.rs +++ b/components/style/selector_parser.rs @@ -7,7 +7,6 @@ #![deny(missing_docs)] use cssparser::{Parser as CssParser, ParserInput}; -use selectors::Element; use selectors::parser::SelectorList; use std::fmt::{self, Debug}; use style_traits::ParseError; @@ -103,14 +102,6 @@ pub enum PseudoElementCascadeType { Precomputed, } -/// An extension to rust-selector's `Element` trait. -pub trait ElementExt: Element + Debug { - /// Whether this element should match user and author rules. - /// - /// We use this for Native Anonymous Content in Gecko. - fn matches_user_and_author_rules(&self) -> bool; -} - /// A per-functional-pseudo map, from a given pseudo to a `T`. #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index 887503f9a11..719e76f42f2 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -16,14 +16,12 @@ use invalidation::element::element_wrapper::ElementSnapshot; use properties::ComputedValues; use properties::PropertyFlags; use properties::longhands::display::computed_value as display; -use selector_parser::{AttrValue as SelectorAttrValue, ElementExt, PseudoElementCascadeType, SelectorParser}; -use selectors::Element; +use selector_parser::{AttrValue as SelectorAttrValue, PseudoElementCascadeType, SelectorParser}; use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity}; use selectors::parser::{SelectorMethods, SelectorParseErrorKind}; use selectors::visitor::SelectorVisitor; use std::ascii::AsciiExt; use std::fmt; -use std::fmt::Debug; use std::mem; use std::ops::{Deref, DerefMut}; use style_traits::{ParseError, StyleParseErrorKind}; @@ -715,13 +713,6 @@ impl ServoElementSnapshot { } } -impl + Debug> ElementExt for E { - #[inline] - fn matches_user_and_author_rules(&self) -> bool { - true - } -} - /// Returns whether the language is matched, as defined by /// [RFC 4647](https://tools.ietf.org/html/rfc4647#section-3.3.2). pub fn extended_filtering(tag: &str, range: &str) -> bool {