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

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

Issue 1151263007: Devtools: Move animation to separate module (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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) 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 /** 5 /**
6 * @constructor 6 * @constructor
7 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 * @implements {WebInspector.TargetManager.Observer} 8 * @implements {WebInspector.TargetManager.Observer}
9 */ 9 */
10 WebInspector.AnimationTimeline = function() 10 WebInspector.AnimationTimeline = function()
11 { 11 {
12 WebInspector.VBox.call(this, true); 12 WebInspector.VBox.call(this, true);
13 this.registerRequiredCSS("elements/animationTimeline.css"); 13 this.registerRequiredCSS("animation/animationTimeline.css");
14 this.element.classList.add("animations-timeline"); 14 this.element.classList.add("animations-timeline");
15 15
16 this._grid = this.contentElement.createSVGChild("svg", "animation-timeline-g rid"); 16 this._grid = this.contentElement.createSVGChild("svg", "animation-timeline-g rid");
17 this.contentElement.appendChild(this._createScrubber()); 17 this.contentElement.appendChild(this._createScrubber());
18 WebInspector.installDragHandle(this._timelineScrubberHead, this._scrubberDra gStart.bind(this), this._scrubberDragMove.bind(this), this._scrubberDragEnd.bind (this), "move"); 18 WebInspector.installDragHandle(this._timelineScrubberHead, this._scrubberDra gStart.bind(this), this._scrubberDragMove.bind(this), this._scrubberDragEnd.bind (this), "move");
19 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.millis ToString(0)); 19 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.millis ToString(0));
20 20
21 this._underlyingPlaybackRate = 1; 21 this._underlyingPlaybackRate = 1;
22 this.contentElement.appendChild(this._createHeader()); 22 this.contentElement.appendChild(this._createHeader());
23 this._animationsContainer = this.contentElement.createChild("div", "animatio n-timeline-rows"); 23 this._animationsContainer = this.contentElement.createChild("div", "animatio n-timeline-rows");
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 targetRemoved: function(target) 67 targetRemoved: function(target)
68 { 68 {
69 this._removeEventListeners(target); 69 this._removeEventListeners(target);
70 }, 70 },
71 71
72 /** 72 /**
73 * @param {!WebInspector.Target} target 73 * @param {!WebInspector.Target} target
74 */ 74 */
75 _addEventListeners: function(target) 75 _addEventListeners: function(target)
76 { 76 {
77 target.animationModel.ensureEnabled(); 77 var animationModel = WebInspector.AnimationModel.fromTarget(target);
78 target.animationModel.addEventListener(WebInspector.AnimationModel.Event s.AnimationPlayerCreated, this._animationCreated, this); 78 animationModel.ensureEnabled();
79 target.animationModel.addEventListener(WebInspector.AnimationModel.Event s.AnimationPlayerCanceled, this._animationCanceled, this); 79 animationModel.addEventListener(WebInspector.AnimationModel.Events.Anima tionPlayerCreated, this._animationCreated, this);
80 animationModel.addEventListener(WebInspector.AnimationModel.Events.Anima tionPlayerCanceled, this._animationCanceled, this);
80 }, 81 },
81 82
82 /** 83 /**
83 * @param {!WebInspector.Target} target 84 * @param {!WebInspector.Target} target
84 */ 85 */
85 _removeEventListeners: function(target) 86 _removeEventListeners: function(target)
86 { 87 {
87 target.animationModel.removeEventListener(WebInspector.AnimationModel.Ev ents.AnimationPlayerCreated, this._animationCreated, this); 88 var animationModel = WebInspector.AnimationModel.fromTarget(target);
88 target.animationModel.removeEventListener(WebInspector.AnimationModel.Ev ents.AnimationPlayerCanceled, this._animationCanceled, this); 89 animationModel.removeEventListener(WebInspector.AnimationModel.Events.An imationPlayerCreated, this._animationCreated, this);
90 animationModel.removeEventListener(WebInspector.AnimationModel.Events.An imationPlayerCanceled, this._animationCanceled, this);
89 }, 91 },
90 92
91 /** 93 /**
92 * @param {?WebInspector.DOMNode} node 94 * @param {?WebInspector.DOMNode} node
93 */ 95 */
94 setNode: function(node) 96 setNode: function(node)
95 { 97 {
96 for (var nodeUI of this._nodesMap.values()) 98 for (var nodeUI of this._nodesMap.values())
97 nodeUI.setNode(node); 99 nodeUI.setNode(node);
98 }, 100 },
(...skipping 18 matching lines...) Expand all
117 */ 119 */
118 _createHeader: function() 120 _createHeader: function()
119 { 121 {
120 /** 122 /**
121 * @param {!Event} event 123 * @param {!Event} event
122 * @this {WebInspector.AnimationTimeline} 124 * @this {WebInspector.AnimationTimeline}
123 */ 125 */
124 function playbackSliderInputHandler(event) 126 function playbackSliderInputHandler(event)
125 { 127 {
126 this._underlyingPlaybackRate = WebInspector.AnimationTimeline.Global PlaybackRates[event.target.value]; 128 this._underlyingPlaybackRate = WebInspector.AnimationTimeline.Global PlaybackRates[event.target.value];
127 var target = WebInspector.targetManager.mainTarget(); 129 this._setPlaybackRate(this._playbackRate());
128 if (target)
129 target.animationModel.setPlaybackRate(this._playbackRate());
130 this._playbackLabel.textContent = this._underlyingPlaybackRate + "✕" ; 130 this._playbackLabel.textContent = this._underlyingPlaybackRate + "✕" ;
131 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); 131 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record();
132 this._updateTimelineAnimations(); 132 this._updateTimelineAnimations();
133 } 133 }
134 134
135 var container = createElementWithClass("div", "animation-timeline-header "); 135 var container = createElementWithClass("div", "animation-timeline-header ");
136 var controls = container.createChild("div", "animation-controls"); 136 var controls = container.createChild("div", "animation-controls");
137 container.createChild("div", "animation-timeline-markers"); 137 container.createChild("div", "animation-timeline-markers");
138 138
139 var toolbar = new WebInspector.Toolbar(controls); 139 var toolbar = new WebInspector.Toolbar(controls);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (this._timerSpinnerPlayer) { 197 if (this._timerSpinnerPlayer) {
198 this._timerSpinnerPlayer.playbackRate = this._playbackRate(); 198 this._timerSpinnerPlayer.playbackRate = this._playbackRate();
199 this._timerFillerPlayer.playbackRate = this._playbackRate(); 199 this._timerFillerPlayer.playbackRate = this._playbackRate();
200 this._timerMaskPlayer.playbackRate = this._playbackRate(); 200 this._timerMaskPlayer.playbackRate = this._playbackRate();
201 } 201 }
202 }, 202 },
203 203
204 _togglePause: function() 204 _togglePause: function()
205 { 205 {
206 this._paused = !this._paused; 206 this._paused = !this._paused;
207 var target = WebInspector.targetManager.mainTarget(); 207 this._setPlaybackRate(this._playbackRate());
208 if (target)
209 target.animationModel.setPlaybackRate(this._playbackRate());
210 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); 208 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record();
211 this._pauseButton.element.classList.toggle("pause-toolbar-item"); 209 this._pauseButton.element.classList.toggle("pause-toolbar-item");
212 this._pauseButton.element.classList.toggle("play-toolbar-item"); 210 this._pauseButton.element.classList.toggle("play-toolbar-item");
213 this._updateTimelineAnimations(); 211 this._updateTimelineAnimations();
214 }, 212 },
215 213
216 _replay: function() 214 _replay: function()
217 { 215 {
218 if (this.startTime() === undefined) 216 if (this.startTime() === undefined)
219 return; 217 return;
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 { 539 {
542 if (!this._scrubberPlayer) 540 if (!this._scrubberPlayer)
543 return false; 541 return false;
544 542
545 this._originalScrubberTime = this._scrubberPlayer.currentTime; 543 this._originalScrubberTime = this._scrubberPlayer.currentTime;
546 this._timelineScrubber.classList.remove("animation-timeline-end"); 544 this._timelineScrubber.classList.remove("animation-timeline-end");
547 this._timelineScrubber.classList.remove("animation-timeline-capturing"); 545 this._timelineScrubber.classList.remove("animation-timeline-capturing");
548 this._scrubberPlayer.pause(); 546 this._scrubberPlayer.pause();
549 this._originalMousePosition = new WebInspector.Geometry.Point(event.x, e vent.y); 547 this._originalMousePosition = new WebInspector.Geometry.Point(event.x, e vent.y);
550 548
551 var target = WebInspector.targetManager.mainTarget(); 549 this._setPlaybackRate(0);
552 if (target)
553 target.animationModel.setPlaybackRate(0);
554 return true; 550 return true;
555 }, 551 },
556 552
557 /** 553 /**
558 * @param {!Event} event 554 * @param {!Event} event
559 */ 555 */
560 _scrubberDragMove: function(event) 556 _scrubberDragMove: function(event)
561 { 557 {
562 var delta = event.x - this._originalMousePosition.x; 558 var delta = event.x - this._originalMousePosition.x;
563 this._scrubberPlayer.currentTime = Math.min(this._originalScrubberTime + delta / this.pixelMsRatio(), this.duration() - this._scrubberRadius / this.pixe lMsRatio()); 559 this._scrubberPlayer.currentTime = Math.min(this._originalScrubberTime + delta / this.pixelMsRatio(), this.duration() - this._scrubberRadius / this.pixe lMsRatio());
564 var currentTime = Math.max(0, Math.round(this._scrubberPlayer.currentTim e)); 560 var currentTime = Math.max(0, Math.round(this._scrubberPlayer.currentTim e));
565 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(currentTime)); 561 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(currentTime));
566 var targets = WebInspector.targetManager.targets(); 562 var targets = WebInspector.targetManager.targets();
567 for (var target of targets) 563 for (var target of targets)
568 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime() + currentTime)); 564 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime() + currentTime));
569 }, 565 },
570 566
571 /** 567 /**
572 * @param {!Event} event 568 * @param {!Event} event
573 */ 569 */
574 _scrubberDragEnd: function(event) 570 _scrubberDragEnd: function(event)
575 { 571 {
576 if (this._scrubberPlayer.currentTime < this.duration() - this._scrubberR adius / this.pixelMsRatio()) 572 if (this._scrubberPlayer.currentTime < this.duration() - this._scrubberR adius / this.pixelMsRatio())
577 this._scrubberPlayer.play(); 573 this._scrubberPlayer.play();
578 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this)); 574 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this));
575 this._setPlaybackRate(this._playbackRate());
576 },
577
578 /**
579 * @param {number} playbackRate
580 */
581 _setPlaybackRate: function(playbackRate)
582 {
579 var target = WebInspector.targetManager.mainTarget(); 583 var target = WebInspector.targetManager.mainTarget();
580 if (target) 584 if (target)
581 target.animationModel.setPlaybackRate(this._playbackRate()); 585 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(playb ackRate);
582 }, 586 },
583 587
584 __proto__: WebInspector.VBox.prototype 588 __proto__: WebInspector.VBox.prototype
585 } 589 }
586 590
587 /** 591 /**
588 * @constructor 592 * @constructor
589 * @param {!WebInspector.AnimationModel.AnimationNode} animationNode 593 * @param {!WebInspector.AnimationModel.AnimationNode} animationNode
590 */ 594 */
591 WebInspector.AnimationTimeline.NodeUI = function(animationNode) { 595 WebInspector.AnimationTimeline.NodeUI = function(animationNode) {
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 "Light Blue": WebInspector.Color.parse("#03A9F4"), 1143 "Light Blue": WebInspector.Color.parse("#03A9F4"),
1140 "Deep Orange": WebInspector.Color.parse("#FF5722"), 1144 "Deep Orange": WebInspector.Color.parse("#FF5722"),
1141 "Blue": WebInspector.Color.parse("#5677FC"), 1145 "Blue": WebInspector.Color.parse("#5677FC"),
1142 "Lime": WebInspector.Color.parse("#CDDC39"), 1146 "Lime": WebInspector.Color.parse("#CDDC39"),
1143 "Blue Grey": WebInspector.Color.parse("#607D8B"), 1147 "Blue Grey": WebInspector.Color.parse("#607D8B"),
1144 "Pink": WebInspector.Color.parse("#E91E63"), 1148 "Pink": WebInspector.Color.parse("#E91E63"),
1145 "Green": WebInspector.Color.parse("#0F9D58"), 1149 "Green": WebInspector.Color.parse("#0F9D58"),
1146 "Brown": WebInspector.Color.parse("#795548"), 1150 "Brown": WebInspector.Color.parse("#795548"),
1147 "Cyan": WebInspector.Color.parse("#00BCD4") 1151 "Cyan": WebInspector.Color.parse("#00BCD4")
1148 } 1152 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/animation/AnimationModel.js ('k') | Source/devtools/front_end/animation/animationTimeline.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698