From 20d2a06967c71e36b32789a6cb3dcf4ff2fe0f58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 30 Oct 2020 19:47:19 +0000 Subject: [PATCH] style: Use document quirks mode rather than sheet quirks mode for stylesheet invalidation. In order to determine whether classes or ids are case insensitive we need the document quirks mode. The sheet quirks mode almost always matches, but may not match when sheets are added by privileged APIs. Differential Revision: https://phabricator.services.mozilla.com/D95061 --- components/style/gecko/media_queries.rs | 6 ++++++ components/style/invalidation/stylesheets.rs | 2 +- components/style/stylesheet_set.rs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/components/style/gecko/media_queries.rs b/components/style/gecko/media_queries.rs index e5ffccf11c1..08425f22059 100644 --- a/components/style/gecko/media_queries.rs +++ b/components/style/gecko/media_queries.rs @@ -9,6 +9,7 @@ use crate::gecko::values::{convert_nscolor_to_rgba, convert_rgba_to_nscolor}; use crate::gecko_bindings::bindings; use crate::gecko_bindings::structs; use crate::media_queries::MediaType; +use crate::context::QuirksMode; use crate::properties::ComputedValues; use crate::string_cache::Atom; use crate::values::computed::Length; @@ -143,6 +144,11 @@ impl Device { .store(size.px().to_bits(), Ordering::Relaxed) } + /// The quirks mode of the document. + pub fn quirks_mode(&self) -> QuirksMode { + self.document().mCompatMode.into() + } + /// Sets the body text color for the "inherit color from body" quirk. /// /// diff --git a/components/style/invalidation/stylesheets.rs b/components/style/invalidation/stylesheets.rs index b50e04b0f0b..8ac2b57b34e 100644 --- a/components/style/invalidation/stylesheets.rs +++ b/components/style/invalidation/stylesheets.rs @@ -140,7 +140,7 @@ impl StylesheetInvalidationSet { return; // Nothing to do here. } - let quirks_mode = stylesheet.quirks_mode(guard); + let quirks_mode = device.quirks_mode(); for rule in stylesheet.effective_rules(device, guard) { self.collect_invalidations_for_rule(rule, guard, device, quirks_mode); if self.fully_invalid { diff --git a/components/style/stylesheet_set.rs b/components/style/stylesheet_set.rs index 93f4b986052..fe743025419 100644 --- a/components/style/stylesheet_set.rs +++ b/components/style/stylesheet_set.rs @@ -450,7 +450,7 @@ macro_rules! sheet_set_methods { change_kind: RuleChangeKind, ) { if let Some(device) = device { - let quirks_mode = sheet.quirks_mode(guard); + let quirks_mode = device.quirks_mode(); self.invalidations.rule_changed( sheet, rule,