Don't reconstruct the layout object when going from no pseudo to pseudo with no content for ::before and ::after.

Fixes Gecko bug 1376073.  r=emilio
This commit is contained in:
Boris Zbarsky 2017-07-28 17:41:53 -04:00
parent 12a49dc0be
commit 91d4956da5
5 changed files with 70 additions and 12 deletions

View file

@ -162,6 +162,13 @@ impl fmt::Debug for EagerPseudoArray {
}
}
// Can't use [None; EAGER_PSEUDO_COUNT] here because it complains
// about Copy not being implemented for our Arc type.
#[cfg(feature = "gecko")]
const EMPTY_PSEUDO_ARRAY: &'static EagerPseudoArrayInner = &[None, None, None, None];
#[cfg(feature = "servo")]
const EMPTY_PSEUDO_ARRAY: &'static EagerPseudoArrayInner = &[None, None, None];
impl EagerPseudoStyles {
/// Returns whether there are any pseudo styles.
pub fn is_empty(&self) -> bool {
@ -169,13 +176,19 @@ impl EagerPseudoStyles {
}
/// Grabs a reference to the list of styles, if they exist.
pub fn as_array(&self) -> Option<&EagerPseudoArrayInner> {
pub fn as_optional_array(&self) -> Option<&EagerPseudoArrayInner> {
match self.0 {
None => None,
Some(ref x) => Some(&x.0),
}
}
/// Grabs a reference to the list of styles or a list of None if
/// there are no styles to be had.
pub fn as_array(&self) -> &EagerPseudoArrayInner {
self.as_optional_array().unwrap_or(EMPTY_PSEUDO_ARRAY)
}
/// Returns a reference to the style for a given eager pseudo, if it exists.
pub fn get(&self, pseudo: &PseudoElement) -> Option<&Arc<ComputedValues>> {
debug_assert!(pseudo.is_eager());