Skip to content

Commit

Permalink
Determine animated types from specified types
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Feb 10, 2018
1 parent a90e660 commit aa7cc26
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 12 additions & 0 deletions components/style/properties/data.py
Expand Up @@ -229,6 +229,11 @@ def explicitly_enabled_in_chrome(self):
def enabled_in_content(self):
return self.enabled_in == "content"

def base_type(self):
if self.predefined_type and not self.is_vector:
return "::values::specified::{}".format(self.predefined_type)
return "longhands::{}::SpecifiedValue".format(self.ident)

def specified_type(self):
if self.predefined_type and not self.is_vector:
ty = "::values::specified::{}".format(self.predefined_type)
Expand Down Expand Up @@ -281,6 +286,13 @@ def specified_is_copy(self):
}
return bool(self.keyword)

def animated_type(self):
assert self.animatable
computed = "<{} as ToComputedValue>::ComputedValue".format(self.base_type())
if self.is_animatable_with_computed_value:
return computed
return "<{} as ToAnimatedValue>::AnimatedValue".format(computed)


class Shorthand(object):
def __init__(self, name, sub_properties, spec=None, servo_pref=None, gecko_pref=None,
Expand Down
11 changes: 5 additions & 6 deletions components/style/properties/helpers/animated_properties.mako.rs
Expand Up @@ -4,7 +4,10 @@

<%namespace name="helpers" file="/helpers.mako.rs" />

<% from data import to_idl_name, SYSTEM_FONT_LONGHANDS %>
<%
from data import to_idl_name, SYSTEM_FONT_LONGHANDS
from itertools import groupby
%>

use cssparser::Parser;
#[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap;
Expand Down Expand Up @@ -349,11 +352,7 @@ pub enum AnimationValue {
% for prop in data.longhands:
% if prop.animatable:
/// `${prop.name}`
% if prop.is_animatable_with_computed_value:
${prop.camel_case}(longhands::${prop.ident}::computed_value::T),
% else:
${prop.camel_case}(<longhands::${prop.ident}::computed_value::T as ToAnimatedValue>::AnimatedValue),
% endif
${prop.camel_case}(${prop.animated_type()}),
% else:
/// `${prop.name}` (not animatable)
${prop.camel_case}(Void),
Expand Down

0 comments on commit aa7cc26

Please sign in to comment.