Skip to content

Commit

Permalink
Blending between two rotateZ() transform values should serialize as r…
Browse files Browse the repository at this point in the history
…otate3d()

https://bugs.webkit.org/show_bug.cgi?id=245527

Reviewed by Antti Koivisto.

We didn't have a way to differentiate a rotation provided as rotateZ() rather than rotate().
We now keep a distinct OperationType value for ROTATE_Z and ensure we never simplify to the
ROTATE type in the primitiveType() override of RotateTransformOperation.

We also fix computedTransform() to correctly use the angle rather than the individual axis
for the rotateX/Y/Z functions.

* LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-computed-value-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-transforms/animation/transform-interpolation-inline-value-expected.txt:
* Source/WebCore/css/ComputedStyleExtractor.cpp:
(WebCore::computedTransform):
* Source/WebCore/platform/graphics/transforms/RotateTransformOperation.h:
* Source/WebCore/platform/graphics/transforms/TransformOperation.cpp:
* Source/WebCore/platform/graphics/transforms/TransformOperation.h:

Canonical link: https://commits.webkit.org/254782@main
  • Loading branch information
graouts committed Sep 23, 2022
1 parent 68d7d60 commit 1f231e2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 15 deletions.
Expand Up @@ -27,10 +27,10 @@ PASS Interpolation between translate(50px, -50px) and translate(100px, 50px) giv
PASS Interpolation between translate(50px, -50px) and translate(100px, 50px) gives the correct computed value halfway according to computedStyleMap with zoom active.
PASS Interpolation between rotate(30deg) and rotate(90deg) gives the correct computed value halfway according to computedStyleMap.
PASS Interpolation between rotate(30deg) and rotate(90deg) gives the correct computed value halfway according to computedStyleMap with zoom active.
FAIL Interpolation between rotateZ(30deg) and rotateZ(90deg) gives the correct computed value halfway according to computedStyleMap. assert_equals: The value at 50% progress is as expected expected "rotate3d(0, 0, 1, 60deg)" but got "rotate(60deg)"
FAIL Interpolation between rotateZ(30deg) and rotateZ(90deg) gives the correct computed value halfway according to computedStyleMap with zoom active. assert_equals: The value at 50% progress is as expected expected "rotate3d(0, 0, 1, 60deg)" but got "rotate(60deg)"
FAIL Interpolation between rotate(0deg) and rotateZ(90deg) gives the correct computed value halfway according to computedStyleMap. assert_equals: The value at 50% progress is as expected expected "rotate3d(0, 0, 1, 45deg)" but got "rotate(45deg)"
FAIL Interpolation between rotate(0deg) and rotateZ(90deg) gives the correct computed value halfway according to computedStyleMap with zoom active. assert_equals: The value at 50% progress is as expected expected "rotate3d(0, 0, 1, 45deg)" but got "rotate(45deg)"
PASS Interpolation between rotateZ(30deg) and rotateZ(90deg) gives the correct computed value halfway according to computedStyleMap.
PASS Interpolation between rotateZ(30deg) and rotateZ(90deg) gives the correct computed value halfway according to computedStyleMap with zoom active.
PASS Interpolation between rotate(0deg) and rotateZ(90deg) gives the correct computed value halfway according to computedStyleMap.
PASS Interpolation between rotate(0deg) and rotateZ(90deg) gives the correct computed value halfway according to computedStyleMap with zoom active.
PASS Interpolation between rotateX(0deg) and rotateX(90deg) gives the correct computed value halfway according to computedStyleMap.
PASS Interpolation between rotateX(0deg) and rotateX(90deg) gives the correct computed value halfway according to computedStyleMap with zoom active.
PASS Interpolation between rotate(0deg) and rotateX(90deg) gives the correct computed value halfway according to computedStyleMap.
Expand Down
Expand Up @@ -13,8 +13,8 @@ PASS Interpolation between translate3d(0,0,-50px) and translateZ(50px) gives the
PASS Interpolation between translate(50px, 0px) and translate(100px, 0px) gives the correct computed value halfway according to commitStyles.
PASS Interpolation between translate(50px, -50px) and translate(100px, 50px) gives the correct computed value halfway according to commitStyles.
PASS Interpolation between rotate(30deg) and rotate(90deg) gives the correct computed value halfway according to commitStyles.
FAIL Interpolation between rotateZ(30deg) and rotateZ(90deg) gives the correct computed value halfway according to commitStyles. assert_equals: The value at 50% progress is as expected expected "rotateZ(60deg)" but got "rotate(60deg)"
FAIL Interpolation between rotate(0deg) and rotateZ(90deg) gives the correct computed value halfway according to commitStyles. assert_equals: The value at 50% progress is as expected expected "rotate3d(0, 0, 1, 45deg)" but got "rotate(45deg)"
FAIL Interpolation between rotateZ(30deg) and rotateZ(90deg) gives the correct computed value halfway according to commitStyles. assert_equals: The value at 50% progress is as expected expected "rotateZ(60deg)" but got "rotate3d(0, 0, 1, 60deg)"
PASS Interpolation between rotate(0deg) and rotateZ(90deg) gives the correct computed value halfway according to commitStyles.
FAIL Interpolation between rotateX(0deg) and rotateX(90deg) gives the correct computed value halfway according to commitStyles. assert_equals: The value at 50% progress is as expected expected "rotateX(45deg)" but got "rotate3d(1, 0, 0, 45deg)"
PASS Interpolation between rotate(0deg) and rotateX(90deg) gives the correct computed value halfway according to commitStyles.
FAIL Interpolation between scale(1) and scale(2) gives the correct computed value halfway according to commitStyles. assert_equals: The value at 50% progress is as expected expected "scale(1.5)" but got "scale(1.5, 1.5)"
Expand Down
8 changes: 6 additions & 2 deletions Source/WebCore/css/ComputedStyleExtractor.cpp
Expand Up @@ -806,11 +806,15 @@ static Ref<CSSValue> computedTransform(RenderElement* renderer, const RenderStyl
// rotate
case TransformOperation::ROTATE_X:
functionValue = CSSFunctionValue::create(CSSValueRotateX);
functionValue->append(cssValuePool.createValue(downcast<RotateTransformOperation>(*operation).x(), CSSUnitType::CSS_NUMBER));
functionValue->append(cssValuePool.createValue(downcast<RotateTransformOperation>(*operation).angle(), CSSUnitType::CSS_DEG));
break;
case TransformOperation::ROTATE_Y:
functionValue = CSSFunctionValue::create(CSSValueRotateX);
functionValue->append(cssValuePool.createValue(downcast<RotateTransformOperation>(*operation).y(), CSSUnitType::CSS_NUMBER));
functionValue->append(cssValuePool.createValue(downcast<RotateTransformOperation>(*operation).angle(), CSSUnitType::CSS_DEG));
break;
case TransformOperation::ROTATE_Z:
functionValue = CSSFunctionValue::create(CSSValueRotateZ);
functionValue->append(cssValuePool.createValue(downcast<RotateTransformOperation>(*operation).angle(), CSSUnitType::CSS_DEG));
break;
case TransformOperation::ROTATE: {
auto& rotate = downcast<RotateTransformOperation>(*operation);
Expand Down
Expand Up @@ -53,9 +53,7 @@ class RotateTransformOperation final : public TransformOperation {
double z() const { return m_z; }
double angle() const { return m_angle; }

// The 2D rotation primitive doesn't handle any direction vectors other than [0, 0, 1],
// so even if the rotation is representable in 2D, it might be a 3D rotation.
OperationType primitiveType() const final { return (isRepresentableIn2D() && z() == 1.0) ? ROTATE : ROTATE_3D; }
OperationType primitiveType() const final { return type() == ROTATE ? ROTATE : ROTATE_3D; }

bool operator==(const RotateTransformOperation& other) const { return operator==(static_cast<const TransformOperation&>(other)); }
bool operator==(const TransformOperation&) const override;
Expand Down
Expand Up @@ -56,6 +56,7 @@ TextStream& operator<<(TextStream& ts, TransformOperation::OperationType type)
case TransformOperation::TRANSLATE_3D: ts << "translate3d"; break;
case TransformOperation::ROTATE_X: ts << "rotateX"; break;
case TransformOperation::ROTATE_Y: ts << "rotateY"; break;
case TransformOperation::ROTATE_Z: ts << "rotateZ"; break;
case TransformOperation::ROTATE_3D: ts << "rotate3d"; break;
case TransformOperation::MATRIX_3D: ts << "matrix3d"; break;
case TransformOperation::PERSPECTIVE: ts << "perspective"; break;
Expand Down
Expand Up @@ -40,13 +40,12 @@ class TransformOperation : public RefCounted<TransformOperation> {
enum OperationType {
SCALE_X, SCALE_Y, SCALE,
TRANSLATE_X, TRANSLATE_Y, TRANSLATE,
ROTATE,
ROTATE_Z = ROTATE,
SKEW_X, SKEW_Y, SKEW,
ROTATE_X, ROTATE_Y, ROTATE,
SKEW_X, SKEW_Y, SKEW,
MATRIX,
SCALE_Z, SCALE_3D,
TRANSLATE_Z, TRANSLATE_3D,
ROTATE_X, ROTATE_Y, ROTATE_3D,
ROTATE_Z, ROTATE_3D,
MATRIX_3D,
PERSPECTIVE,
IDENTITY, NONE
Expand Down

0 comments on commit 1f231e2

Please sign in to comment.