mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Create a generic flag system for properties
This commit is contained in:
parent
355d5f89da
commit
67799f9445
6 changed files with 36 additions and 35 deletions
|
@ -128,8 +128,7 @@ class Longhand(object):
|
|||
need_clone=False, need_index=False, gecko_ffi_name=None, depend_on_viewport_size=False,
|
||||
allowed_in_keyframe_block=True, complex_color=False, cast_type='u8',
|
||||
has_uncacheable_values=False, logical=False, alias=None, extra_prefixes=None, boxed=False,
|
||||
creates_stacking_context=False, fixpos_cb=False, abspos_cb=False,
|
||||
allowed_in_page_rule=False):
|
||||
flags=None, allowed_in_page_rule=False):
|
||||
self.name = name
|
||||
if not spec:
|
||||
raise TypeError("Spec should be specified for %s" % name)
|
||||
|
@ -153,9 +152,7 @@ class Longhand(object):
|
|||
self.alias = alias.split() if alias else []
|
||||
self.extra_prefixes = extra_prefixes.split() if extra_prefixes else []
|
||||
self.boxed = arg_to_bool(boxed)
|
||||
self.creates_stacking_context = arg_to_bool(creates_stacking_context)
|
||||
self.fixpos_cb = arg_to_bool(fixpos_cb)
|
||||
self.abspos_cb = arg_to_bool(abspos_cb)
|
||||
self.flags = flags.split() if flags else []
|
||||
self.allowed_in_page_rule = arg_to_bool(allowed_in_page_rule)
|
||||
|
||||
# https://drafts.csswg.org/css-animations/#keyframes
|
||||
|
@ -190,7 +187,7 @@ class Longhand(object):
|
|||
class Shorthand(object):
|
||||
def __init__(self, name, sub_properties, spec=None, experimental=False, internal=False,
|
||||
allowed_in_keyframe_block=True, alias=None, extra_prefixes=None,
|
||||
allowed_in_page_rule=False):
|
||||
allowed_in_page_rule=False, flags=None):
|
||||
self.name = name
|
||||
if not spec:
|
||||
raise TypeError("Spec should be specified for %s" % name)
|
||||
|
@ -204,6 +201,7 @@ class Shorthand(object):
|
|||
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 []
|
||||
|
||||
# https://drafts.csswg.org/css-animations/#keyframes
|
||||
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
|
||||
|
|
|
@ -107,8 +107,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed",
|
|||
need_clone="True",
|
||||
extra_gecko_values="sticky",
|
||||
animation_type="none",
|
||||
creates_stacking_context="True",
|
||||
abspos_cb="True",
|
||||
flags="CREATES_STACKING_CONTEXT ABSPOS_CB",
|
||||
spec="https://drafts.csswg.org/css-position/#position-property")}
|
||||
|
||||
<%helpers:single_keyword_computed name="float"
|
||||
|
@ -1111,8 +1110,7 @@ ${helpers.predefined_type("scroll-snap-coordinate",
|
|||
|
||||
<%helpers:longhand name="transform" products="gecko servo" extra_prefixes="webkit"
|
||||
animation_type="normal"
|
||||
creates_stacking_context="True"
|
||||
fixpos_cb="True"
|
||||
flags="CREATES_STACKING_CONTEXT FIXPOS_CB"
|
||||
spec="https://drafts.csswg.org/css-transforms/#propdef-transform">
|
||||
use app_units::Au;
|
||||
use values::specified::{Angle, Length, LengthOrPercentage, Number};
|
||||
|
@ -1825,7 +1823,7 @@ ${helpers.single_keyword("isolation",
|
|||
"auto isolate",
|
||||
products="gecko",
|
||||
spec="https://drafts.fxtf.org/compositing/#isolation",
|
||||
creates_stacking_context=True,
|
||||
flags="CREATES_STACKING_CONTEXT",
|
||||
animation_type="none")}
|
||||
|
||||
// TODO add support for logical values recto and verso
|
||||
|
@ -1864,8 +1862,7 @@ ${helpers.predefined_type("perspective",
|
|||
gecko_ffi_name="mChildPerspective",
|
||||
spec="https://drafts.csswg.org/css-transforms/#perspective",
|
||||
extra_prefixes="moz webkit",
|
||||
creates_stacking_context=True,
|
||||
fixpos_cb=True,
|
||||
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
|
||||
animation_type="normal")}
|
||||
|
||||
<%helpers:longhand name="perspective-origin" boxed="True" animation_type="normal" extra_prefixes="moz webkit"
|
||||
|
@ -1963,8 +1960,7 @@ ${helpers.single_keyword("transform-style",
|
|||
"flat preserve-3d",
|
||||
spec="https://drafts.csswg.org/css-transforms/#transform-style-property",
|
||||
extra_prefixes="moz webkit",
|
||||
creates_stacking_context=True,
|
||||
fixpos_cb=True,
|
||||
flags="CREATES_STACKING_CONTEXT FIXPOS_CB",
|
||||
animation_type="none")}
|
||||
|
||||
<%helpers:longhand name="transform-origin" animation_type="normal" extra_prefixes="moz webkit" boxed="True"
|
||||
|
|
|
@ -11,7 +11,7 @@ ${helpers.predefined_type("opacity",
|
|||
"Opacity",
|
||||
"1.0",
|
||||
animation_type="normal",
|
||||
creates_stacking_context=True,
|
||||
flags="CREATES_STACKING_CONTEXT",
|
||||
spec="https://drafts.csswg.org/css-color/#opacity")}
|
||||
|
||||
<%helpers:vector_longhand name="box-shadow" allow_empty="True"
|
||||
|
@ -87,8 +87,7 @@ ${helpers.predefined_type("clip",
|
|||
|
||||
// FIXME: This prop should be animatable
|
||||
<%helpers:longhand name="filter" animation_type="none" extra_prefixes="webkit"
|
||||
creates_stacking_context="True"
|
||||
fixpos_cb="True"
|
||||
flags="CREATES_STACKING_CONTEXT FIXPOS_CB"
|
||||
spec="https://drafts.fxtf.org/filters/#propdef-filter">
|
||||
//pub use self::computed_value::T as SpecifiedValue;
|
||||
use cssparser;
|
||||
|
@ -526,5 +525,5 @@ ${helpers.single_keyword("mix-blend-mode",
|
|||
color-burn hard-light soft-light difference exclusion hue
|
||||
saturation color luminosity""", gecko_constant_prefix="NS_STYLE_BLEND",
|
||||
animation_type="none",
|
||||
creates_stacking_context=True,
|
||||
flags="CREATES_STACKING_CONTEXT",
|
||||
spec="https://drafts.fxtf.org/compositing/#propdef-mix-blend-mode")}
|
||||
|
|
|
@ -26,9 +26,10 @@
|
|||
${helpers.predefined_type("z-index", "IntegerOrAuto",
|
||||
"Either::Second(Auto)",
|
||||
spec="https://www.w3.org/TR/CSS2/visuren.html#z-index",
|
||||
creates_stacking_context=True,
|
||||
flags="CREATES_STACKING_CONTEXT",
|
||||
animation_type="normal")}
|
||||
|
||||
|
||||
// CSS Flexible Box Layout Module Level 1
|
||||
// http://www.w3.org/TR/css3-flexbox/
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ ${helpers.single_keyword("mask-type", "luminance alpha",
|
|||
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-type")}
|
||||
|
||||
<%helpers:longhand name="clip-path" animation_type="none" products="gecko" boxed="True"
|
||||
creates_stacking_context="True"
|
||||
flags="CREATES_STACKING_CONTEXT"
|
||||
spec="https://drafts.fxtf.org/css-masking/#propdef-clip-path">
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
|
@ -200,7 +200,7 @@ ${helpers.single_keyword("mask-composite",
|
|||
|
||||
<%helpers:vector_longhand name="mask-image" products="gecko" animation_type="none" extra_prefixes="webkit"
|
||||
has_uncacheable_values="${product == 'gecko'}"
|
||||
creates_stacking_context="True"
|
||||
flags="CREATES_STACKING_CONTEXT",
|
||||
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-image">
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
|
|
|
@ -469,13 +469,13 @@ bitflags! {
|
|||
/// A set of flags for properties.
|
||||
pub flags PropertyFlags: u8 {
|
||||
/// This property requires a stacking context.
|
||||
const CREATES_STACKING_CONTEXT = 0x01,
|
||||
const CREATES_STACKING_CONTEXT = 1 << 0,
|
||||
/// This property has values that can establish a containing block for
|
||||
/// fixed positioned and absolutely positioned elements.
|
||||
const FIXPOS_CB = 0x02,
|
||||
const FIXPOS_CB = 1 << 1,
|
||||
/// This property has values that can establish a containing block for
|
||||
/// absolutely positioned elements.
|
||||
const ABSPOS_CB = 0x04,
|
||||
const ABSPOS_CB = 1 << 2,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -518,20 +518,14 @@ impl LonghandId {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns PropertyFlags for given property.
|
||||
/// Returns PropertyFlags for given longhand property.
|
||||
pub fn flags(&self) -> PropertyFlags {
|
||||
match *self {
|
||||
% for property in data.longhands:
|
||||
LonghandId::${property.camel_case} =>
|
||||
%if property.creates_stacking_context:
|
||||
CREATES_STACKING_CONTEXT |
|
||||
%endif
|
||||
%if property.fixpos_cb:
|
||||
FIXPOS_CB |
|
||||
%endif
|
||||
%if property.abspos_cb:
|
||||
ABSPOS_CB |
|
||||
%endif
|
||||
% for flag in property.flags:
|
||||
${flag} |
|
||||
% endfor
|
||||
PropertyFlags::empty(),
|
||||
% endfor
|
||||
}
|
||||
|
@ -658,6 +652,19 @@ impl ShorthandId {
|
|||
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns PropertyFlags for given shorthand property.
|
||||
pub fn flags(&self) -> PropertyFlags {
|
||||
match *self {
|
||||
% for property in data.shorthands:
|
||||
ShorthandId::${property.camel_case} =>
|
||||
% for flag in property.flags:
|
||||
${flag} |
|
||||
% endfor
|
||||
PropertyFlags::empty(),
|
||||
% endfor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Servo's representation of a declared value for a given `T`, which is the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue