diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 237f6200ce17..ab19e417fc32 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -7649,9 +7649,10 @@ bool nsDisplayTransform::ComputePerspectiveMatrix(const nsIFrame* aFrame, } MOZ_ASSERT(perspectiveDisplay->mChildPerspective.IsLength()); - float perspective = - perspectiveDisplay->mChildPerspective.length._0.ToCSSPixels(); - perspective = std::max(1.0f, perspective); + // TODO(emilio): Seems quite silly to go through app units just to convert to + // float pixels below. + nscoord perspective = + perspectiveDisplay->mChildPerspective.length._0.ToAppUnits(); if (perspective < std::numeric_limits::epsilon()) { return true; } @@ -7678,8 +7679,7 @@ bool nsDisplayTransform::ComputePerspectiveMatrix(const nsIFrame* aFrame, perspectiveOrigin += frameToPerspectiveGfxOffset; aOutMatrix._34 = - -1.0 / NSAppUnitsToFloatPixels(CSSPixel::ToAppUnits(perspective), - aAppUnitsPerPixel); + -1.0 / NSAppUnitsToFloatPixels(perspective, aAppUnitsPerPixel); aOutMatrix.ChangeBasis(Point3D(perspectiveOrigin.x, perspectiveOrigin.y, 0)); return true; diff --git a/layout/style/nsStyleTransformMatrix.h b/layout/style/nsStyleTransformMatrix.h index 5978fa245a14..0655ae9fe0a6 100644 --- a/layout/style/nsStyleTransformMatrix.h +++ b/layout/style/nsStyleTransformMatrix.h @@ -39,8 +39,8 @@ enum class MatrixTransformOperator : uint8_t { Interpolate, Accumulate }; // follows CSSWG's resolution on perspective(0). See bug 1316236. inline void ApplyPerspectiveToMatrix(mozilla::gfx::Matrix4x4& aMatrix, float aDepth) { - if (aDepth > 0) { - aMatrix.Perspective(std::max(aDepth, 1.0f)); + if (aDepth >= std::numeric_limits::epsilon()) { + aMatrix.Perspective(aDepth); } } diff --git a/servo/components/style/values/animated/transform.rs b/servo/components/style/values/animated/transform.rs index a204ec2be2e6..621ae60084d6 100644 --- a/servo/components/style/values/animated/transform.rs +++ b/servo/components/style/values/animated/transform.rs @@ -1204,8 +1204,8 @@ impl ComputeSquaredDistance for ComputedTransformOperation { // FIXME(emilio): Is this right? Why interpolating this with // Perspective but not with anything else? let mut p_matrix = Matrix3D::identity(); - if p.px() >= 0. { - p_matrix.m34 = -1. / p.px().max(1.); + if p.px() > 0. { + p_matrix.m34 = -1. / p.px(); } p_matrix.compute_squared_distance(&m) }, diff --git a/servo/components/style/values/generics/transform.rs b/servo/components/style/values/generics/transform.rs index a1143f5691b7..141e1d056b25 100644 --- a/servo/components/style/values/generics/transform.rs +++ b/servo/components/style/values/generics/transform.rs @@ -582,10 +582,17 @@ impl Transform { /// Return the transform matrix from a perspective length. #[inline] pub fn create_perspective_matrix(d: CSSFloat) -> Transform3D { - if d < 0.0 { + // TODO(gw): The transforms spec says that perspective length must + // be positive. However, there is some confusion between the spec + // and browser implementations as to handling the case of 0 for the + // perspective value. Until the spec bug is resolved, at least ensure + // that a provided perspective value of <= 0.0 doesn't cause panics + // and behaves as it does in other browsers. + // See https://lists.w3.org/Archives/Public/www-style/2016Jan/0020.html for more details. + if d <= 0.0 { Transform3D::identity() } else { - Transform3D::perspective(d.max(1.)) + Transform3D::perspective(d) } } diff --git a/testing/web-platform/meta/css/css-transforms/perspective-zero-2.html.ini b/testing/web-platform/meta/css/css-transforms/perspective-zero-2.html.ini new file mode 100644 index 000000000000..c3150604a8a8 --- /dev/null +++ b/testing/web-platform/meta/css/css-transforms/perspective-zero-2.html.ini @@ -0,0 +1,2 @@ +[perspective-zero-2.html] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-transforms/perspective-zero-3.html.ini b/testing/web-platform/meta/css/css-transforms/perspective-zero-3.html.ini new file mode 100644 index 000000000000..b2860a8900bf --- /dev/null +++ b/testing/web-platform/meta/css/css-transforms/perspective-zero-3.html.ini @@ -0,0 +1,2 @@ +[perspective-zero-3.html] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-transforms/perspective-zero.html.ini b/testing/web-platform/meta/css/css-transforms/perspective-zero.html.ini new file mode 100644 index 000000000000..66e93c50082e --- /dev/null +++ b/testing/web-platform/meta/css/css-transforms/perspective-zero.html.ini @@ -0,0 +1,2 @@ +[perspective-zero.html] + expected: FAIL diff --git a/testing/web-platform/meta/css/css-transforms/transform3d-perspective-005.html.ini b/testing/web-platform/meta/css/css-transforms/transform3d-perspective-005.html.ini new file mode 100644 index 000000000000..ae307d59949d --- /dev/null +++ b/testing/web-platform/meta/css/css-transforms/transform3d-perspective-005.html.ini @@ -0,0 +1,2 @@ +[transform3d-perspective-005.html] + expected: FAIL diff --git a/testing/web-platform/meta/web-animations/animation-model/animation-types/interpolation-per-property-002.html.ini b/testing/web-platform/meta/web-animations/animation-model/animation-types/interpolation-per-property-002.html.ini new file mode 100644 index 000000000000..cefd295810f8 --- /dev/null +++ b/testing/web-platform/meta/web-animations/animation-model/animation-types/interpolation-per-property-002.html.ini @@ -0,0 +1,4 @@ +[interpolation-per-property-002.html] + [transform: perspective] + expected: FAIL +