Commit d20b39ee authored by alancutter's avatar alancutter Committed by Commit bot

Update DevTools animation timeline to handle TransitionKeyframeEffectModels

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-Original-Commit-Position: refs/heads/master@{#455333}
Committed: https://chromium.googlesource.com/chromium/src/+/a7a57ecd7c36b7bd579d45e0f199f7679edc5197
Review-Url: https://codereview.chromium.org/2732223002
Cr-Commit-Position: refs/heads/master@{#455995}
parent 368901b0
<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() {
// Force style recalcs that will trigger a transition.
getComputedStyle(node).left;
node.style.left = "100px";
getComputedStyle(node).left;
}
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>
...@@ -302,6 +302,14 @@ blink::Animation* InspectorAnimationAgent::animationClone( ...@@ -302,6 +302,14 @@ blink::Animation* InspectorAnimationAgent::animationClone(
for (auto& oldKeyframe : oldKeyframes) for (auto& oldKeyframe : oldKeyframes)
newKeyframes.push_back(toAnimatableValueKeyframe(oldKeyframe.get())); newKeyframes.push_back(toAnimatableValueKeyframe(oldKeyframe.get()));
newModel = AnimatableValueKeyframeEffectModel::create(newKeyframes); 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( KeyframeEffect* newEffect = KeyframeEffect::create(
...@@ -372,15 +380,15 @@ Response InspectorAnimationAgent::setTiming(const String& animationId, ...@@ -372,15 +380,15 @@ Response InspectorAnimationAgent::setTiming(const String& animationId,
if (type == AnimationType::CSSTransition) { if (type == AnimationType::CSSTransition) {
KeyframeEffect* effect = toKeyframeEffect(animation->effect()); KeyframeEffect* effect = toKeyframeEffect(animation->effect());
KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model()); KeyframeEffectModelBase* model = toKeyframeEffectModelBase(effect->model());
const AnimatableValueKeyframeEffectModel* oldModel = const TransitionKeyframeEffectModel* oldModel =
toAnimatableValueKeyframeEffectModel(model); toTransitionKeyframeEffectModel(model);
// Refer to CSSAnimations::calculateTransitionUpdateForProperty() for the // Refer to CSSAnimations::calculateTransitionUpdateForProperty() for the
// structure of transitions. // structure of transitions.
const KeyframeVector& frames = oldModel->getFrames(); const KeyframeVector& frames = oldModel->getFrames();
ASSERT(frames.size() == 3); ASSERT(frames.size() == 3);
KeyframeVector newFrames; KeyframeVector newFrames;
for (int i = 0; i < 3; i++) 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 // Update delay, represented by the distance between the first two
// keyframes. // keyframes.
newFrames[1]->setOffset(delay / (delay + duration)); newFrames[1]->setOffset(delay / (delay + duration));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment