Skip to content

Commit

Permalink
Update DevTools animation timeline to handle TransitionKeyframeEffect…
Browse files Browse the repository at this point in the history
…Models

CSS Transitions was refactored to use TransitionKeyframes instead of
AnimatableValueKeyframes in https://codereview.chromium.org/2680923005.
This patch updates the DevTools animation timeline to handle the new
data type for transitions.

BUG=698669

Review-Url: https://codereview.chromium.org/2732223002
Cr-Commit-Position: refs/heads/master@{#455333}
(cherry picked from commit a7a57ec)

Review-Url: https://codereview.chromium.org/2737263003 .
Cr-Commit-Position: refs/branch-heads/3029@{nwjs#78}
Cr-Branched-From: 939b32e-refs/heads/master@{#454471}
  • Loading branch information
alancutter committed Mar 9, 2017
1 parent c71044e commit 3b90437
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This test passes if it does not crash.


Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<html>
<head>
<style>
#node {
transition: left 100s;
left: 0px;
}
</style>
<script src="../../http/tests/inspector/inspector-test.js"></script>
<script src="../../http/tests/inspector/elements-test.js"></script>
<script>
function startCSSTransition() {
node.style.left = "100px";
}

var initialize_Animations = function() {
InspectorTest.preloadModule("animation");
}

function test() {
UI.viewManager.showView("animations");
var timeline = self.runtime.sharedInstance(Animation.AnimationTimeline);
InspectorTest.evaluateInPage("startCSSTransition()");
InspectorTest.waitForAnimationAdded(animationAdded);
function animationAdded(group) {
group.animations()[0].setTiming(1, 0);
InspectorTest.completeTest();
}
}

</script>
</head>

<body onload="runTest()">
<p>
This test passes if it does not crash.
</p>

<div id="node"></div>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ blink::Animation* InspectorAnimationAgent::animationClone(
for (auto& oldKeyframe : oldKeyframes)
newKeyframes.push_back(toAnimatableValueKeyframe(oldKeyframe.get()));
newModel = AnimatableValueKeyframeEffectModel::create(newKeyframes);
} else if (oldModel->isTransitionKeyframeEffectModel()) {
TransitionKeyframeEffectModel* oldTransitionKeyframeModel =
toTransitionKeyframeEffectModel(oldModel);
KeyframeVector oldKeyframes = oldTransitionKeyframeModel->getFrames();
TransitionKeyframeVector newKeyframes;
for (auto& oldKeyframe : oldKeyframes)
newKeyframes.push_back(toTransitionKeyframe(oldKeyframe.get()));
newModel = TransitionKeyframeEffectModel::create(newKeyframes);
}

KeyframeEffect* newEffect = KeyframeEffect::create(
Expand Down Expand Up @@ -370,15 +378,15 @@ Response InspectorAnimationAgent::setTiming(const String& animationId,
if (type == AnimationType::CSSTransition) {
KeyframeEffect* effect = toKeyframeEffect(animation->effect());
KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model());
const AnimatableValueKeyframeEffectModel* oldModel =
toAnimatableValueKeyframeEffectModel(model);
const TransitionKeyframeEffectModel* oldModel =
toTransitionKeyframeEffectModel(model);
// Refer to CSSAnimations::calculateTransitionUpdateForProperty() for the
// structure of transitions.
const KeyframeVector& frames = oldModel->getFrames();
ASSERT(frames.size() == 3);
KeyframeVector newFrames;
for (int i = 0; i < 3; i++)
newFrames.push_back(toAnimatableValueKeyframe(frames[i]->clone().get()));
newFrames.push_back(toTransitionKeyframe(frames[i]->clone().get()));
// Update delay, represented by the distance between the first two
// keyframes.
newFrames[1]->setOffset(delay / (delay + duration));
Expand Down

0 comments on commit 3b90437

Please sign in to comment.