Permalink
Browse files

Auto merge of #19751 - servo:selectors, r=bholley

Clean up the selectors crate for a new crates.io release

<!-- 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/19751)
<!-- Reviewable:end -->
  • Loading branch information...
bors-servo committed Jan 12, 2018
2 parents 1a83665 + befadc5 commit 6ca651c0c8271ce185448e1db95b893a276eaed9
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -17,6 +17,7 @@ cssparser = "0.23.0"
euclid = "0.16"
hashglobe = { path = "../hashglobe" }
mozjs = { version = "0.1.8", features = ["promises"], optional = true }
selectors = { path = "../selectors" }
servo_arc = { path = "../servo_arc" }
smallbitvec = "1.0.3"
smallvec = "0.6"
@@ -49,6 +49,7 @@ extern crate euclid;
extern crate hashglobe;
#[cfg(feature = "servo")]
extern crate mozjs as js;
extern crate selectors;
extern crate servo_arc;
extern crate smallbitvec;
extern crate smallvec;
@@ -640,6 +641,13 @@ impl<T: MallocSizeOf, U> MallocSizeOf for euclid::TypedVector2D<T, U> {
}
}
impl MallocSizeOf for selectors::parser::AncestorHashes {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
let selectors::parser::AncestorHashes { ref packed_hashes } = *self;
packed_hashes.size_of(ops)
}
}
#[cfg(feature = "servo")]
impl<Static: string_cache::StaticAtomSet> MallocSizeOf for string_cache::Atom<Static> {
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize {
@@ -1,8 +1,8 @@
[package]
name = "selectors"
version = "0.19.0" # Not yet published
authors = ["Simon Sapin <simon.sapin@exyr.org>", "Alan Jeffrey <ajeffrey@mozilla.com>"]
version = "0.19.0"
authors = ["The Servo Project Developers"]
documentation = "https://docs.rs/selectors/"
description = "CSS Selectors matching for Rust"
@@ -15,11 +15,8 @@ build = "build.rs"
[lib]
name = "selectors"
path = "lib.rs"
# https://github.com/servo/servo/issues/16710
doctest = false
[features]
gecko_like_types = []
bench = []
[dependencies]
@@ -28,15 +25,10 @@ matches = "0.1"
cssparser = "0.23.0"
log = "0.3"
fnv = "1.0"
malloc_size_of = { path = "../malloc_size_of" }
malloc_size_of_derive = { path = "../malloc_size_of_derive" }
phf = "0.7.18"
precomputed-hash = "0.1"
servo_arc = { path = "../servo_arc" }
servo_arc = { version = "0.1", path = "../servo_arc" }
smallvec = "0.6"
[dev-dependencies]
size_of_test = {path = "../size_of_test"}
[build-dependencies]
phf_codegen = "0.7.18"

This file was deleted.

Oops, something went wrong.
@@ -10,11 +10,8 @@
#[macro_use] extern crate log;
#[macro_use] extern crate matches;
extern crate fnv;
extern crate malloc_size_of;
#[macro_use] extern crate malloc_size_of_derive;
extern crate phf;
extern crate precomputed_hash;
#[cfg(test)] #[macro_use] extern crate size_of_test;
extern crate servo_arc;
extern crate smallvec;
@@ -25,8 +22,6 @@ pub mod context;
pub mod matching;
mod nth_index_cache;
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;
@@ -19,7 +19,7 @@ use std::borrow::{Borrow, Cow};
use std::fmt::{self, Display, Debug, Write};
use std::iter::Rev;
use std::slice;
use visitor::SelectorVisitor;
pub use visitor::{Visit, SelectorVisitor};
/// A trait that represents a pseudo-element.
pub trait PseudoElement : Sized + ToCss {
@@ -86,17 +86,17 @@ macro_rules! with_all_bounds {
pub trait SelectorImpl: Clone + Sized + 'static {
type ExtraMatchingData: Sized + Default + 'static;
type AttrValue: $($InSelector)*;
type Identifier: $($InSelector)* + PrecomputedHash;
type ClassName: $($InSelector)* + PrecomputedHash;
type LocalName: $($InSelector)* + Borrow<Self::BorrowedLocalName> + PrecomputedHash;
type NamespaceUrl: $($CommonBounds)* + Default + Borrow<Self::BorrowedNamespaceUrl> + PrecomputedHash;
type Identifier: $($InSelector)*;
type ClassName: $($InSelector)*;
type LocalName: $($InSelector)* + Borrow<Self::BorrowedLocalName>;
type NamespaceUrl: $($CommonBounds)* + Default + Borrow<Self::BorrowedNamespaceUrl>;
type NamespacePrefix: $($InSelector)* + Default;
type BorrowedNamespaceUrl: ?Sized + Eq;
type BorrowedLocalName: ?Sized + Eq;
/// non tree-structural pseudo-classes
/// (see: https://drafts.csswg.org/selectors/#structural-pseudos)
type NonTSPseudoClass: $($CommonBounds)* + Sized + ToCss + SelectorMethods<Impl = Self>;
type NonTSPseudoClass: $($CommonBounds)* + Sized + ToCss;
/// pseudo-elements
type PseudoElement: $($CommonBounds)* + PseudoElement<Impl = Self>;
@@ -266,7 +266,7 @@ where
/// off the upper bits) at the expense of making the fourth somewhat more
/// complicated to assemble, because we often bail out before checking all the
/// hashes.
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AncestorHashes {
pub packed_hashes: [u32; 3],
}
@@ -275,14 +275,24 @@ impl AncestorHashes {
pub fn new<Impl: SelectorImpl>(
selector: &Selector<Impl>,
quirks_mode: QuirksMode,
) -> Self {
) -> Self
where Impl::Identifier: PrecomputedHash,
Impl::ClassName: PrecomputedHash,
Impl::LocalName: PrecomputedHash,
Impl::NamespaceUrl: PrecomputedHash,
{
Self::from_iter(selector.iter(), quirks_mode)
}
fn from_iter<Impl: SelectorImpl>(
iter: SelectorIter<Impl>,
quirks_mode: QuirksMode,
) -> Self {
) -> Self
where Impl::Identifier: PrecomputedHash,
Impl::ClassName: PrecomputedHash,
Impl::LocalName: PrecomputedHash,
Impl::NamespaceUrl: PrecomputedHash,
{
// Compute ancestor hashes for the bloom filter.
let mut hashes = [0u32; 4];
let mut hash_iter = AncestorIter::new(iter)
@@ -316,15 +326,7 @@ impl AncestorHashes {
}
}
pub trait SelectorMethods {
type Impl: SelectorImpl;
fn visit<V>(&self, visitor: &mut V) -> bool
where
V: SelectorVisitor<Impl = Self::Impl>;
}
impl<Impl: SelectorImpl> SelectorMethods for Selector<Impl> {
impl<Impl: SelectorImpl> Visit for Selector<Impl> where Impl::NonTSPseudoClass: Visit<Impl=Impl> {
type Impl = Impl;
fn visit<V>(&self, visitor: &mut V) -> bool
@@ -354,7 +356,7 @@ impl<Impl: SelectorImpl> SelectorMethods for Selector<Impl> {
}
}
impl<Impl: SelectorImpl> SelectorMethods for Component<Impl> {
impl<Impl: SelectorImpl> Visit for Component<Impl> where Impl::NonTSPseudoClass: Visit<Impl=Impl> {
type Impl = Impl;
fn visit<V>(&self, visitor: &mut V) -> bool
@@ -789,7 +791,12 @@ pub enum Component<Impl: SelectorImpl> {
impl<Impl: SelectorImpl> Component<Impl> {
/// Compute the ancestor hash to check against the bloom filter.
fn ancestor_hash(&self, quirks_mode: QuirksMode) -> Option<u32> {
fn ancestor_hash(&self, quirks_mode: QuirksMode) -> Option<u32>
where Impl::Identifier: PrecomputedHash,
Impl::ClassName: PrecomputedHash,
Impl::LocalName: PrecomputedHash,
Impl::NamespaceUrl: PrecomputedHash,
{
match *self {
Component::LocalName(LocalName { ref name, ref lower_name }) => {
// Only insert the local-name into the filter if it's all
@@ -1998,7 +2005,7 @@ pub mod tests {
}
}
impl SelectorMethods for PseudoClass {
impl Visit for PseudoClass {
type Impl = DummySelectorImpl;
fn visit<V>(&self, _visitor: &mut V) -> bool
@@ -2068,12 +2075,6 @@ pub mod tests {
}
}
impl PrecomputedHash for DummyAtom {
fn precomputed_hash(&self) -> u32 {
return 0
}
}
impl<'i> Parser<'i> for DummyParser {
type Impl = DummySelectorImpl;
type Error = SelectorParseErrorKind<'i>;
Oops, something went wrong.

0 comments on commit 6ca651c

Please sign in to comment.