mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #20134 - emilio:split-stuff, r=nox
style: Split out NonCustomPropertyId::enabled_for_all_content from allowed_in. This is part of a patch that was reviewed by nox in #20081, but which I reverted because that approach didn't quite work. I think I have something that works now, but I'm waiting for a Geckotry. Landing this should be worth it in the meantime though. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20134) <!-- Reviewable:end -->
This commit is contained in:
commit
b9e16e54aa
1 changed files with 65 additions and 46 deletions
|
@ -438,45 +438,17 @@ impl NonCustomPropertyId {
|
|||
MAP[self.0]
|
||||
}
|
||||
|
||||
fn allowed_in(self, context: &ParserContext) -> bool {
|
||||
debug_assert!(
|
||||
matches!(
|
||||
context.rule_type(),
|
||||
CssRuleType::Keyframe | CssRuleType::Page | CssRuleType::Style
|
||||
),
|
||||
"Declarations are only expected inside a keyframe, page, or style rule."
|
||||
);
|
||||
#[inline]
|
||||
fn enabled_for_all_content(self) -> bool {
|
||||
${static_non_custom_property_id_set(
|
||||
"EXPERIMENTAL",
|
||||
lambda p: p.experimental(product)
|
||||
)}
|
||||
|
||||
<% id_set = static_non_custom_property_id_set %>
|
||||
|
||||
${id_set("DISALLOWED_IN_KEYFRAME_BLOCK", lambda p: not p.allowed_in_keyframe_block)}
|
||||
${id_set("DISALLOWED_IN_PAGE_RULE", lambda p: not p.allowed_in_page_rule)}
|
||||
match context.rule_type() {
|
||||
CssRuleType::Keyframe if DISALLOWED_IN_KEYFRAME_BLOCK.contains(self) => {
|
||||
return false;
|
||||
}
|
||||
CssRuleType::Page if DISALLOWED_IN_PAGE_RULE.contains(self) => {
|
||||
return false;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// The semantics of these are kinda hard to reason about, what follows
|
||||
// is a description of the different combinations that can happen with
|
||||
// these three sets.
|
||||
//
|
||||
// Experimental properties are generally controlled by prefs, but an
|
||||
// experimental property explicitly enabled in certain context (UA or
|
||||
// chrome sheets) is always usable in the context regardless of the
|
||||
// pref value.
|
||||
//
|
||||
// Non-experimental properties are either normal properties which are
|
||||
// usable everywhere, or internal-only properties which are only usable
|
||||
// in certain context they are explicitly enabled in.
|
||||
${id_set("ENABLED_IN_UA_SHEETS", lambda p: p.explicitly_enabled_in_ua_sheets())}
|
||||
${id_set("ENABLED_IN_CHROME", lambda p: p.explicitly_enabled_in_chrome())}
|
||||
${id_set("EXPERIMENTAL", lambda p: p.experimental(product))}
|
||||
${id_set("ALWAYS_ENABLED", lambda p: (not p.experimental(product)) and p.enabled_in_content())}
|
||||
${static_non_custom_property_id_set(
|
||||
"ALWAYS_ENABLED",
|
||||
lambda p: (not p.experimental(product)) and p.enabled_in_content()
|
||||
)}
|
||||
|
||||
let passes_pref_check = || {
|
||||
% if product == "servo":
|
||||
|
@ -508,6 +480,61 @@ impl NonCustomPropertyId {
|
|||
return true
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn allowed_in(self, context: &ParserContext) -> bool {
|
||||
debug_assert!(
|
||||
matches!(
|
||||
context.rule_type(),
|
||||
CssRuleType::Keyframe | CssRuleType::Page | CssRuleType::Style
|
||||
),
|
||||
"Declarations are only expected inside a keyframe, page, or style rule."
|
||||
);
|
||||
|
||||
${static_non_custom_property_id_set(
|
||||
"DISALLOWED_IN_KEYFRAME_BLOCK",
|
||||
lambda p: not p.allowed_in_keyframe_block
|
||||
)}
|
||||
${static_non_custom_property_id_set(
|
||||
"DISALLOWED_IN_PAGE_RULE",
|
||||
lambda p: not p.allowed_in_page_rule
|
||||
)}
|
||||
match context.rule_type() {
|
||||
CssRuleType::Keyframe if DISALLOWED_IN_KEYFRAME_BLOCK.contains(self) => {
|
||||
return false;
|
||||
}
|
||||
CssRuleType::Page if DISALLOWED_IN_PAGE_RULE.contains(self) => {
|
||||
return false;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// The semantics of these are kinda hard to reason about, what follows
|
||||
// is a description of the different combinations that can happen with
|
||||
// these three sets.
|
||||
//
|
||||
// Experimental properties are generally controlled by prefs, but an
|
||||
// experimental property explicitly enabled in certain context (UA or
|
||||
// chrome sheets) is always usable in the context regardless of the
|
||||
// pref value.
|
||||
//
|
||||
// Non-experimental properties are either normal properties which are
|
||||
// usable everywhere, or internal-only properties which are only usable
|
||||
// in certain context they are explicitly enabled in.
|
||||
if self.enabled_for_all_content() {
|
||||
return true;
|
||||
}
|
||||
|
||||
${static_non_custom_property_id_set(
|
||||
"ENABLED_IN_UA_SHEETS",
|
||||
lambda p: p.explicitly_enabled_in_ua_sheets()
|
||||
)}
|
||||
${static_non_custom_property_id_set(
|
||||
"ENABLED_IN_CHROME",
|
||||
lambda p: p.explicitly_enabled_in_chrome()
|
||||
)}
|
||||
|
||||
if context.stylesheet_origin == Origin::UserAgent &&
|
||||
ENABLED_IN_UA_SHEETS.contains(self)
|
||||
{
|
||||
|
@ -1805,14 +1832,6 @@ impl PropertyDeclaration {
|
|||
}
|
||||
}
|
||||
|
||||
/// The shorthands that this longhand is part of.
|
||||
pub fn shorthands(&self) -> &'static [ShorthandId] {
|
||||
match self.id() {
|
||||
PropertyDeclarationId::Longhand(id) => id.shorthands(),
|
||||
PropertyDeclarationId::Custom(..) => &[],
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns true if this property declaration is for one of the animatable
|
||||
/// properties.
|
||||
pub fn is_animatable(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue