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

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

Issue 1417173002: Devtools Animations: Pause button based on groups not global (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
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()
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 this._playbackLabel.textContent = this._underlyingPlaybackRate + "x"; 183 this._playbackLabel.textContent = this._underlyingPlaybackRate + "x";
184 var playbackSliderValue = 0; 184 var playbackSliderValue = 0;
185 for (var rate of WebInspector.AnimationTimeline.GlobalPlaybackRates) { 185 for (var rate of WebInspector.AnimationTimeline.GlobalPlaybackRates) {
186 if (this._underlyingPlaybackRate > rate) 186 if (this._underlyingPlaybackRate > rate)
187 playbackSliderValue++; 187 playbackSliderValue++;
188 } 188 }
189 this._playbackSlider.value = playbackSliderValue; 189 this._playbackSlider.value = playbackSliderValue;
190 190
191 var target = WebInspector.targetManager.mainTarget(); 191 var target = WebInspector.targetManager.mainTarget();
192 if (target) 192 if (target)
193 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(this. _playbackRate()); 193 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(this. _underlyingPlaybackRate);
194 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Ani mationsPlaybackRateChanged); 194 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Ani mationsPlaybackRateChanged);
195 if (this._scrubberPlayer) 195 if (this._scrubberPlayer)
196 this._scrubberPlayer.playbackRate = this._playbackRate(); 196 this._scrubberPlayer.playbackRate = this._effectivePlaybackRate();
197 }, 197 },
198 198
199 _controlButtonToggle: function() 199 _controlButtonToggle: function()
200 { 200 {
201 if (this._emptyTimelineMessage) 201 if (this._emptyTimelineMessage)
202 return; 202 return;
203 if (this._controlButton.element.classList.contains("play-outline-toolbar -item")) 203 if (this._controlButton.element.classList.contains("play-outline-toolbar -item"))
204 this._togglePause(false); 204 this._togglePause(false);
205 else if (this._controlButton.element.classList.contains("replay-outline- toolbar-item")) 205 else if (this._controlButton.element.classList.contains("replay-outline- toolbar-item"))
206 this._replay(); 206 this._replay();
207 else 207 else
208 this._togglePause(true); 208 this._togglePause(true);
209 this._updateControlButton(); 209 this._updateControlButton();
210 }, 210 },
211 211
212 _updateControlButton: function() 212 _updateControlButton: function()
213 { 213 {
214 this._controlButton.setEnabled(!!this._selectedGroup);
214 this._controlButton.element.classList.remove("play-outline-toolbar-item" ); 215 this._controlButton.element.classList.remove("play-outline-toolbar-item" );
215 this._controlButton.element.classList.remove("replay-outline-toolbar-ite m"); 216 this._controlButton.element.classList.remove("replay-outline-toolbar-ite m");
216 this._controlButton.element.classList.remove("pause-outline-toolbar-item "); 217 this._controlButton.element.classList.remove("pause-outline-toolbar-item ");
217 if (this._paused) { 218 if (this._selectedGroup && this._selectedGroup.paused()) {
218 this._controlButton.element.classList.add("play-outline-toolbar-item "); 219 this._controlButton.element.classList.add("play-outline-toolbar-item ");
219 this._controlButton.setTitle(WebInspector.UIString("Play timeline")) ; 220 this._controlButton.setTitle(WebInspector.UIString("Play timeline")) ;
220 this._controlButton.setToggled(true); 221 this._controlButton.setToggled(true);
221 } else if (!this._scrubberPlayer || this._scrubberPlayer.currentTime >= this.duration() - this._scrubberRadius / this.pixelMsRatio()) { 222 } else if (!this._scrubberPlayer || this._scrubberPlayer.currentTime >= this.duration() - this._scrubberRadius / this.pixelMsRatio()) {
222 this._controlButton.element.classList.add("replay-outline-toolbar-it em"); 223 this._controlButton.element.classList.add("replay-outline-toolbar-it em");
223 this._controlButton.setTitle(WebInspector.UIString("Replay timeline" )); 224 this._controlButton.setTitle(WebInspector.UIString("Replay timeline" ));
224 this._controlButton.setToggled(true); 225 this._controlButton.setToggled(true);
225 } else { 226 } else {
226 this._controlButton.element.classList.add("pause-outline-toolbar-ite m"); 227 this._controlButton.element.classList.add("pause-outline-toolbar-ite m");
227 this._controlButton.setTitle(WebInspector.UIString("Pause timeline") ); 228 this._controlButton.setTitle(WebInspector.UIString("Pause timeline") );
228 this._controlButton.setToggled(false); 229 this._controlButton.setToggled(false);
229 } 230 }
230 }, 231 },
231 232
232 _updateAnimationsPlaybackRate: function() 233 _updateAnimationsPlaybackRate: function()
233 { 234 {
234 /** 235 /**
235 * @param {number} playbackRate 236 * @param {number} playbackRate
236 * @this {WebInspector.AnimationTimeline} 237 * @this {WebInspector.AnimationTimeline}
237 */ 238 */
238 function syncPlaybackRate(playbackRate) 239 function syncPlaybackRate(playbackRate)
239 { 240 {
240 this._underlyingPlaybackRate = playbackRate; 241 this._underlyingPlaybackRate = playbackRate;
241 this._updatePlaybackControls(); 242 this._updatePlaybackControls();
242 } 243 }
243 244
244 delete this._paused;
245 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Type.Page)) 245 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Type.Page))
246 WebInspector.AnimationModel.fromTarget(target).playbackRatePromise() .then(syncPlaybackRate.bind(this)); 246 WebInspector.AnimationModel.fromTarget(target).playbackRatePromise() .then(syncPlaybackRate.bind(this));
247 }, 247 },
248 248
249 /** 249 /**
250 * @return {number} 250 * @return {number}
251 */ 251 */
252 _playbackRate: function() 252 _effectivePlaybackRate: function()
253 { 253 {
254 return this._paused ? 0 : this._underlyingPlaybackRate; 254 return this._selectedGroup && this._selectedGroup.paused() ? 0 : this._u nderlyingPlaybackRate;
255 }, 255 },
256 256
257 /** 257 /**
258 * @param {boolean} pause 258 * @param {boolean} pause
259 */ 259 */
260 _togglePause: function(pause) 260 _togglePause: function(pause)
261 { 261 {
262 this._paused = pause; 262 this._selectedGroup.togglePause(pause);
263 for (var target of WebInspector.targetManager.targets(WebInspector.Targe t.Type.Page))
264 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(this. _playbackRate());
265 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Ani mationsPlaybackRateChanged);
266 if (this._scrubberPlayer) 263 if (this._scrubberPlayer)
267 this._scrubberPlayer.playbackRate = this._playbackRate(); 264 this._scrubberPlayer.playbackRate = this._effectivePlaybackRate();
268 }, 265 },
269 266
270 _replay: function() 267 _replay: function()
271 { 268 {
272 if (!this._selectedGroup) 269 if (!this._selectedGroup)
273 return; 270 return;
274 this._selectedGroup.seekTo(0); 271 this._selectedGroup.seekTo(0);
275 this._animateTime(0); 272 this._animateTime(0);
276 }, 273 },
277 274
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 _animateTime: function(currentTime) 560 _animateTime: function(currentTime)
564 { 561 {
565 if (this._scrubberPlayer) 562 if (this._scrubberPlayer)
566 this._scrubberPlayer.cancel(); 563 this._scrubberPlayer.cancel();
567 564
568 var scrubberDuration = this.duration() - this._scrubberRadius / this.pix elMsRatio(); 565 var scrubberDuration = this.duration() - this._scrubberRadius / this.pix elMsRatio();
569 this._scrubberPlayer = this._timelineScrubber.animate([ 566 this._scrubberPlayer = this._timelineScrubber.animate([
570 { transform: "translateX(0px)" }, 567 { transform: "translateX(0px)" },
571 { transform: "translateX(" + (this.width() - this._scrubberRadius) + "px)" } 568 { transform: "translateX(" + (this.width() - this._scrubberRadius) + "px)" }
572 ], { duration: scrubberDuration , fill: "forwards" }); 569 ], { duration: scrubberDuration , fill: "forwards" });
573 this._scrubberPlayer.playbackRate = this._playbackRate(); 570 this._scrubberPlayer.playbackRate = this._effectivePlaybackRate();
574 this._scrubberPlayer.onfinish = this._updateControlButton.bind(this); 571 this._scrubberPlayer.onfinish = this._updateControlButton.bind(this);
575 this._scrubberPlayer.currentTime = currentTime; 572 this._scrubberPlayer.currentTime = currentTime;
576 this._timelineScrubber.classList.remove("animation-timeline-end"); 573 this._timelineScrubber.classList.remove("animation-timeline-end");
577 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this)); 574 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this));
578 }, 575 },
579 576
580 /** 577 /**
581 * @return {number} 578 * @return {number}
582 */ 579 */
583 pixelMsRatio: function() 580 pixelMsRatio: function()
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 */ 748 */
752 WebInspector.AnimationTimeline.StepTimingFunction.parse = function(text) { 749 WebInspector.AnimationTimeline.StepTimingFunction.parse = function(text) {
753 var match = text.match(/^step-(start|middle|end)$/); 750 var match = text.match(/^step-(start|middle|end)$/);
754 if (match) 751 if (match)
755 return new WebInspector.AnimationTimeline.StepTimingFunction(1, match[1] ); 752 return new WebInspector.AnimationTimeline.StepTimingFunction(1, match[1] );
756 match = text.match(/^steps\((\d+), (start|middle|end)\)$/); 753 match = text.match(/^steps\((\d+), (start|middle|end)\)$/);
757 if (match) 754 if (match)
758 return new WebInspector.AnimationTimeline.StepTimingFunction(parseInt(ma tch[1], 10), match[2]); 755 return new WebInspector.AnimationTimeline.StepTimingFunction(parseInt(ma tch[1], 10), match[2]);
759 return null; 756 return null;
760 } 757 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698