diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 2b11109bbc4..274da76571c 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -63,7 +63,7 @@ class Longhand(object): def __init__(self, style_struct, name, 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): + allowed_in_keyframe_block=True, complex_color=False, cast_type='u8'): self.name = name self.keyword = keyword self.predefined_type = predefined_type @@ -78,6 +78,7 @@ 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 # https://drafts.csswg.org/css-animations/#keyframes # > The inside of accepts any CSS property diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 85ebdfdaaab..46bcd37d534 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -490,21 +490,29 @@ impl Debug for ${style_struct.gecko_struct_name} { "CSSColor": impl_color, } - def predefined_type_method(longhand): + def longhand_method(longhand): args = dict(ident=longhand.ident, gecko_ffi_name=longhand.gecko_ffi_name, need_clone=longhand.need_clone) - method = predefined_types[longhand.predefined_type] - # additional type-specific arguments - if longhand.predefined_type in ["CSSColor"]: - args.update(complex_color=longhand.complex_color) + # get the method and pass additional keyword or type-specific arguments + if longhand.keyword: + method = impl_keyword + args.update(keyword=longhand.keyword) + if "font" in longhand.ident: + args.update(cast_type=longhand.cast_type) + else: + method = predefined_types[longhand.predefined_type] + if longhand.predefined_type in ["CSSColor"]: + args.update(complex_color=longhand.complex_color) method(**args) - keyword_longhands = [x for x in longhands if x.keyword and x.name not in force_stub] - predefined_longhands = [x for x in longhands - if x.predefined_type in predefined_types and x.name not in force_stub] - stub_longhands = [x for x in longhands if x not in keyword_longhands + predefined_longhands] + picked_longhands, stub_longhands = [], [] + for x in longhands: + if (x.keyword or x.predefined_type in predefined_types) and x.name not in force_stub: + picked_longhands.append(x) + else: + stub_longhands.append(x) # If one of the longhands is not handled # by either: @@ -518,6 +526,7 @@ impl Debug for ${style_struct.gecko_struct_name} { # If you hit this error, please add `product="servo"` to the longhand. # In case the longhand is used in a shorthand, add it to the force_stub # list above. + for stub in stub_longhands: if stub.name not in force_stub: raise Exception("Don't know what to do with longhand %s in style struct %s" @@ -533,10 +542,8 @@ impl ${style_struct.gecko_struct_name} { * Auto-Generated Methods. */ <% - for longhand in keyword_longhands: - impl_keyword(longhand.ident, longhand.gecko_ffi_name, longhand.keyword, longhand.need_clone) - for longhand in predefined_longhands: - predefined_type_method(longhand) + for longhand in picked_longhands: + longhand_method(longhand) %> /*