mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
Auto merge of #17574 - heycam:experimental, r=Manishearth
style: Make "internal" and "experimental" interact in the same way as Gecko. From https://bugzilla.mozilla.org/show_bug.cgi?id=1375374. <!-- 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/17574) <!-- Reviewable:end -->
This commit is contained in:
commit
d47de6ccfc
3 changed files with 45 additions and 36 deletions
|
@ -151,7 +151,7 @@ class Longhand(object):
|
||||||
allowed_in_keyframe_block=True, cast_type='u8',
|
allowed_in_keyframe_block=True, cast_type='u8',
|
||||||
has_uncacheable_values=False, logical=False, alias=None, extra_prefixes=None, boxed=False,
|
has_uncacheable_values=False, logical=False, alias=None, extra_prefixes=None, boxed=False,
|
||||||
flags=None, allowed_in_page_rule=False, allow_quirks=False, ignored_when_colors_disabled=False,
|
flags=None, allowed_in_page_rule=False, allow_quirks=False, ignored_when_colors_disabled=False,
|
||||||
vector=False):
|
gecko_pref_ident=None, vector=False):
|
||||||
self.name = name
|
self.name = name
|
||||||
if not spec:
|
if not spec:
|
||||||
raise TypeError("Spec should be specified for %s" % name)
|
raise TypeError("Spec should be specified for %s" % name)
|
||||||
|
@ -178,6 +178,7 @@ class Longhand(object):
|
||||||
self.allowed_in_page_rule = arg_to_bool(allowed_in_page_rule)
|
self.allowed_in_page_rule = arg_to_bool(allowed_in_page_rule)
|
||||||
self.allow_quirks = allow_quirks
|
self.allow_quirks = allow_quirks
|
||||||
self.ignored_when_colors_disabled = ignored_when_colors_disabled
|
self.ignored_when_colors_disabled = ignored_when_colors_disabled
|
||||||
|
self.gecko_pref_ident = gecko_pref_ident or self.ident
|
||||||
self.is_vector = vector
|
self.is_vector = vector
|
||||||
|
|
||||||
# https://drafts.csswg.org/css-animations/#keyframes
|
# https://drafts.csswg.org/css-animations/#keyframes
|
||||||
|
@ -214,7 +215,7 @@ class Longhand(object):
|
||||||
class Shorthand(object):
|
class Shorthand(object):
|
||||||
def __init__(self, name, sub_properties, spec=None, experimental=False, internal=False,
|
def __init__(self, name, sub_properties, spec=None, experimental=False, internal=False,
|
||||||
allowed_in_keyframe_block=True, alias=None, extra_prefixes=None,
|
allowed_in_keyframe_block=True, alias=None, extra_prefixes=None,
|
||||||
allowed_in_page_rule=False, flags=None):
|
allowed_in_page_rule=False, flags=None, gecko_pref_ident=None):
|
||||||
self.name = name
|
self.name = name
|
||||||
if not spec:
|
if not spec:
|
||||||
raise TypeError("Spec should be specified for %s" % name)
|
raise TypeError("Spec should be specified for %s" % name)
|
||||||
|
@ -229,6 +230,7 @@ class Shorthand(object):
|
||||||
self.extra_prefixes = extra_prefixes.split() if extra_prefixes else []
|
self.extra_prefixes = extra_prefixes.split() if extra_prefixes else []
|
||||||
self.allowed_in_page_rule = arg_to_bool(allowed_in_page_rule)
|
self.allowed_in_page_rule = arg_to_bool(allowed_in_page_rule)
|
||||||
self.flags = flags.split() if flags else []
|
self.flags = flags.split() if flags else []
|
||||||
|
self.gecko_pref_ident = gecko_pref_ident or self.ident
|
||||||
|
|
||||||
# https://drafts.csswg.org/css-animations/#keyframes
|
# https://drafts.csswg.org/css-animations/#keyframes
|
||||||
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
|
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
|
||||||
|
|
|
@ -171,6 +171,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
|
||||||
gecko_enum_prefix="StyleFloat"
|
gecko_enum_prefix="StyleFloat"
|
||||||
gecko_inexhaustive="True"
|
gecko_inexhaustive="True"
|
||||||
gecko_ffi_name="mFloat"
|
gecko_ffi_name="mFloat"
|
||||||
|
gecko_pref_ident="float_"
|
||||||
spec="https://drafts.csswg.org/css-box/#propdef-float">
|
spec="https://drafts.csswg.org/css-box/#propdef-float">
|
||||||
no_viewport_percentage!(SpecifiedValue);
|
no_viewport_percentage!(SpecifiedValue);
|
||||||
impl ToComputedValue for SpecifiedValue {
|
impl ToComputedValue for SpecifiedValue {
|
||||||
|
|
|
@ -1179,30 +1179,46 @@ impl ToCss for PropertyDeclaration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<%def name="property_pref_check(property)">
|
<%def name="property_exposure_check(property)">
|
||||||
% if property.experimental and product == "servo":
|
// For properties that are experimental but not internal, the pref will
|
||||||
if !PREFS.get("${property.experimental}")
|
// control its availability in all sheets. For properties that are
|
||||||
.as_boolean().unwrap_or(false) {
|
// both experimental and internal, the pref only controls its
|
||||||
return Err(PropertyDeclarationParseError::ExperimentalProperty)
|
// availability in non-UA sheets (and in UA sheets it is always available).
|
||||||
}
|
let is_experimental =
|
||||||
% endif
|
% if property.experimental and product == "servo":
|
||||||
% if product == "gecko":
|
true;
|
||||||
<%
|
% elif product == "gecko":
|
||||||
# gecko can't use the identifier `float`
|
structs::root::mozilla::SERVO_PREF_ENABLED_${property.gecko_pref_ident};
|
||||||
# and instead uses `float_`
|
% else:
|
||||||
# XXXManishearth make this an attr on the property
|
false;
|
||||||
# itself?
|
% endif
|
||||||
pref_ident = property.ident
|
|
||||||
if pref_ident == "float":
|
let passes_pref_check =
|
||||||
pref_ident = "float_"
|
% if property.experimental and product == "servo":
|
||||||
%>
|
PREFS.get("${property.experimental}").as_boolean().unwrap_or(false);
|
||||||
if structs::root::mozilla::SERVO_PREF_ENABLED_${pref_ident} {
|
% elif product == "gecko":
|
||||||
let id = structs::${helpers.to_nscsspropertyid(property.ident)};
|
{
|
||||||
let enabled = unsafe { bindings::Gecko_PropertyId_IsPrefEnabled(id) };
|
let id = structs::${helpers.to_nscsspropertyid(property.ident)};
|
||||||
if !enabled {
|
unsafe { bindings::Gecko_PropertyId_IsPrefEnabled(id) }
|
||||||
return Err(PropertyDeclarationParseError::ExperimentalProperty)
|
};
|
||||||
|
% else:
|
||||||
|
true;
|
||||||
|
% endif
|
||||||
|
|
||||||
|
% if property.internal:
|
||||||
|
if context.stylesheet_origin != Origin::UserAgent {
|
||||||
|
if is_experimental {
|
||||||
|
if !passes_pref_check {
|
||||||
|
return Err(PropertyDeclarationParseError::ExperimentalProperty);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return Err(PropertyDeclarationParseError::UnknownProperty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
% else:
|
||||||
|
if is_experimental && !passes_pref_check {
|
||||||
|
return Err(PropertyDeclarationParseError::ExperimentalProperty);
|
||||||
|
}
|
||||||
% endif
|
% endif
|
||||||
</%def>
|
</%def>
|
||||||
|
|
||||||
|
@ -1418,18 +1434,13 @@ impl PropertyDeclaration {
|
||||||
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
|
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
% if property.internal:
|
|
||||||
if context.stylesheet_origin != Origin::UserAgent {
|
|
||||||
return Err(PropertyDeclarationParseError::UnknownProperty)
|
|
||||||
}
|
|
||||||
% endif
|
|
||||||
% if not property.allowed_in_page_rule:
|
% if not property.allowed_in_page_rule:
|
||||||
if rule_type == CssRuleType::Page {
|
if rule_type == CssRuleType::Page {
|
||||||
return Err(PropertyDeclarationParseError::NotAllowedInPageRule)
|
return Err(PropertyDeclarationParseError::NotAllowedInPageRule)
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
${property_pref_check(property)}
|
${property_exposure_check(property)}
|
||||||
|
|
||||||
match longhands::${property.ident}::parse_declared(context, input) {
|
match longhands::${property.ident}::parse_declared(context, input) {
|
||||||
Ok(value) => {
|
Ok(value) => {
|
||||||
|
@ -1452,18 +1463,13 @@ impl PropertyDeclaration {
|
||||||
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
|
return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
% if shorthand.internal:
|
|
||||||
if context.stylesheet_origin != Origin::UserAgent {
|
|
||||||
return Err(PropertyDeclarationParseError::UnknownProperty)
|
|
||||||
}
|
|
||||||
% endif
|
|
||||||
% if not shorthand.allowed_in_page_rule:
|
% if not shorthand.allowed_in_page_rule:
|
||||||
if rule_type == CssRuleType::Page {
|
if rule_type == CssRuleType::Page {
|
||||||
return Err(PropertyDeclarationParseError::NotAllowedInPageRule)
|
return Err(PropertyDeclarationParseError::NotAllowedInPageRule)
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
${property_pref_check(shorthand)}
|
${property_exposure_check(shorthand)}
|
||||||
|
|
||||||
match input.try(|i| CSSWideKeyword::parse(context, i)) {
|
match input.try(|i| CSSWideKeyword::parse(context, i)) {
|
||||||
Ok(keyword) => {
|
Ok(keyword) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue