mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
layout: Remove type parameter from PseudoElementType.
Everyone uses () now.
This commit is contained in:
parent
cb2bba8777
commit
e32d6f6adf
7 changed files with 60 additions and 69 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue