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

Side by Side Diff: Source/devtools/front_end/animation/AnimationModel.js

Issue 1218433007: Devtools Animations: Add buffer and effect selection to animation timeline (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix test Created 5 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 5
6 /** 6 /**
7 * @constructor 7 * @constructor
8 * @extends {WebInspector.SDKModel} 8 * @extends {WebInspector.SDKModel}
9 * @param {!WebInspector.Target} target 9 * @param {!WebInspector.Target} target
10 */ 10 */
11 WebInspector.AnimationModel = function(target) 11 WebInspector.AnimationModel = function(target)
12 { 12 {
13 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target); 13 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target);
14 this._agent = target.animationAgent(); 14 this._agent = target.animationAgent();
15 target.registerAnimationDispatcher(new WebInspector.AnimationDispatcher(this )); 15 target.registerAnimationDispatcher(new WebInspector.AnimationDispatcher(this ));
16 /** @type {!Map.<string, !WebInspector.AnimationModel.Animation>} */ 16 /** @type {!Map.<string, !WebInspector.AnimationModel.Animation>} */
17 this._animationsById = new Map(); 17 this._animationsById = new Map();
18 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationGroup>} */ 18 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationGroup>} */
19 this._animationGroups = new Map(); 19 this._animationGroups = new Map();
20 /** @type {!Array.<string>} */ 20 /** @type {!Array.<string>} */
21 this._pendingAnimations = []; 21 this._pendingAnimations = [];
22 } 22 }
23 23
24 WebInspector.AnimationModel.Events = { 24 WebInspector.AnimationModel.Events = {
25 AnimationCreated: "AnimationCreated", 25 AnimationGroupStarted: "AnimationGroupStarted",
26 AnimationCanceled: "AnimationCanceled" 26 AnimationCanceled: "AnimationCanceled"
27 } 27 }
28 28
29 WebInspector.AnimationModel.prototype = { 29 WebInspector.AnimationModel.prototype = {
30 /** 30 /**
31 * @param {string} id 31 * @param {string} id
32 */ 32 */
33 animationCreated: function(id) 33 animationCreated: function(id)
34 { 34 {
35 this._pendingAnimations.push(id); 35 this._pendingAnimations.push(id);
36 }, 36 },
37 37
38 /** 38 /**
39 * @param {!AnimationAgent.Animation} payload 39 * @param {!AnimationAgent.Animation} payload
40 */ 40 */
41 animationStarted: function(payload) 41 animationStarted: function(payload)
42 { 42 {
43 var animation = WebInspector.AnimationModel.Animation.parsePayload(this. target(), payload); 43 var animation = WebInspector.AnimationModel.Animation.parsePayload(this. target(), payload);
44 this._animationsById.set(animation.id(), animation); 44 this._animationsById.set(animation.id(), animation);
45 45
46 for (var id of this._pendingAnimations) { 46 for (var id of this._pendingAnimations) {
47 if (!this._animationsById.get(id)) 47 if (!this._animationsById.get(id))
48 return; 48 return;
49 } 49 }
50 50
51 while (this._pendingAnimations.length) { 51 while (this._pendingAnimations.length) {
52 var group = this._createGroupFromPendingAnimations(); 52 var group = this._createGroupFromPendingAnimations();
53 this._animationGroups.set(group.id(), group); 53 this._animationGroups.set(group.id(), group);
54 // TODO(samli): Dispatch single group event. 54 this.dispatchEventToListeners(WebInspector.AnimationModel.Events.Ani mationGroupStarted, group);
55 for (var anim of group.animations())
56 this.dispatchEventToListeners(WebInspector.AnimationModel.Events .AnimationCreated, { "player": anim, "resetTimeline": anim.id() === group.id() } );
57 } 55 }
58 }, 56 },
59 57
60 /** 58 /**
61 * @return {!WebInspector.AnimationModel.AnimationGroup} 59 * @return {!WebInspector.AnimationModel.AnimationGroup}
62 */ 60 */
63 _createGroupFromPendingAnimations: function() 61 _createGroupFromPendingAnimations: function()
64 { 62 {
65 console.assert(this._pendingAnimations.length); 63 console.assert(this._pendingAnimations.length);
66 var groupedAnimations = [this._animationsById.get(this._pendingAnimation s.shift())]; 64 var groupedAnimations = [this._animationsById.get(this._pendingAnimation s.shift())];
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 }, 510 },
513 511
514 /** 512 /**
515 * @return {!Array.<!WebInspector.AnimationModel.Animation>} 513 * @return {!Array.<!WebInspector.AnimationModel.Animation>}
516 */ 514 */
517 animations: function() 515 animations: function()
518 { 516 {
519 return this._animations; 517 return this._animations;
520 }, 518 },
521 519
520 /**
521 * @return {number}
522 */
523 startTime: function()
524 {
525 return this._animations[0].startTime();
526 },
527
522 __proto__: WebInspector.SDKObject.prototype 528 __proto__: WebInspector.SDKObject.prototype
523 } 529 }
524 530
525 531
526 /** 532 /**
527 * @constructor 533 * @constructor
528 * @implements {AnimationAgent.Dispatcher} 534 * @implements {AnimationAgent.Dispatcher}
529 */ 535 */
530 WebInspector.AnimationDispatcher = function(animationModel) 536 WebInspector.AnimationDispatcher = function(animationModel)
531 { 537 {
(...skipping 21 matching lines...) Expand all
553 559
554 /** 560 /**
555 * @override 561 * @override
556 * @param {string} id 562 * @param {string} id
557 */ 563 */
558 animationCanceled: function(id) 564 animationCanceled: function(id)
559 { 565 {
560 this._animationModel.animationCanceled(id); 566 this._animationModel.animationCanceled(id);
561 } 567 }
562 } 568 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698