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:
Bobby Holley 2017-03-31 17:46:48 -07:00
parent e8ed3e0b7f
commit 1ff008caa3
5 changed files with 53 additions and 46 deletions

View file

@ -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)
}
})