style: [css-content] Implement 'content: none' for elements

Differential Revision: https://phabricator.services.mozilla.com/D114130
This commit is contained in:
Mats Palmgren 2023-05-22 09:55:31 +02:00 committed by Oriol Brufau
parent 183ec78be5
commit d92f66246e

View file

@ -23,20 +23,19 @@ impl ToResolvedValue for computed::Content {
#[inline] #[inline]
fn to_resolved_value(self, context: &Context) -> Self { fn to_resolved_value(self, context: &Context) -> Self {
let is_before_or_after = context let (is_pseudo, is_before_or_after, is_marker) =
.style match context.style.pseudo() {
.pseudo() Some(ref pseudo) => (true, pseudo.is_before_or_after(), pseudo.is_marker()),
.map_or(false, |p| p.is_before_or_after()); None => (false, false, false)
let is_marker = context };
.style
.pseudo()
.map_or(false, |p| p.is_marker());
match self { match self {
Self::Normal if is_before_or_after => Self::None, 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. // 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, other => other,
} }
} }