From abd57d2b8d0dc321bb1a99268f1902600ff8fdea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 11 May 2023 13:29:32 +0000 Subject: [PATCH] Bug 1832481 - Container units should prevent us from using the rule cache. r=dshin Much like with font-relative units, when they're used for a non-inherited property we need to avoid using the rule cache. This is because two elements matching the same rules won't get guaranteed-equal non-inherited style structs. Depends on D177732 Differential Revision: https://phabricator.services.mozilla.com/D177733 --- .../style/values/specified/length.rs | 3 +++ .../container-units-rule-cache-ref.html | 18 ++++++++++++++ .../container-units-rule-cache.html | 24 +++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 testing/web-platform/tests/css/css-contain/container-queries/container-units-rule-cache-ref.html create mode 100644 testing/web-platform/tests/css/css-contain/container-queries/container-units-rule-cache.html diff --git a/servo/components/style/values/specified/length.rs b/servo/components/style/values/specified/length.rs index 28f438f20b510..7159fdcf5c97c 100644 --- a/servo/components/style/values/specified/length.rs +++ b/servo/components/style/values/specified/length.rs @@ -784,6 +784,9 @@ impl ContainerRelativeLength { /// Computes the given container-relative length. pub fn to_computed_value(&self, context: &Context) -> CSSPixelLength { + if context.for_non_inherited_property.is_some() { + context.rule_cache_conditions.borrow_mut().set_uncacheable(); + } let size = context.get_container_size_query(); let (factor, container_length) = match *self { Self::Cqw(v) => (v, size.get_container_width(context)), diff --git a/testing/web-platform/tests/css/css-contain/container-queries/container-units-rule-cache-ref.html b/testing/web-platform/tests/css/css-contain/container-queries/container-units-rule-cache-ref.html new file mode 100644 index 0000000000000..6c8261959f674 --- /dev/null +++ b/testing/web-platform/tests/css/css-contain/container-queries/container-units-rule-cache-ref.html @@ -0,0 +1,18 @@ + + + +
+
+
+
+
+
diff --git a/testing/web-platform/tests/css/css-contain/container-queries/container-units-rule-cache.html b/testing/web-platform/tests/css/css-contain/container-queries/container-units-rule-cache.html new file mode 100644 index 0000000000000..cc93f7793ae6b --- /dev/null +++ b/testing/web-platform/tests/css/css-contain/container-queries/container-units-rule-cache.html @@ -0,0 +1,24 @@ + + + + + + + + +
+
+
+
+
+