Auto merge of #18492 - Manishearth:stylo-translate, r=hiikezoe

stylo: Preserve variants of 2d translate/rotate/scale functions in computed transform

Necessary for the animation inspector to show the right thing.

r=hiikezoe https://bugzilla.mozilla.org/show_bug.cgi?id=1391145

fixes bug 1391145

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18492)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-09-16 03:33:44 -05:00 committed by GitHub
commit 90689b7916
4 changed files with 198 additions and 20 deletions

View file

@ -80,6 +80,18 @@ impl TransformList {
for operation in list {
let matrix = match *operation {
ComputedOperation::RotateX(theta) => {
let theta = Angle::from_radians(2.0f32 * f32::consts::PI - theta.radians());
Transform3D::create_rotation(1., 0., 0., theta.into())
}
ComputedOperation::RotateY(theta) => {
let theta = Angle::from_radians(2.0f32 * f32::consts::PI - theta.radians());
Transform3D::create_rotation(0., 1., 0., theta.into())
}
ComputedOperation::RotateZ(theta) => {
let theta = Angle::from_radians(2.0f32 * f32::consts::PI - theta.radians());
Transform3D::create_rotation(0., 0., 1., theta.into())
}
ComputedOperation::Rotate(ax, ay, az, theta) => {
let theta = Angle::from_radians(2.0f32 * f32::consts::PI - theta.radians());
let (ax, ay, az, theta) =
@ -89,9 +101,35 @@ impl TransformList {
ComputedOperation::Perspective(d) => {
Self::create_perspective_matrix(d.px())
}
ComputedOperation::ScaleX(sx) => {
Transform3D::create_scale(sx, 1., 1.)
}
ComputedOperation::ScaleY(sy) => {
Transform3D::create_scale(1., sy, 1.)
}
ComputedOperation::ScaleZ(sz) => {
Transform3D::create_scale(1., 1., sz)
}
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.px())
}
ComputedOperation::Translate(tx, ty, tz) => {
let (tx, ty) = match reference_box {
Some(relative_border_box) => {