Commit 5216a2dc authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

Fix float-cast overflow in CompositorTransformOperations

Some functions in this class calls APIs in cc::TransformOperations,
which all take floats. But those functions provide doubles, and that
causes float-cast overflow.

This CL solves the problem by using SkDoubleToMScalar, and layout tests
are added.

Bug: 995038
Change-Id: Ic1b73c31d6090f38c7c6f342d9e953c58567604c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761733
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688518}
parent e9dd5bcb
......@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/platform/animation/compositor_transform_operations.h"
#include "third_party/skia/include/core/SkMatrix44.h"
#include "ui/gfx/transform.h"
namespace blink {
......@@ -26,26 +27,30 @@ bool CompositorTransformOperations::CanBlendWith(
void CompositorTransformOperations::AppendTranslate(double x,
double y,
double z) {
transform_operations_.AppendTranslate(x, y, z);
transform_operations_.AppendTranslate(
SkDoubleToMScalar(x), SkDoubleToMScalar(y), SkDoubleToMScalar(z));
}
void CompositorTransformOperations::AppendRotate(double x,
double y,
double z,
double degrees) {
transform_operations_.AppendRotate(x, y, z, degrees);
transform_operations_.AppendRotate(SkDoubleToMScalar(x), SkDoubleToMScalar(y),
SkDoubleToMScalar(z),
SkDoubleToMScalar(degrees));
}
void CompositorTransformOperations::AppendScale(double x, double y, double z) {
transform_operations_.AppendScale(x, y, z);
transform_operations_.AppendScale(SkDoubleToMScalar(x), SkDoubleToMScalar(y),
SkDoubleToMScalar(z));
}
void CompositorTransformOperations::AppendSkew(double x, double y) {
transform_operations_.AppendSkew(x, y);
transform_operations_.AppendSkew(SkDoubleToMScalar(x), SkDoubleToMScalar(y));
}
void CompositorTransformOperations::AppendPerspective(double depth) {
transform_operations_.AppendPerspective(depth);
transform_operations_.AppendPerspective(SkDoubleToMScalar(depth));
}
void CompositorTransformOperations::AppendMatrix(const SkMatrix44& matrix) {
......
......@@ -48,6 +48,12 @@ test_valid_value("transform", "skewY(0)", "skewY(0deg)");
test_valid_value("transform", "skewY(-90deg)");
test_valid_value("transform", "translate(1px, 2%) scale(3, 4) rotate(-90deg)");
// Regression test for crbug.com/995038
test_valid_value("transform", "translateX(2e80px)", "translateX(3.40282e+38px)");
test_valid_value("transform", "rotate(2e80deg)", "rotate(3.40282e+38deg)");
test_valid_value("transform", "scaleX(2e80)", "scaleX(3.40282e+38)");
test_valid_value("transform", "skewX(2e80deg)", "skewX(3.40282e+38deg)");
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment