From 4abfa1a2d813f1625c345dd8a020c371daa48641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 1 Jul 2019 21:39:47 +0000 Subject: [PATCH] style: Don't optimize out recascading of children when becoming or stopping being display: contents. Since they can change whether descendants get blockified. Differential Revision: https://phabricator.services.mozilla.com/D35818 --- components/style/matching.rs | 47 +++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/components/style/matching.rs b/components/style/matching.rs index b4b472ea1c3..c34ada24a92 100644 --- a/components/style/matching.rs +++ b/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. //