From 6cb665df9543860b639b8bddcabad8c5f82a8c3e Mon Sep 17 00:00:00 2001 From: David Shin Date: Mon, 17 Oct 2022 17:26:14 +0000 Subject: [PATCH] style: Rematch all descendants when `container-type` changes Extend WPT to ensure invalidation of descendants deeper than one. Differential Revision: https://phabricator.services.mozilla.com/D158058 --- components/style/matching.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/style/matching.rs b/components/style/matching.rs index 2eed53e29b2..f62c8cbbdfb 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -970,6 +970,15 @@ pub trait MatchMethods: TElement { None => return ChildRestyleRequirement::MustCascadeChildren, }; + let old_container_type = old_primary_style.clone_container_type(); + let new_container_type = new_primary_style.clone_container_type(); + if old_container_type != new_container_type && !new_container_type.is_size_container_type() + { + // Stopped being a size container. Re-evaluate container queries and units on all our descendants. + // Changes into and between different size containment is handled in `UpdateContainerQueryStyles`. + restyle_requirement = ChildRestyleRequirement::MustMatchDescendants; + } + restyle_requirement = cmp::max( restyle_requirement, self.accumulate_damage_for(