Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[chromium] Must account for empty transformation lists when checking …

…for big rotations.


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

Reviewed by James Robinson.

Source/WebCore:

AnimationTranslationUtil.cpp is supposed to reject large rotations
(>= 180 degrees between keyframes). The current code assumes that if
the lists of transforms at two consecutive keyframes do not match
(i.e., are different types), then do not need to reject. The rationale
is that we will revert to matrix blending -- we will collapse the lists
of transform operations to matrices at each keyframe and blend those.
Unfortunately, this is not true if a list is empty. It can be the case
that we transition from no transform to a rotation about the z axis of
360 degrees. In this case, the first list of transform operations will
be empty and the second will have a single rotation of 360 degrees. An
empty list should be treated as a rotation of zero degrees.

Unit tested in: GraphicsLayerChromiumTest.createTransformAnimationWithBigRotationAndEmptyTransformOperationList

* platform/graphics/chromium/AnimationTranslationUtil.cpp:
(WebCore::causesRotationOfAtLeast180Degrees):

Source/WebKit/chromium:

Adds a test to check that creating an animation with a big (> 180
degree) rotation, where the transform operations list in the 1st
keyframe is empty fails as expected.

* tests/AnimationTranslationUtilTest.cpp:
(WebKit::TEST):
(WebKit):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@125702 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information...
commit 847bbaa7b571786a2f331769452a332bdc6d4132 1 parent 8fd6ed8
vollick authored
View
24 Source/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2012-08-15 Ian Vollick <vollick@chromium.org>
+
+ [chromium] Must account for empty transformation lists when checking for big rotations.
+ https://bugs.webkit.org/show_bug.cgi?id=93975
+
+ Reviewed by James Robinson.
+
+ AnimationTranslationUtil.cpp is supposed to reject large rotations
+ (>= 180 degrees between keyframes). The current code assumes that if
+ the lists of transforms at two consecutive keyframes do not match
+ (i.e., are different types), then do not need to reject. The rationale
+ is that we will revert to matrix blending -- we will collapse the lists
+ of transform operations to matrices at each keyframe and blend those.
+ Unfortunately, this is not true if a list is empty. It can be the case
+ that we transition from no transform to a rotation about the z axis of
+ 360 degrees. In this case, the first list of transform operations will
+ be empty and the second will have a single rotation of 360 degrees. An
+ empty list should be treated as a rotation of zero degrees.
+
+ Unit tested in: GraphicsLayerChromiumTest.createTransformAnimationWithBigRotationAndEmptyTransformOperationList
+
+ * platform/graphics/chromium/AnimationTranslationUtil.cpp:
+ (WebCore::causesRotationOfAtLeast180Degrees):
+
2012-08-15 Beth Dakin <bdakin@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=93693
View
30 Source/WebCore/platform/graphics/chromium/AnimationTranslationUtil.cpp
@@ -153,19 +153,31 @@ bool causesRotationOfAtLeast180Degrees(const TransformAnimationValue* value, con
const TransformOperations& operations = *value->value();
const TransformOperations& lastOperations = *lastValue->value();
- // We'll be doing matrix interpolation in this case. No risk of incorrect
- // rotations here.
- if (!operations.operationsMatch(lastOperations))
+ // We'll be doing matrix interpolation in this case. No risk of incorrect rotations here.
+ if (operations.size() && lastOperations.size() && !operations.operationsMatch(lastOperations))
return false;
- for (size_t i = 0; i < operations.size(); ++i) {
- if (!isRotationType(operations.operations()[i]->getOperationType()))
- continue;
+ size_t numOperations = max(operations.size(), lastOperations.size());
+ for (size_t i = 0; i < numOperations; ++i) {
+ float angle = 0;
+ if (i < operations.size()) {
+ if (!isRotationType(operations.operations()[i]->getOperationType()))
+ continue;
- RotateTransformOperation* rotation = static_cast<RotateTransformOperation*>(operations.operations()[i].get());
- RotateTransformOperation* lastRotation = static_cast<RotateTransformOperation*>(lastOperations.operations()[i].get());
+ RotateTransformOperation* rotation = static_cast<RotateTransformOperation*>(operations.operations()[i].get());
+ angle = rotation->angle();
+ }
+
+ float lastAngle = 0;
+ if (i < lastOperations.size()) {
+ if (!isRotationType(lastOperations.operations()[i]->getOperationType()))
+ continue;
+
+ RotateTransformOperation* lastRotation = static_cast<RotateTransformOperation*>(lastOperations.operations()[i].get());
+ lastAngle = lastRotation->angle();
+ }
- if (fabs(rotation->angle() - lastRotation->angle()) >= 180)
+ if (fabs(angle - lastAngle) >= 180)
return true;
}
View
15 Source/WebKit/chromium/ChangeLog
@@ -1,3 +1,18 @@
+2012-08-15 Ian Vollick <vollick@chromium.org>
+
+ [chromium] Must account for empty transformation lists when checking for big rotations.
+ https://bugs.webkit.org/show_bug.cgi?id=93975
+
+ Reviewed by James Robinson.
+
+ Adds a test to check that creating an animation with a big (> 180
+ degree) rotation, where the transform operations list in the 1st
+ keyframe is empty fails as expected.
+
+ * tests/AnimationTranslationUtilTest.cpp:
+ (WebKit::TEST):
+ (WebKit):
+
2012-08-15 Joshua Bell <jsbell@chromium.org>
[chromium] IndexedDB: Delete unused WebKit API cursor accessors
View
18 Source/WebKit/chromium/tests/AnimationTranslationUtilTest.cpp
@@ -99,6 +99,24 @@ TEST(AnimationTranslationUtilTest, createTransformAnimationWithBigRotation)
EXPECT_FALSE(animationCanBeTranslated(values, animation.get()));
}
+TEST(AnimationTranslationUtilTest, createTransformAnimationWithBigRotationAndEmptyTransformOperationList)
+{
+ const double duration = 1;
+ WebCore::KeyframeValueList values(AnimatedPropertyWebkitTransform);
+
+ TransformOperations operations1;
+ values.insert(new TransformAnimationValue(0, &operations1));
+
+ TransformOperations operations2;
+ operations2.operations().append(RotateTransformOperation::create(270, TransformOperation::ROTATE));
+ values.insert(new TransformAnimationValue(duration, &operations2));
+
+ RefPtr<Animation> animation = Animation::create();
+ animation->setDuration(duration);
+
+ EXPECT_FALSE(animationCanBeTranslated(values, animation.get()));
+}
+
TEST(AnimationTranslationUtilTest, createTransformAnimationWithRotationInvolvingNegativeAngles)
{
const double duration = 1;
Please sign in to comment.
Something went wrong with that request. Please try again.