mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Improve some ergonomics around pseudo-elements.
I think a lot of the current indirection predates the crate merge. MozReview-Commit-ID: FM28dgZa5go
This commit is contained in:
parent
e8ed3e0b7f
commit
1ff008caa3
5 changed files with 53 additions and 46 deletions
|
@ -102,26 +102,6 @@ pub enum PseudoElementCascadeType {
|
|||
Precomputed,
|
||||
}
|
||||
|
||||
impl PseudoElementCascadeType {
|
||||
/// Simple accessor to check whether the cascade type is eager.
|
||||
#[inline]
|
||||
pub fn is_eager(&self) -> bool {
|
||||
*self == PseudoElementCascadeType::Eager
|
||||
}
|
||||
|
||||
/// Simple accessor to check whether the cascade type is lazy.
|
||||
#[inline]
|
||||
pub fn is_lazy(&self) -> bool {
|
||||
*self == PseudoElementCascadeType::Lazy
|
||||
}
|
||||
|
||||
/// Simple accessor to check whether the cascade type is precomputed.
|
||||
#[inline]
|
||||
pub fn is_precomputed(&self) -> bool {
|
||||
*self == PseudoElementCascadeType::Precomputed
|
||||
}
|
||||
}
|
||||
|
||||
/// An extension to rust-selector's `Element` trait.
|
||||
pub trait ElementExt: Element<Impl=SelectorImpl> + Debug {
|
||||
/// Whether this element is a `link`.
|
||||
|
@ -144,7 +124,7 @@ impl SelectorImpl {
|
|||
where F: FnMut(PseudoElement),
|
||||
{
|
||||
Self::each_pseudo_element(|pseudo| {
|
||||
if Self::pseudo_element_cascade_type(&pseudo).is_eager() {
|
||||
if pseudo.is_eager() {
|
||||
fun(pseudo)
|
||||
}
|
||||
})
|
||||
|
@ -160,7 +140,7 @@ impl SelectorImpl {
|
|||
where F: FnMut(PseudoElement),
|
||||
{
|
||||
Self::each_pseudo_element(|pseudo| {
|
||||
if Self::pseudo_element_cascade_type(&pseudo).is_precomputed() {
|
||||
if pseudo.is_precomputed() {
|
||||
fun(pseudo)
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue