Hoist sink into selectors.

It probably makes more sense (eventually) to put it in SmallVec.

MozReview-Commit-ID: AIBKCLiMNN2
This commit is contained in:
Bobby Holley 2017-06-17 20:13:12 -07:00
parent 2159d48382
commit db8f59407f
8 changed files with 6 additions and 28 deletions

View file

@ -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};

View file

@ -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;

View file

@ -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;

View file

@ -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<A: Array> Push<A::Item> for SmallVec<A> {
SmallVec::push(self, value);
}
}
/// A struct that implements `Push`, but only stores whether it's empty.
pub struct ForgetfulSink<T>(bool, PhantomData<T>);
impl<T> ForgetfulSink<T> {
/// 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<T> Push<T> for ForgetfulSink<T> {
fn push(&mut self, _value: T) {
self.0 = false;
}
}

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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")]