From db8f59407f93e07111cf2bf0c5d691fcef4e40c9 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Sat, 17 Jun 2017 20:13:12 -0700 Subject: [PATCH] Hoist sink into selectors. It probably makes more sense (eventually) to put it in SmallVec. MozReview-Commit-ID: AIBKCLiMNN2 --- components/script/dom/element.rs | 2 +- components/script/layout_wrapper.rs | 2 +- components/selectors/lib.rs | 1 + components/{style => selectors}/sink.rs | 22 ---------------------- components/style/dom.rs | 2 +- components/style/gecko/wrapper.rs | 2 +- components/style/lib.rs | 1 - components/style/stylist.rs | 2 +- 8 files changed, 6 insertions(+), 28 deletions(-) rename components/{style => selectors}/sink.rs (64%) diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index c0570ad83cc0..9d5229827177 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -89,6 +89,7 @@ use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivit use selectors::matching::{ElementSelectorFlags, LocalMatchingContext, MatchingContext, MatchingMode}; use selectors::matching::{HAS_EDGE_CHILD_SELECTOR, HAS_SLOW_SELECTOR, HAS_SLOW_SELECTOR_LATER_SIBLINGS}; use selectors::matching::{RelevantLinkStatus, matches_selector_list}; +use selectors::sink::Push; use servo_atoms::Atom; use std::ascii::AsciiExt; use std::borrow::Cow; @@ -109,7 +110,6 @@ use style::rule_tree::CascadeLevel; use style::selector_parser::{NonTSPseudoClass, PseudoElement, RestyleDamage, SelectorImpl, SelectorParser}; use style::selector_parser::extended_filtering; use style::shared_lock::{SharedRwLock, Locked}; -use style::sink::Push; use style::stylearc::Arc; use style::thread_state; use style::values::{CSSFloat, Either}; diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs index aaaf5cce1074..d26493589c25 100644 --- a/components/script/layout_wrapper.rs +++ b/components/script/layout_wrapper.rs @@ -52,6 +52,7 @@ use script_layout_interface::wrapper_traits::{PseudoElementType, ThreadSafeLayou use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity}; use selectors::matching::{ElementSelectorFlags, LocalMatchingContext, MatchingContext, RelevantLinkStatus}; use selectors::matching::VisitedHandlingMode; +use selectors::sink::Push; use servo_atoms::Atom; use servo_url::ServoUrl; use std::fmt; @@ -75,7 +76,6 @@ use style::properties::{ComputedValues, PropertyDeclarationBlock}; use style::selector_parser::{AttrValue as SelectorAttrValue, NonTSPseudoClass, PseudoClassStringArg}; use style::selector_parser::{PseudoElement, SelectorImpl, extended_filtering}; use style::shared_lock::{SharedRwLock as StyleSharedRwLock, Locked as StyleLocked}; -use style::sink::Push; use style::str::is_whitespace; use style::stylearc::Arc; diff --git a/components/selectors/lib.rs b/components/selectors/lib.rs index 16a7949cfa9c..bde7acef1894 100644 --- a/components/selectors/lib.rs +++ b/components/selectors/lib.rs @@ -20,6 +20,7 @@ pub mod matching; pub mod parser; #[cfg(test)] mod size_of_tests; #[cfg(any(test, feature = "gecko_like_types"))] pub mod gecko_like_types; +pub mod sink; mod tree; pub mod visitor; diff --git a/components/style/sink.rs b/components/selectors/sink.rs similarity index 64% rename from components/style/sink.rs rename to components/selectors/sink.rs index 343bf07d869b..3c57aa143c45 100644 --- a/components/style/sink.rs +++ b/components/selectors/sink.rs @@ -6,7 +6,6 @@ #![deny(missing_docs)] use smallvec::{Array, SmallVec}; -use std::marker::PhantomData; /// A trait to abstract over a `push` method that may be implemented for /// different kind of types. @@ -30,24 +29,3 @@ impl Push for SmallVec { SmallVec::push(self, value); } } - -/// A struct that implements `Push`, but only stores whether it's empty. -pub struct ForgetfulSink(bool, PhantomData); - -impl ForgetfulSink { - /// Trivially construct a new `ForgetfulSink`. - pub fn new() -> Self { - ForgetfulSink(true, PhantomData) - } - - /// Whether this sink is empty or not. - pub fn is_empty(&self) -> bool { - self.0 - } -} - -impl Push for ForgetfulSink { - fn push(&mut self, _value: T) { - self.0 = false; - } -} diff --git a/components/style/dom.rs b/components/style/dom.rs index 545463f4bd06..9cc7b2c1e4b5 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -21,8 +21,8 @@ use rule_tree::CascadeLevel; use selector_parser::{AttrValue, ElementExt, PreExistingComputedValues}; use selector_parser::{PseudoClassStringArg, PseudoElement}; use selectors::matching::{ElementSelectorFlags, VisitedHandlingMode}; +use selectors::sink::Push; use shared_lock::Locked; -use sink::Push; use smallvec::VecLike; use std::fmt; #[cfg(feature = "gecko")] use std::collections::HashMap; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 42c9997e6918..602e500de0dd 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -76,8 +76,8 @@ use selectors::Element; use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator, CaseSensitivity, NamespaceConstraint}; use selectors::matching::{ElementSelectorFlags, LocalMatchingContext, MatchingContext}; use selectors::matching::{RelevantLinkStatus, VisitedHandlingMode}; +use selectors::sink::Push; use shared_lock::Locked; -use sink::Push; use smallvec::VecLike; use std::cell::RefCell; use std::collections::HashMap; diff --git a/components/style/lib.rs b/components/style/lib.rs index 05b147d12be4..e2ed31d14671 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -126,7 +126,6 @@ pub mod sharing; pub mod stylist; #[cfg(feature = "servo")] #[allow(unsafe_code)] pub mod servo; pub mod sequential; -pub mod sink; pub mod str; pub mod style_adjuster; pub mod stylesheet_set; diff --git a/components/style/stylist.rs b/components/style/stylist.rs index ae63d62a52de..5a849a0ab7f2 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -31,9 +31,9 @@ use selectors::matching::{ElementSelectorFlags, matches_selector, MatchingContex use selectors::matching::AFFECTED_BY_PRESENTATIONAL_HINTS; use selectors::parser::{AncestorHashes, Combinator, Component, Selector, SelectorAndHashes}; use selectors::parser::{SelectorIter, SelectorMethods}; +use selectors::sink::Push; use selectors::visitor::SelectorVisitor; use shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards}; -use sink::Push; use smallvec::VecLike; use std::fmt::Debug; #[cfg(feature = "servo")]