Skip to content

Commit

Permalink
Reframe less on restyles that involve nonexistent first-letter frames…
Browse files Browse the repository at this point in the history
… in Gecko.

Gecko bug 1324618 part 9 servo bits: https://bugzilla.mozilla.org/show_bug.cgi?id=1324618
  • Loading branch information
bzbarsky committed Jun 27, 2017
1 parent 40dd807 commit d40e27d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions components/style/gecko/pseudo_element.rs
Expand Up @@ -77,6 +77,12 @@ impl PseudoElement {
matches!(*self, PseudoElement::Before | PseudoElement::After)
}

/// Whether this pseudo-element is ::first-letter.
#[inline]
pub fn is_first_letter(&self) -> bool {
*self == PseudoElement::FirstLetter
}

/// Whether this pseudo-element is lazily-cascaded.
#[inline]
pub fn is_lazy(&self) -> bool {
Expand Down
16 changes: 16 additions & 0 deletions components/style/matching.rs
Expand Up @@ -1507,9 +1507,25 @@ pub trait MatchMethods : TElement {
// triggering any change.
return StyleDifference::new(RestyleDamage::empty(), StyleChange::Unchanged)
}
// FIXME(bz): This will keep reframing replaced elements. Do we
// need this at all? Seems like if we add/remove ::before or
// ::after styles we would get reframed over in match_pseudos and if
// that part didn't change and we had no frame for the
// ::before/::after then we don't care. Need to double-check that
// we handle the "content" and "display" properties changing
// correctly, though.
// https://bugzilla.mozilla.org/show_bug.cgi?id=1376352
return StyleDifference::new(RestyleDamage::reconstruct(), StyleChange::Changed)
}

if pseudo.map_or(false, |p| p.is_first_letter()) {
// No one cares about this pseudo, and we've checked above that
// we're not switching from a "cares" to a "doesn't care" state
// or vice versa.
return StyleDifference::new(RestyleDamage::empty(),
StyleChange::Unchanged)
}

// Something else. Be conservative for now.
warn!("Reframing due to lack of old style source: {:?}, pseudo: {:?}",
self, pseudo);
Expand Down
7 changes: 7 additions & 0 deletions components/style/servo/selector_parser.rs
Expand Up @@ -38,6 +38,7 @@ pub enum PseudoElement {
After = 0,
Before,
Selection,
// If/when :first-letter is added, update is_first_letter accordingly.
// Non-eager pseudos.
DetailsSummary,
DetailsContent,
Expand Down Expand Up @@ -110,6 +111,12 @@ impl PseudoElement {
matches!(*self, PseudoElement::After | PseudoElement::Before)
}

/// Whether the current pseudo element is :first-letter
#[inline]
pub fn is_first_letter(&self) -> bool {
false
}

/// Whether this pseudo-element is eagerly-cascaded.
#[inline]
pub fn is_eager(&self) -> bool {
Expand Down

0 comments on commit d40e27d

Please sign in to comment.