From a478c1bf906b074ef2bb011f3fe5b376adfa55df Mon Sep 17 00:00:00 2001 From: Ziran Sun Date: Fri, 9 Dec 2022 10:15:31 +0000 Subject: [PATCH] style: Don't share style for cousins that are using Container Queries Differential Revision: https://phabricator.services.mozilla.com/D164224 --- components/style/data.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/components/style/data.rs b/components/style/data.rs index c546f0828f3..a3951322004 100644 --- a/components/style/data.rs +++ b/components/style/data.rs @@ -476,10 +476,16 @@ impl ElementData { /// happens later in the styling pipeline. The former gives us the stronger guarantees /// we need for style sharing, the latter does not. pub fn safe_for_cousin_sharing(&self) -> bool { - !self.flags.intersects( + if self.flags.intersects( ElementDataFlags::TRAVERSED_WITHOUT_STYLING | ElementDataFlags::PRIMARY_STYLE_REUSED_VIA_RULE_NODE, - ) + ) { + return false; + } + if !self.styles.primary().get_box().clone_container_type().is_normal() { + return false; + } + true } /// Measures memory usage.