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

Side by Side Diff: third_party/WebKit/Source/core/inspector/InspectorAnimationAgent.cpp

Issue 2944423003: Implement new AnimationTimeline superclass (Closed)
Patch Set: Rebase Created 3 years, 5 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/animation/SuperAnimationTimeline.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/inspector/InspectorAnimationAgent.h" 5 #include "core/inspector/InspectorAnimationAgent.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "bindings/core/v8/V8BindingForCore.h" 8 #include "bindings/core/v8/V8BindingForCore.h"
9 #include "core/animation/Animation.h" 9 #include "core/animation/Animation.h"
10 #include "core/animation/AnimationEffectReadOnly.h" 10 #include "core/animation/AnimationEffectReadOnly.h"
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 if (!response.isSuccess()) 238 if (!response.isSuccess())
239 return response; 239 return response;
240 if (id_to_animation_clone_.at(id)) 240 if (id_to_animation_clone_.at(id))
241 animation = id_to_animation_clone_.at(id); 241 animation = id_to_animation_clone_.at(id);
242 242
243 if (animation->Paused()) { 243 if (animation->Paused()) {
244 *current_time = animation->currentTime(); 244 *current_time = animation->currentTime();
245 } else { 245 } else {
246 // Use startTime where possible since currentTime is limited. 246 // Use startTime where possible since currentTime is limited.
247 *current_time = 247 *current_time =
248 animation->timeline()->currentTime() - animation->startTime(); 248 animation->TimelineInternal()->currentTime() - animation->startTime();
249 } 249 }
250 return Response::OK(); 250 return Response::OK();
251 } 251 }
252 252
253 Response InspectorAnimationAgent::setPaused( 253 Response InspectorAnimationAgent::setPaused(
254 std::unique_ptr<protocol::Array<String>> animation_ids, 254 std::unique_ptr<protocol::Array<String>> animation_ids,
255 bool paused) { 255 bool paused) {
256 for (size_t i = 0; i < animation_ids->length(); ++i) { 256 for (size_t i = 0; i < animation_ids->length(); ++i) {
257 String animation_id = animation_ids->get(i); 257 String animation_id = animation_ids->get(i);
258 blink::Animation* animation = nullptr; 258 blink::Animation* animation = nullptr;
259 Response response = AssertAnimation(animation_id, animation); 259 Response response = AssertAnimation(animation_id, animation);
260 if (!response.isSuccess()) 260 if (!response.isSuccess())
261 return response; 261 return response;
262 blink::Animation* clone = AnimationClone(animation); 262 blink::Animation* clone = AnimationClone(animation);
263 if (!clone) 263 if (!clone)
264 return Response::Error("Failed to clone detached animation"); 264 return Response::Error("Failed to clone detached animation");
265 if (paused && !clone->Paused()) { 265 if (paused && !clone->Paused()) {
266 // Ensure we restore a current time if the animation is limited. 266 // Ensure we restore a current time if the animation is limited.
267 double current_time = 267 double current_time =
268 clone->timeline()->currentTime() - clone->startTime(); 268 clone->TimelineInternal()->currentTime() - clone->startTime();
269 clone->pause(); 269 clone->pause();
270 clone->setCurrentTime(current_time, false); 270 clone->setCurrentTime(current_time, false);
271 } else if (!paused && clone->Paused()) { 271 } else if (!paused && clone->Paused()) {
272 clone->Unpause(); 272 clone->Unpause();
273 } 273 }
274 } 274 }
275 return Response::OK(); 275 return Response::OK();
276 } 276 }
277 277
278 blink::Animation* InspectorAnimationAgent::AnimationClone( 278 blink::Animation* InspectorAnimationAgent::AnimationClone(
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 return Response::Error("Could not find animation with given id"); 547 return Response::Error("Could not find animation with given id");
548 return Response::OK(); 548 return Response::OK();
549 } 549 }
550 550
551 AnimationTimeline& InspectorAnimationAgent::ReferenceTimeline() { 551 AnimationTimeline& InspectorAnimationAgent::ReferenceTimeline() {
552 return inspected_frames_->Root()->GetDocument()->Timeline(); 552 return inspected_frames_->Root()->GetDocument()->Timeline();
553 } 553 }
554 554
555 double InspectorAnimationAgent::NormalizedStartTime( 555 double InspectorAnimationAgent::NormalizedStartTime(
556 blink::Animation& animation) { 556 blink::Animation& animation) {
557 if (ReferenceTimeline().PlaybackRate() == 0) 557 if (ReferenceTimeline().PlaybackRate() == 0) {
558 return animation.startTime() + ReferenceTimeline().currentTime() - 558 return animation.startTime() + ReferenceTimeline().currentTime() -
559 animation.timeline()->currentTime(); 559 animation.TimelineInternal()->currentTime();
560 return animation.startTime() + 560 }
561 (animation.timeline()->ZeroTime() - ReferenceTimeline().ZeroTime()) * 561 return animation.startTime() + (animation.TimelineInternal()->ZeroTime() -
562 1000 * ReferenceTimeline().PlaybackRate(); 562 ReferenceTimeline().ZeroTime()) *
563 1000 * ReferenceTimeline().PlaybackRate();
563 } 564 }
564 565
565 DEFINE_TRACE(InspectorAnimationAgent) { 566 DEFINE_TRACE(InspectorAnimationAgent) {
566 visitor->Trace(inspected_frames_); 567 visitor->Trace(inspected_frames_);
567 visitor->Trace(css_agent_); 568 visitor->Trace(css_agent_);
568 visitor->Trace(id_to_animation_); 569 visitor->Trace(id_to_animation_);
569 visitor->Trace(id_to_animation_clone_); 570 visitor->Trace(id_to_animation_clone_);
570 InspectorBaseAgent::Trace(visitor); 571 InspectorBaseAgent::Trace(visitor);
571 } 572 }
572 573
573 } // namespace blink 574 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/animation/SuperAnimationTimeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698