mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Add a clone helper that works regardless of whether the property is logical.
Bug: 1473793 Reviewed-by: heycam
This commit is contained in:
parent
769188ddbb
commit
263d4258ea
2 changed files with 21 additions and 17 deletions
|
@ -207,8 +207,8 @@ impl AnimatedProperty {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
LonghandId::${prop.camel_case} => {
|
LonghandId::${prop.camel_case} => {
|
||||||
let old_computed = old_style.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}();
|
let old_computed = old_style.clone_${prop.ident}();
|
||||||
let new_computed = new_style.get_${prop.style_struct.ident.strip("_")}().clone_${prop.ident}();
|
let new_computed = new_style.clone_${prop.ident}();
|
||||||
AnimatedProperty::${prop.camel_case}(
|
AnimatedProperty::${prop.camel_case}(
|
||||||
% if prop.is_animatable_with_computed_value:
|
% if prop.is_animatable_with_computed_value:
|
||||||
old_computed,
|
old_computed,
|
||||||
|
@ -546,15 +546,13 @@ impl AnimationValue {
|
||||||
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
|
/// Get an AnimationValue for an AnimatableLonghand from a given computed values.
|
||||||
pub fn from_computed_values(
|
pub fn from_computed_values(
|
||||||
property: LonghandId,
|
property: LonghandId,
|
||||||
computed_values: &ComputedValues
|
style: &ComputedValues,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
Some(match property {
|
Some(match property {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
% if prop.animatable:
|
% if prop.animatable:
|
||||||
LonghandId::${prop.camel_case} => {
|
LonghandId::${prop.camel_case} => {
|
||||||
let computed = computed_values
|
let computed = style.clone_${prop.ident}();
|
||||||
.get_${prop.style_struct.ident.strip("_")}()
|
|
||||||
.clone_${prop.ident}();
|
|
||||||
AnimationValue::${prop.camel_case}(
|
AnimationValue::${prop.camel_case}(
|
||||||
% if prop.is_animatable_with_computed_value:
|
% if prop.is_animatable_with_computed_value:
|
||||||
computed
|
computed
|
||||||
|
|
|
@ -2615,6 +2615,22 @@ impl ComputedValues {
|
||||||
self.custom_properties.as_ref()
|
self.custom_properties.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
% for prop in data.longhands:
|
||||||
|
/// Gets the computed value of a given property.
|
||||||
|
#[inline(always)]
|
||||||
|
#[allow(non_snake_case)]
|
||||||
|
pub fn clone_${prop.ident}(
|
||||||
|
&self,
|
||||||
|
) -> longhands::${prop.ident}::computed_value::T {
|
||||||
|
self.get_${prop.style_struct.ident.strip("_")}()
|
||||||
|
% if prop.logical:
|
||||||
|
.clone_${prop.ident}(self.writing_mode)
|
||||||
|
% else:
|
||||||
|
.clone_${prop.ident}()
|
||||||
|
% endif
|
||||||
|
}
|
||||||
|
% endfor
|
||||||
|
|
||||||
/// Writes the value of the given longhand as a string in `dest`.
|
/// Writes the value of the given longhand as a string in `dest`.
|
||||||
///
|
///
|
||||||
/// Note that the value will usually be the computed value, except for
|
/// Note that the value will usually be the computed value, except for
|
||||||
|
@ -2635,20 +2651,10 @@ impl ComputedValues {
|
||||||
match property_id {
|
match property_id {
|
||||||
% for prop in data.longhands:
|
% for prop in data.longhands:
|
||||||
LonghandId::${prop.camel_case} => {
|
LonghandId::${prop.camel_case} => {
|
||||||
let style_struct =
|
let value = self.clone_${prop.ident}();
|
||||||
self.get_${prop.style_struct.ident.strip("_")}();
|
|
||||||
let value =
|
|
||||||
style_struct
|
|
||||||
% if prop.logical:
|
|
||||||
.clone_${prop.ident}(self.writing_mode);
|
|
||||||
% else:
|
|
||||||
.clone_${prop.ident}();
|
|
||||||
% endif
|
|
||||||
|
|
||||||
% if prop.predefined_type == "Color":
|
% if prop.predefined_type == "Color":
|
||||||
let value = self.resolve_color(value);
|
let value = self.resolve_color(value);
|
||||||
% endif
|
% endif
|
||||||
|
|
||||||
value.to_css(dest)
|
value.to_css(dest)
|
||||||
}
|
}
|
||||||
% endfor
|
% endfor
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue