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:
bors-servo 2017-11-16 14:01:39 -06:00 committed by GitHub
commit e07245caba
19 changed files with 143 additions and 74 deletions

View file

@ -81,7 +81,7 @@ def write(directory, filename, content):
def write_html(properties): def write_html(properties):
properties = dict( properties = dict(
(p.name, { (p.name, {
"flag": p.experimental, "flag": p.servo_pref,
"shorthand": hasattr(p, "sub_properties") "shorthand": hasattr(p, "sub_properties")
}) })
for p in properties.longhands + properties.shorthands for p in properties.longhands + properties.shorthands

View file

@ -146,12 +146,12 @@ def arg_to_bool(arg):
class Longhand(object): class Longhand(object):
def __init__(self, style_struct, name, spec=None, animation_value_type=None, derived_from=None, keyword=None, 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, need_index=False, custom_cascade_function=None, gecko_ffi_name=None,
allowed_in_keyframe_block=True, cast_type='u8', allowed_in_keyframe_block=True, cast_type='u8',
logical=False, alias=None, extra_prefixes=None, boxed=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,
gecko_pref_ident=None, vector=False, need_animatable=False): vector=False, need_animatable=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)
@ -161,7 +161,8 @@ class Longhand(object):
self.ident = to_rust_ident(name) self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident) self.camel_case = to_camel_case(self.ident)
self.style_struct = style_struct 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 = custom_cascade
self.custom_cascade_function = custom_cascade_function if custom_cascade else None self.custom_cascade_function = custom_cascade_function if custom_cascade else None
self.internal = internal self.internal = internal
@ -177,7 +178,6 @@ 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
@ -205,11 +205,25 @@ class Longhand(object):
self.transitionable = False self.transitionable = False
self.animation_type = None 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): 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_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 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)
@ -217,14 +231,14 @@ class Shorthand(object):
self.ident = to_rust_ident(name) self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident) self.camel_case = to_camel_case(self.ident)
self.derived_from = None 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.sub_properties = sub_properties
self.internal = internal self.internal = internal
self.alias = alias.split() if alias else [] self.alias = alias.split() if alias else []
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
@ -252,18 +266,40 @@ class Shorthand(object):
animatable = property(get_animatable) animatable = property(get_animatable)
transitionable = property(get_transitionable) 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): class Alias(object):
def __init__(self, name, original): def __init__(self, name, original):
self.name = name self.name = name
self.ident = to_rust_ident(name) self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident) self.camel_case = to_camel_case(self.ident)
self.gecko_pref_ident = to_rust_ident(name)
self.internal = original.internal 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_page_rule = original.allowed_in_page_rule
self.allowed_in_keyframe_block = original.allowed_in_keyframe_block 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): class Method(object):
def __init__(self, name, return_type=None, arg_types=None, is_mut=False): def __init__(self, name, return_type=None, arg_types=None, is_mut=False):

View file

@ -680,10 +680,9 @@
% endif % endif
</%def> </%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, shorthand = data.declare_shorthand(name, sub_properties.split(), **kwargs)
**kwargs)
%> %>
% if shorthand: % if shorthand:
/// ${shorthand.spec} /// ${shorthand.spec}

View file

@ -92,6 +92,7 @@ ${helpers.single_keyword("background-blend-mode",
color-burn hard-light soft-light difference exclusion hue color-burn hard-light soft-light difference exclusion hue
saturation color luminosity""", saturation color luminosity""",
gecko_constant_prefix="NS_STYLE_BLEND", gecko_constant_prefix="NS_STYLE_BLEND",
gecko_pref="layout.css.background-blend-mode.enabled",
vector=True, products="gecko", animation_value_type="discrete", vector=True, products="gecko", animation_value_type="discrete",
spec="https://drafts.fxtf.org/compositing/#background-blend-mode", spec="https://drafts.fxtf.org/compositing/#background-blend-mode",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")} flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER")}

View file

@ -191,6 +191,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
${helpers.single_keyword("box-decoration-break", "slice clone", ${helpers.single_keyword("box-decoration-break", "slice clone",
gecko_enum_prefix="StyleBoxDecorationBreak", gecko_enum_prefix="StyleBoxDecorationBreak",
gecko_pref="layout.css.box-decoration-break.enabled",
spec="https://drafts.csswg.org/css-break/#propdef-box-decoration-break", spec="https://drafts.csswg.org/css-break/#propdef-box-decoration-break",
products="gecko", animation_value_type="discrete")} products="gecko", animation_value_type="discrete")}

View file

@ -239,7 +239,6 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
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_"
flags="APPLIES_TO_FIRST_LETTER" flags="APPLIES_TO_FIRST_LETTER"
spec="https://drafts.csswg.org/css-box/#propdef-float"> spec="https://drafts.csswg.org/css-box/#propdef-float">
impl ToComputedValue for SpecifiedValue { 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", ${helpers.single_keyword("overflow-clip-box", "padding-box content-box",
products="gecko", animation_value_type="discrete", internal=True, products="gecko", animation_value_type="discrete", internal=True,
gecko_pref="layout.css.overflow-clip-box.enabled",
flags="APPLIES_TO_PLACEHOLDER", flags="APPLIES_TO_PLACEHOLDER",
spec="Internal, not web-exposed, \ spec="Internal, not web-exposed, \
may be standardized in the future (https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-clip-box)")} 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", "ScrollSnapPoint",
"computed::ScrollSnapPoint::none()", "computed::ScrollSnapPoint::none()",
animation_value_type="discrete", animation_value_type="discrete",
gecko_pref="layout.css.scroll-snap.enabled",
products="gecko", products="gecko",
spec="Nonstandard (https://www.w3.org/TR/2015/WD-css-snappoints-1-20150326/#scroll-snap-points)", 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", "Position",
"computed::Position::zero()", "computed::Position::zero()",
products="gecko", products="gecko",
gecko_pref="layout.css.scroll-snap.enabled",
boxed="True", boxed="True",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
animation_value_type="discrete")} animation_value_type="discrete")}
@ -562,6 +564,7 @@ ${helpers.predefined_type(
"computed::Position::zero()", "computed::Position::zero()",
vector=True, vector=True,
products="gecko", products="gecko",
gecko_pref="layout.css.scroll-snap.enabled",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-destination)",
animation_value_type="discrete", animation_value_type="discrete",
allow_empty="NotInitial" allow_empty="NotInitial"
@ -579,6 +582,7 @@ ${helpers.predefined_type("transform", "Transform",
// https://www.w3.org/TR/cssom-view-1/ // https://www.w3.org/TR/cssom-view-1/
${helpers.single_keyword("scroll-behavior", ${helpers.single_keyword("scroll-behavior",
"auto smooth", "auto smooth",
gecko_pref="layout.css.scroll-behavior.property-enabled",
products="gecko", products="gecko",
spec="https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior", spec="https://drafts.csswg.org/cssom-view/#propdef-scroll-behavior",
animation_value_type="discrete")} animation_value_type="discrete")}
@ -590,6 +594,7 @@ ${helpers.single_keyword("scroll-behavior",
"computed::ScrollSnapType::None", "computed::ScrollSnapType::None",
products="gecko", products="gecko",
needs_context=False, 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)", spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type-x)",
animation_value_type="discrete" animation_value_type="discrete"
)} )}
@ -600,6 +605,7 @@ ${helpers.single_keyword("scroll-behavior",
${helpers.single_keyword("isolation", ${helpers.single_keyword("isolation",
"auto isolate", "auto isolate",
products="gecko", products="gecko",
gecko_pref="layout.css.isolation.enabled",
spec="https://drafts.fxtf.org/compositing/#isolation", spec="https://drafts.fxtf.org/compositing/#isolation",
flags="CREATES_STACKING_CONTEXT", flags="CREATES_STACKING_CONTEXT",
animation_value_type="discrete")} animation_value_type="discrete")}
@ -666,6 +672,7 @@ ${helpers.single_keyword("transform-box",
"border-box fill-box view-box", "border-box fill-box view-box",
gecko_enum_prefix="StyleGeometryBox", gecko_enum_prefix="StyleGeometryBox",
products="gecko", products="gecko",
gecko_pref="svg.transform-box.enabled",
spec="https://drafts.csswg.org/css-transforms/#transform-box", spec="https://drafts.csswg.org/css-transforms/#transform-box",
gecko_inexhaustive="True", gecko_inexhaustive="True",
animation_value_type="discrete")} animation_value_type="discrete")}
@ -693,6 +700,7 @@ ${helpers.predefined_type("transform-origin",
// also update the glue once they are implemented in gecko. // also update the glue once they are implemented in gecko.
<%helpers:longhand name="contain" animation_value_type="discrete" products="gecko" <%helpers:longhand name="contain" animation_value_type="discrete" products="gecko"
flags="FIXPOS_CB" flags="FIXPOS_CB"
gecko_pref="layout.css.contain.enabled",
spec="https://drafts.csswg.org/css-contain/#contain-property"> spec="https://drafts.csswg.org/css-contain/#contain-property">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -894,6 +902,7 @@ ${helpers.predefined_type(
"generics::basic_shape::ShapeSource::None", "generics::basic_shape::ShapeSource::None",
products="gecko", products="gecko",
boxed=True, boxed=True,
gecko_pref="layout.css.shape-outside.enabled",
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
flags="APPLIES_TO_FIRST_LETTER", flags="APPLIES_TO_FIRST_LETTER",
spec="https://drafts.csswg.org/css-shapes/#shape-outside-property", spec="https://drafts.csswg.org/css-shapes/#shape-outside-property",
@ -902,6 +911,7 @@ ${helpers.predefined_type(
<%helpers:longhand name="touch-action" <%helpers:longhand name="touch-action"
products="gecko" products="gecko"
animation_value_type="discrete" animation_value_type="discrete"
gecko_pref="layout.css.touch_action.enabled"
spec="https://compat.spec.whatwg.org/#touch-action"> spec="https://compat.spec.whatwg.org/#touch-action">
use gecko_bindings::structs; use gecko_bindings::structs;
use std::fmt; use std::fmt;

View file

@ -12,7 +12,7 @@ ${helpers.predefined_type("column-width",
initial_specified_value="Either::Second(Auto)", initial_specified_value="Either::Second(Auto)",
extra_prefixes="moz", extra_prefixes="moz",
animation_value_type="NonNegativeLengthOrAuto", animation_value_type="NonNegativeLengthOrAuto",
experimental=True, servo_pref="layout.column-width.enabled",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-width")} spec="https://drafts.csswg.org/css-multicol/#propdef-column-width")}
@ -20,7 +20,7 @@ ${helpers.predefined_type("column-count",
"PositiveIntegerOrAuto", "PositiveIntegerOrAuto",
"Either::Second(Auto)", "Either::Second(Auto)",
initial_specified_value="Either::Second(Auto)", initial_specified_value="Either::Second(Auto)",
experimental="True", servo_pref="layout.column-count.enabled",
animation_value_type="PositiveIntegerOrAuto", animation_value_type="PositiveIntegerOrAuto",
extra_prefixes="moz", extra_prefixes="moz",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-count")} spec="https://drafts.csswg.org/css-multicol/#propdef-column-count")}
@ -29,7 +29,7 @@ ${helpers.predefined_type("column-gap",
"length::NonNegativeLengthOrNormal", "length::NonNegativeLengthOrNormal",
"Either::Second(Normal)", "Either::Second(Normal)",
extra_prefixes="moz", extra_prefixes="moz",
experimental=True, servo_pref="layout.column-gap.enabled",
animation_value_type="NonNegativeLengthOrNormal", animation_value_type="NonNegativeLengthOrNormal",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap")} spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap")}
@ -62,6 +62,7 @@ ${helpers.predefined_type(
${helpers.single_keyword("column-span", "none all", ${helpers.single_keyword("column-span", "none all",
products="gecko", animation_value_type="discrete", products="gecko", animation_value_type="discrete",
gecko_pref="layout.css.column-span.enabled",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-span")} spec="https://drafts.csswg.org/css-multicol/#propdef-column-span")}
${helpers.single_keyword("column-rule-style", ${helpers.single_keyword("column-rule-style",

View file

@ -52,4 +52,5 @@ ${helpers.single_keyword("mix-blend-mode",
saturation color luminosity""", gecko_constant_prefix="NS_STYLE_BLEND", saturation color luminosity""", gecko_constant_prefix="NS_STYLE_BLEND",
animation_value_type="discrete", animation_value_type="discrete",
flags="CREATES_STACKING_CONTEXT", flags="CREATES_STACKING_CONTEXT",
gecko_pref="layout.css.mix-blend-mode.enabled",
spec="https://drafts.fxtf.org/compositing/#propdef-mix-blend-mode")} spec="https://drafts.fxtf.org/compositing/#propdef-mix-blend-mode")}

View file

@ -1065,6 +1065,7 @@ https://drafts.csswg.org/css-fonts-4/#low-level-font-variation-settings-control-
${helpers.predefined_type("font-variation-settings", ${helpers.predefined_type("font-variation-settings",
"FontVariantSettings", "FontVariantSettings",
products="gecko", products="gecko",
gecko_pref="layout.css.font-variations.enabled",
initial_value="specified::FontVariantSettings::normal()", initial_value="specified::FontVariantSettings::normal()",
animation_value_type="ComputedValue", animation_value_type="ComputedValue",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", 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", "auto grayscale",
gecko_constant_prefix="NS_FONT_SMOOTHING", gecko_constant_prefix="NS_FONT_SMOOTHING",
gecko_ffi_name="mFont.smoothing", gecko_ffi_name="mFont.smoothing",
gecko_pref="layout.css.osx-font-smoothing.enabled",
products="gecko", products="gecko",
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/font-smooth)", 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", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",

View file

@ -22,7 +22,7 @@ ${helpers.single_keyword("writing-mode",
extra_gecko_aliases="lr=horizontal-tb lr-tb=horizontal-tb \ extra_gecko_aliases="lr=horizontal-tb lr-tb=horizontal-tb \
rl=horizontal-tb rl-tb=horizontal-tb \ rl=horizontal-tb rl-tb=horizontal-tb \
tb=vertical-rl tb-rl=vertical-rl", tb=vertical-rl tb-rl=vertical-rl",
experimental=True, servo_pref="layout.writing-mode.enabled",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-writing-modes/#propdef-writing-mode")} 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/ // https://drafts.csswg.org/css-color/
${helpers.single_keyword("color-adjust", ${helpers.single_keyword("color-adjust",
"economy exact", products="gecko", "economy exact", products="gecko",
gecko_pref="layout.css.color-adjust.enabled",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-color/#propdef-color-adjust")} spec="https://drafts.csswg.org/css-color/#propdef-color-adjust")}
@ -60,6 +61,7 @@ ${helpers.single_keyword("image-rendering",
<%helpers:longhand name="image-orientation" <%helpers:longhand name="image-orientation"
products="gecko" products="gecko"
animation_value_type="discrete" animation_value_type="discrete"
gecko_pref="layout.css.image-orientation.enabled"
spec="https://drafts.csswg.org/css-images/#propdef-image-orientation, \ spec="https://drafts.csswg.org/css-images/#propdef-image-orientation, \
/// additional values in https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation"> /// additional values in https://developer.mozilla.org/en-US/docs/Web/CSS/image-orientation">
use std::fmt; use std::fmt;

View file

@ -132,6 +132,7 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)",
<%helpers:longhand name="paint-order" <%helpers:longhand name="paint-order"
animation_value_type="discrete" animation_value_type="discrete"
gecko_pref="svg.paint-order.enabled"
products="gecko" products="gecko"
spec="https://www.w3.org/TR/SVG2/painting.html#PaintOrder"> spec="https://www.w3.org/TR/SVG2/painting.html#PaintOrder">
use std::fmt; use std::fmt;

View file

@ -66,6 +66,7 @@ ${helpers.single_keyword("word-break",
extra_specified="${'distribute' if product == 'gecko' else ''}" extra_specified="${'distribute' if product == 'gecko' else ''}"
gecko_enum_prefix="StyleTextJustify" gecko_enum_prefix="StyleTextJustify"
animation_value_type="discrete" animation_value_type="discrete"
gecko_pref="layout.css.text-justify.enabled"
flags="APPLIES_TO_PLACEHOLDER", flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-text/#propdef-text-justify"> spec="https://drafts.csswg.org/css-text/#propdef-text-justify">
@ -689,6 +690,7 @@ ${helpers.predefined_type(
"Color", "Color",
"computed_value::T::currentcolor()", "computed_value::T::currentcolor()",
products="gecko", products="gecko",
gecko_pref="layout.css.prefixes.webkit",
animation_value_type="AnimatedColor", animation_value_type="AnimatedColor",
ignored_when_colors_disabled=True, ignored_when_colors_disabled=True,
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
@ -703,6 +705,7 @@ ${helpers.predefined_type(
products="gecko", products="gecko",
animation_value_type="AnimatedColor", animation_value_type="AnimatedColor",
ignored_when_colors_disabled=True, ignored_when_colors_disabled=True,
gecko_pref="layout.css.prefixes.webkit",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color", 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())", initial_specified_value="specified::BorderSideWidth::Length(specified::Length::zero())",
computed_type="::values::computed::NonNegativeLength", computed_type="::values::computed::NonNegativeLength",
products="gecko", products="gecko",
gecko_pref="layout.css.prefixes.webkit",
flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER", flags="APPLIES_TO_FIRST_LETTER APPLIES_TO_FIRST_LINE APPLIES_TO_PLACEHOLDER",
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width", spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width",
animation_value_type="discrete")} animation_value_type="discrete")}
@ -732,6 +736,7 @@ ${helpers.single_keyword("ruby-position", "over under",
${helpers.single_keyword("text-combine-upright", "none all", ${helpers.single_keyword("text-combine-upright", "none all",
products="gecko", animation_value_type="discrete", 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")} spec="https://drafts.csswg.org/css-writing-modes-3/#text-combine-upright")}
// SVG 1.1: Section 11 - Painting: Filling, Stroking and Marker Symbols // SVG 1.1: Section 11 - Painting: Filling, Stroking and Marker Symbols

View file

@ -257,6 +257,7 @@ ${helpers.predefined_type("object-position",
"computed::NonNegativeLengthOrPercentage::zero()", "computed::NonNegativeLengthOrPercentage::zero()",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-%s-gap" % kind, spec="https://drafts.csswg.org/css-grid/#propdef-grid-%s-gap" % kind,
animation_value_type="NonNegativeLengthOrPercentage", animation_value_type="NonNegativeLengthOrPercentage",
gecko_pref="layout.css.grid.enabled",
products="gecko")} products="gecko")}
% for range in ["start", "end"]: % for range in ["start", "end"]:
@ -266,6 +267,7 @@ ${helpers.predefined_type("object-position",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-%s-%s" % (kind, range), spec="https://drafts.csswg.org/css-grid/#propdef-grid-%s-%s" % (kind, range),
products="gecko", products="gecko",
gecko_pref="layout.css.grid.enabled",
boxed=True)} boxed=True)}
% endfor % endfor
@ -277,6 +279,7 @@ ${helpers.predefined_type("object-position",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-%ss" % kind, spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-%ss" % kind,
products="gecko", products="gecko",
gecko_pref="layout.css.grid.enabled",
boxed=True)} boxed=True)}
${helpers.predefined_type("grid-template-%ss" % kind, ${helpers.predefined_type("grid-template-%ss" % kind,
@ -285,6 +288,7 @@ ${helpers.predefined_type("object-position",
products="gecko", products="gecko",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-%ss" % kind, spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-%ss" % kind,
boxed=True, boxed=True,
gecko_pref="layout.css.grid.enabled",
animation_value_type="discrete")} animation_value_type="discrete")}
% endfor % endfor
@ -292,6 +296,7 @@ ${helpers.predefined_type("object-position",
<%helpers:longhand name="grid-auto-flow" <%helpers:longhand name="grid-auto-flow"
spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-flow" spec="https://drafts.csswg.org/css-grid/#propdef-grid-auto-flow"
products="gecko" products="gecko"
gecko_pref="layout.css.grid.enabled"
animation_value_type="discrete"> animation_value_type="discrete">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -415,6 +420,7 @@ ${helpers.predefined_type("object-position",
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-areas" spec="https://drafts.csswg.org/css-grid/#propdef-grid-template-areas"
products="gecko" products="gecko"
animation_value_type="discrete" animation_value_type="discrete"
gecko_pref="layout.css.grid.enabled"
boxed="True"> boxed="True">
use hash::FnvHashMap; use hash::FnvHashMap;
use std::fmt; use std::fmt;

View file

@ -62,4 +62,5 @@ ${helpers.predefined_type(
animation_value_type="discrete", animation_value_type="discrete",
products="gecko", products="gecko",
flags="APPLIES_TO_FIRST_LETTER", flags="APPLIES_TO_FIRST_LETTER",
gecko_pref="layout.css.initial-letter.enabled",
spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials")} spec="https://drafts.csswg.org/css-inline/#sizing-drop-initials")}

View file

@ -184,6 +184,7 @@ pub mod shorthands {
data.declare_shorthand( data.declare_shorthand(
"all", "all",
logical_longhands + other_longhands, logical_longhands + other_longhands,
gecko_pref="layout.css.all-shorthand.enabled",
spec="https://drafts.csswg.org/css-cascade-3/#all-shorthand" spec="https://drafts.csswg.org/css-cascade-3/#all-shorthand"
) )
%> %>
@ -238,7 +239,7 @@ impl NonCustomPropertyIdSet {
static ${name}: NonCustomPropertyIdSet = NonCustomPropertyIdSet { static ${name}: NonCustomPropertyIdSet = NonCustomPropertyIdSet {
<% <%
storage = [0] * ((len(data.longhands) + len(data.shorthands) + len(data.all_aliases()) - 1 + 32) / 32) 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): if is_member(property):
storage[i / 32] |= 1 << (i % 32) storage[i / 32] |= 1 << (i % 32)
%> %>
@ -1157,6 +1158,7 @@ impl PropertyId {
Some(context) => context, Some(context) => context,
None => { None => {
default = PropertyParserContext { default = PropertyParserContext {
in_chrome_stylesheet: false,
stylesheet_origin: Origin::Author, stylesheet_origin: Origin::Author,
rule_type: CssRuleType::Style, rule_type: CssRuleType::Style,
}; };
@ -1286,84 +1288,76 @@ impl PropertyId {
_ => {} _ => {}
} }
// For properties that are experimental but not internal, the pref will // The semantics of these are kinda hard to reason about, what follows
// control its availability in all sheets. For properties that are // is a description of the different combinations that can happen with
// both experimental and internal, the pref only controls its // these three sets.
// availability in non-UA sheets (and in UA sheets it is always available). //
${id_set("INTERNAL", lambda p: p.internal)} // Experimental properties are generally controlled by prefs, but an
// experimental property explicitly enabled in certain context (UA or
% if product == "servo": // chrome sheets) is always usable in the context regardless of the
${id_set("EXPERIMENTAL", lambda p: p.experimental)} // pref value.
% endif //
% if product == "gecko": // Non-experimental properties are either normal properties which are
use gecko_bindings::structs::root::mozilla; // usable everywhere, or internal-only properties which are only usable
static EXPERIMENTAL: NonCustomPropertyIdSet = NonCustomPropertyIdSet { // in certain context they are explicitly enabled in.
<% ${id_set("ENABLED_IN_UA_SHEETS", lambda p: p.explicitly_enabled_in_ua_sheets())}
grouped = [] ${id_set("ENABLED_IN_CHROME", lambda p: p.explicitly_enabled_in_chrome())}
properties = data.longhands + data.shorthands + data.all_aliases() ${id_set("EXPERIMENTAL", lambda p: p.experimental(product))}
while properties: ${id_set("ALWAYS_ENABLED", lambda p: not p.experimental(product) and not p.explicitly_enabled_in_ua_sheets())}
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
let passes_pref_check = || { let passes_pref_check = || {
% if product == "servo": % if product == "servo":
static PREF_NAME: [Option< &str>; ${len(data.longhands) + len(data.shorthands)}] = [ static PREF_NAME: [Option< &str>; ${len(data.longhands) + len(data.shorthands)}] = [
% for property in data.longhands + data.shorthands: % for property in data.longhands + data.shorthands:
% if property.experimental: % if property.servo_pref:
Some("${property.experimental}"), Some("${property.servo_pref}"),
% else: % else:
None, None,
% endif % endif
% endfor % endfor
]; ];
match PREF_NAME[id.0] { let pref = match PREF_NAME[id.0] {
None => true, None => return true,
Some(pref) => PREFS.get(pref).as_boolean().unwrap_or(false) Some(pref) => pref,
} };
% endif
% if product == "gecko": PREFS.get(pref).as_boolean().unwrap_or(false)
% else:
let id = match alias { let id = match alias {
Some(alias_id) => alias_id.to_nscsspropertyid().unwrap(), Some(alias_id) => alias_id.to_nscsspropertyid().unwrap(),
None => self.to_nscsspropertyid().unwrap(), None => self.to_nscsspropertyid().unwrap(),
}; };
unsafe { structs::nsCSSProps_gPropertyEnabled[id as usize] } unsafe { structs::nsCSSProps_gPropertyEnabled[id as usize] }
% endif % endif
}; };
if INTERNAL.contains(id) { if ALWAYS_ENABLED.contains(id) {
if context.stylesheet_origin != Origin::UserAgent { return Ok(())
if EXPERIMENTAL.contains(id) {
if !passes_pref_check() {
return Err(())
}
} else {
return Err(())
}
}
} else {
if EXPERIMENTAL.contains(id) && !passes_pref_check() {
return Err(());
}
} }
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. /// Parsing Context for PropertyId.
pub struct PropertyParserContext { 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, /// The Origin of the stylesheet, whether it's a user,
/// author or user-agent stylesheet. /// author or user-agent stylesheet.
pub stylesheet_origin: Origin, pub stylesheet_origin: Origin,
@ -1375,6 +1369,7 @@ impl PropertyParserContext {
/// Creates a PropertyParserContext with given stylesheet origin and rule type. /// Creates a PropertyParserContext with given stylesheet origin and rule type.
pub fn new(context: &ParserContext) -> Self { pub fn new(context: &ParserContext) -> Self {
Self { Self {
in_chrome_stylesheet: context.in_chrome_stylesheet(),
stylesheet_origin: context.stylesheet_origin, stylesheet_origin: context.stylesheet_origin,
rule_type: context.rule_type(), rule_type: context.rule_type(),
} }

View file

@ -331,6 +331,7 @@ macro_rules! try_parse_one {
</%helpers:shorthand> </%helpers:shorthand>
<%helpers:shorthand name="scroll-snap-type" products="gecko" <%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" sub_properties="scroll-snap-type-x scroll-snap-type-y"
spec="https://drafts.csswg.org/css-scroll-snap/#propdef-scroll-snap-type"> spec="https://drafts.csswg.org/css-scroll-snap/#propdef-scroll-snap-type">
use properties::longhands::scroll_snap_type_x; use properties::longhands::scroll_snap_type_x;
@ -360,6 +361,7 @@ macro_rules! try_parse_one {
<%helpers:shorthand name="-moz-transform" products="gecko" <%helpers:shorthand name="-moz-transform" products="gecko"
sub_properties="transform" sub_properties="transform"
gecko_pref="layout.css.prefixes.transforms"
flags="SHORTHAND_ALIAS_PROPERTY" flags="SHORTHAND_ALIAS_PROPERTY"
derive_serialize="True" derive_serialize="True"
spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform"> spec="Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/transform">

View file

@ -6,7 +6,7 @@
<%helpers:shorthand name="columns" <%helpers:shorthand name="columns"
sub_properties="column-width column-count" sub_properties="column-width column-count"
experimental="True" servo_pref="layout.columns.enabled",
derive_serialize="True" derive_serialize="True"
extra_prefixes="moz" spec="https://drafts.csswg.org/css-multicol/#propdef-columns"> extra_prefixes="moz" spec="https://drafts.csswg.org/css-multicol/#propdef-columns">
use properties::longhands::{column_count, column_width}; use properties::longhands::{column_count, column_width};

View file

@ -46,6 +46,7 @@
<%helpers:shorthand name="-webkit-text-stroke" <%helpers:shorthand name="-webkit-text-stroke"
sub_properties="-webkit-text-stroke-width sub_properties="-webkit-text-stroke-width
-webkit-text-stroke-color" -webkit-text-stroke-color"
gecko_pref="layout.css.prefixes.webkit"
products="gecko" products="gecko"
derive_serialize="True" derive_serialize="True"
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke"> spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke">

View file

@ -103,6 +103,7 @@
</%helpers:shorthand> </%helpers:shorthand>
<%helpers:shorthand name="grid-gap" sub_properties="grid-row-gap grid-column-gap" <%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" spec="https://drafts.csswg.org/css-grid/#propdef-grid-gap"
products="gecko"> products="gecko">
use properties::longhands::{grid_row_gap, grid_column_gap}; use properties::longhands::{grid_row_gap, grid_column_gap};
@ -134,6 +135,7 @@
% for kind in ["row", "column"]: % for kind in ["row", "column"]:
<%helpers:shorthand name="grid-${kind}" sub_properties="grid-${kind}-start grid-${kind}-end" <%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}" spec="https://drafts.csswg.org/css-grid/#propdef-grid-${kind}"
products="gecko"> products="gecko">
use values::specified::GridLine; use values::specified::GridLine;
@ -173,6 +175,7 @@
% endfor % endfor
<%helpers:shorthand name="grid-area" <%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" sub_properties="grid-row-start grid-row-end grid-column-start grid-column-end"
spec="https://drafts.csswg.org/css-grid/#propdef-grid-area" spec="https://drafts.csswg.org/css-grid/#propdef-grid-area"
products="gecko"> products="gecko">
@ -238,6 +241,7 @@
</%helpers:shorthand> </%helpers:shorthand>
<%helpers:shorthand name="grid-template" <%helpers:shorthand name="grid-template"
gecko_pref="layout.css.grid.enabled"
sub_properties="grid-template-rows grid-template-columns grid-template-areas" sub_properties="grid-template-rows grid-template-columns grid-template-areas"
spec="https://drafts.csswg.org/css-grid/#propdef-grid-template" spec="https://drafts.csswg.org/css-grid/#propdef-grid-template"
products="gecko"> products="gecko">
@ -459,6 +463,7 @@
</%helpers:shorthand> </%helpers:shorthand>
<%helpers:shorthand name="grid" <%helpers:shorthand name="grid"
gecko_pref="layout.css.grid.enabled"
sub_properties="grid-template-rows grid-template-columns grid-template-areas sub_properties="grid-template-rows grid-template-columns grid-template-areas
grid-auto-rows grid-auto-columns grid-auto-flow" grid-auto-rows grid-auto-columns grid-auto-flow"
spec="https://drafts.csswg.org/css-grid/#propdef-grid" spec="https://drafts.csswg.org/css-grid/#propdef-grid"