From d92f66246e5c78b684ff0e640942331e552c94a6 Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Mon, 22 May 2023 09:55:31 +0200 Subject: [PATCH] style: [css-content] Implement 'content: none' for elements Differential Revision: https://phabricator.services.mozilla.com/D114130 --- components/style/values/resolved/counters.rs | 21 ++++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/components/style/values/resolved/counters.rs b/components/style/values/resolved/counters.rs index 3bb439a104d..c00e63fda22 100644 --- a/components/style/values/resolved/counters.rs +++ b/components/style/values/resolved/counters.rs @@ -23,20 +23,19 @@ impl ToResolvedValue for computed::Content { #[inline] fn to_resolved_value(self, context: &Context) -> Self { - let is_before_or_after = context - .style - .pseudo() - .map_or(false, |p| p.is_before_or_after()); - let is_marker = context - .style - .pseudo() - .map_or(false, |p| p.is_marker()); - + let (is_pseudo, is_before_or_after, is_marker) = + match context.style.pseudo() { + Some(ref pseudo) => (true, pseudo.is_before_or_after(), pseudo.is_marker()), + None => (false, false, false) + }; match self { Self::Normal if is_before_or_after => Self::None, - // For now, make `content: none` compute to `normal` for elements + // For now, make `content: none` compute to `normal` for pseudos // other than ::before, ::after and ::marker, as we don't respect it. - Self::None if !is_before_or_after && !is_marker => Self::Normal, + // https://github.com/w3c/csswg-drafts/issues/6124 + // Ditto for non-pseudo elements if the pref is disabled. + Self::None if (is_pseudo && !is_before_or_after && !is_marker) || + (!is_pseudo && !static_prefs::pref!("layout.css.element-content-none.enabled")) => Self::Normal, other => other, } }