mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Remove the ElementExt trait.
It is likely it's the most useless trait ever existing.
This commit is contained in:
parent
1e351ef8c4
commit
bfe230f3ed
4 changed files with 25 additions and 31 deletions
|
@ -20,8 +20,8 @@ use properties::{AnimationRules, ComputedValues, PropertyDeclarationBlock};
|
||||||
#[cfg(feature = "gecko")] use properties::LonghandId;
|
#[cfg(feature = "gecko")] use properties::LonghandId;
|
||||||
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue;
|
#[cfg(feature = "gecko")] use properties::animated_properties::AnimationValue;
|
||||||
use rule_tree::CascadeLevel;
|
use rule_tree::CascadeLevel;
|
||||||
use selector_parser::{AttrValue, ElementExt};
|
use selector_parser::{AttrValue, PseudoClassStringArg, PseudoElement, SelectorImpl};
|
||||||
use selector_parser::{PseudoClassStringArg, PseudoElement};
|
use selectors::Element as SelectorsElement;
|
||||||
use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode};
|
use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode};
|
||||||
use selectors::sink::Push;
|
use selectors::sink::Push;
|
||||||
use servo_arc::{Arc, ArcBorrow};
|
use servo_arc::{Arc, ArcBorrow};
|
||||||
|
@ -242,8 +242,17 @@ pub trait PresentationalHintsSynthesizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The element trait, the main abstraction the style crate acts over.
|
/// The element trait, the main abstraction the style crate acts over.
|
||||||
pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
|
pub trait TElement
|
||||||
ElementExt + PresentationalHintsSynthesizer {
|
: Eq
|
||||||
|
+ PartialEq
|
||||||
|
+ Debug
|
||||||
|
+ Hash
|
||||||
|
+ Sized
|
||||||
|
+ Copy
|
||||||
|
+ Clone
|
||||||
|
+ SelectorsElement<Impl = SelectorImpl>
|
||||||
|
+ PresentationalHintsSynthesizer
|
||||||
|
{
|
||||||
/// The concrete node type.
|
/// The concrete node type.
|
||||||
type ConcreteNode: TNode<ConcreteElement = Self>;
|
type ConcreteNode: TNode<ConcreteElement = Self>;
|
||||||
|
|
||||||
|
@ -263,6 +272,11 @@ pub trait TElement : Eq + PartialEq + Debug + Hash + Sized + Copy + Clone +
|
||||||
/// font-size used for rem units.
|
/// font-size used for rem units.
|
||||||
fn owner_doc_matches_for_testing(&self, _: &Device) -> bool { true }
|
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.
|
/// Returns the depth of this element in the DOM.
|
||||||
fn depth(&self) -> usize {
|
fn depth(&self) -> usize {
|
||||||
let mut depth = 0;
|
let mut depth = 0;
|
||||||
|
|
|
@ -75,7 +75,7 @@ use properties::animated_properties::{AnimationValue, AnimationValueMap};
|
||||||
use properties::animated_properties::TransitionProperty;
|
use properties::animated_properties::TransitionProperty;
|
||||||
use properties::style_structs::Font;
|
use properties::style_structs::Font;
|
||||||
use rule_tree::CascadeLevel as ServoCascadeLevel;
|
use rule_tree::CascadeLevel as ServoCascadeLevel;
|
||||||
use selector_parser::{AttrValue, ElementExt, PseudoClassStringArg};
|
use selector_parser::{AttrValue, PseudoClassStringArg};
|
||||||
use selectors::{Element, OpaqueElement};
|
use selectors::{Element, OpaqueElement};
|
||||||
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator, CaseSensitivity, NamespaceConstraint};
|
use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator, CaseSensitivity, NamespaceConstraint};
|
||||||
use selectors::matching::{ElementSelectorFlags, MatchingContext};
|
use selectors::matching::{ElementSelectorFlags, MatchingContext};
|
||||||
|
@ -1105,6 +1105,11 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
self.flags() & (NODE_IS_NATIVE_ANONYMOUS as u32) != 0
|
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> {
|
fn implemented_pseudo_element(&self) -> Option<PseudoElement> {
|
||||||
if !self.is_native_anonymous() {
|
if !self.is_native_anonymous() {
|
||||||
return None;
|
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use cssparser::{Parser as CssParser, ParserInput};
|
use cssparser::{Parser as CssParser, ParserInput};
|
||||||
use selectors::Element;
|
|
||||||
use selectors::parser::SelectorList;
|
use selectors::parser::SelectorList;
|
||||||
use std::fmt::{self, Debug};
|
use std::fmt::{self, Debug};
|
||||||
use style_traits::ParseError;
|
use style_traits::ParseError;
|
||||||
|
@ -103,14 +102,6 @@ pub enum PseudoElementCascadeType {
|
||||||
Precomputed,
|
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`.
|
/// A per-functional-pseudo map, from a given pseudo to a `T`.
|
||||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
|
|
|
@ -16,14 +16,12 @@ use invalidation::element::element_wrapper::ElementSnapshot;
|
||||||
use properties::ComputedValues;
|
use properties::ComputedValues;
|
||||||
use properties::PropertyFlags;
|
use properties::PropertyFlags;
|
||||||
use properties::longhands::display::computed_value as display;
|
use properties::longhands::display::computed_value as display;
|
||||||
use selector_parser::{AttrValue as SelectorAttrValue, ElementExt, PseudoElementCascadeType, SelectorParser};
|
use selector_parser::{AttrValue as SelectorAttrValue, PseudoElementCascadeType, SelectorParser};
|
||||||
use selectors::Element;
|
|
||||||
use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity};
|
use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity};
|
||||||
use selectors::parser::{SelectorMethods, SelectorParseErrorKind};
|
use selectors::parser::{SelectorMethods, SelectorParseErrorKind};
|
||||||
use selectors::visitor::SelectorVisitor;
|
use selectors::visitor::SelectorVisitor;
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::Debug;
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
use style_traits::{ParseError, StyleParseErrorKind};
|
use style_traits::{ParseError, StyleParseErrorKind};
|
||||||
|
@ -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
|
/// Returns whether the language is matched, as defined by
|
||||||
/// [RFC 4647](https://tools.ietf.org/html/rfc4647#section-3.3.2).
|
/// [RFC 4647](https://tools.ietf.org/html/rfc4647#section-3.3.2).
|
||||||
pub fn extended_filtering(tag: &str, range: &str) -> bool {
|
pub fn extended_filtering(tag: &str, range: &str) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue