Chromium Code Reviews| 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 * @param {!WebInspector.ResourceTreeModel} resourceTreeModel | |
| 10 */ | 11 */ |
| 11 WebInspector.AnimationModel = function(target) | 12 WebInspector.AnimationModel = function(target, resourceTreeModel) |
| 12 { | 13 { |
| 13 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target); | 14 WebInspector.SDKModel.call(this, WebInspector.AnimationModel, target); |
| 14 this._agent = target.animationAgent(); | 15 this._agent = target.animationAgent(); |
| 15 target.registerAnimationDispatcher(new WebInspector.AnimationDispatcher(this )); | 16 target.registerAnimationDispatcher(new WebInspector.AnimationDispatcher(this )); |
| 16 /** @type {!Map.<string, !WebInspector.AnimationModel.Animation>} */ | 17 /** @type {!Map.<string, !WebInspector.AnimationModel.Animation>} */ |
| 17 this._animationsById = new Map(); | 18 this._animationsById = new Map(); |
| 18 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationGroup>} */ | 19 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationGroup>} */ |
| 19 this._animationGroups = new Map(); | 20 this._animationGroups = new Map(); |
| 20 /** @type {!Array.<string>} */ | 21 /** @type {!Array.<string>} */ |
| 21 this._pendingAnimations = []; | 22 this._pendingAnimations = []; |
| 22 this._playbackRate = 1; | 23 this._playbackRate = 1; |
| 23 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve ntTypes.MainFrameNavigated, this._reset, this); | 24 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes .MainFrameNavigated, this._reset, this); |
| 24 this._screenshotCapture = new WebInspector.AnimationModel.ScreenshotCapture( target, this); | 25 this._screenshotCapture = new WebInspector.AnimationModel.ScreenshotCapture( target, this, resourceTreeModel); |
| 25 } | 26 } |
| 26 | 27 |
| 27 WebInspector.AnimationModel.Events = { | 28 WebInspector.AnimationModel.Events = { |
| 28 AnimationGroupStarted: "AnimationGroupStarted", | 29 AnimationGroupStarted: "AnimationGroupStarted", |
| 29 ModelReset: "ModelReset" | 30 ModelReset: "ModelReset" |
| 30 } | 31 } |
| 31 | 32 |
| 32 WebInspector.AnimationModel.prototype = { | 33 WebInspector.AnimationModel.prototype = { |
| 33 _reset: function() | 34 _reset: function() |
| 34 { | 35 { |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 WebInspector.AnimationModel._symbol = Symbol("AnimationModel"); | 202 WebInspector.AnimationModel._symbol = Symbol("AnimationModel"); |
| 202 | 203 |
| 203 /** | 204 /** |
| 204 * @param {!WebInspector.Target} target | 205 * @param {!WebInspector.Target} target |
| 205 * @return {?WebInspector.AnimationModel} | 206 * @return {?WebInspector.AnimationModel} |
| 206 */ | 207 */ |
| 207 WebInspector.AnimationModel.fromTarget = function(target) | 208 WebInspector.AnimationModel.fromTarget = function(target) |
| 208 { | 209 { |
| 209 if (!target.hasBrowserCapability()) | 210 if (!target.hasBrowserCapability()) |
| 210 return null; | 211 return null; |
| 211 if (!target[WebInspector.AnimationModel._symbol]) | 212 if (!target[WebInspector.AnimationModel._symbol]) { |
| 212 target[WebInspector.AnimationModel._symbol] = new WebInspector.Animation Model(target); | 213 var resourceTreeModel = /** @type {!WebInspector.ResourceTreeModel} */ ( WebInspector.ResourceTreeModel.fromTarget(target)); |
|
pfeldman
2016/07/13 23:55:56
You could as well do this in the WebInspector.Anim
eostroukhov-old
2016/07/20 23:46:14
Done.
| |
| 214 target[WebInspector.AnimationModel._symbol] = new WebInspector.Animation Model(target, resourceTreeModel); | |
| 215 } | |
| 213 | 216 |
| 214 return target[WebInspector.AnimationModel._symbol]; | 217 return target[WebInspector.AnimationModel._symbol]; |
| 215 } | 218 } |
| 216 | 219 |
| 217 /** | 220 /** |
| 218 * @constructor | 221 * @constructor |
| 219 * @extends {WebInspector.SDKObject} | 222 * @extends {WebInspector.SDKObject} |
| 220 * @param {!WebInspector.Target} target | 223 * @param {!WebInspector.Target} target |
| 221 * @param {!AnimationAgent.Animation} payload | 224 * @param {!AnimationAgent.Animation} payload |
| 222 */ | 225 */ |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 872 animationStarted: function(payload) | 875 animationStarted: function(payload) |
| 873 { | 876 { |
| 874 this._animationModel.animationStarted(payload); | 877 this._animationModel.animationStarted(payload); |
| 875 } | 878 } |
| 876 } | 879 } |
| 877 | 880 |
| 878 /** | 881 /** |
| 879 * @constructor | 882 * @constructor |
| 880 * @param {!WebInspector.Target} target | 883 * @param {!WebInspector.Target} target |
| 881 * @param {!WebInspector.AnimationModel} model | 884 * @param {!WebInspector.AnimationModel} model |
| 885 * @param {!WebInspector.ResourceTreeModel} resourceTreeModel | |
| 882 */ | 886 */ |
| 883 WebInspector.AnimationModel.ScreenshotCapture = function(target, model) | 887 WebInspector.AnimationModel.ScreenshotCapture = function(target, model, resource TreeModel) |
| 884 { | 888 { |
| 885 this._target = target; | 889 this._target = target; |
| 886 /** @type {!Array<!WebInspector.AnimationModel.ScreenshotCapture.Request>} * / | 890 /** @type {!Array<!WebInspector.AnimationModel.ScreenshotCapture.Request>} * / |
| 887 this._requests = []; | 891 this._requests = []; |
| 888 this._target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeMod el.EventTypes.ScreencastFrame, this._screencastFrame, this); | 892 resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes .ScreencastFrame, this._screencastFrame, this); |
| 889 this._model = model; | 893 this._model = model; |
| 890 this._model.addEventListener(WebInspector.AnimationModel.Events.ModelReset, this._stopScreencast, this); | 894 this._model.addEventListener(WebInspector.AnimationModel.Events.ModelReset, this._stopScreencast, this); |
| 891 } | 895 } |
| 892 | 896 |
| 893 /** @typedef {{ endTime: number, screenshots: !Array.<string>}} */ | 897 /** @typedef {{ endTime: number, screenshots: !Array.<string>}} */ |
| 894 WebInspector.AnimationModel.ScreenshotCapture.Request; | 898 WebInspector.AnimationModel.ScreenshotCapture.Request; |
| 895 | 899 |
| 896 WebInspector.AnimationModel.ScreenshotCapture.prototype = { | 900 WebInspector.AnimationModel.ScreenshotCapture.prototype = { |
| 897 /** | 901 /** |
| 898 * @param {number} duration | 902 * @param {number} duration |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 945 if (!this._capturing) | 949 if (!this._capturing) |
| 946 return; | 950 return; |
| 947 | 951 |
| 948 delete this._stopTimer; | 952 delete this._stopTimer; |
| 949 delete this._endTime; | 953 delete this._endTime; |
| 950 this._requests = []; | 954 this._requests = []; |
| 951 this._capturing = false; | 955 this._capturing = false; |
| 952 this._target.pageAgent().stopScreencast(); | 956 this._target.pageAgent().stopScreencast(); |
| 953 } | 957 } |
| 954 } | 958 } |
| OLD | NEW |