mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00: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
|
@ -109,7 +109,10 @@ pub enum ConstructionItem {
|
|||
/// Inline fragments and associated {ib} splits that have not yet found flows.
|
||||
InlineFragments(InlineFragmentsConstructionResult),
|
||||
/// Potentially ignorable whitespace.
|
||||
Whitespace(OpaqueNode, PseudoElementType<()>, ServoArc<ComputedValues>, RestyleDamage),
|
||||
///
|
||||
/// FIXME(emilio): How could whitespace have any PseudoElementType other
|
||||
/// than Normal?
|
||||
Whitespace(OpaqueNode, PseudoElementType, ServoArc<ComputedValues>, RestyleDamage),
|
||||
/// TableColumn Fragment
|
||||
TableColumnFragment(Fragment),
|
||||
}
|
||||
|
@ -257,7 +260,7 @@ impl InlineFragmentsAccumulator {
|
|||
fragments: IntermediateInlineFragments::new(),
|
||||
enclosing_node: Some(InlineFragmentNodeInfo {
|
||||
address: node.opaque(),
|
||||
pseudo: node.get_pseudo_element_type().strip(),
|
||||
pseudo: node.get_pseudo_element_type(),
|
||||
style: node.style(style_context),
|
||||
selected_style: node.selected_style(),
|
||||
flags: InlineFragmentNodeFlags::FIRST_FRAGMENT_OF_ELEMENT |
|
||||
|
@ -695,7 +698,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
let specific_fragment_info = SpecificFragmentInfo::UnscannedText(info);
|
||||
fragments.fragments.push_back(Fragment::from_opaque_node_and_style(
|
||||
node.opaque(),
|
||||
node.get_pseudo_element_type().strip(),
|
||||
node.get_pseudo_element_type(),
|
||||
style,
|
||||
selected_style,
|
||||
node.restyle_damage(),
|
||||
|
@ -715,7 +718,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
};
|
||||
fragments.fragments.push_back(Fragment::from_opaque_node_and_style(
|
||||
node.opaque(),
|
||||
node.get_pseudo_element_type().strip(),
|
||||
node.get_pseudo_element_type(),
|
||||
style.clone(),
|
||||
selected_style.clone(),
|
||||
node.restyle_damage(),
|
||||
|
@ -851,7 +854,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
Box::new(UnscannedTextFragmentInfo::new(String::new(), None))
|
||||
);
|
||||
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
||||
node.get_pseudo_element_type().strip(),
|
||||
node.get_pseudo_element_type(),
|
||||
node_style.clone(),
|
||||
node.selected_style(),
|
||||
node.restyle_damage(),
|
||||
|
@ -898,7 +901,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
if node.is_ignorable_whitespace(context) {
|
||||
return ConstructionResult::ConstructionItem(ConstructionItem::Whitespace(
|
||||
node.opaque(),
|
||||
node.get_pseudo_element_type().strip(),
|
||||
node.get_pseudo_element_type(),
|
||||
context.stylist.style_for_anonymous(
|
||||
&context.guards, &PseudoElement::ServoText, &style),
|
||||
node.restyle_damage()))
|
||||
|
@ -951,7 +954,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
let fragment_info = SpecificFragmentInfo::InlineBlock(InlineBlockFragmentInfo::new(
|
||||
block_flow));
|
||||
let fragment = Fragment::from_opaque_node_and_style(node.opaque(),
|
||||
node.get_pseudo_element_type().strip(),
|
||||
node.get_pseudo_element_type(),
|
||||
style,
|
||||
node.selected_style(),
|
||||
node.restyle_damage(),
|
||||
|
@ -1392,7 +1395,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
|
|||
if fragment.node != node.opaque() {
|
||||
continue
|
||||
}
|
||||
if fragment.pseudo != node.get_pseudo_element_type().strip() {
|
||||
if fragment.pseudo != node.get_pseudo_element_type() {
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -1641,10 +1644,10 @@ impl<ConcreteThreadSafeLayoutNode> NodeUtils for ConcreteThreadSafeLayoutNode
|
|||
|
||||
fn construction_result_mut(self, data: &mut LayoutData) -> &mut ConstructionResult {
|
||||
match self.get_pseudo_element_type() {
|
||||
PseudoElementType::Before(_) => &mut data.before_flow_construction_result,
|
||||
PseudoElementType::After(_) => &mut data.after_flow_construction_result,
|
||||
PseudoElementType::DetailsSummary(_) => &mut data.details_summary_flow_construction_result,
|
||||
PseudoElementType::DetailsContent(_) => &mut data.details_content_flow_construction_result,
|
||||
PseudoElementType::Before => &mut data.before_flow_construction_result,
|
||||
PseudoElementType::After => &mut data.after_flow_construction_result,
|
||||
PseudoElementType::DetailsSummary => &mut data.details_summary_flow_construction_result,
|
||||
PseudoElementType::DetailsContent => &mut data.details_content_flow_construction_result,
|
||||
PseudoElementType::Normal => &mut data.flow_construction_result,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2278,10 +2278,10 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
fn fragment_type(&self) -> FragmentType {
|
||||
match self.pseudo {
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ pub struct Fragment {
|
|||
pub restyle_damage: RestyleDamage,
|
||||
|
||||
/// The pseudo-element that this fragment represents.
|
||||
pub pseudo: PseudoElementType<()>,
|
||||
pub pseudo: PseudoElementType,
|
||||
|
||||
/// Various flags for this fragment.
|
||||
pub flags: FragmentFlags,
|
||||
|
@ -622,7 +622,7 @@ impl Fragment {
|
|||
margin: LogicalMargin::zero(writing_mode),
|
||||
specific: specific,
|
||||
inline_context: None,
|
||||
pseudo: node.get_pseudo_element_type().strip(),
|
||||
pseudo: node.get_pseudo_element_type(),
|
||||
flags: FragmentFlags::empty(),
|
||||
debug_id: DebugId::new(),
|
||||
stacking_context_id: StackingContextId::root(),
|
||||
|
@ -631,7 +631,7 @@ impl Fragment {
|
|||
|
||||
/// Constructs a new `Fragment` instance from an opaque node.
|
||||
pub fn from_opaque_node_and_style(node: OpaqueNode,
|
||||
pseudo: PseudoElementType<()>,
|
||||
pseudo: PseudoElementType,
|
||||
style: ServoArc<ComputedValues>,
|
||||
selected_style: ServoArc<ComputedValues>,
|
||||
mut restyle_damage: RestyleDamage,
|
||||
|
|
|
@ -368,7 +368,7 @@ impl Counter {
|
|||
fn render(&self,
|
||||
layout_context: &LayoutContext,
|
||||
node: OpaqueNode,
|
||||
pseudo: PseudoElementType<()>,
|
||||
pseudo: PseudoElementType,
|
||||
style: ::ServoArc<ComputedValues>,
|
||||
list_style_type: ListStyleType,
|
||||
mode: RenderingMode)
|
||||
|
@ -431,7 +431,7 @@ struct CounterValue {
|
|||
/// Creates fragment info for a literal string.
|
||||
fn render_text(layout_context: &LayoutContext,
|
||||
node: OpaqueNode,
|
||||
pseudo: PseudoElementType<()>,
|
||||
pseudo: PseudoElementType,
|
||||
style: ::ServoArc<ComputedValues>,
|
||||
string: String)
|
||||
-> Option<SpecificFragmentInfo> {
|
||||
|
|
|
@ -1766,7 +1766,7 @@ pub struct InlineFragmentNodeInfo {
|
|||
pub address: OpaqueNode,
|
||||
pub style: ServoArc<ComputedValues>,
|
||||
pub selected_style: ServoArc<ComputedValues>,
|
||||
pub pseudo: PseudoElementType<()>,
|
||||
pub pseudo: PseudoElementType,
|
||||
pub flags: InlineFragmentNodeFlags,
|
||||
}
|
||||
|
||||
|
|
|
@ -803,7 +803,7 @@ pub struct ServoThreadSafeLayoutNode<'ln> {
|
|||
|
||||
/// The pseudo-element type, with (optionally)
|
||||
/// a specified display value to override the stylesheet.
|
||||
pseudo: PseudoElementType<()>,
|
||||
pseudo: PseudoElementType,
|
||||
}
|
||||
|
||||
impl<'a> PartialEq for ServoThreadSafeLayoutNode<'a> {
|
||||
|
@ -993,7 +993,7 @@ impl<ConcreteNode> ThreadSafeLayoutNodeChildrenIterator<ConcreteNode>
|
|||
unsafe { parent.dangerous_first_child() }
|
||||
})
|
||||
},
|
||||
PseudoElementType::DetailsContent(_) | PseudoElementType::DetailsSummary(_) => {
|
||||
PseudoElementType::DetailsContent | PseudoElementType::DetailsSummary => {
|
||||
unsafe { parent.dangerous_first_child() }
|
||||
},
|
||||
_ => None,
|
||||
|
@ -1011,9 +1011,9 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
|
|||
fn next(&mut self) -> Option<ConcreteNode> {
|
||||
use ::selectors::Element;
|
||||
match self.parent_node.get_pseudo_element_type() {
|
||||
PseudoElementType::Before(_) | PseudoElementType::After(_) => None,
|
||||
PseudoElementType::Before | PseudoElementType::After => None,
|
||||
|
||||
PseudoElementType::DetailsSummary(_) => {
|
||||
PseudoElementType::DetailsSummary => {
|
||||
let mut current_node = self.current_node.clone();
|
||||
loop {
|
||||
let next_node = if let Some(ref node) = current_node {
|
||||
|
@ -1033,7 +1033,7 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
|
|||
}
|
||||
}
|
||||
|
||||
PseudoElementType::DetailsContent(_) => {
|
||||
PseudoElementType::DetailsContent => {
|
||||
let node = self.current_node.clone();
|
||||
let node = node.and_then(|node| {
|
||||
if node.is_element() &&
|
||||
|
@ -1052,7 +1052,7 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
|
|||
let node = self.current_node.clone();
|
||||
if let Some(ref node) = node {
|
||||
self.current_node = match node.get_pseudo_element_type() {
|
||||
PseudoElementType::Before(_) => {
|
||||
PseudoElementType::Before => {
|
||||
self.parent_node.get_details_summary_pseudo()
|
||||
.or_else(|| unsafe { self.parent_node.dangerous_first_child() })
|
||||
.or_else(|| self.parent_node.get_after_pseudo())
|
||||
|
@ -1060,11 +1060,9 @@ impl<ConcreteNode> Iterator for ThreadSafeLayoutNodeChildrenIterator<ConcreteNod
|
|||
PseudoElementType::Normal => {
|
||||
unsafe { node.dangerous_next_sibling() }.or_else(|| self.parent_node.get_after_pseudo())
|
||||
},
|
||||
PseudoElementType::DetailsSummary(_) => self.parent_node.get_details_content_pseudo(),
|
||||
PseudoElementType::DetailsContent(_) => self.parent_node.get_after_pseudo(),
|
||||
PseudoElementType::After(_) => {
|
||||
None
|
||||
},
|
||||
PseudoElementType::DetailsSummary => self.parent_node.get_details_content_pseudo(),
|
||||
PseudoElementType::DetailsContent => self.parent_node.get_after_pseudo(),
|
||||
PseudoElementType::After => None,
|
||||
};
|
||||
}
|
||||
node
|
||||
|
@ -1082,7 +1080,7 @@ pub struct ServoThreadSafeLayoutElement<'le> {
|
|||
|
||||
/// The pseudo-element type, with (optionally)
|
||||
/// a specified display value to override the stylesheet.
|
||||
pseudo: PseudoElementType<()>,
|
||||
pseudo: PseudoElementType,
|
||||
}
|
||||
|
||||
impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> {
|
||||
|
@ -1095,11 +1093,11 @@ impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_pseudo_element_type(&self) -> PseudoElementType<()> {
|
||||
fn get_pseudo_element_type(&self) -> PseudoElementType {
|
||||
self.pseudo
|
||||
}
|
||||
|
||||
fn with_pseudo(&self, pseudo: PseudoElementType<()>) -> Self {
|
||||
fn with_pseudo(&self, pseudo: PseudoElementType) -> Self {
|
||||
ServoThreadSafeLayoutElement {
|
||||
element: self.element.clone(),
|
||||
pseudo,
|
||||
|
|
|
@ -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