Bug 1342139 - Part 2: Add flags to longhands for gecko glue r?xidorn
MozReview-Commit-ID: LaL2MNOK9J7
--- a/servo/components/style/properties/data.py
+++ b/servo/components/style/properties/data.py
@@ -91,17 +91,18 @@ def arg_to_bool(arg):
return arg == "True"
class Longhand(object):
def __init__(self, style_struct, name, spec=None, animatable=None, derived_from=None, keyword=None,
predefined_type=None, custom_cascade=False, experimental=False, internal=False,
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):
+ has_uncacheable_values=False, logical=False, alias=None, extra_prefixes=None, boxed=False,
+ creates_stacking_context=False, fixpos_cb=False, abspos_cb=False):
self.name = name
if not spec:
raise TypeError("Spec should be specified for %s" % name)
self.spec = spec
self.keyword = keyword
self.predefined_type = predefined_type
self.ident = to_rust_ident(name)
self.camel_case = to_camel_case(self.ident)
@@ -115,16 +116,19 @@ class Longhand(object):
self.depend_on_viewport_size = depend_on_viewport_size
self.derived_from = (derived_from or "").split()
self.complex_color = complex_color
self.cast_type = cast_type
self.logical = arg_to_bool(logical)
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)
# https://drafts.csswg.org/css-animations/#keyframes
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
# > except those defined in this specification,
# > but does accept the `animation-play-state` property and interprets it specially.
self.allowed_in_keyframe_block = allowed_in_keyframe_block \
and allowed_in_keyframe_block != "False"
--- a/servo/components/style/properties/longhand/box.mako.rs
+++ b/servo/components/style/properties/longhand/box.mako.rs
@@ -103,16 +103,18 @@
products="gecko", animatable=False, internal=True,
spec="Internal (not web-exposed)")}
<%helpers:single_keyword_computed name="position"
values="static absolute relative fixed"
need_clone="True"
extra_gecko_values="sticky"
animatable="False"
+ creates_stacking_context="True"
+ abspos_cb="True"
spec="https://drafts.csswg.org/css-position/#position-property">
impl SpecifiedValue {
pub fn is_absolutely_positioned_style(&self) -> bool {
matches!(*self, SpecifiedValue::absolute | SpecifiedValue::fixed)
}
}
use values::HasViewportPercentage;
@@ -1111,16 +1113,18 @@
animatable=True,
allow_empty=True,
delegate_animate=True)}
<%helpers:longhand name="transform" products="gecko servo" extra_prefixes="webkit"
animatable="True"
+ creates_stacking_context="True"
+ fixpos_cb="True"
spec="https://drafts.csswg.org/css-transforms/#propdef-transform">
use app_units::Au;
use style_traits::ToCss;
use values::CSSFloat;
use values::HasViewportPercentage;
use std::fmt;
@@ -1667,16 +1671,17 @@
</%helpers:longhand>
// Compositing and Blending Level 1
// http://www.w3.org/TR/compositing-1/
${helpers.single_keyword("isolation",
"auto isolate",
products="gecko",
spec="https://drafts.fxtf.org/compositing/#isolation",
+ creates_stacking_context=True,
animatable=False)}
// TODO add support for logical values recto and verso
${helpers.single_keyword("page-break-after",
"auto always avoid left right",
products="gecko",
spec="https://drafts.csswg.org/css2/page.html#propdef-page-break-after",
animatable=False)}
@@ -1705,16 +1710,18 @@
${helpers.predefined_type("perspective",
"LengthOrNone",
"Either::Second(None_)",
gecko_ffi_name="mChildPerspective",
spec="https://drafts.csswg.org/css-transforms/#perspective",
extra_prefixes="moz webkit",
boxed=True,
+ creates_stacking_context=True,
+ fixpos_cb=True,
animatable=True)}
// FIXME: This prop should be animatable
<%helpers:longhand name="perspective-origin" boxed="True" animatable="False" extra_prefixes="moz webkit"
spec="https://drafts.csswg.org/css-transforms/#perspective-origin-property">
use std::fmt;
use style_traits::ToCss;
use values::HasViewportPercentage;
@@ -1814,16 +1821,18 @@
animatable=False)}
// `auto` keyword is not supported in gecko yet.
${helpers.single_keyword("transform-style",
"auto flat preserve-3d" if product == "servo" else
"flat preserve-3d",
spec="https://drafts.csswg.org/css-transforms/#transform-style-property",
extra_prefixes="moz webkit",
+ creates_stacking_context=True,
+ fixpos_cb=True,
animatable=False)}
<%helpers:longhand name="transform-origin" animatable="True" extra_prefixes="moz webkit" boxed="True"
spec="https://drafts.csswg.org/css-transforms/#transform-origin-property">
use app_units::Au;
use std::fmt;
use style_traits::ToCss;
use values::HasViewportPercentage;
--- a/servo/components/style/properties/longhand/effects.mako.rs
+++ b/servo/components/style/properties/longhand/effects.mako.rs
@@ -6,16 +6,17 @@
// Box-shadow, etc.
<% data.new_style_struct("Effects", inherited=False) %>
${helpers.predefined_type("opacity",
"Opacity",
"1.0",
animatable=True,
+ creates_stacking_context=True,
spec="https://drafts.csswg.org/css-color/#opacity")}
<%helpers:vector_longhand name="box-shadow" allow_empty="True"
animatable="True" extra_prefixes="webkit"
spec="https://drafts.csswg.org/css-backgrounds/#box-shadow">
use cssparser;
use std::fmt;
use style_traits::ToCss;
@@ -81,16 +82,18 @@
"ClipRectOrAuto",
"computed::ClipRectOrAuto::auto()",
animatable=False,
boxed="True",
spec="https://drafts.fxtf.org/css-masking/#clip-property")}
// FIXME: This prop should be animatable
<%helpers:longhand name="filter" animatable="False" extra_prefixes="webkit"
+ creates_stacking_context="True"
+ fixpos_cb="True"
spec="https://drafts.fxtf.org/filters/#propdef-filter">
//pub use self::computed_value::T as SpecifiedValue;
use cssparser;
use std::fmt;
use style_traits::{self, ToCss};
use values::{CSSFloat, HasViewportPercentage};
use values::specified::{Angle, CSSColor, Length, Shadow};
use values::specified::url::SpecifiedUrl;
@@ -511,9 +514,10 @@ pub fn parse_origin(context: &ParserCont
}
}
${helpers.single_keyword("mix-blend-mode",
"""normal multiply screen overlay darken lighten color-dodge
color-burn hard-light soft-light difference exclusion hue
saturation color luminosity""", gecko_constant_prefix="NS_STYLE_BLEND",
animatable=False,
+ creates_stacking_context=True,
spec="https://drafts.fxtf.org/compositing/#propdef-mix-blend-mode")}
--- a/servo/components/style/properties/longhand/position.mako.rs
+++ b/servo/components/style/properties/longhand/position.mako.rs
@@ -21,16 +21,17 @@
"computed::LengthOrPercentageOrAuto::Auto",
spec="https://drafts.csswg.org/css-logical-props/#propdef-offset-%s" % side,
animatable=True, logical=True)}
% endfor
${helpers.predefined_type("z-index", "IntegerOrAuto",
"Either::Second(Auto)",
spec="https://www.w3.org/TR/CSS2/visuren.html#z-index",
+ creates_stacking_context=True,
animatable="True")}
// CSS Flexible Box Layout Module Level 1
// http://www.w3.org/TR/css3-flexbox/
// Flex container properties
${helpers.single_keyword("flex-direction", "row row-reverse column column-reverse",
spec="https://drafts.csswg.org/css-flexbox/#flex-direction-property",
--- a/servo/components/style/properties/longhand/svg.mako.rs
+++ b/servo/components/style/properties/longhand/svg.mako.rs
@@ -54,16 +54,17 @@
// CSS Masking Module Level 1
// https://drafts.fxtf.org/css-masking
${helpers.single_keyword("mask-type", "luminance alpha",
products="gecko", animatable=False,
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-type")}
<%helpers:longhand name="clip-path" animatable="False" products="gecko" boxed="True"
+ creates_stacking_context="True"
spec="https://drafts.fxtf.org/css-masking/#propdef-clip-path">
use std::fmt;
use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::basic_shape::{ShapeSource, GeometryBox};
pub mod computed_value {
use app_units::Au;
@@ -184,17 +185,18 @@
"add subtract intersect exclude",
vector=True,
products="gecko",
extra_prefixes="webkit",
animatable=False,
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-composite")}
<%helpers:vector_longhand name="mask-image" products="gecko" animatable="False" extra_prefixes="webkit"
- has_uncacheable_values="${product == 'gecko'}",
+ has_uncacheable_values="${product == 'gecko'}"
+ creates_stacking_context="True"
spec="https://drafts.fxtf.org/css-masking/#propdef-mask-image">
use std::fmt;
use style_traits::ToCss;
use std::sync::Arc;
use values::specified::Image;
use values::specified::url::SpecifiedUrl;
use values::HasViewportPercentage;
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -414,16 +414,30 @@ impl Parse for CSSWideKeyword {
"initial" => Ok(CSSWideKeyword::Initial),
"inherit" => Ok(CSSWideKeyword::Inherit),
"unset" => Ok(CSSWideKeyword::Unset),
_ => Err(())
}
}
}
+bitflags! {
+ /// A set of flags for properties.
+ pub flags PropertyFlags: u8 {
+ /// This property requires a stacking context.
+ const CREATES_STACKING_CONTEXT = 0x01,
+ /// This property has values that can establish a containing block for
+ /// fixed positioned and absolutely positioned elements.
+ const FIXPOS_CB = 0x02,
+ /// This property has values that can establish a containing block for
+ /// absolutely positioned elements.
+ const ABSPOS_CB = 0x04,
+ }
+}
+
/// An identifier for a given longhand property.
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum LonghandId {
% for i, property in enumerate(data.longhands):
/// ${property.name}
${property.camel_case} = ${i},
% endfor
@@ -452,16 +466,35 @@ impl LonghandId {
</%def>
</%helpers:logical_setter_helper>
}
% endif
% endfor
_ => *self
}
}
+
+ /// Returns PropertyFlags for given 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
+ PropertyFlags::empty(),
+ % endfor
+ }
+ }
}
/// An identifier for a given shorthand property.
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
pub enum ShorthandId {
% for property in data.shorthands:
/// ${property.name}