mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
style: Add derived ToShmem implementations.
Differential Revision: https://phabricator.services.mozilla.com/D17197
This commit is contained in:
parent
128c6ae94a
commit
40248ae5fd
93 changed files with 649 additions and 267 deletions
|
@ -31,6 +31,8 @@ precomputed-hash = "0.1"
|
|||
servo_arc = { version = "0.1", path = "../servo_arc" }
|
||||
smallvec = "0.6"
|
||||
thin-slice = "0.1.0"
|
||||
to_shmem = { path = "../to_shmem" }
|
||||
to_shmem_derive = { path = "../to_shmem_derive" }
|
||||
|
||||
[build-dependencies]
|
||||
phf_codegen = "0.7.18"
|
||||
|
|
|
@ -6,11 +6,15 @@ use crate::parser::SelectorImpl;
|
|||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
#[derive(Clone, Eq, PartialEq, ToShmem)]
|
||||
#[shmem(no_bounds)]
|
||||
pub struct AttrSelectorWithOptionalNamespace<Impl: SelectorImpl> {
|
||||
#[shmem(field_bound)]
|
||||
pub namespace: Option<NamespaceConstraint<(Impl::NamespacePrefix, Impl::NamespaceUrl)>>,
|
||||
#[shmem(field_bound)]
|
||||
pub local_name: Impl::LocalName,
|
||||
pub local_name_lower: Impl::LocalName,
|
||||
#[shmem(field_bound)]
|
||||
pub operation: ParsedAttrSelectorOperation<Impl::AttrValue>,
|
||||
pub never_matches: bool,
|
||||
}
|
||||
|
@ -24,7 +28,7 @@ impl<Impl: SelectorImpl> AttrSelectorWithOptionalNamespace<Impl> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
#[derive(Clone, Eq, PartialEq, ToShmem)]
|
||||
pub enum NamespaceConstraint<NamespaceUrl> {
|
||||
Any,
|
||||
|
||||
|
@ -32,7 +36,7 @@ pub enum NamespaceConstraint<NamespaceUrl> {
|
|||
Specific(NamespaceUrl),
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
#[derive(Clone, Eq, PartialEq, ToShmem)]
|
||||
pub enum ParsedAttrSelectorOperation<AttrValue> {
|
||||
Exists,
|
||||
WithValue {
|
||||
|
@ -72,7 +76,7 @@ impl<AttrValue> AttrSelectorOperation<AttrValue> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Eq, PartialEq, ToShmem)]
|
||||
pub enum AttrSelectorOperator {
|
||||
Equal,
|
||||
Includes,
|
||||
|
@ -132,7 +136,7 @@ impl AttrSelectorOperator {
|
|||
/// The definition of whitespace per CSS Selectors Level 3 § 4.
|
||||
pub static SELECTOR_WHITESPACE: &'static [char] = &[' ', '\t', '\n', '\r', '\x0C'];
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToShmem)]
|
||||
pub enum ParsedCaseSensitivity {
|
||||
// 's' was specified.
|
||||
ExplicitCaseSensitive,
|
||||
|
|
|
@ -199,7 +199,7 @@ pub const HAS_SLOTTED_BIT: u32 = 1 << 31;
|
|||
|
||||
/// We use ten bits for each specificity kind (id, class, element), and the two
|
||||
/// high bits for the pseudo and slotted flags.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToShmem)]
|
||||
pub struct SpecificityAndFlags(pub u32);
|
||||
|
||||
impl SpecificityAndFlags {
|
||||
|
|
|
@ -21,6 +21,9 @@ extern crate precomputed_hash;
|
|||
extern crate servo_arc;
|
||||
extern crate smallvec;
|
||||
extern crate thin_slice;
|
||||
extern crate to_shmem;
|
||||
#[macro_use]
|
||||
extern crate to_shmem_derive;
|
||||
|
||||
pub mod attr;
|
||||
pub mod bloom;
|
||||
|
|
|
@ -221,8 +221,9 @@ pub trait Parser<'i> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct SelectorList<Impl: SelectorImpl>(pub SmallVec<[Selector<Impl>; 1]>);
|
||||
#[derive(Clone, Debug, Eq, PartialEq, ToShmem)]
|
||||
#[shmem(no_bounds)]
|
||||
pub struct SelectorList<Impl: SelectorImpl>(#[shmem(field_bound)] pub SmallVec<[Selector<Impl>; 1]>);
|
||||
|
||||
impl<Impl: SelectorImpl> SelectorList<Impl> {
|
||||
/// Parse a comma-separated list of Selectors.
|
||||
|
@ -507,8 +508,9 @@ pub fn namespace_empty_string<Impl: SelectorImpl>() -> Impl::NamespaceUrl {
|
|||
///
|
||||
/// This reordering doesn't change the semantics of selector matching, and we
|
||||
/// handle it in to_css to make it invisible to serialization.
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct Selector<Impl: SelectorImpl>(ThinArc<SpecificityAndFlags, Component<Impl>>);
|
||||
#[derive(Clone, Eq, PartialEq, ToShmem)]
|
||||
#[shmem(no_bounds)]
|
||||
pub struct Selector<Impl: SelectorImpl>(#[shmem(field_bound)] ThinArc<SpecificityAndFlags, Component<Impl>>);
|
||||
|
||||
impl<Impl: SelectorImpl> Selector<Impl> {
|
||||
#[inline]
|
||||
|
@ -776,7 +778,7 @@ impl<'a, Impl: SelectorImpl> Iterator for AncestorIter<'a, Impl> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToShmem)]
|
||||
pub enum Combinator {
|
||||
Child, // >
|
||||
Descendant, // space
|
||||
|
@ -824,22 +826,24 @@ impl Combinator {
|
|||
/// optimal packing and cache performance, see [1].
|
||||
///
|
||||
/// [1] https://bugzilla.mozilla.org/show_bug.cgi?id=1357973
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
#[derive(Clone, Eq, PartialEq, ToShmem)]
|
||||
#[shmem(no_bounds)]
|
||||
pub enum Component<Impl: SelectorImpl> {
|
||||
Combinator(Combinator),
|
||||
|
||||
ExplicitAnyNamespace,
|
||||
ExplicitNoNamespace,
|
||||
DefaultNamespace(Impl::NamespaceUrl),
|
||||
Namespace(Impl::NamespacePrefix, Impl::NamespaceUrl),
|
||||
DefaultNamespace(#[shmem(field_bound)] Impl::NamespaceUrl),
|
||||
Namespace(#[shmem(field_bound)] Impl::NamespacePrefix, #[shmem(field_bound)] Impl::NamespaceUrl),
|
||||
|
||||
ExplicitUniversalType,
|
||||
LocalName(LocalName<Impl>),
|
||||
|
||||
ID(Impl::Identifier),
|
||||
Class(Impl::ClassName),
|
||||
ID(#[shmem(field_bound)] Impl::Identifier),
|
||||
Class(#[shmem(field_bound)] Impl::ClassName),
|
||||
|
||||
AttributeInNoNamespaceExists {
|
||||
#[shmem(field_bound)]
|
||||
local_name: Impl::LocalName,
|
||||
local_name_lower: Impl::LocalName,
|
||||
},
|
||||
|
@ -847,6 +851,7 @@ pub enum Component<Impl: SelectorImpl> {
|
|||
AttributeInNoNamespace {
|
||||
local_name: Impl::LocalName,
|
||||
operator: AttrSelectorOperator,
|
||||
#[shmem(field_bound)]
|
||||
value: Impl::AttrValue,
|
||||
case_sensitivity: ParsedCaseSensitivity,
|
||||
never_matches: bool,
|
||||
|
@ -878,7 +883,7 @@ pub enum Component<Impl: SelectorImpl> {
|
|||
FirstOfType,
|
||||
LastOfType,
|
||||
OnlyOfType,
|
||||
NonTSPseudoClass(Impl::NonTSPseudoClass),
|
||||
NonTSPseudoClass(#[shmem(field_bound)] Impl::NonTSPseudoClass),
|
||||
/// The ::slotted() pseudo-element (which isn't actually a pseudo-element,
|
||||
/// and probably should be a pseudo-class):
|
||||
///
|
||||
|
@ -902,7 +907,7 @@ pub enum Component<Impl: SelectorImpl> {
|
|||
///
|
||||
/// See https://github.com/w3c/csswg-drafts/issues/2158
|
||||
Host(Option<Selector<Impl>>),
|
||||
PseudoElement(Impl::PseudoElement),
|
||||
PseudoElement(#[shmem(field_bound)] Impl::PseudoElement),
|
||||
}
|
||||
|
||||
impl<Impl: SelectorImpl> Component<Impl> {
|
||||
|
@ -957,8 +962,10 @@ impl<Impl: SelectorImpl> Component<Impl> {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
#[derive(Clone, Eq, PartialEq, ToShmem)]
|
||||
#[shmem(no_bounds)]
|
||||
pub struct LocalName<Impl: SelectorImpl> {
|
||||
#[shmem(field_bound)]
|
||||
pub name: Impl::LocalName,
|
||||
pub lower_name: Impl::LocalName,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue