Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1081)

Unified Diff: Source/core/inspector/InspectorAnimationAgent.cpp

Issue 1042143005: Devtools Animations: Support multiple frames in the animation timeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InspectorAnimationAgent.cpp
diff --git a/Source/core/inspector/InspectorAnimationAgent.cpp b/Source/core/inspector/InspectorAnimationAgent.cpp
index fe063f4aeca66c36c81f83ed303828bff05e5ceb..fd99493e3fd46f57ffba5161e6630002dbb935ec 100644
--- a/Source/core/inspector/InspectorAnimationAgent.cpp
+++ b/Source/core/inspector/InspectorAnimationAgent.cpp
@@ -171,6 +171,12 @@ static PassRefPtr<TypeBuilder::Animation::KeyframesRule> buildObjectForAnimation
return keyframesObject.release();
}
+static double normalizedStartTime(AnimationPlayer& player)
+{
+ ASSERT(player.timeline());
+ return player.startTime() / player.timeline()->playbackRate() + player.timeline()->zeroTime() * 1000;
pfeldman 2015/04/01 13:06:45 What time is this?
samli 2015/04/02 09:58:00 We take relative timeline times and convert them t
pfeldman 2015/04/02 14:42:38 But zeroTime is already monotonicTime, why do mult
samli 2015/04/02 20:13:19 Chrome's internal representations are in seconds.
+}
+
PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::buildObjectForAnimationPlayer(AnimationPlayer& player)
{
// Find type of animation
@@ -208,7 +214,7 @@ PassRefPtr<TypeBuilder::Animation::AnimationPlayer> InspectorAnimationAgent::bui
.setPausedState(player.paused())
.setPlayState(player.playState())
.setPlaybackRate(player.playbackRate())
- .setStartTime(player.startTime())
+ .setStartTime(normalizedStartTime(player))
.setCurrentTime(player.currentTime())
.setSource(animationObject.release())
.setType(animationType);
@@ -243,20 +249,41 @@ void InspectorAnimationAgent::getAnimationPlayersForNode(ErrorString* errorStrin
void InspectorAnimationAgent::getPlaybackRate(ErrorString*, double* playbackRate)
{
+ // All timelines should have the same playback rate
*playbackRate = m_pageAgent->inspectedFrame()->document()->timeline().playbackRate();
}
-void InspectorAnimationAgent::setPlaybackRate(ErrorString*, double playbackRate)
+void InspectorAnimationAgent::setPlaybackRate(ErrorString*, double playbackRate, RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationStartTime>>& animationStartTimes)
{
for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tree().traverseNext(m_pageAgent->inspectedFrame())) {
if (frame->isLocalFrame())
toLocalFrame(frame)->document()->timeline().setPlaybackRate(playbackRate);
}
+ animationStartTimes = buildArrayForStartTimes();
+}
+
+void InspectorAnimationAgent::setCurrentTime(ErrorString*, double normalisedCurrentTime, RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationStartTime>>& animationStartTimes)
+{
+ for (Frame* frame = m_pageAgent->inspectedFrame(); frame; frame = frame->tree().traverseNext(m_pageAgent->inspectedFrame())) {
pfeldman 2015/04/01 13:06:45 It is strange that this synchronization takes plac
samli 2015/04/02 09:58:00 This code isn't to sync timelines. This code is us
pfeldman 2015/04/02 14:42:38 Ok, I think I understand.
+ if (frame->isLocalFrame()) {
+ AnimationTimeline& timeline = toLocalFrame(frame)->document()->timeline();
+ timeline.setCurrentTime((normalisedCurrentTime - timeline.zeroTime() * 1000) * timeline.playbackRate());
pfeldman 2015/04/02 14:42:38 There is something wrong with the timeline units:
samli 2015/04/02 20:13:19 I think this is the milliseconds confusion?
+ }
+ }
+ animationStartTimes = buildArrayForStartTimes();
}
-void InspectorAnimationAgent::setCurrentTime(ErrorString*, double currentTime)
+PassRefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationStartTime>> InspectorAnimationAgent::buildArrayForStartTimes()
{
- m_pageAgent->inspectedFrame()->document()->timeline().setCurrentTime(currentTime);
+ RefPtr<TypeBuilder::Array<TypeBuilder::Animation::AnimationStartTime>> animationStartTimes = TypeBuilder::Array<TypeBuilder::Animation::AnimationStartTime>::create();
+ for (const auto& pair : m_idToAnimationPlayer) {
+ const RefPtr<AnimationPlayer> player = pair.value;
+ RefPtr<TypeBuilder::Animation::AnimationStartTime> startTimeObject = TypeBuilder::Animation::AnimationStartTime::create()
+ .setId(pair.key)
+ .setStartTime(normalizedStartTime(*player.get()));
+ animationStartTimes->addItem(startTimeObject);
+ }
+ return animationStartTimes.release();
}
void InspectorAnimationAgent::setTiming(ErrorString* errorString, const String& playerId, double duration, double delay)
@@ -281,10 +308,10 @@ void InspectorAnimationAgent::didCreateAnimationPlayer(AnimationPlayer* player)
// Check threshold
double latestStartTime = 0;
for (const auto& p : m_idToAnimationPlayer.values())
- latestStartTime = max(latestStartTime, p->startTime());
+ latestStartTime = max(latestStartTime, normalizedStartTime(*p));
bool reset = false;
- if (player->startTime() - latestStartTime > 1000) {
+ if (normalizedStartTime(*player) - latestStartTime > 1000) {
reset = true;
m_idToAnimationPlayer.clear();
m_idToAnimationType.clear();

Powered by Google App Engine
This is Rietveld 408576698