Skip to content

Commit

Permalink
style: Don't optimize out recascading of children when becoming or st…
Browse files Browse the repository at this point in the history
…opping being display: contents.

Since they can change whether descendants get blockified.

Differential Revision: https://phabricator.services.mozilla.com/D35818
  • Loading branch information
emilio committed Jul 8, 2019
1 parent 1af30fa commit 4abfa1a
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions components/style/matching.rs
Expand Up @@ -503,32 +503,35 @@ trait PrivateMatchMethods: TElement {
let old_display = old_values.get_box().clone_display();
let new_display = new_values.get_box().clone_display();

// If we used to be a display: none element, and no longer are,
// our children need to be restyled because they're unstyled.
//
// NOTE(emilio): Gecko has the special-case of -moz-binding, but
// that gets handled on the frame constructor when processing
// the reframe, so no need to handle that here.
if old_display == Display::None && old_display != new_display {
return ChildCascadeRequirement::MustCascadeChildren;
}

// Blockification of children may depend on our display value,
// so we need to actually do the recascade. We could potentially
// do better, but it doesn't seem worth it.
if old_display.is_item_container() != new_display.is_item_container() {
return ChildCascadeRequirement::MustCascadeChildren;
}

// Line break suppression may also be affected if the display
// type changes from ruby to non-ruby.
#[cfg(feature = "gecko")]
{
if old_display.is_ruby_type() != new_display.is_ruby_type() {
if old_display != new_display {
// If we used to be a display: none element, and no longer are, our
// children need to be restyled because they're unstyled.
if old_display == Display::None {
return ChildCascadeRequirement::MustCascadeChildren;
}
// Blockification of children may depend on our display value,
// so we need to actually do the recascade. We could potentially
// do better, but it doesn't seem worth it.
if old_display.is_item_container() != new_display.is_item_container() {
return ChildCascadeRequirement::MustCascadeChildren;
}
// We may also need to blockify and un-blockify descendants if our
// display goes from / to display: contents, since the "layout
// parent style" changes.
if old_display.is_contents() || new_display.is_contents() {
return ChildCascadeRequirement::MustCascadeChildren;
}
// Line break suppression may also be affected if the display
// type changes from ruby to non-ruby.
#[cfg(feature = "gecko")]
{
if old_display.is_ruby_type() != new_display.is_ruby_type() {
return ChildCascadeRequirement::MustCascadeChildren;
}
}
}


// Children with justify-items: auto may depend on our
// justify-items property value.
//
Expand Down

0 comments on commit 4abfa1a

Please sign in to comment.