Skip to content
Permalink
Browse files

style: Don't optimize out recascading of children when becoming or st…

…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 1, 2019
1 parent 1af30fa commit 4abfa1a2d813f1625c345dd8a020c371daa48641
Showing with 25 additions and 22 deletions.
  1. +25 −22 components/style/matching.rs
@@ -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.
//

0 comments on commit 4abfa1a

Please sign in to comment.
You can’t perform that action at this time.