Skip to content
Permalink
Browse files

stylo: Preserve the variant of translate() values in computed transforms

  • Loading branch information
Manishearth committed Sep 13, 2017
1 parent d461347 commit 83e3394904ff18839737452a68c8aa02f83f3b34
@@ -3069,6 +3069,9 @@ fn static_assert() {
${transform_function_arm("MatrixWithPercents", "matrix3d", ["number"] * 12 + ["lop"] * 2
+ ["length"] + ["number"])}
${transform_function_arm("Skew", "skew", ["angle"] * 2)}
${transform_function_arm("TranslateX", "translatex", ["lop"])}
${transform_function_arm("TranslateY", "translatey", ["lop"])}
${transform_function_arm("TranslateZ", "translatez", ["length"])}
${transform_function_arm("Translate", "translate3d", ["lop", "lop", "length"])}
${transform_function_arm("Scale", "scale3d", ["number"] * 3)}
${transform_function_arm("Rotate", "rotate3d", ["number"] * 3 + ["angle"])}
@@ -3189,6 +3192,10 @@ fn static_assert() {
match transform_function {
${computed_operation_arm("Matrix", "matrix3d", ["number"] * 16)}
${computed_operation_arm("Skew", "skew", ["angle"] * 2)}

${computed_operation_arm("TranslateX", "translatex", ["lop"])}
${computed_operation_arm("TranslateY", "translatey", ["lop"])}
${computed_operation_arm("TranslateZ", "translatez", ["length"])}
${computed_operation_arm("Translate", "translate3d", ["lop", "lop", "length"])}
${computed_operation_arm("Scale", "scale3d", ["number"] * 3)}
${computed_operation_arm("Rotate", "rotate3d", ["number"] * 3 + ["angle"])}
@@ -1135,6 +1135,21 @@ impl ToAnimatedZero for TransformOperation {
sy.to_animated_zero()?,
))
},
TransformOperation::TranslateX(ref tx) => {
Ok(TransformOperation::TranslateX(
tx.to_animated_zero()?
))
},
TransformOperation::TranslateY(ref ty) => {
Ok(TransformOperation::TranslateY(
ty.to_animated_zero()?
))
},
TransformOperation::TranslateZ(ref tz) => {
Ok(TransformOperation::TranslateZ(
tz.to_animated_zero()?
))
},
TransformOperation::Translate(ref tx, ref ty, ref tz) => {
Ok(TransformOperation::Translate(
tx.to_animated_zero()?,
@@ -683,6 +683,9 @@ ${helpers.predefined_type(
// For `-moz-transform` matrix and matrix3d.
MatrixWithPercents(ComputedMatrixWithPercents),
Skew(computed::Angle, computed::Angle),
TranslateX(LengthOrPercentage),
TranslateY(LengthOrPercentage),
TranslateZ(Length),
Translate(computed::LengthOrPercentage,
computed::LengthOrPercentage,
computed::Length),
@@ -1262,24 +1265,15 @@ ${helpers.predefined_type(
}
SpecifiedOperation::TranslateX(ref tx) => {
let tx = tx.to_computed_value(context);
result.push(computed_value::ComputedOperation::Translate(
tx,
computed::length::LengthOrPercentage::zero(),
computed::length::Length::new(0.)));
result.push(computed_value::ComputedOperation::TranslateX(tx));
}
SpecifiedOperation::TranslateY(ref ty) => {
let ty = ty.to_computed_value(context);
result.push(computed_value::ComputedOperation::Translate(
computed::length::LengthOrPercentage::zero(),
ty,
computed::length::Length::new(0.)));
result.push(computed_value::ComputedOperation::TranslateY(ty));
}
SpecifiedOperation::TranslateZ(ref tz) => {
let tz = tz.to_computed_value(context);
result.push(computed_value::ComputedOperation::Translate(
computed::length::LengthOrPercentage::zero(),
computed::length::LengthOrPercentage::zero(),
tz));
result.push(computed_value::ComputedOperation::TranslateZ(tz));
}
SpecifiedOperation::Translate3D(ref tx, ref ty, ref tz) => {
let tx = tx.to_computed_value(context);
@@ -1423,9 +1417,19 @@ ${helpers.predefined_type(
m44: Number::from_computed_value(&computed.m44),
});
}
computed_value::ComputedOperation::TranslateX(ref tx) => {
result.push(SpecifiedOperation::TranslateX(
ToComputedValue::from_computed_value(tx)));
}
computed_value::ComputedOperation::TranslateY(ref ty) => {
result.push(SpecifiedOperation::TranslateY(
ToComputedValue::from_computed_value(ty)));
}
computed_value::ComputedOperation::TranslateZ(ref tz) => {
result.push(SpecifiedOperation::TranslateZ(
ToComputedValue::from_computed_value(tz)));
}
computed_value::ComputedOperation::Translate(ref tx, ref ty, ref tz) => {
// XXXManishearth we lose information here; perhaps we should try to
// recover the original function? Not sure if this can be observed.
result.push(SpecifiedOperation::Translate3D(
ToComputedValue::from_computed_value(tx),
ToComputedValue::from_computed_value(ty),
@@ -92,6 +92,23 @@ impl TransformList {
ComputedOperation::Scale(sx, sy, sz) => {
Transform3D::create_scale(sx, sy, sz)
}
ComputedOperation::TranslateX(tx) => {
let tx = match reference_box {
Some(relative_border_box) => tx.to_used_value(relative_border_box.size.width).to_f32_px(),
None => extract_pixel_length(&tx),
};
Transform3D::create_translation(tx, 0., 0.)
}
ComputedOperation::TranslateY(ty) => {
let ty = match reference_box {
Some(relative_border_box) => ty.to_used_value(relative_border_box.size.height).to_f32_px(),
None => extract_pixel_length(&ty),
};
Transform3D::create_translation(0., ty, 0.)
}
ComputedOperation::TranslateZ(tz) => {
Transform3D::create_translation(0., 0., tz.to_f32_px())
}
ComputedOperation::Translate(tx, ty, tz) => {
let (tx, ty) = match reference_box {
Some(relative_border_box) => {

0 comments on commit 83e3394

Please sign in to comment.
You can’t perform that action at this time.