| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.SDKModelObserver<!Animation.AnimationModel>} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 Animation.AnimationTimeline = class extends UI.VBox { | 8 Animation.AnimationTimeline = class extends UI.VBox { |
| 9 constructor() { | 9 constructor() { |
| 10 super(true); | 10 super(true); |
| 11 this.registerRequiredCSS('animation/animationTimeline.css'); | 11 this.registerRequiredCSS('animation/animationTimeline.css'); |
| 12 this.element.classList.add('animations-timeline'); | 12 this.element.classList.add('animations-timeline'); |
| 13 | 13 |
| 14 this._grid = this.contentElement.createSVGChild('svg', 'animation-timeline-g
rid'); | 14 this._grid = this.contentElement.createSVGChild('svg', 'animation-timeline-g
rid'); |
| 15 | 15 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 26 /** @type {!Map.<!Protocol.DOM.BackendNodeId, !Animation.AnimationTimeline.N
odeUI>} */ | 26 /** @type {!Map.<!Protocol.DOM.BackendNodeId, !Animation.AnimationTimeline.N
odeUI>} */ |
| 27 this._nodesMap = new Map(); | 27 this._nodesMap = new Map(); |
| 28 this._uiAnimations = []; | 28 this._uiAnimations = []; |
| 29 this._groupBuffer = []; | 29 this._groupBuffer = []; |
| 30 /** @type {!Map.<!Animation.AnimationModel.AnimationGroup, !Animation.Animat
ionGroupPreviewUI>} */ | 30 /** @type {!Map.<!Animation.AnimationModel.AnimationGroup, !Animation.Animat
ionGroupPreviewUI>} */ |
| 31 this._previewMap = new Map(); | 31 this._previewMap = new Map(); |
| 32 this._symbol = Symbol('animationTimeline'); | 32 this._symbol = Symbol('animationTimeline'); |
| 33 /** @type {!Map.<string, !Animation.AnimationModel.Animation>} */ | 33 /** @type {!Map.<string, !Animation.AnimationModel.Animation>} */ |
| 34 this._animationsMap = new Map(); | 34 this._animationsMap = new Map(); |
| 35 SDK.targetManager.addModelListener(SDK.DOMModel, SDK.DOMModel.Events.NodeRem
oved, this._nodeRemoved, this); | 35 SDK.targetManager.addModelListener(SDK.DOMModel, SDK.DOMModel.Events.NodeRem
oved, this._nodeRemoved, this); |
| 36 SDK.targetManager.observeTargets(this, SDK.Target.Capability.DOM); | 36 SDK.targetManager.observeModels(Animation.AnimationModel, this); |
| 37 UI.context.addFlavorChangeListener(SDK.DOMNode, this._nodeChanged, this); | 37 UI.context.addFlavorChangeListener(SDK.DOMNode, this._nodeChanged, this); |
| 38 } | 38 } |
| 39 | 39 |
| 40 /** | 40 /** |
| 41 * @override | 41 * @override |
| 42 */ | 42 */ |
| 43 wasShown() { | 43 wasShown() { |
| 44 for (var target of SDK.targetManager.targets(SDK.Target.Capability.DOM)) | 44 for (var animationModel of SDK.targetManager.models(Animation.AnimationModel
)) |
| 45 this._addEventListeners(target); | 45 this._addEventListeners(animationModel); |
| 46 } | 46 } |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * @override | 49 * @override |
| 50 */ | 50 */ |
| 51 willHide() { | 51 willHide() { |
| 52 for (var target of SDK.targetManager.targets(SDK.Target.Capability.DOM)) | 52 for (var animationModel of SDK.targetManager.models(Animation.AnimationModel
)) |
| 53 this._removeEventListeners(target); | 53 this._removeEventListeners(animationModel); |
| 54 this._popoverHelper.hidePopover(); | 54 this._popoverHelper.hidePopover(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * @override | 58 * @override |
| 59 * @param {!SDK.Target} target | 59 * @param {!Animation.AnimationModel} animationModel |
| 60 */ | 60 */ |
| 61 targetAdded(target) { | 61 modelAdded(animationModel) { |
| 62 if (this.isShowing()) | 62 if (this.isShowing()) |
| 63 this._addEventListeners(target); | 63 this._addEventListeners(animationModel); |
| 64 } | 64 } |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * @override | 67 * @override |
| 68 * @param {!SDK.Target} target | 68 * @param {!Animation.AnimationModel} animationModel |
| 69 */ | 69 */ |
| 70 targetRemoved(target) { | 70 modelRemoved(animationModel) { |
| 71 this._removeEventListeners(target); | 71 this._removeEventListeners(animationModel); |
| 72 } | 72 } |
| 73 | 73 |
| 74 /** | 74 /** |
| 75 * @param {!SDK.Target} target | 75 * @param {!Animation.AnimationModel} animationModel |
| 76 */ | 76 */ |
| 77 _addEventListeners(target) { | 77 _addEventListeners(animationModel) { |
| 78 var animationModel = Animation.AnimationModel.fromTarget(target); | |
| 79 animationModel.ensureEnabled(); | 78 animationModel.ensureEnabled(); |
| 80 animationModel.addEventListener( | 79 animationModel.addEventListener( |
| 81 Animation.AnimationModel.Events.AnimationGroupStarted, this._animationGr
oupStarted, this); | 80 Animation.AnimationModel.Events.AnimationGroupStarted, this._animationGr
oupStarted, this); |
| 82 animationModel.addEventListener(Animation.AnimationModel.Events.ModelReset,
this._reset, this); | 81 animationModel.addEventListener(Animation.AnimationModel.Events.ModelReset,
this._reset, this); |
| 83 } | 82 } |
| 84 | 83 |
| 85 /** | 84 /** |
| 86 * @param {!SDK.Target} target | 85 * @param {!Animation.AnimationModel} animationModel |
| 87 */ | 86 */ |
| 88 _removeEventListeners(target) { | 87 _removeEventListeners(animationModel) { |
| 89 var animationModel = Animation.AnimationModel.fromTarget(target); | |
| 90 animationModel.removeEventListener( | 88 animationModel.removeEventListener( |
| 91 Animation.AnimationModel.Events.AnimationGroupStarted, this._animationGr
oupStarted, this); | 89 Animation.AnimationModel.Events.AnimationGroupStarted, this._animationGr
oupStarted, this); |
| 92 animationModel.removeEventListener(Animation.AnimationModel.Events.ModelRese
t, this._reset, this); | 90 animationModel.removeEventListener(Animation.AnimationModel.Events.ModelRese
t, this._reset, this); |
| 93 } | 91 } |
| 94 | 92 |
| 95 _nodeChanged() { | 93 _nodeChanged() { |
| 96 for (var nodeUI of this._nodesMap.values()) | 94 for (var nodeUI of this._nodesMap.values()) |
| 97 nodeUI._nodeChanged(); | 95 nodeUI._nodeChanged(); |
| 98 } | 96 } |
| 99 | 97 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 this._pauseButton.setToggled(this._allPaused); | 209 this._pauseButton.setToggled(this._allPaused); |
| 212 this._setPlaybackRate(this._playbackRate); | 210 this._setPlaybackRate(this._playbackRate); |
| 213 this._pauseButton.setTitle(this._allPaused ? Common.UIString('Resume all') :
Common.UIString('Pause all')); | 211 this._pauseButton.setTitle(this._allPaused ? Common.UIString('Resume all') :
Common.UIString('Pause all')); |
| 214 } | 212 } |
| 215 | 213 |
| 216 /** | 214 /** |
| 217 * @param {number} playbackRate | 215 * @param {number} playbackRate |
| 218 */ | 216 */ |
| 219 _setPlaybackRate(playbackRate) { | 217 _setPlaybackRate(playbackRate) { |
| 220 this._playbackRate = playbackRate; | 218 this._playbackRate = playbackRate; |
| 221 var target = SDK.targetManager.mainTarget(); | 219 for (var animationModel of SDK.targetManager.models(Animation.AnimationModel
)) |
| 222 if (target) | 220 animationModel.setPlaybackRate(this._allPaused ? 0 : this._playbackRate); |
| 223 Animation.AnimationModel.fromTarget(target).setPlaybackRate(this._allPause
d ? 0 : this._playbackRate); | |
| 224 Host.userMetrics.actionTaken(Host.UserMetrics.Action.AnimationsPlaybackRateC
hanged); | 221 Host.userMetrics.actionTaken(Host.UserMetrics.Action.AnimationsPlaybackRateC
hanged); |
| 225 if (this._scrubberPlayer) | 222 if (this._scrubberPlayer) |
| 226 this._scrubberPlayer.playbackRate = this._effectivePlaybackRate(); | 223 this._scrubberPlayer.playbackRate = this._effectivePlaybackRate(); |
| 227 | 224 |
| 228 this._updatePlaybackControls(); | 225 this._updatePlaybackControls(); |
| 229 } | 226 } |
| 230 | 227 |
| 231 _updatePlaybackControls() { | 228 _updatePlaybackControls() { |
| 232 for (var button of this._playbackRateButtons) { | 229 for (var button of this._playbackRateButtons) { |
| 233 var selected = this._playbackRate === button.playbackRate; | 230 var selected = this._playbackRate === button.playbackRate; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 static parse(text) { | 730 static parse(text) { |
| 734 var match = text.match(/^steps\((\d+), (start|middle)\)$/); | 731 var match = text.match(/^steps\((\d+), (start|middle)\)$/); |
| 735 if (match) | 732 if (match) |
| 736 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1
], 10), match[2]); | 733 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1
], 10), match[2]); |
| 737 match = text.match(/^steps\((\d+)\)$/); | 734 match = text.match(/^steps\((\d+)\)$/); |
| 738 if (match) | 735 if (match) |
| 739 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1
], 10), 'end'); | 736 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1
], 10), 'end'); |
| 740 return null; | 737 return null; |
| 741 } | 738 } |
| 742 }; | 739 }; |
| OLD | NEW |