Skip to content

Commit

Permalink
Hoist sink into selectors.
Browse files Browse the repository at this point in the history
It probably makes more sense (eventually) to put it in SmallVec.

MozReview-Commit-ID: AIBKCLiMNN2
  • Loading branch information
bholley committed Jun 20, 2017
1 parent 2159d48 commit db8f594
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 28 deletions.
2 changes: 1 addition & 1 deletion components/script/dom/element.rs
Expand Up @@ -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;
Expand All @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion components/script/layout_wrapper.rs
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
1 change: 1 addition & 0 deletions components/selectors/lib.rs
Expand Up @@ -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;

Expand Down
22 changes: 0 additions & 22 deletions components/style/sink.rs → components/selectors/sink.rs
Expand Up @@ -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.
Expand All @@ -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;
}
}
2 changes: 1 addition & 1 deletion components/style/dom.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion components/style/gecko/wrapper.rs
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion components/style/lib.rs
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion components/style/stylist.rs
Expand Up @@ -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")]
Expand Down

0 comments on commit db8f594

Please sign in to comment.