Skip to content

Commit

Permalink
Normalize rotations in computed transforms
Browse files Browse the repository at this point in the history
  • Loading branch information
canova committed Sep 15, 2016
1 parent 1901a21 commit 20b3c4b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/style/properties/longhand/effects.mako.rs
Expand Up @@ -1099,7 +1099,8 @@ ${helpers.predefined_type("opacity",
result.push(computed_value::ComputedOperation::Scale(sx, sy, sz));
}
SpecifiedOperation::Rotate(ax, ay, az, theta) => {
result.push(computed_value::ComputedOperation::Rotate(ax, ay, az, theta));
let len = (ax * ax + ay * ay + az * az).sqrt();
result.push(computed_value::ComputedOperation::Rotate(ax / len, ay / len, az / len, theta));
}
SpecifiedOperation::Skew(theta_x, theta_y) => {
result.push(computed_value::ComputedOperation::Skew(theta_x, theta_y));
Expand Down
24 changes: 24 additions & 0 deletions tests/wpt/mozilla/meta/MANIFEST.json
Expand Up @@ -3720,6 +3720,18 @@
"url": "/_mozilla/css/non-inline-block-resets-underline-property.html"
}
],
"css/normalize-rotation.html": [
{
"path": "css/normalize-rotation.html",
"references": [
[
"/_mozilla/css/normalize-rotation-ref.html",
"=="
]
],
"url": "/_mozilla/css/normalize-rotation.html"
}
],
"css/noscript.html": [
{
"path": "css/noscript.html",
Expand Down Expand Up @@ -13114,6 +13126,18 @@
"url": "/_mozilla/css/non-inline-block-resets-underline-property.html"
}
],
"css/normalize-rotation.html": [
{
"path": "css/normalize-rotation.html",
"references": [
[
"/_mozilla/css/normalize-rotation-ref.html",
"=="
]
],
"url": "/_mozilla/css/normalize-rotation.html"
}
],
"css/noscript.html": [
{
"path": "css/noscript.html",
Expand Down
21 changes: 21 additions & 0 deletions tests/wpt/mozilla/tests/css/normalize-rotation-ref.html
@@ -0,0 +1,21 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Rotations should be normalized in computed transforms</title>
<style type="text/css">
#box {
width: 100px;
height: 100px;
transform: rotate3d(0.5,0.5,0.5,45deg);
background-color: red;
position: absolute;
top: 200px;
left: 200px;
}
</style>
</head>
<body>
<div id="box"></div>
</body>
</html>
22 changes: 22 additions & 0 deletions tests/wpt/mozilla/tests/css/normalize-rotation.html
@@ -0,0 +1,22 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Rotations should be normalized in computed transforms</title>
<link rel="match" href="normalize-rotation-ref.html">
<style type="text/css">
#box {
width: 100px;
height: 100px;
transform: rotate3d(1,1,1,45deg);
background-color: red;
position: absolute;
top: 200px;
left: 200px;
}
</style>
</head>
<body>
<div id="box"></div>
</body>
</html>

0 comments on commit 20b3c4b

Please sign in to comment.