Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Drive-by breaking changes #105

Merged
merged 2 commits into from Feb 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 1 addition & 6 deletions Cargo.toml
@@ -1,7 +1,7 @@
[package]

name = "selectors"
version = "0.16.0"
version = "0.17.0"
authors = ["Simon Sapin <simon.sapin@exyr.org>", "Alan Jeffrey <ajeffrey@mozilla.com>"]
documentation = "https://docs.rs/selectors/"

Expand All @@ -11,13 +11,8 @@ readme = "README.md"
keywords = ["css", "selectors"]
license = "MPL-2.0"

[features]
heap_size = ["heapsize", "heapsize_plugin"]

[dependencies]
bitflags = "0.7"
matches = "0.1"
cssparser = ">=0.6, <0.8"
fnv = "1.0"
heapsize = {version = "0.3", features = ["unstable"], optional = true}
heapsize_plugin = {version = "0.1.0", optional = true}
4 changes: 0 additions & 4 deletions src/lib.rs
Expand Up @@ -2,10 +2,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#![cfg_attr(feature = "heap_size", feature(plugin, custom_derive))]
#![cfg_attr(feature = "heap_size", plugin(heapsize_plugin))]

#[cfg(feature = "heap_size")] extern crate heapsize;
#[macro_use] extern crate bitflags;
#[macro_use] extern crate cssparser;
#[macro_use] extern crate matches;
Expand Down
2 changes: 1 addition & 1 deletion src/matching.rs
Expand Up @@ -426,7 +426,7 @@ fn matches_simple_selector<E>(
false
}
SimpleSelector::NonTSPseudoClass(ref pc) => {
relation_if!(element.match_non_ts_pseudo_class(pc.clone()),
relation_if!(element.match_non_ts_pseudo_class(pc),
AFFECTED_BY_STATE)
}
SimpleSelector::FirstChild => {
Expand Down
26 changes: 3 additions & 23 deletions src/parser.rs
Expand Up @@ -83,21 +83,11 @@ macro_rules! with_bounds {
}
}

macro_rules! with_heap_size_bound {
($( $HeapSizeOf: tt )*) => {
with_bounds! {
[Clone + Eq + Hash $($HeapSizeOf)*]
[From<String> + for<'a> From<&'a str>]
}
}
with_bounds! {
[Clone + Eq + Hash]
[From<String> + for<'a> From<&'a str>]
}

#[cfg(feature = "heap_size")]
with_heap_size_bound!(+ ::heapsize::HeapSizeOf);

#[cfg(not(feature = "heap_size"))]
with_heap_size_bound!();

pub trait Parser {
type Impl: SelectorImpl;

Expand Down Expand Up @@ -130,7 +120,6 @@ pub trait Parser {
}
}

#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
#[derive(PartialEq, Clone, Debug)]
pub struct SelectorList<Impl: SelectorImpl>(pub Vec<Selector<Impl>>);

Expand All @@ -146,7 +135,6 @@ impl<Impl: SelectorImpl> SelectorList<Impl> {
}
}

#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
#[derive(PartialEq, Clone)]
pub struct Selector<Impl: SelectorImpl> {
pub complex_selector: Arc<ComplexSelector<Impl>>,
Expand Down Expand Up @@ -234,14 +222,12 @@ impl<Impl: SelectorImpl> ComplexSelector<Impl> {
}
}

#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
#[derive(Clone, Eq, Hash, PartialEq)]
pub struct ComplexSelector<Impl: SelectorImpl> {
pub compound_selector: Vec<SimpleSelector<Impl>>,
pub next: Option<(Arc<ComplexSelector<Impl>>, Combinator)>, // c.next is left of c
}

#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
#[derive(Eq, PartialEq, Clone, Copy, Debug, Hash)]
pub enum Combinator {
Child, // >
Expand All @@ -250,7 +236,6 @@ pub enum Combinator {
LaterSibling, // ~
}

#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
#[derive(Eq, PartialEq, Clone, Hash)]
pub enum SimpleSelector<Impl: SelectorImpl> {
ID(Impl::Identifier),
Expand Down Expand Up @@ -289,38 +274,33 @@ pub enum SimpleSelector<Impl: SelectorImpl> {
}

#[derive(Eq, PartialEq, Clone, Hash, Copy, Debug)]
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
pub enum CaseSensitivity {
CaseSensitive, // Selectors spec says language-defined, but HTML says sensitive.
CaseInsensitive,
}


#[derive(Eq, PartialEq, Clone, Hash)]
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
pub struct LocalName<Impl: SelectorImpl> {
pub name: Impl::LocalName,
pub lower_name: Impl::LocalName,
}

#[derive(Eq, PartialEq, Clone, Hash)]
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
pub struct AttrSelector<Impl: SelectorImpl> {
pub name: Impl::LocalName,
pub lower_name: Impl::LocalName,
pub namespace: NamespaceConstraint<Impl>,
}

#[derive(Eq, PartialEq, Clone, Hash, Debug)]
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
pub enum NamespaceConstraint<Impl: SelectorImpl> {
Any,
Specific(Namespace<Impl>),
}

/// FIXME(SimonSapin): should Hash only hash the URL? What is it used for?
#[derive(Eq, PartialEq, Clone, Hash)]
#[cfg_attr(feature = "heap_size", derive(HeapSizeOf))]
pub struct Namespace<Impl: SelectorImpl> {
pub prefix: Option<Impl::NamespacePrefix>,
pub url: Impl::NamespaceUrl,
Expand Down
2 changes: 1 addition & 1 deletion src/tree.rs
Expand Up @@ -140,7 +140,7 @@ pub trait Element: MatchAttr + Sized {
fn get_local_name(&self) -> &<Self::Impl as SelectorImpl>::BorrowedLocalName;
fn get_namespace(&self) -> &<Self::Impl as SelectorImpl>::BorrowedNamespaceUrl;

fn match_non_ts_pseudo_class(&self, pc: <Self::Impl as SelectorImpl>::NonTSPseudoClass) -> bool;
fn match_non_ts_pseudo_class(&self, pc: &<Self::Impl as SelectorImpl>::NonTSPseudoClass) -> bool;

fn get_id(&self) -> Option<<Self::Impl as SelectorImpl>::Identifier>;
fn has_class(&self, name: &<Self::Impl as SelectorImpl>::ClassName) -> bool;
Expand Down