style: Remove unused optional display from PseudoElementType definition.

Everyone passes None now.
This commit is contained in:
Emilio Cobos Álvarez 2018-01-14 21:18:00 +01:00
parent 55174991b6
commit cb2bba8777
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
3 changed files with 13 additions and 24 deletions

View file

@ -1473,15 +1473,7 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
None => {
// Pseudo-element.
let style = node.style(self.style_context());
let display = match node.get_pseudo_element_type() {
PseudoElementType::Normal => Display::Inline,
PseudoElementType::Before(maybe_display) |
PseudoElementType::After(maybe_display) |
PseudoElementType::DetailsContent(maybe_display) |
PseudoElementType::DetailsSummary(maybe_display)
=> maybe_display.unwrap_or(style.get_box().display),
};
(display, style.get_box().float, style.get_box().position)
(style.get_box().display, style.get_box().float, style.get_box().position)
}
Some(LayoutNodeType::Element(_)) => {
let style = node.style(self.style_context());

View file

@ -63,7 +63,6 @@ use std::sync::atomic::Ordering;
use style::CaseSensitivityExt;
use style::applicable_declarations::ApplicableDeclarationBlock;
use style::attr::AttrValue;
use style::computed_values::display;
use style::context::SharedStyleContext;
use style::data::ElementData;
use style::dom::{DomChildren, LayoutIterator, NodeInfo, OpaqueNode};
@ -804,7 +803,7 @@ pub struct ServoThreadSafeLayoutNode<'ln> {
/// The pseudo-element type, with (optionally)
/// a specified display value to override the stylesheet.
pseudo: PseudoElementType<Option<display::T>>,
pseudo: PseudoElementType<()>,
}
impl<'a> PartialEq for ServoThreadSafeLayoutNode<'a> {
@ -1083,7 +1082,7 @@ pub struct ServoThreadSafeLayoutElement<'le> {
/// The pseudo-element type, with (optionally)
/// a specified display value to override the stylesheet.
pseudo: PseudoElementType<Option<display::T>>,
pseudo: PseudoElementType<()>,
}
impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> {
@ -1096,15 +1095,14 @@ impl<'le> ThreadSafeLayoutElement for ServoThreadSafeLayoutElement<'le> {
}
}
fn get_pseudo_element_type(&self) -> PseudoElementType<Option<display::T>> {
fn get_pseudo_element_type(&self) -> PseudoElementType<()> {
self.pseudo
}
fn with_pseudo(&self,
pseudo: PseudoElementType<Option<display::T>>) -> Self {
fn with_pseudo(&self, pseudo: PseudoElementType<()>) -> Self {
ServoThreadSafeLayoutElement {
element: self.element.clone(),
pseudo: pseudo,
pseudo,
}
}

View file

@ -17,7 +17,6 @@ use servo_arc::Arc;
use servo_url::ServoUrl;
use std::fmt::Debug;
use style::attr::AttrValue;
use style::computed_values::display::T as Display;
use style::context::SharedStyleContext;
use style::data::ElementData;
use style::dom::{LayoutIterator, NodeInfo, TNode};
@ -197,7 +196,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo
fn as_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>;
#[inline]
fn get_pseudo_element_type(&self) -> PseudoElementType<Option<Display>> {
fn get_pseudo_element_type(&self) -> PseudoElementType<()> {
self.as_element().map_or(PseudoElementType::Normal, |el| el.get_pseudo_element_type())
}
@ -302,7 +301,7 @@ pub trait ThreadSafeLayoutElement
/// Creates a new `ThreadSafeLayoutElement` for the same `LayoutElement`
/// with a different pseudo-element type.
fn with_pseudo(&self, pseudo: PseudoElementType<Option<Display>>) -> 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`.
@ -325,12 +324,12 @@ pub trait ThreadSafeLayoutElement
fn style_data(&self) -> AtomicRef<ElementData>;
#[inline]
fn get_pseudo_element_type(&self) -> PseudoElementType<Option<Display>>;
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(None)))
Some(self.with_pseudo(PseudoElementType::Before(())))
} else {
None
}
@ -339,7 +338,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(None)))
Some(self.with_pseudo(PseudoElementType::After(())))
} else {
None
}
@ -349,7 +348,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(None)))
Some(self.with_pseudo(PseudoElementType::DetailsSummary(())))
} else {
None
}
@ -360,7 +359,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(None)))
Some(self.with_pseudo(PseudoElementType::DetailsContent(())))
} else {
None
}