mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #19235 - emilio:chrome-props, r=xidorn
style: Add infra to differentiate chrome and UA sheets. This keeps the behavior of stuff being accessible from chrome stylesheets being the same of content sheets except on the UA origin. That will be changed in a followup. <!-- 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/19235) <!-- Reviewable:end -->
This commit is contained in:
commit
e07245caba
19 changed files with 143 additions and 74 deletions
|
@ -81,7 +81,7 @@ def write(directory, filename, content):
|
|||
def write_html(properties):
|
||||
properties = dict(
|
||||
(p.name, {
|
||||
"flag": p.experimental,
|
||||
"flag": p.servo_pref,
|
||||
"shorthand": hasattr(p, "sub_properties")
|
||||
})
|
||||
for p in properties.longhands + properties.shorthands
|
||||
|
|
|
@ -146,12 +146,12 @@ def arg_to_bool(arg):
|
|||
|
||||
class Longhand(object):
|
||||
def __init__(self, style_struct, name, spec=None, animation_value_type=None, derived_from=None, keyword=None,
|
||||
predefined_type=None, custom_cascade=False, experimental=False, internal=False,
|
||||
predefined_type=None, custom_cascade=False, servo_pref=None, gecko_pref=None, internal=False,
|
||||
need_index=False, custom_cascade_function=None, gecko_ffi_name=None,
|
||||
allowed_in_keyframe_block=True, cast_type='u8',
|
||||
logical=False, alias=None, extra_prefixes=None, boxed=False,
|
||||
flags=None, allowed_in_page_rule=False, allow_quirks=False, ignored_when_colors_disabled=False,
|
||||
gecko_pref_ident=None, vector=False, need_animatable=False):
|
||||
vector=False, need_animatable=False):
|
||||
self.name = name
|
||||
if not spec:
|
||||
raise TypeError("Spec should be specified for %s" % name)
|
||||
|
@ -161,7 +161,8 @@ class Longhand(object):
|
|||
self.ident = to_rust_ident(name)
|
||||
self.camel_case = to_camel_case(self.ident)
|
||||
self.style_struct = style_struct
|
||||
self.experimental = ("layout.%s.enabled" % name) if experimental else None
|
||||
self.servo_pref = servo_pref
|
||||
self.gecko_pref = gecko_pref
|
||||
self.custom_cascade = custom_cascade
|
||||
self.custom_cascade_function = custom_cascade_function if custom_cascade else None
|
||||
self.internal = internal
|
||||
|
@ -177,7 +178,6 @@ class Longhand(object):
|
|||
self.allowed_in_page_rule = arg_to_bool(allowed_in_page_rule)
|
||||
self.allow_quirks = allow_quirks
|
||||
self.ignored_when_colors_disabled = ignored_when_colors_disabled
|
||||
self.gecko_pref_ident = gecko_pref_ident or self.ident
|
||||
self.is_vector = vector
|
||||
|
||||
# https://drafts.csswg.org/css-animations/#keyframes
|
||||
|
@ -205,11 +205,25 @@ class Longhand(object):
|
|||
self.transitionable = False
|
||||
self.animation_type = None
|
||||
|
||||
def experimental(self, product):
|
||||
if product == "gecko":
|
||||
return bool(self.gecko_pref)
|
||||
return bool(self.servo_pref)
|
||||
|
||||
# FIXME(emilio): Shorthand and Longhand should really share a base class.
|
||||
def explicitly_enabled_in_ua_sheets(self):
|
||||
return self.internal
|
||||
|
||||
# TODO(emilio): Change the `internal` field to something like `enabled_in`.
|
||||
def explicitly_enabled_in_chrome(self):
|
||||
return False
|
||||
|
||||
|
||||
class Shorthand(object):
|
||||
def __init__(self, name, sub_properties, spec=None, experimental=False, internal=False,
|
||||
def __init__(self, name, sub_properties, spec=None, servo_pref=None, gecko_pref=None,
|
||||
internal=False,
|
||||
allowed_in_keyframe_block=True, alias=None, extra_prefixes=None,
|
||||
allowed_in_page_rule=False, flags=None, gecko_pref_ident=None):
|
||||
allowed_in_page_rule=False, flags=None):
|
||||
self.name = name
|
||||
if not spec:
|
||||
raise TypeError("Spec should be specified for %s" % name)
|
||||
|
@ -217,14 +231,14 @@ class Shorthand(object):
|
|||
self.ident = to_rust_ident(name)
|
||||
self.camel_case = to_camel_case(self.ident)
|
||||
self.derived_from = None
|
||||
self.experimental = ("layout.%s.enabled" % name) if experimental else None
|
||||
self.servo_pref = servo_pref
|
||||
self.gecko_pref = gecko_pref
|
||||
self.sub_properties = sub_properties
|
||||
self.internal = internal
|
||||
self.alias = alias.split() if alias else []
|
||||
self.extra_prefixes = extra_prefixes.split() if extra_prefixes else []
|
||||
self.allowed_in_page_rule = arg_to_bool(allowed_in_page_rule)
|
||||
self.flags = flags.split() if flags else []
|
||||
self.gecko_pref_ident = gecko_pref_ident or self.ident
|
||||
|
||||
# https://drafts.csswg.org/css-animations/#keyframes
|
||||
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
|
||||
|
@ -252,18 +266,40 @@ class Shorthand(object):
|
|||
animatable = property(get_animatable)
|
||||
transitionable = property(get_transitionable)
|
||||
|
||||
def experimental(self, product):
|
||||
if product == "gecko":
|
||||
return bool(self.gecko_pref)
|
||||
return bool(self.servo_pref)
|
||||
|
||||
def explicitly_enabled_in_ua_sheets(self):
|
||||
return self.internal
|
||||
|
||||
def explicitly_enabled_in_chrome(self):
|
||||
return False
|
||||
|
||||
|
||||
class Alias(object):
|
||||
def __init__(self, name, original):
|
||||
self.name = name
|
||||
self.ident = to_rust_ident(name)
|
||||
self.camel_case = to_camel_case(self.ident)
|
||||
self.gecko_pref_ident = to_rust_ident(name)
|
||||
self.internal = original.internal
|
||||
self.experimental = original.experimental
|
||||
self.servo_pref = original.servo_pref
|
||||
self.gecko_pref = original.gecko_pref
|
||||
self.allowed_in_page_rule = original.allowed_in_page_rule
|
||||
self.allowed_in_keyframe_block = original.allowed_in_keyframe_block
|
||||
|
||||
def experimental(self, product):
|
||||
if product == "gecko":
|
||||
return bool(self.gecko_pref)
|
||||
return bool(self.servo_pref)
|
||||
|
||||
def explicitly_enabled_in_ua_sheets(self):
|
||||
return self.internal
|
||||
|
||||
def explicitly_enabled_in_chrome(self):
|
||||
return False
|
||||
|
||||
|
||||
class Method(object):
|
||||
def __init__(self, name, return_type=None, arg_types=None, is_mut=False):
|
||||
|
|
|
@ -680,10 +680,9 @@
|
|||
% endif
|
||||
</%def>
|
||||
|
||||
<%def name="shorthand(name, sub_properties, experimental=False, derive_serialize=False, **kwargs)">
|
||||
<%def name="shorthand(name, sub_properties, derive_serialize=False, **kwargs)">
|
||||
<%
|
||||
shorthand = data.declare_shorthand(name, sub_properties.split(), experimental=experimental,
|
||||
**kwargs)
|
||||
shorthand = data.declare_shorthand(name, sub_properties.split(), **kwargs)
|
||||
%>
|
||||
% if shorthand:
|
||||
/// ${shorthand.spec}
|
||||
|
|
|
@ -92,6 +92,7 @@ ${helpers.single_keyword("background-blend-mode",
|
|||
color-burn hard-light soft-light difference exclusion hue
|
||||
saturation color luminosity""",
|
||||
gecko_constant_prefix="NS_STYLE_BLEND",
|
||||
gecko_pref="layout.css.background-blend-mode.enabled",
|
||||
vector=True, products="gecko", animation_value_type="discrete",
|
||||
spec="https://drafts.fxtf.org/compositing/#background-blend-mode",
|
||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}
|
||||
|
|
|
@ -191,6 +191,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
|
|||
|
||||
${helpers.single_keyword("box-decoration-break", "slice clone",
|
||||
gecko_enum_prefix="StyleBoxDecorationBreak",
|
||||
gecko_pref="layout.css.box-decoration-break.enabled",
|
||||
spec="https://drafts.csswg.org/css-break/#propdef-box-decoration-break",
|
||||
products="gecko", animation_value_type="discrete")}
|
||||
|
||||
|
|
|
@ -239,7 +239,6 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
|
|||
gecko_enum_prefix="StyleFloat"
|
||||
gecko_inexhaustive="True"
|
||||
gecko_ffi_name="mFloat"
|
||||
gecko_pref_ident="float_"
|
||||
flags="APPLIES_TO_FIRST_LETTER"
|
||||
spec="https://drafts.csswg.org/css-box/#propdef-float">
|
||||
impl ToComputedValue for SpecifiedValue {
|
||||
|
@ -375,6 +374,7 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box",
|
|||
|
||||
${helpers.single_keyword("overflow-clip-box", "padding-box content-box",
|
||||
products="gecko", animation_value_type="discrete", internal=True,
|
||||
gecko_pref="layout.css.overflow-clip-box.enabled",
|
||||
flags="APPLIES_TO_PLACEHOLDER",
|
||||
spec="Internal, not web-exposed, \
|
||||
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")}
|
||||
|
@ -543,6 +543,7 @@ ${helpers.predefined_type("animation-delay",
|
|||
"ScrollSnapPoint",
|
||||
"computed::ScrollSnapPoint::none()",
|
||||
animation_value_type="discrete",
|
||||
gecko_pref="layout.css.scroll-snap.enabled",
|
||||
products="gecko",
|
||||
spec="Nonstandard (https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/#scroll-snap-points)",
|
||||
)}
|
||||
|
@ -552,6 +553,7 @@ ${helpers.predefined_type("scroll-snap-destination",
|
|||
"Position",
|
||||
"computed::Position::zero()",
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.scroll-snap.enabled",
|
||||
boxed="True",
|
||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
|
||||
animation_value_type="discrete")}
|
||||
|
@ -562,6 +564,7 @@ ${helpers.predefined_type(
|
|||
"computed::Position::zero()",
|
||||
vector=True,
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.scroll-snap.enabled",
|
||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
|
||||
animation_value_type="discrete",
|
||||
allow_empty="NotInitial"
|
||||
|
@ -579,6 +582,7 @@ ${helpers.predefined_type("transform", "Transform",
|
|||
// https://www.w3.org/TR/cssom-view-1/
|
||||
${helpers.single_keyword("scroll-behavior",
|
||||
"auto smooth",
|
||||
gecko_pref="layout.css.scroll-behavior.property-enabled",
|
||||
products="gecko",
|
||||
spec="https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior",
|
||||
animation_value_type="discrete")}
|
||||
|
@ -590,6 +594,7 @@ ${helpers.single_keyword("scroll-behavior",
|
|||
"computed::ScrollSnapType::None",
|
||||
products="gecko",
|
||||
needs_context=False,
|
||||
gecko_pref="layout.css.scroll-snap.enabled",
|
||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type-x)",
|
||||
animation_value_type="discrete"
|
||||
)}
|
||||
|
@ -600,6 +605,7 @@ ${helpers.single_keyword("scroll-behavior",
|
|||
${helpers.single_keyword("isolation",
|
||||
"auto isolate",
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.isolation.enabled",
|
||||
spec="https://drafts.fxtf.org/compositing/#isolation",
|
||||
flags="CREATES_STACKING_CONTEXT",
|
||||
animation_value_type="discrete")}
|
||||
|
@ -666,6 +672,7 @@ ${helpers.single_keyword("transform-box",
|
|||
"border-box fill-box view-box",
|
||||
gecko_enum_prefix="StyleGeometryBox",
|
||||
products="gecko",
|
||||
gecko_pref="svg.transform-box.enabled",
|
||||
spec="https://drafts.csswg.org/css-transforms/#transform-box",
|
||||
gecko_inexhaustive="True",
|
||||
animation_value_type="discrete")}
|
||||
|
@ -693,6 +700,7 @@ ${helpers.predefined_type("transform-origin",
|
|||
// also update the glue once they are implemented in gecko.
|
||||
<%helpers:longhand name="contain" animation_value_type="discrete" products="gecko"
|
||||
flags="FIXPOS_CB"
|
||||
gecko_pref="layout.css.contain.enabled",
|
||||
spec="https://drafts.csswg.org/css-contain/#contain-property">
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
|
@ -894,6 +902,7 @@ ${helpers.predefined_type(
|
|||
"generics::basic_shape::ShapeSource::None",
|
||||
products="gecko",
|
||||
boxed=True,
|
||||
gecko_pref="layout.css.shape-outside.enabled",
|
||||
animation_value_type="ComputedValue",
|
||||
flags="APPLIES_TO_FIRST_LETTER",
|
||||
spec="https://drafts.csswg.org/css-shapes/#shape-outside-property",
|
||||
|
@ -902,6 +911,7 @@ ${helpers.predefined_type(
|
|||
<%helpers:longhand name="touch-action"
|
||||
products="gecko"
|
||||
animation_value_type="discrete"
|
||||
gecko_pref="layout.css.touch_action.enabled"
|
||||
spec="https://compat.spec.whatwg.org/#touch-action">
|
||||
use gecko_bindings::structs;
|
||||
use std::fmt;
|
||||
|
|
|
@ -12,7 +12,7 @@ ${helpers.predefined_type("column-width",
|
|||
initial_specified_value="Either::Second(Auto)",
|
||||
extra_prefixes="moz",
|
||||
animation_value_type="NonNegativeLengthOrAuto",
|
||||
experimental=True,
|
||||
servo_pref="layout.column-width.enabled",
|
||||
spec="https://drafts.csswg.org/css-multicol/#propdef-column-width")}
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ ${helpers.predefined_type("column-count",
|
|||
"PositiveIntegerOrAuto",
|
||||
"Either::Second(Auto)",
|
||||
initial_specified_value="Either::Second(Auto)",
|
||||
experimental="True",
|
||||
servo_pref="layout.column-count.enabled",
|
||||
animation_value_type="PositiveIntegerOrAuto",
|
||||
extra_prefixes="moz",
|
||||
spec="https://drafts.csswg.org/css-multicol/#propdef-column-count")}
|
||||
|
@ -29,7 +29,7 @@ ${helpers.predefined_type("column-gap",
|
|||
"length::NonNegativeLengthOrNormal",
|
||||
"Either::Second(Normal)",
|
||||
extra_prefixes="moz",
|
||||
experimental=True,
|
||||
servo_pref="layout.column-gap.enabled",
|
||||
animation_value_type="NonNegativeLengthOrNormal",
|
||||
spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap")}
|
||||
|
||||
|
@ -62,6 +62,7 @@ ${helpers.predefined_type(
|
|||
|
||||
${helpers.single_keyword("column-span", "none all",
|
||||
products="gecko", animation_value_type="discrete",
|
||||
gecko_pref="layout.css.column-span.enabled",
|
||||
spec="https://drafts.csswg.org/css-multicol/#propdef-column-span")}
|
||||
|
||||
${helpers.single_keyword("column-rule-style",
|
||||
|
|
|
@ -52,4 +52,5 @@ ${helpers.single_keyword("mix-blend-mode",
|
|||
saturation color luminosity""", gecko_constant_prefix="NS_STYLE_BLEND",
|
||||
animation_value_type="discrete",
|
||||
flags="CREATES_STACKING_CONTEXT",
|
||||
gecko_pref="layout.css.mix-blend-mode.enabled",
|
||||
spec="https://drafts.fxtf.org/compositing/#propdef-mix-blend-mode")}
|
||||
|
|
|
@ -1065,6 +1065,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
|
|||
${helpers.predefined_type("font-variation-settings",
|
||||
"FontVariantSettings",
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.font-variations.enabled",
|
||||
initial_value="specified::FontVariantSettings::normal()",
|
||||
animation_value_type="ComputedValue",
|
||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||
|
@ -1372,6 +1373,7 @@ ${helpers.single_keyword("-moz-osx-font-smoothing",
|
|||
"auto grayscale",
|
||||
gecko_constant_prefix="NS_FONT_SMOOTHING",
|
||||
gecko_ffi_name="mFont.smoothing",
|
||||
gecko_pref="layout.css.osx-font-smoothing.enabled",
|
||||
products="gecko",
|
||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth)",
|
||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||
|
|
|
@ -22,7 +22,7 @@ ${helpers.single_keyword("writing-mode",
|
|||
extra_gecko_aliases="lr=horizontal-tb lr-tb=horizontal-tb \
|
||||
rl=horizontal-tb rl-tb=horizontal-tb \
|
||||
tb=vertical-rl tb-rl=vertical-rl",
|
||||
experimental=True,
|
||||
servo_pref="layout.writing-mode.enabled",
|
||||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode")}
|
||||
|
||||
|
@ -41,6 +41,7 @@ ${helpers.single_keyword("text-orientation",
|
|||
// https://drafts.csswg.org/css-color/
|
||||
${helpers.single_keyword("color-adjust",
|
||||
"economy exact", products="gecko",
|
||||
gecko_pref="layout.css.color-adjust.enabled",
|
||||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-color/#propdef-color-adjust")}
|
||||
|
||||
|
@ -60,6 +61,7 @@ ${helpers.single_keyword("image-rendering",
|
|||
<%helpers:longhand name="image-orientation"
|
||||
products="gecko"
|
||||
animation_value_type="discrete"
|
||||
gecko_pref="layout.css.image-orientation.enabled"
|
||||
spec="https://drafts.csswg.org/css-images/#propdef-image-orientation, \
|
||||
/// additional values in https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation">
|
||||
use std::fmt;
|
||||
|
|
|
@ -132,6 +132,7 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
|
|||
|
||||
<%helpers:longhand name="paint-order"
|
||||
animation_value_type="discrete"
|
||||
gecko_pref="svg.paint-order.enabled"
|
||||
products="gecko"
|
||||
spec="https://www.w3.org/TR/SVG2/painting.html#PaintOrder">
|
||||
use std::fmt;
|
||||
|
|
|
@ -66,6 +66,7 @@ ${helpers.single_keyword("word-break",
|
|||
extra_specified="${'distribute' if product == 'gecko' else ''}"
|
||||
gecko_enum_prefix="StyleTextJustify"
|
||||
animation_value_type="discrete"
|
||||
gecko_pref="layout.css.text-justify.enabled"
|
||||
flags="APPLIES_TO_PLACEHOLDER",
|
||||
spec="https://drafts.csswg.org/css-text/#propdef-text-justify">
|
||||
|
||||
|
@ -689,6 +690,7 @@ ${helpers.predefined_type(
|
|||
"Color",
|
||||
"computed_value::T::currentcolor()",
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.prefixes.webkit",
|
||||
animation_value_type="AnimatedColor",
|
||||
ignored_when_colors_disabled=True,
|
||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||
|
@ -703,6 +705,7 @@ ${helpers.predefined_type(
|
|||
products="gecko",
|
||||
animation_value_type="AnimatedColor",
|
||||
ignored_when_colors_disabled=True,
|
||||
gecko_pref="layout.css.prefixes.webkit",
|
||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color",
|
||||
)}
|
||||
|
@ -713,6 +716,7 @@ ${helpers.predefined_type("-webkit-text-stroke-width",
|
|||
initial_specified_value="specified::BorderSideWidth::Length(specified::Length::zero())",
|
||||
computed_type="::values::computed::NonNegativeLength",
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.prefixes.webkit",
|
||||
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
|
||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width",
|
||||
animation_value_type="discrete")}
|
||||
|
@ -732,6 +736,7 @@ ${helpers.single_keyword("ruby-position", "over under",
|
|||
|
||||
${helpers.single_keyword("text-combine-upright", "none all",
|
||||
products="gecko", animation_value_type="discrete",
|
||||
gecko_pref="layout.css.text-combine-upright.enabled",
|
||||
spec="https://drafts.csswg.org/css-writing-modes-3/#text-combine-upright")}
|
||||
|
||||
// SVG 1.1: Section 11 - Painting: Filling, Stroking and Marker Symbols
|
||||
|
|
|
@ -257,6 +257,7 @@ ${helpers.predefined_type("object-position",
|
|||
"computed::NonNegativeLengthOrPercentage::zero()",
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-%s-gap" % kind,
|
||||
animation_value_type="NonNegativeLengthOrPercentage",
|
||||
gecko_pref="layout.css.grid.enabled",
|
||||
products="gecko")}
|
||||
|
||||
% for range in ["start", "end"]:
|
||||
|
@ -266,6 +267,7 @@ ${helpers.predefined_type("object-position",
|
|||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-%s-%s" % (kind, range),
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.grid.enabled",
|
||||
boxed=True)}
|
||||
% endfor
|
||||
|
||||
|
@ -277,6 +279,7 @@ ${helpers.predefined_type("object-position",
|
|||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-%ss" % kind,
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.grid.enabled",
|
||||
boxed=True)}
|
||||
|
||||
${helpers.predefined_type("grid-template-%ss" % kind,
|
||||
|
@ -285,6 +288,7 @@ ${helpers.predefined_type("object-position",
|
|||
products="gecko",
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-%ss" % kind,
|
||||
boxed=True,
|
||||
gecko_pref="layout.css.grid.enabled",
|
||||
animation_value_type="discrete")}
|
||||
|
||||
% endfor
|
||||
|
@ -292,6 +296,7 @@ ${helpers.predefined_type("object-position",
|
|||
<%helpers:longhand name="grid-auto-flow"
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-flow"
|
||||
products="gecko"
|
||||
gecko_pref="layout.css.grid.enabled"
|
||||
animation_value_type="discrete">
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
|
@ -415,6 +420,7 @@ ${helpers.predefined_type("object-position",
|
|||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-areas"
|
||||
products="gecko"
|
||||
animation_value_type="discrete"
|
||||
gecko_pref="layout.css.grid.enabled"
|
||||
boxed="True">
|
||||
use hash::FnvHashMap;
|
||||
use std::fmt;
|
||||
|
|
|
@ -62,4 +62,5 @@ ${helpers.predefined_type(
|
|||
animation_value_type="discrete",
|
||||
products="gecko",
|
||||
flags="APPLIES_TO_FIRST_LETTER",
|
||||
gecko_pref="layout.css.initial-letter.enabled",
|
||||
spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials")}
|
||||
|
|
|
@ -184,6 +184,7 @@ pub mod shorthands {
|
|||
data.declare_shorthand(
|
||||
"all",
|
||||
logical_longhands + other_longhands,
|
||||
gecko_pref="layout.css.all-shorthand.enabled",
|
||||
spec="https://drafts.csswg.org/css-cascade-3/#all-shorthand"
|
||||
)
|
||||
%>
|
||||
|
@ -238,7 +239,7 @@ impl NonCustomPropertyIdSet {
|
|||
static ${name}: NonCustomPropertyIdSet = NonCustomPropertyIdSet {
|
||||
<%
|
||||
storage = [0] * ((len(data.longhands) + len(data.shorthands) + len(data.all_aliases()) - 1 + 32) / 32)
|
||||
for i, property in enumerate(data.longhands + data.shorthands):
|
||||
for i, property in enumerate(data.longhands + data.shorthands + data.all_aliases()):
|
||||
if is_member(property):
|
||||
storage[i / 32] |= 1 << (i % 32)
|
||||
%>
|
||||
|
@ -1157,6 +1158,7 @@ impl PropertyId {
|
|||
Some(context) => context,
|
||||
None => {
|
||||
default = PropertyParserContext {
|
||||
in_chrome_stylesheet: false,
|
||||
stylesheet_origin: Origin::Author,
|
||||
rule_type: CssRuleType::Style,
|
||||
};
|
||||
|
@ -1286,84 +1288,76 @@ impl PropertyId {
|
|||
_ => {}
|
||||
}
|
||||
|
||||
// For properties that are experimental but not internal, the pref will
|
||||
// control its availability in all sheets. For properties that are
|
||||
// both experimental and internal, the pref only controls its
|
||||
// availability in non-UA sheets (and in UA sheets it is always available).
|
||||
${id_set("INTERNAL", lambda p: p.internal)}
|
||||
|
||||
% if product == "servo":
|
||||
${id_set("EXPERIMENTAL", lambda p: p.experimental)}
|
||||
% endif
|
||||
% if product == "gecko":
|
||||
use gecko_bindings::structs::root::mozilla;
|
||||
static EXPERIMENTAL: NonCustomPropertyIdSet = NonCustomPropertyIdSet {
|
||||
<%
|
||||
grouped = []
|
||||
properties = data.longhands + data.shorthands + data.all_aliases()
|
||||
while properties:
|
||||
grouped.append(properties[:32])
|
||||
properties = properties[32:]
|
||||
%>
|
||||
storage: [
|
||||
% for group in grouped:
|
||||
(0
|
||||
% for i, property in enumerate(group):
|
||||
| ((mozilla::SERVO_PREF_ENABLED_${property.gecko_pref_ident} as u32) << ${i})
|
||||
% endfor
|
||||
),
|
||||
% endfor
|
||||
]
|
||||
};
|
||||
% endif
|
||||
// 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 not p.explicitly_enabled_in_ua_sheets())}
|
||||
|
||||
let passes_pref_check = || {
|
||||
% if product == "servo":
|
||||
static PREF_NAME: [Option< &str>; ${len(data.longhands) + len(data.shorthands)}] = [
|
||||
% for property in data.longhands + data.shorthands:
|
||||
% if property.experimental:
|
||||
Some("${property.experimental}"),
|
||||
% if property.servo_pref:
|
||||
Some("${property.servo_pref}"),
|
||||
% else:
|
||||
None,
|
||||
% endif
|
||||
% endfor
|
||||
];
|
||||
match PREF_NAME[id.0] {
|
||||
None => true,
|
||||
Some(pref) => PREFS.get(pref).as_boolean().unwrap_or(false)
|
||||
}
|
||||
% endif
|
||||
% if product == "gecko":
|
||||
let pref = match PREF_NAME[id.0] {
|
||||
None => return true,
|
||||
Some(pref) => pref,
|
||||
};
|
||||
|
||||
PREFS.get(pref).as_boolean().unwrap_or(false)
|
||||
% else:
|
||||
let id = match alias {
|
||||
Some(alias_id) => alias_id.to_nscsspropertyid().unwrap(),
|
||||
None => self.to_nscsspropertyid().unwrap(),
|
||||
};
|
||||
|
||||
unsafe { structs::nsCSSProps_gPropertyEnabled[id as usize] }
|
||||
% endif
|
||||
};
|
||||
|
||||
if INTERNAL.contains(id) {
|
||||
if context.stylesheet_origin != Origin::UserAgent {
|
||||
if EXPERIMENTAL.contains(id) {
|
||||
if !passes_pref_check() {
|
||||
return Err(())
|
||||
}
|
||||
} else {
|
||||
return Err(())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if EXPERIMENTAL.contains(id) && !passes_pref_check() {
|
||||
return Err(());
|
||||
}
|
||||
if ALWAYS_ENABLED.contains(id) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
Ok(())
|
||||
if EXPERIMENTAL.contains(id) && passes_pref_check() {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
if context.stylesheet_origin == Origin::UserAgent &&
|
||||
ENABLED_IN_UA_SHEETS.contains(id)
|
||||
{
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
if context.in_chrome_stylesheet && ENABLED_IN_CHROME.contains(id) {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Parsing Context for PropertyId.
|
||||
pub struct PropertyParserContext {
|
||||
/// Whether the property is parsed in a chrome:// stylesheet.
|
||||
pub in_chrome_stylesheet: bool,
|
||||
/// The Origin of the stylesheet, whether it's a user,
|
||||
/// author or user-agent stylesheet.
|
||||
pub stylesheet_origin: Origin,
|
||||
|
@ -1375,6 +1369,7 @@ impl PropertyParserContext {
|
|||
/// Creates a PropertyParserContext with given stylesheet origin and rule type.
|
||||
pub fn new(context: &ParserContext) -> Self {
|
||||
Self {
|
||||
in_chrome_stylesheet: context.in_chrome_stylesheet(),
|
||||
stylesheet_origin: context.stylesheet_origin,
|
||||
rule_type: context.rule_type(),
|
||||
}
|
||||
|
|
|
@ -331,6 +331,7 @@ macro_rules! try_parse_one {
|
|||
</%helpers:shorthand>
|
||||
|
||||
<%helpers:shorthand name="scroll-snap-type" products="gecko"
|
||||
gecko_pref="layout.css.scroll-snap.enabled"
|
||||
sub_properties="scroll-snap-type-x scroll-snap-type-y"
|
||||
spec="https://drafts.csswg.org/css-scroll-snap/#propdef-scroll-snap-type">
|
||||
use properties::longhands::scroll_snap_type_x;
|
||||
|
@ -360,6 +361,7 @@ macro_rules! try_parse_one {
|
|||
|
||||
<%helpers:shorthand name="-moz-transform" products="gecko"
|
||||
sub_properties="transform"
|
||||
gecko_pref="layout.css.prefixes.transforms"
|
||||
flags="SHORTHAND_ALIAS_PROPERTY"
|
||||
derive_serialize="True"
|
||||
spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<%helpers:shorthand name="columns"
|
||||
sub_properties="column-width column-count"
|
||||
experimental="True"
|
||||
servo_pref="layout.columns.enabled",
|
||||
derive_serialize="True"
|
||||
extra_prefixes="moz" spec="https://drafts.csswg.org/css-multicol/#propdef-columns">
|
||||
use properties::longhands::{column_count, column_width};
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<%helpers:shorthand name="-webkit-text-stroke"
|
||||
sub_properties="-webkit-text-stroke-width
|
||||
-webkit-text-stroke-color"
|
||||
gecko_pref="layout.css.prefixes.webkit"
|
||||
products="gecko"
|
||||
derive_serialize="True"
|
||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke">
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
</%helpers:shorthand>
|
||||
|
||||
<%helpers:shorthand name="grid-gap" sub_properties="grid-row-gap grid-column-gap"
|
||||
gecko_pref="layout.css.grid.enabled"
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-gap"
|
||||
products="gecko">
|
||||
use properties::longhands::{grid_row_gap, grid_column_gap};
|
||||
|
@ -134,6 +135,7 @@
|
|||
|
||||
% for kind in ["row", "column"]:
|
||||
<%helpers:shorthand name="grid-${kind}" sub_properties="grid-${kind}-start grid-${kind}-end"
|
||||
gecko_pref="layout.css.grid.enabled"
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-${kind}"
|
||||
products="gecko">
|
||||
use values::specified::GridLine;
|
||||
|
@ -173,6 +175,7 @@
|
|||
% endfor
|
||||
|
||||
<%helpers:shorthand name="grid-area"
|
||||
gecko_pref="layout.css.grid.enabled"
|
||||
sub_properties="grid-row-start grid-row-end grid-column-start grid-column-end"
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-area"
|
||||
products="gecko">
|
||||
|
@ -238,6 +241,7 @@
|
|||
</%helpers:shorthand>
|
||||
|
||||
<%helpers:shorthand name="grid-template"
|
||||
gecko_pref="layout.css.grid.enabled"
|
||||
sub_properties="grid-template-rows grid-template-columns grid-template-areas"
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template"
|
||||
products="gecko">
|
||||
|
@ -459,6 +463,7 @@
|
|||
</%helpers:shorthand>
|
||||
|
||||
<%helpers:shorthand name="grid"
|
||||
gecko_pref="layout.css.grid.enabled"
|
||||
sub_properties="grid-template-rows grid-template-columns grid-template-areas
|
||||
grid-auto-rows grid-auto-columns grid-auto-flow"
|
||||
spec="https://drafts.csswg.org/css-grid/#propdef-grid"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue