| Index: third_party/WebKit/Source/devtools/front_end/animation/AnimationModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/animation/AnimationModel.js b/third_party/WebKit/Source/devtools/front_end/animation/AnimationModel.js
|
| index 28b24e4c4d9ef2cf9eb55c11a0fd48da6ba213eb..53c48784f63186d00dc8ec77c8c108150a39bf74 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/animation/AnimationModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/animation/AnimationModel.js
|
| @@ -11,6 +11,7 @@ Animation.AnimationModel = class extends SDK.SDKModel {
|
| */
|
| constructor(target) {
|
| super(target);
|
| + this._runtimeModel = target.runtimeModel;
|
| this._agent = target.animationAgent();
|
| target.registerAnimationDispatcher(new Animation.AnimationDispatcher(this));
|
| /** @type {!Map.<string, !Animation.AnimationModel.Animation>} */
|
| @@ -23,15 +24,8 @@ Animation.AnimationModel = class extends SDK.SDKModel {
|
| var resourceTreeModel =
|
| /** @type {!SDK.ResourceTreeModel} */ (SDK.ResourceTreeModel.fromTarget(target));
|
| resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.MainFrameNavigated, this._reset, this);
|
| - this._screenshotCapture = new Animation.AnimationModel.ScreenshotCapture(target, this, resourceTreeModel);
|
| - }
|
| -
|
| - /**
|
| - * @param {!SDK.Target} target
|
| - * @return {?Animation.AnimationModel}
|
| - */
|
| - static fromTarget(target) {
|
| - return target.model(Animation.AnimationModel);
|
| + this._screenshotCapture =
|
| + new Animation.AnimationModel.ScreenshotCapture(this, target.pageAgent(), resourceTreeModel);
|
| }
|
|
|
| _reset() {
|
| @@ -60,7 +54,7 @@ Animation.AnimationModel = class extends SDK.SDKModel {
|
| * @param {!Protocol.Animation.Animation} payload
|
| */
|
| animationStarted(payload) {
|
| - var animation = Animation.AnimationModel.Animation.parsePayload(this.target(), payload);
|
| + var animation = Animation.AnimationModel.Animation.parsePayload(this, payload);
|
|
|
| // Ignore Web Animations custom effects & groups.
|
| if (animation.type() === 'WebAnimation' && animation.source().keyframesRule().keyframes().length === 0) {
|
| @@ -156,7 +150,7 @@ Animation.AnimationModel = class extends SDK.SDKModel {
|
| * @param {!Array.<string>} animations
|
| */
|
| _releaseAnimations(animations) {
|
| - this.target().animationAgent().releaseAnimations(animations);
|
| + this._agent.releaseAnimations(animations);
|
| }
|
|
|
| /**
|
| @@ -198,24 +192,24 @@ Animation.AnimationModel.Events = {
|
| /**
|
| * @unrestricted
|
| */
|
| -Animation.AnimationModel.Animation = class extends SDK.SDKObject {
|
| +Animation.AnimationModel.Animation = class {
|
| /**
|
| - * @param {!SDK.Target} target
|
| + * @param {!Animation.AnimationModel} animationModel
|
| * @param {!Protocol.Animation.Animation} payload
|
| */
|
| - constructor(target, payload) {
|
| - super(target);
|
| + constructor(animationModel, payload) {
|
| + this._animationModel = animationModel;
|
| this._payload = payload;
|
| - this._source = new Animation.AnimationModel.AnimationEffect(this.target(), this._payload.source);
|
| + this._source = new Animation.AnimationModel.AnimationEffect(animationModel, this._payload.source);
|
| }
|
|
|
| /**
|
| - * @param {!SDK.Target} target
|
| + * @param {!Animation.AnimationModel} animationModel
|
| * @param {!Protocol.Animation.Animation} payload
|
| * @return {!Animation.AnimationModel.Animation}
|
| */
|
| - static parsePayload(target, payload) {
|
| - return new Animation.AnimationModel.Animation(target, payload);
|
| + static parsePayload(animationModel, payload) {
|
| + return new Animation.AnimationModel.Animation(animationModel, payload);
|
| }
|
|
|
| /**
|
| @@ -335,7 +329,7 @@ Animation.AnimationModel.Animation = class extends SDK.SDKObject {
|
| this._source.node().then(this._updateNodeStyle.bind(this, duration, delay));
|
| this._source._duration = duration;
|
| this._source._delay = delay;
|
| - this.target().animationAgent().setTiming(this.id(), duration, delay);
|
| + this._animationModel._agent.setTiming(this.id(), duration, delay);
|
| }
|
|
|
| /**
|
| @@ -370,10 +364,10 @@ Animation.AnimationModel.Animation = class extends SDK.SDKObject {
|
| * @this {!Animation.AnimationModel.Animation}
|
| */
|
| function callback(error, payload) {
|
| - return !error ? this.target().runtimeModel.createRemoteObject(payload) : null;
|
| + return !error ? this._animationModel._runtimeModel.createRemoteObject(payload) : null;
|
| }
|
|
|
| - return this.target().animationAgent().resolveAnimation(this.id(), callback.bind(this));
|
| + return this._animationModel._agent.resolveAnimation(this.id(), callback.bind(this));
|
| }
|
|
|
| /**
|
| @@ -395,16 +389,16 @@ Animation.AnimationModel.Animation.Type = {
|
| /**
|
| * @unrestricted
|
| */
|
| -Animation.AnimationModel.AnimationEffect = class extends SDK.SDKObject {
|
| +Animation.AnimationModel.AnimationEffect = class {
|
| /**
|
| - * @param {!SDK.Target} target
|
| + * @param {!Animation.AnimationModel} animationModel
|
| * @param {!Protocol.Animation.AnimationEffect} payload
|
| */
|
| - constructor(target, payload) {
|
| - super(target);
|
| + constructor(animationModel, payload) {
|
| + this._animationModel = animationModel;
|
| this._payload = payload;
|
| if (payload.keyframesRule)
|
| - this._keyframesRule = new Animation.AnimationModel.KeyframesRule(target, payload.keyframesRule);
|
| + this._keyframesRule = new Animation.AnimationModel.KeyframesRule(payload.keyframesRule);
|
| this._delay = this._payload.delay;
|
| this._duration = this._payload.duration;
|
| }
|
| @@ -466,7 +460,7 @@ Animation.AnimationModel.AnimationEffect = class extends SDK.SDKObject {
|
| */
|
| node() {
|
| if (!this._deferredNode)
|
| - this._deferredNode = new SDK.DeferredDOMNode(this.target(), this.backendNodeId());
|
| + this._deferredNode = new SDK.DeferredDOMNode(this._animationModel.target(), this.backendNodeId());
|
| return this._deferredNode.resolvePromise();
|
| }
|
|
|
| @@ -474,7 +468,7 @@ Animation.AnimationModel.AnimationEffect = class extends SDK.SDKObject {
|
| * @return {!SDK.DeferredDOMNode}
|
| */
|
| deferredNode() {
|
| - return new SDK.DeferredDOMNode(this.target(), this.backendNodeId());
|
| + return new SDK.DeferredDOMNode(this._animationModel.target(), this.backendNodeId());
|
| }
|
|
|
| /**
|
| @@ -502,16 +496,14 @@ Animation.AnimationModel.AnimationEffect = class extends SDK.SDKObject {
|
| /**
|
| * @unrestricted
|
| */
|
| -Animation.AnimationModel.KeyframesRule = class extends SDK.SDKObject {
|
| +Animation.AnimationModel.KeyframesRule = class {
|
| /**
|
| - * @param {!SDK.Target} target
|
| * @param {!Protocol.Animation.KeyframesRule} payload
|
| */
|
| - constructor(target, payload) {
|
| - super(target);
|
| + constructor(payload) {
|
| this._payload = payload;
|
| this._keyframes = this._payload.keyframes.map(function(keyframeStyle) {
|
| - return new Animation.AnimationModel.KeyframeStyle(target, keyframeStyle);
|
| + return new Animation.AnimationModel.KeyframeStyle(keyframeStyle);
|
| });
|
| }
|
|
|
| @@ -520,7 +512,7 @@ Animation.AnimationModel.KeyframesRule = class extends SDK.SDKObject {
|
| */
|
| _setKeyframesPayload(payload) {
|
| this._keyframes = payload.map(function(keyframeStyle) {
|
| - return new Animation.AnimationModel.KeyframeStyle(this._target, keyframeStyle);
|
| + return new Animation.AnimationModel.KeyframeStyle(keyframeStyle);
|
| });
|
| }
|
|
|
| @@ -542,13 +534,11 @@ Animation.AnimationModel.KeyframesRule = class extends SDK.SDKObject {
|
| /**
|
| * @unrestricted
|
| */
|
| -Animation.AnimationModel.KeyframeStyle = class extends SDK.SDKObject {
|
| +Animation.AnimationModel.KeyframeStyle = class {
|
| /**
|
| - * @param {!SDK.Target} target
|
| * @param {!Protocol.Animation.KeyframeStyle} payload
|
| */
|
| - constructor(target, payload) {
|
| - super(target);
|
| + constructor(payload) {
|
| this._payload = payload;
|
| this._offset = this._payload.offset;
|
| }
|
| @@ -585,15 +575,14 @@ Animation.AnimationModel.KeyframeStyle = class extends SDK.SDKObject {
|
| /**
|
| * @unrestricted
|
| */
|
| -Animation.AnimationModel.AnimationGroup = class extends SDK.SDKObject {
|
| +Animation.AnimationModel.AnimationGroup = class {
|
| /**
|
| - * @param {!Animation.AnimationModel} model
|
| + * @param {!Animation.AnimationModel} animationModel
|
| * @param {string} id
|
| * @param {!Array.<!Animation.AnimationModel.Animation>} animations
|
| */
|
| - constructor(model, id, animations) {
|
| - super(model.target());
|
| - this._model = model;
|
| + constructor(animationModel, id, animations) {
|
| + this._animationModel = animationModel;
|
| this._id = id;
|
| this._animations = animations;
|
| this._paused = false;
|
| @@ -616,8 +605,8 @@ Animation.AnimationModel.AnimationGroup = class extends SDK.SDKObject {
|
| }
|
|
|
| release() {
|
| - this._model._animationGroups.remove(this.id());
|
| - this._model._releaseAnimations(this._animationIds());
|
| + this._animationModel._animationGroups.remove(this.id());
|
| + this._animationModel._releaseAnimations(this._animationIds());
|
| }
|
|
|
| /**
|
| @@ -656,7 +645,7 @@ Animation.AnimationModel.AnimationGroup = class extends SDK.SDKObject {
|
| * @param {number} currentTime
|
| */
|
| seekTo(currentTime) {
|
| - this.target().animationAgent().seekAnimations(this._animationIds(), currentTime);
|
| + this._animationModel._agent.seekAnimations(this._animationIds(), currentTime);
|
| }
|
|
|
| /**
|
| @@ -673,7 +662,7 @@ Animation.AnimationModel.AnimationGroup = class extends SDK.SDKObject {
|
| if (paused === this._paused)
|
| return;
|
| this._paused = paused;
|
| - this.target().animationAgent().setPaused(this._animationIds(), paused);
|
| + this._animationModel._agent.setPaused(this._animationIds(), paused);
|
| }
|
|
|
| /**
|
| @@ -694,7 +683,7 @@ Animation.AnimationModel.AnimationGroup = class extends SDK.SDKObject {
|
| if (!longestAnim || anim.endTime() > longestAnim.endTime())
|
| longestAnim = anim;
|
| }
|
| - return this.target().animationAgent().getCurrentTime(longestAnim.id(), callback).catchException(0);
|
| + return this._animationModel._agent.getCurrentTime(longestAnim.id(), callback).catchException(0);
|
| }
|
|
|
| /**
|
| @@ -728,7 +717,7 @@ Animation.AnimationModel.AnimationGroup = class extends SDK.SDKObject {
|
| * @param {!Animation.AnimationModel.AnimationGroup} group
|
| */
|
| _update(group) {
|
| - this._model._releaseAnimations(this._animationIds());
|
| + this._animationModel._releaseAnimations(this._animationIds());
|
| this._animations = group._animations;
|
| }
|
|
|
| @@ -785,17 +774,17 @@ Animation.AnimationDispatcher = class {
|
| */
|
| Animation.AnimationModel.ScreenshotCapture = class {
|
| /**
|
| - * @param {!SDK.Target} target
|
| - * @param {!Animation.AnimationModel} model
|
| + * @param {!Animation.AnimationModel} animationModel
|
| + * @param {!Protocol.PageAgent} pageAgent
|
| * @param {!SDK.ResourceTreeModel} resourceTreeModel
|
| */
|
| - constructor(target, model, resourceTreeModel) {
|
| - this._target = target;
|
| + constructor(animationModel, pageAgent, resourceTreeModel) {
|
| /** @type {!Array<!Animation.AnimationModel.ScreenshotCapture.Request>} */
|
| this._requests = [];
|
| resourceTreeModel.addEventListener(SDK.ResourceTreeModel.Events.ScreencastFrame, this._screencastFrame, this);
|
| - this._model = model;
|
| - this._model.addEventListener(Animation.AnimationModel.Events.ModelReset, this._stopScreencast, this);
|
| + this._pageAgent = pageAgent;
|
| + this._animationModel = animationModel;
|
| + this._animationModel.addEventListener(Animation.AnimationModel.Events.ModelReset, this._stopScreencast, this);
|
| }
|
|
|
| /**
|
| @@ -803,7 +792,7 @@ Animation.AnimationModel.ScreenshotCapture = class {
|
| * @param {!Array<string>} screenshots
|
| */
|
| captureScreenshots(duration, screenshots) {
|
| - var screencastDuration = Math.min(duration / this._model._playbackRate, 3000);
|
| + var screencastDuration = Math.min(duration / this._animationModel._playbackRate, 3000);
|
| var endTime = screencastDuration + window.performance.now();
|
| this._requests.push({endTime: endTime, screenshots: screenshots});
|
|
|
| @@ -816,7 +805,7 @@ Animation.AnimationModel.ScreenshotCapture = class {
|
| if (this._capturing)
|
| return;
|
| this._capturing = true;
|
| - this._target.pageAgent().startScreencast('jpeg', 80, undefined, 300, 2);
|
| + this._pageAgent.startScreencast('jpeg', 80, undefined, 300, 2);
|
| }
|
|
|
| /**
|
| @@ -849,7 +838,7 @@ Animation.AnimationModel.ScreenshotCapture = class {
|
| delete this._endTime;
|
| this._requests = [];
|
| this._capturing = false;
|
| - this._target.pageAgent().stopScreencast();
|
| + this._pageAgent.stopScreencast();
|
| }
|
| };
|
|
|
|
|