| OLD | NEW |
| 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 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); | 22 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.MainFrameNavigated, this._mainFrameNavigated, this); |
| 23 } | 23 } |
| 24 | 24 |
| 25 WebInspector.AnimationModel.Events = { | 25 WebInspector.AnimationModel.Events = { |
| 26 AnimationGroupStarted: "AnimationGroupStarted", | 26 AnimationGroupStarted: "AnimationGroupStarted" |
| 27 AnimationCanceled: "AnimationCanceled" | |
| 28 } | 27 } |
| 29 | 28 |
| 30 WebInspector.AnimationModel.prototype = { | 29 WebInspector.AnimationModel.prototype = { |
| 31 _mainFrameNavigated: function() | 30 _mainFrameNavigated: function() |
| 32 { | 31 { |
| 33 this._animationsById.clear(); | 32 this._animationsById.clear(); |
| 34 this._animationGroups.clear(); | 33 this._animationGroups.clear(); |
| 35 this._pendingAnimations = []; | 34 this._pendingAnimations = []; |
| 36 }, | 35 }, |
| 37 | 36 |
| 38 /** | 37 /** |
| 39 * @param {string} id | 38 * @param {string} id |
| 40 */ | 39 */ |
| 41 animationCreated: function(id) | 40 animationCreated: function(id) |
| 42 { | 41 { |
| 43 this._pendingAnimations.push(id); | 42 this._pendingAnimations.push(id); |
| 44 }, | 43 }, |
| 45 | 44 |
| 45 _animationCancelled: function(id) |
| 46 { |
| 47 this._pendingAnimations.remove(id); |
| 48 this._flushPendingAnimationsIfNeeded(); |
| 49 }, |
| 50 |
| 46 /** | 51 /** |
| 47 * @param {!AnimationAgent.Animation} payload | 52 * @param {!AnimationAgent.Animation} payload |
| 48 */ | 53 */ |
| 49 animationStarted: function(payload) | 54 animationStarted: function(payload) |
| 50 { | 55 { |
| 51 var animation = WebInspector.AnimationModel.Animation.parsePayload(this.
target(), payload); | 56 var animation = WebInspector.AnimationModel.Animation.parsePayload(this.
target(), payload); |
| 52 this._animationsById.set(animation.id(), animation); | 57 this._animationsById.set(animation.id(), animation); |
| 58 this._flushPendingAnimationsIfNeeded(); |
| 59 }, |
| 53 | 60 |
| 61 _flushPendingAnimationsIfNeeded: function() |
| 62 { |
| 54 for (var id of this._pendingAnimations) { | 63 for (var id of this._pendingAnimations) { |
| 55 if (!this._animationsById.get(id)) | 64 if (!this._animationsById.get(id)) |
| 56 return; | 65 return; |
| 57 } | 66 } |
| 58 | 67 |
| 59 while (this._pendingAnimations.length) | 68 while (this._pendingAnimations.length) |
| 60 this._matchExistingGroups(this._createGroupFromPendingAnimations()); | 69 this._matchExistingGroups(this._createGroupFromPendingAnimations()); |
| 61 }, | 70 }, |
| 62 | 71 |
| 63 /** | 72 /** |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 * @override | 754 * @override |
| 746 * @param {string} id | 755 * @param {string} id |
| 747 */ | 756 */ |
| 748 animationCreated: function(id) | 757 animationCreated: function(id) |
| 749 { | 758 { |
| 750 this._animationModel.animationCreated(id); | 759 this._animationModel.animationCreated(id); |
| 751 }, | 760 }, |
| 752 | 761 |
| 753 /** | 762 /** |
| 754 * @override | 763 * @override |
| 764 * @param {string} id |
| 765 */ |
| 766 animationCancelled: function(id) |
| 767 { |
| 768 this._animationModel._animationCancelled(id); |
| 769 }, |
| 770 |
| 771 /** |
| 772 * @override |
| 755 * @param {!AnimationAgent.Animation} payload | 773 * @param {!AnimationAgent.Animation} payload |
| 756 */ | 774 */ |
| 757 animationStarted: function(payload) | 775 animationStarted: function(payload) |
| 758 { | 776 { |
| 759 this._animationModel.animationStarted(payload); | 777 this._animationModel.animationStarted(payload); |
| 760 } | 778 } |
| 761 } | 779 } |
| OLD | NEW |