Skip to content

Commit

Permalink
Fix DCHECK when compositing additive CSS transform animations
Browse files Browse the repository at this point in the history
Previously CSSTransformNonInterpolableValue assumed that anything that was
composited on-top of would be single. However that is not true; in the simple
case where there is a replace animation before it, the replace effect will be a
pair:

target.animate({ transform: [ 'scale(1)', 'scale(2)' ] }, 1000);
target.animate({ transform: [ 'rotate(0)', 'rotate(90deg)' ] },
               { duration: 1000, composite: 'add' });

In the example above, the scale animation would not yet have been reduced to a
single interpolated value, so the DCHECK for is_single_ would fail. This CL
fixes the logic to perform an interpolation in that case.

Bug: 979952
Change-Id: I36a3221c55aa3d98281a21a4ac93d95d61c5a1ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1750200
Reviewed-by: Kevin Ellis <kevers@chromium.org>
Commit-Queue: Stephen McGruer <smcgruer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#686789}
  • Loading branch information
stephenmcgruer authored and chromium-wpt-export-bot committed Aug 14, 2019
1 parent a06709f commit eba08b2
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions css/css-transforms/animation/composited-transform.html
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>Composition of transform animations</title>
<link rel="help" href="https://drafts.csswg.org/css-transforms-2/#combining-transform-lists">
<meta name="assert" content="transform animations should composite correctly">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<div id="target"><div>

<script>
test(() => {
var anim1 = target.animate(
{ transform: [ 'translateX(0)', 'translateX(100px)' ]},
1000
);
var anim2 = target.animate(
{ transform: [ 'translateY(0)', 'translateY(100px)' ]},
{duration: 1000, composite: 'add'}
);

anim1.pause();
anim2.pause();

anim1.currentTime = 200;
anim2.currentTime = 800;

// The computation here should be:
// underlying_value = 'translateX(0)' --> 'translateX(100px)' @ 0.2
// = 'translateX(20px)'
// final_value = 0.2 * ('translateX(20px) translateY(0)') +
// 0.8 * ('translateX(20px) translateY(100px)')
// = 'translateX(20px) translateY(80px)'
// = 'matrix(1, 0, 0, 1, 20, 80)'
assert_equals(getComputedStyle(target).transform, 'matrix(1, 0, 0, 1, 20, 80)')
}, 'An additive transform animation on-top of a replace transform animation ' +
'should composite correctly');
</script>

0 comments on commit eba08b2

Please sign in to comment.