Skip to content

Commit

Permalink
Handle rotate, rotate{x|y|z}, and skew{x|y} properly when cloning tra…
Browse files Browse the repository at this point in the history
…nsforms.
  • Loading branch information
BorisChiou committed Oct 27, 2017
1 parent 52c81a0 commit 3a29c63
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion components/style/properties/gecko.mako.rs
Expand Up @@ -3081,6 +3081,13 @@ fn static_assert() {
};

unsafe {
use gecko_bindings::structs::nsCSSKeyword;
use values::computed::Angle;

let get_array_angle = || -> Angle {
bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, 1).get_angle()
};

match transform_function {
${computed_operation_arm("Matrix", "matrix3d", ["number"] * 16)}
${computed_operation_arm("Skew", "skew", ["angle"] * 2)}
Expand All @@ -3092,7 +3099,29 @@ fn static_assert() {
["list"] * 2 + ["percentage"])}
${computed_operation_arm("AccumulateMatrix", "accumulatematrix",
["list"] * 2 + ["percentage_to_integer"])}
_ => panic!("We shouldn't set any other transform function types"),
// FIXME: Bug 1391145 will introduce new types for these keywords. For now, we
// temporarily don't use |computed_operation_arm| because these are special cases
// for compositor animations when we use Gecko style backend on the main thread,
// and I don't want to add too many special cases in |computed_operation_arm|.
//
// Note: Gecko only converts translate and scale into the corresponding primitive
// functions, so we still need to handle the following functions.
nsCSSKeyword::eCSSKeyword_skewx => {
ComputedOperation::Skew(get_array_angle(), Angle::zero())
},
nsCSSKeyword::eCSSKeyword_skewy => {
ComputedOperation::Skew(Angle::zero(), get_array_angle())
},
nsCSSKeyword::eCSSKeyword_rotatex => {
ComputedOperation::Rotate(1.0, 0.0, 0.0, get_array_angle())
},
nsCSSKeyword::eCSSKeyword_rotatey => {
ComputedOperation::Rotate(0.0, 1.0, 0.0, get_array_angle())
},
nsCSSKeyword::eCSSKeyword_rotatez | nsCSSKeyword::eCSSKeyword_rotate => {
ComputedOperation::Rotate(0.0, 0.0, 1.0, get_array_angle())
},
_ => panic!("{:?} is not an acceptable transform function", transform_function),
}
}
}
Expand Down

0 comments on commit 3a29c63

Please sign in to comment.