mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Merge similar arms in AnimationValue::from_declaration 🐉🐲
This slims that function by 12KB according to bloaty.
This commit is contained in:
parent
9c94fe4279
commit
18b9775173
1 changed files with 49 additions and 28 deletions
|
@ -547,37 +547,58 @@ impl AnimationValue {
|
||||||
extra_custom_properties: Option<<&Arc<::custom_properties::CustomPropertiesMap>>,
|
extra_custom_properties: Option<<&Arc<::custom_properties::CustomPropertiesMap>>,
|
||||||
initial: &ComputedValues
|
initial: &ComputedValues
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
use properties::LonghandId;
|
use super::PropertyDeclarationVariantRepr;
|
||||||
|
|
||||||
|
<%
|
||||||
|
keyfunc = lambda x: (
|
||||||
|
x.specified_type(),
|
||||||
|
x.animated_type(),
|
||||||
|
x.boxed,
|
||||||
|
not x.is_animatable_with_computed_value,
|
||||||
|
x.style_struct.inherited,
|
||||||
|
x.ident in SYSTEM_FONT_LONGHANDS and product == "gecko",
|
||||||
|
)
|
||||||
|
%>
|
||||||
|
|
||||||
let animatable = match *decl {
|
let animatable = match *decl {
|
||||||
% for prop in data.longhands:
|
% for (specified_ty, ty, boxed, to_animated, inherit, system), props in groupby(animated, key=keyfunc):
|
||||||
% if prop.animatable:
|
${" |\n".join("PropertyDeclaration::{}(ref value)".format(prop.camel_case) for prop in props)} => {
|
||||||
PropertyDeclaration::${prop.camel_case}(ref val) => {
|
let decl_repr = unsafe {
|
||||||
context.for_non_inherited_property =
|
&*(decl as *const _ as *const PropertyDeclarationVariantRepr<${specified_ty}>)
|
||||||
% if prop.style_struct.inherited:
|
};
|
||||||
None;
|
% if inherit:
|
||||||
% else:
|
context.for_non_inherited_property = None;
|
||||||
Some(LonghandId::${prop.camel_case});
|
% else:
|
||||||
% endif
|
context.for_non_inherited_property = unsafe {
|
||||||
% if prop.ident in SYSTEM_FONT_LONGHANDS and product == "gecko":
|
Some(*(&decl_repr.tag as *const u16 as *const LonghandId))
|
||||||
if let Some(sf) = val.get_system() {
|
};
|
||||||
longhands::system_font::resolve_system_font(sf, context);
|
% endif
|
||||||
|
% if system:
|
||||||
|
if let Some(sf) = value.get_system() {
|
||||||
|
longhands::system_font::resolve_system_font(sf, context)
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
% if prop.boxed:
|
% if boxed:
|
||||||
let computed = (**val).to_computed_value(context);
|
let value = (**value).to_computed_value(context);
|
||||||
% else:
|
% else:
|
||||||
let computed = val.to_computed_value(context);
|
let value = value.to_computed_value(context);
|
||||||
% endif
|
% endif
|
||||||
AnimationValue::${prop.camel_case}(
|
% if to_animated:
|
||||||
% if prop.is_animatable_with_computed_value:
|
let value = value.to_animated_value();
|
||||||
computed
|
% endif
|
||||||
% else:
|
|
||||||
computed.to_animated_value()
|
unsafe {
|
||||||
% endif
|
let mut out = mem::uninitialized();
|
||||||
)
|
ptr::write(
|
||||||
},
|
&mut out as *mut _ as *mut AnimationValueVariantRepr<${ty}>,
|
||||||
% endif
|
AnimationValueVariantRepr {
|
||||||
|
tag: decl_repr.tag,
|
||||||
|
value,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
out
|
||||||
|
}
|
||||||
|
}
|
||||||
% endfor
|
% endfor
|
||||||
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
|
PropertyDeclaration::CSSWideKeyword(ref declaration) => {
|
||||||
match declaration.id {
|
match declaration.id {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue