Skip to content

Commit

Permalink
Auto merge of #18894 - emilio:bye-elementext, r=nox
Browse files Browse the repository at this point in the history
style: Remove the ElementExt trait.

It is likely it's the most useless trait ever existing.

<!-- 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/18894)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo committed Oct 16, 2017
2 parents a5100e3 + bfe230f commit 7d05c76
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 31 deletions.
22 changes: 18 additions & 4 deletions components/style/dom.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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<Impl = SelectorImpl>
+ PresentationalHintsSynthesizer
{
/// The concrete node type.
type ConcreteNode: TNode<ConcreteElement = Self>;

Expand All @@ -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;
Expand Down
14 changes: 6 additions & 8 deletions components/style/gecko/wrapper.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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<PseudoElement> {
if !self.is_native_anonymous() {
return None;
Expand Down Expand Up @@ -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()
}
}
9 changes: 0 additions & 9 deletions components/style/selector_parser.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -103,14 +102,6 @@ pub enum PseudoElementCascadeType {
Precomputed,
}

/// An extension to rust-selector's `Element` trait.
pub trait ElementExt: Element<Impl=SelectorImpl> + 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))]
Expand Down
11 changes: 1 addition & 10 deletions components/style/servo/selector_parser.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -715,13 +713,6 @@ impl ServoElementSnapshot {
}
}

impl<E: Element<Impl=SelectorImpl> + 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 {
Expand Down

0 comments on commit 7d05c76

Please sign in to comment.