diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-01-14 21:28:50 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-01-14 21:45:39 +0100 |
commit | e32d6f6adf0d97b628ed90f1bca72e69a590e281 (patch) | |
tree | 4625bc576de99dbda32fd0af44eb68228151c643 /components/script_layout_interface/wrapper_traits.rs | |
parent | cb2bba8777192b416989527d472fdd0348f0b551 (diff) | |
download | servo-e32d6f6adf0d97b628ed90f1bca72e69a590e281.tar.gz servo-e32d6f6adf0d97b628ed90f1bca72e69a590e281.zip |
layout: Remove type parameter from PseudoElementType.
Everyone uses () now.
Diffstat (limited to 'components/script_layout_interface/wrapper_traits.rs')
-rw-r--r-- | components/script_layout_interface/wrapper_traits.rs | 56 |
1 files changed, 23 insertions, 33 deletions
diff --git a/components/script_layout_interface/wrapper_traits.rs b/components/script_layout_interface/wrapper_traits.rs index c08e79b29a3..d6b8794b9d6 100644 --- a/components/script_layout_interface/wrapper_traits.rs +++ b/components/script_layout_interface/wrapper_traits.rs @@ -28,46 +28,36 @@ use style::stylist::RuleInclusion; use webrender_api::ClipId; #[derive(Clone, Copy, Debug, PartialEq)] -pub enum PseudoElementType<T> { +pub enum PseudoElementType { Normal, - Before(T), - After(T), - DetailsSummary(T), - DetailsContent(T), + Before, + After, + DetailsSummary, + DetailsContent, } -impl<T> PseudoElementType<T> { +impl PseudoElementType { pub fn is_before(&self) -> bool { match *self { - PseudoElementType::Before(_) => true, + PseudoElementType::Before => true, _ => false, } } pub fn is_replaced_content(&self) -> bool { match *self { - PseudoElementType::Before(_) | PseudoElementType::After(_) => true, + PseudoElementType::Before | PseudoElementType::After => true, _ => false, } } - pub fn strip(&self) -> PseudoElementType<()> { - match *self { - PseudoElementType::Normal => PseudoElementType::Normal, - PseudoElementType::Before(_) => PseudoElementType::Before(()), - PseudoElementType::After(_) => PseudoElementType::After(()), - PseudoElementType::DetailsSummary(_) => PseudoElementType::DetailsSummary(()), - PseudoElementType::DetailsContent(_) => PseudoElementType::DetailsContent(()), - } - } - pub fn style_pseudo_element(&self) -> PseudoElement { match *self { PseudoElementType::Normal => unreachable!("style_pseudo_element called with PseudoElementType::Normal"), - PseudoElementType::Before(_) => PseudoElement::Before, - PseudoElementType::After(_) => PseudoElement::After, - PseudoElementType::DetailsSummary(_) => PseudoElement::DetailsSummary, - PseudoElementType::DetailsContent(_) => PseudoElement::DetailsContent, + PseudoElementType::Before => PseudoElement::Before, + PseudoElementType::After => PseudoElement::After, + PseudoElementType::DetailsSummary => PseudoElement::DetailsSummary, + PseudoElementType::DetailsContent => PseudoElement::DetailsContent, } } } @@ -196,7 +186,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo fn as_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>; #[inline] - fn get_pseudo_element_type(&self) -> PseudoElementType<()> { + fn get_pseudo_element_type(&self) -> PseudoElementType { self.as_element().map_or(PseudoElementType::Normal, |el| el.get_pseudo_element_type()) } @@ -266,10 +256,10 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo fn fragment_type(&self) -> FragmentType { match self.get_pseudo_element_type() { PseudoElementType::Normal => FragmentType::FragmentBody, - PseudoElementType::Before(_) => FragmentType::BeforePseudoContent, - PseudoElementType::After(_) => FragmentType::AfterPseudoContent, - PseudoElementType::DetailsSummary(_) => FragmentType::FragmentBody, - PseudoElementType::DetailsContent(_) => FragmentType::FragmentBody, + PseudoElementType::Before => FragmentType::BeforePseudoContent, + PseudoElementType::After => FragmentType::AfterPseudoContent, + PseudoElementType::DetailsSummary => FragmentType::FragmentBody, + PseudoElementType::DetailsContent => FragmentType::FragmentBody, } } @@ -301,7 +291,7 @@ pub trait ThreadSafeLayoutElement /// Creates a new `ThreadSafeLayoutElement` for the same `LayoutElement` /// with a different pseudo-element type. - fn with_pseudo(&self, pseudo: PseudoElementType<()>) -> Self; + fn with_pseudo(&self, pseudo: PseudoElementType) -> Self; /// Returns the type ID of this node. /// Returns `None` if this is a pseudo-element; otherwise, returns `Some`. @@ -324,12 +314,12 @@ pub trait ThreadSafeLayoutElement fn style_data(&self) -> AtomicRef<ElementData>; #[inline] - fn get_pseudo_element_type(&self) -> PseudoElementType<()>; + fn get_pseudo_element_type(&self) -> PseudoElementType; #[inline] fn get_before_pseudo(&self) -> Option<Self> { if self.style_data().styles.pseudos.get(&PseudoElement::Before).is_some() { - Some(self.with_pseudo(PseudoElementType::Before(()))) + Some(self.with_pseudo(PseudoElementType::Before)) } else { None } @@ -338,7 +328,7 @@ pub trait ThreadSafeLayoutElement #[inline] fn get_after_pseudo(&self) -> Option<Self> { if self.style_data().styles.pseudos.get(&PseudoElement::After).is_some() { - Some(self.with_pseudo(PseudoElementType::After(()))) + Some(self.with_pseudo(PseudoElementType::After)) } else { None } @@ -348,7 +338,7 @@ pub trait ThreadSafeLayoutElement fn get_details_summary_pseudo(&self) -> Option<Self> { if self.get_local_name() == &local_name!("details") && self.get_namespace() == &ns!(html) { - Some(self.with_pseudo(PseudoElementType::DetailsSummary(()))) + Some(self.with_pseudo(PseudoElementType::DetailsSummary)) } else { None } @@ -359,7 +349,7 @@ pub trait ThreadSafeLayoutElement if self.get_local_name() == &local_name!("details") && self.get_namespace() == &ns!(html) && self.get_attr(&ns!(), &local_name!("open")).is_some() { - Some(self.with_pseudo(PseudoElementType::DetailsContent(()))) + Some(self.with_pseudo(PseudoElementType::DetailsContent)) } else { None } |