mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Split out NonCustomPropertyId::enabled_for_all_content from allowed_in.
This commit is contained in:
parent
a7f38f0f32
commit
17257f94b9
1 changed files with 65 additions and 38 deletions
|
@ -438,45 +438,17 @@ impl NonCustomPropertyId {
|
||||||
MAP[self.0]
|
MAP[self.0]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allowed_in(self, context: &ParserContext) -> bool {
|
#[inline]
|
||||||
debug_assert!(
|
fn enabled_for_all_content(self) -> bool {
|
||||||
matches!(
|
${static_non_custom_property_id_set(
|
||||||
context.rule_type(),
|
"EXPERIMENTAL",
|
||||||
CssRuleType::Keyframe | CssRuleType::Page | CssRuleType::Style
|
lambda p: p.experimental(product)
|
||||||
),
|
)}
|
||||||
"Declarations are only expected inside a keyframe, page, or style rule."
|
|
||||||
);
|
|
||||||
|
|
||||||
<% id_set = static_non_custom_property_id_set %>
|
${static_non_custom_property_id_set(
|
||||||
|
"ALWAYS_ENABLED",
|
||||||
${id_set("DISALLOWED_IN_KEYFRAME_BLOCK", lambda p: not p.allowed_in_keyframe_block)}
|
lambda p: (not p.experimental(product)) and p.enabled_in_content()
|
||||||
${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())}
|
|
||||||
|
|
||||||
let passes_pref_check = || {
|
let passes_pref_check = || {
|
||||||
% if product == "servo":
|
% if product == "servo":
|
||||||
|
@ -508,6 +480,61 @@ impl NonCustomPropertyId {
|
||||||
return true
|
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 &&
|
if context.stylesheet_origin == Origin::UserAgent &&
|
||||||
ENABLED_IN_UA_SHEETS.contains(self)
|
ENABLED_IN_UA_SHEETS.contains(self)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue