mirror of
https://github.com/servo/servo.git
synced 2025-08-16 19:05:33 +01:00
Add slots in PerPseudoElementMap for tree pseudos.
This commit is contained in:
parent
b743d68ccd
commit
4ce3dc7729
6 changed files with 203 additions and 185 deletions
|
@ -27,6 +27,12 @@ pub const EAGER_PSEUDO_COUNT: usize = ${len(EAGER_PSEUDOS)};
|
|||
/// The number of non-functional pseudo-elements.
|
||||
pub const SIMPLE_PSEUDO_COUNT: usize = ${len(SIMPLE_PSEUDOS)};
|
||||
|
||||
/// The number of tree pseudo-elements.
|
||||
pub const TREE_PSEUDO_COUNT: usize = ${len(TREE_PSEUDOS)};
|
||||
|
||||
/// The number of all pseudo-elements.
|
||||
pub const PSEUDO_COUNT: usize = ${len(PSEUDOS)};
|
||||
|
||||
/// The list of eager pseudos.
|
||||
pub const EAGER_PSEUDOS: [PseudoElement; EAGER_PSEUDO_COUNT] = [
|
||||
% for eager_pseudo_name in EAGER_PSEUDOS:
|
||||
|
@ -49,24 +55,22 @@ impl PseudoElement {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns an index if the pseudo-element is a simple (non-functional)
|
||||
/// pseudo.
|
||||
/// Returns an index of the pseudo-element.
|
||||
#[inline]
|
||||
pub fn simple_index(&self) -> Option<usize> {
|
||||
pub fn index(&self) -> usize {
|
||||
match *self {
|
||||
% for i, pseudo in enumerate(SIMPLE_PSEUDOS):
|
||||
${pseudo_element_variant(pseudo)} => Some(${i}),
|
||||
% for i, pseudo in enumerate(PSEUDOS):
|
||||
${pseudo_element_variant(pseudo)} => ${i},
|
||||
% endfor
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns an array of `None` values.
|
||||
///
|
||||
/// FIXME(emilio): Integer generics can't come soon enough.
|
||||
pub fn simple_pseudo_none_array<T>() -> [Option<T>; SIMPLE_PSEUDO_COUNT] {
|
||||
pub fn pseudo_none_array<T>() -> [Option<T>; PSEUDO_COUNT] {
|
||||
[
|
||||
${",\n".join(["None" for pseudo in SIMPLE_PSEUDOS])}
|
||||
${",\n ".join(["None" for pseudo in PSEUDOS])}
|
||||
]
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue