Skip to content

Commit

Permalink
Add prefixes parameter for properties
Browse files Browse the repository at this point in the history
  • Loading branch information
upsuper committed Jan 11, 2017
1 parent 8af8168 commit e494a0f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions components/style/properties/data.py
Expand Up @@ -88,7 +88,7 @@ def __init__(self, style_struct, name, spec=None, animatable=None, derived_from=
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):
has_uncacheable_values=False, logical=False, alias=None, extra_prefixes=None):
self.name = name
if not spec:
raise TypeError("Spec should be specified for %s" % name)
Expand All @@ -110,6 +110,7 @@ def __init__(self, style_struct, name, spec=None, animatable=None, derived_from=
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 []

# https://drafts.csswg.org/css-animations/#keyframes
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
Expand All @@ -135,7 +136,7 @@ def __init__(self, style_struct, name, spec=None, animatable=None, derived_from=

class Shorthand(object):
def __init__(self, name, sub_properties, spec=None, experimental=False, internal=False,
allowed_in_keyframe_block=True, alias=None):
allowed_in_keyframe_block=True, alias=None, extra_prefixes=None):
self.name = name
if not spec:
raise TypeError("Spec should be specified for %s" % name)
Expand All @@ -147,6 +148,7 @@ def __init__(self, name, sub_properties, spec=None, experimental=False, internal
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 []

# https://drafts.csswg.org/css-animations/#keyframes
# > The <declaration-list> inside of <keyframe-block> accepts any CSS property
Expand Down Expand Up @@ -220,12 +222,20 @@ def new_style_struct(self, *args, **kwargs):
def active_style_structs(self):
return [s for s in self.style_structs if s.additional_methods or s.longhands]

def add_prefixed_aliases(self, property):
# FIXME Servo's DOM architecture doesn't support vendor-prefixed properties.
# See servo/servo#14941.
if self.product == "gecko":
for prefix in property.extra_prefixes:
property.alias.append('-%s-%s' % (prefix, property.name))

def declare_longhand(self, name, products="gecko servo", disable_when_testing=False, **kwargs):
products = products.split()
if self.product not in products and not (self.testing and not disable_when_testing):
return

longhand = Longhand(self.current_style_struct, name, **kwargs)
self.add_prefixed_aliases(longhand)
self.current_style_struct.longhands.append(longhand)
self.longhands.append(longhand)
self.longhands_by_name[name] = longhand
Expand All @@ -243,5 +253,6 @@ def declare_shorthand(self, name, sub_properties, products="gecko servo",

sub_properties = [self.longhands_by_name[s] for s in sub_properties]
shorthand = Shorthand(name, sub_properties, *args, **kwargs)
self.add_prefixed_aliases(shorthand)
self.shorthands.append(shorthand)
return shorthand

0 comments on commit e494a0f

Please sign in to comment.