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 /** | 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("elements/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"); |
24 | |
25 this._emptyTimelineMessage = this._animationsContainer.createChild("div", "a nimation-timeline-empty-message"); | |
26 var message = this._emptyTimelineMessage.createChild("div"); | |
27 message.textContent = WebInspector.UIString("Trigger animations on the page to view and tweak them on the animation timeline."); | |
28 | |
24 this._duration = this._defaultDuration(); | 29 this._duration = this._defaultDuration(); |
25 this._scrubberRadius = 25; | 30 this._scrubberRadius = 30; |
26 this._timelineControlsWidth = 200; | 31 this._timelineControlsWidth = 230; |
27 /** @type {!Map.<!DOMAgent.BackendNodeId, !WebInspector.AnimationTimeline.No deUI>} */ | 32 /** @type {!Map.<!DOMAgent.BackendNodeId, !WebInspector.AnimationTimeline.No deUI>} */ |
28 this._nodesMap = new Map(); | 33 this._nodesMap = new Map(); |
29 this._symbol = Symbol("animationTimeline"); | 34 this._symbol = Symbol("animationTimeline"); |
30 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationPlayer>} */ | 35 /** @type {!Map.<string, !WebInspector.AnimationModel.AnimationPlayer>} */ |
31 this._animationsMap = new Map(); | 36 this._animationsMap = new Map(); |
32 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNav igated, this); | 37 WebInspector.targetManager.addModelListener(WebInspector.ResourceTreeModel, WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNav igated, this); |
33 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); | 38 WebInspector.targetManager.addModelListener(WebInspector.DOMModel, WebInspec tor.DOMModel.Events.NodeRemoved, this._nodeRemoved, this); |
34 | 39 |
35 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag e); | 40 WebInspector.targetManager.observeTargets(this, WebInspector.Target.Type.Pag e); |
36 } | 41 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 */ | 122 */ |
118 _createHeader: function() | 123 _createHeader: function() |
119 { | 124 { |
120 /** | 125 /** |
121 * @param {!Event} event | 126 * @param {!Event} event |
122 * @this {WebInspector.AnimationTimeline} | 127 * @this {WebInspector.AnimationTimeline} |
123 */ | 128 */ |
124 function playbackSliderInputHandler(event) | 129 function playbackSliderInputHandler(event) |
125 { | 130 { |
126 this._underlyingPlaybackRate = WebInspector.AnimationTimeline.Global PlaybackRates[event.target.value]; | 131 this._underlyingPlaybackRate = WebInspector.AnimationTimeline.Global PlaybackRates[event.target.value]; |
127 var target = WebInspector.targetManager.mainTarget(); | 132 this._updatePlaybackControls(); |
128 if (target) | |
129 target.animationModel.setPlaybackRate(this._playbackRate()); | |
130 this._playbackLabel.textContent = this._underlyingPlaybackRate + "✕" ; | |
131 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); | |
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); |
140 toolbar.element.classList.add("animation-controls-toolbar"); | 140 toolbar.element.classList.add("animation-controls-toolbar"); |
141 this._pauseButton = new WebInspector.ToolbarButton(WebInspector.UIString ("Pause timeline"), "pause-toolbar-item"); | 141 this._controlButton = new WebInspector.ToolbarButton(WebInspector.UIStri ng("Replay timeline"), "replay-outline-toolbar-item"); |
142 this._pauseButton.addEventListener("click", this._togglePause.bind(this) ); | 142 this._controlButton.addEventListener("click", this._controlButtonToggle. bind(this)); |
143 toolbar.appendToolbarItem(this._pauseButton); | 143 toolbar.appendToolbarItem(this._controlButton); |
144 var replayButton = new WebInspector.ToolbarButton(WebInspector.UIString( "Replay timeline"), "replay-toolbar-item"); | |
145 replayButton.addEventListener("click", this._replay.bind(this)); | |
146 toolbar.appendToolbarItem(replayButton); | |
147 | 144 |
148 this._playbackLabel = controls.createChild("div", "animation-playback-la bel"); | 145 this._playbackLabel = controls.createChild("span", "animation-playback-l abel"); |
149 this._playbackLabel.createTextChild("1x"); | 146 this._playbackLabel.createTextChild("1x"); |
147 this._playbackLabel.addEventListener("keydown", this._playbackLabelInput .bind(this)); | |
150 | 148 |
151 this._playbackSlider = controls.createChild("input", "animation-playback -slider"); | 149 this._playbackSlider = controls.createChild("input", "animation-playback -slider"); |
152 this._playbackSlider.type = "range"; | 150 this._playbackSlider.type = "range"; |
153 this._playbackSlider.min = 0; | 151 this._playbackSlider.min = 0; |
154 this._playbackSlider.max = WebInspector.AnimationTimeline.GlobalPlayback Rates.length - 1; | 152 this._playbackSlider.max = WebInspector.AnimationTimeline.GlobalPlayback Rates.length - 1; |
155 this._playbackSlider.value = this._playbackSlider.max; | 153 this._playbackSlider.value = this._playbackSlider.max; |
156 this._playbackSlider.addEventListener("input", playbackSliderInputHandle r.bind(this)); | 154 this._playbackSlider.addEventListener("input", playbackSliderInputHandle r.bind(this)); |
157 this._updateAnimationsPlaybackRate(); | 155 this._updateAnimationsPlaybackRate(); |
158 | 156 |
159 return container; | 157 return container; |
160 }, | 158 }, |
161 | 159 |
160 /** | |
161 * @param {!Event} event | |
162 */ | |
163 _playbackLabelInput: function(event) | |
pfeldman
2015/06/05 14:34:34
I applied your change and I can now enter random t
samli
2015/06/09 03:53:08
I did test it thoroughly. This is intended. I can'
| |
164 { | |
165 if (!isEnterKey(event)) | |
166 return; | |
167 | |
168 this._underlyingPlaybackRate = parseFloat(this._playbackLabel.textConten t); | |
169 if (isNaN(this._underlyingPlaybackRate)) | |
170 this._underlyingPlaybackRate = 1; | |
171 this._updatePlaybackControls(); | |
172 event.consume(true); | |
173 }, | |
174 | |
175 _updatePlaybackControls: function() | |
176 { | |
177 this._playbackLabel.textContent = this._underlyingPlaybackRate + "x"; | |
178 var playbackSliderValue = 0; | |
179 for (var rate of WebInspector.AnimationTimeline.GlobalPlaybackRates) { | |
180 if (this._underlyingPlaybackRate > rate) | |
181 playbackSliderValue++; | |
182 } | |
183 this._playbackSlider.value = playbackSliderValue; | |
184 | |
185 var target = WebInspector.targetManager.mainTarget(); | |
186 if (target) | |
187 target.animationModel.setPlaybackRate(this._playbackRate()); | |
188 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); | |
189 this._updateTimelineAnimations(); | |
190 }, | |
191 | |
192 _controlButtonToggle: function() | |
193 { | |
194 if (this._emptyTimelineMessage) | |
195 return; | |
196 if (this._controlButton.element.classList.contains("play-outline-toolbar -item")) | |
197 this._togglePause(false); | |
198 else if (this._controlButton.element.classList.contains("replay-outline- toolbar-item")) | |
199 this._replay(); | |
200 else | |
201 this._togglePause(true); | |
202 this._updateControlButton(); | |
203 }, | |
204 | |
205 _updateControlButton: function() | |
206 { | |
207 this._controlButton.element.classList.remove("play-outline-toolbar-item" ); | |
208 this._controlButton.element.classList.remove("replay-outline-toolbar-ite m"); | |
209 this._controlButton.element.classList.remove("pause-outline-toolbar-item "); | |
210 if (this._paused) { | |
211 this._controlButton.element.classList.add("play-outline-toolbar-item "); | |
212 this._controlButton.setTitle("Play timeline"); | |
pfeldman
2015/06/05 14:34:34
UIString please.
samli
2015/06/09 03:53:08
Done.
| |
213 } else if (!this._scrubberPlayer || this._scrubberPlayer.currentTime >= this._scrubberPlayer.source.timing.duration) { | |
214 this._controlButton.element.classList.add("replay-outline-toolbar-it em"); | |
215 this._controlButton.setTitle("Replay timeline"); | |
216 } else { | |
217 this._controlButton.element.classList.add("pause-outline-toolbar-ite m"); | |
218 this._controlButton.setTitle("Pause timeline"); | |
219 } | |
220 }, | |
221 | |
162 _updateAnimationsPlaybackRate: function() | 222 _updateAnimationsPlaybackRate: function() |
163 { | 223 { |
164 /** | 224 /** |
165 * @param {?Protocol.Error} error | 225 * @param {?Protocol.Error} error |
166 * @param {number} playbackRate | 226 * @param {number} playbackRate |
167 * @this {WebInspector.AnimationTimeline} | 227 * @this {WebInspector.AnimationTimeline} |
168 */ | 228 */ |
169 function setPlaybackRate(error, playbackRate) | 229 function setPlaybackRate(error, playbackRate) |
170 { | 230 { |
171 if (playbackRate === 0) { | 231 if (playbackRate === 0) { |
172 playbackRate = 1; | 232 playbackRate = 1; |
173 target.animationAgent().setPlaybackRate(1); | 233 target.animationAgent().setPlaybackRate(1); |
174 } | 234 } |
175 this._underlyingPlaybackRate = playbackRate; | 235 this._underlyingPlaybackRate = playbackRate; |
176 this._playbackSlider.value = WebInspector.AnimationTimeline.GlobalPl aybackRates.indexOf(playbackRate); | 236 this._updatePlaybackControls(); |
177 this._playbackLabel.textContent = playbackRate + "✕"; | |
178 } | 237 } |
179 | 238 |
239 delete this._paused; | |
180 var target = WebInspector.targetManager.mainTarget(); | 240 var target = WebInspector.targetManager.mainTarget(); |
181 if (target) | 241 if (target) |
182 target.animationAgent().getPlaybackRate(setPlaybackRate.bind(this)); | 242 target.animationAgent().getPlaybackRate(setPlaybackRate.bind(this)); |
183 }, | 243 }, |
184 | 244 |
185 /** | 245 /** |
186 * @return {number} | 246 * @return {number} |
187 */ | 247 */ |
188 _playbackRate: function() | 248 _playbackRate: function() |
189 { | 249 { |
190 return this._paused ? 0 : this._underlyingPlaybackRate; | 250 return this._paused ? 0 : this._underlyingPlaybackRate; |
191 }, | 251 }, |
192 | 252 |
193 _updateTimelineAnimations: function() | 253 _updateTimelineAnimations: function() |
194 { | 254 { |
195 if (this._scrubberPlayer) | 255 if (this._scrubberPlayer) |
196 this._scrubberPlayer.playbackRate = this._playbackRate(); | 256 this._scrubberPlayer.playbackRate = this._playbackRate(); |
197 if (this._timerSpinnerPlayer) { | 257 if (this._timerSpinnerPlayer) { |
198 this._timerSpinnerPlayer.playbackRate = this._playbackRate(); | 258 this._timerSpinnerPlayer.playbackRate = this._playbackRate(); |
199 this._timerFillerPlayer.playbackRate = this._playbackRate(); | 259 this._timerFillerPlayer.playbackRate = this._playbackRate(); |
200 this._timerMaskPlayer.playbackRate = this._playbackRate(); | 260 this._timerMaskPlayer.playbackRate = this._playbackRate(); |
201 } | 261 } |
202 }, | 262 }, |
203 | 263 |
204 _togglePause: function() | 264 /** |
265 * @param {boolean} pause | |
266 */ | |
267 _togglePause: function(pause) | |
205 { | 268 { |
206 this._paused = !this._paused; | 269 this._paused = pause; |
207 var target = WebInspector.targetManager.mainTarget(); | 270 var target = WebInspector.targetManager.mainTarget(); |
208 if (target) | 271 if (target) |
209 target.animationModel.setPlaybackRate(this._playbackRate()); | 272 target.animationModel.setPlaybackRate(this._playbackRate()); |
210 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); | 273 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); |
211 this._pauseButton.element.classList.toggle("pause-toolbar-item"); | |
212 this._pauseButton.element.classList.toggle("play-toolbar-item"); | |
213 this._updateTimelineAnimations(); | 274 this._updateTimelineAnimations(); |
214 }, | 275 }, |
215 | 276 |
216 _replay: function() | 277 _replay: function() |
217 { | 278 { |
218 if (this.startTime() === undefined) | 279 if (this.startTime() === undefined) |
219 return; | 280 return; |
220 var targets = WebInspector.targetManager.targets(); | 281 var targets = WebInspector.targetManager.targets(); |
221 for (var target of targets) | 282 for (var target of targets) |
222 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime())); | 283 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime())); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 * @param {!WebInspector.Event} event | 333 * @param {!WebInspector.Event} event |
273 */ | 334 */ |
274 _mainFrameNavigated: function(event) | 335 _mainFrameNavigated: function(event) |
275 { | 336 { |
276 this._reset(); | 337 this._reset(); |
277 this._updateAnimationsPlaybackRate(); | 338 this._updateAnimationsPlaybackRate(); |
278 if (this._scrubberPlayer) | 339 if (this._scrubberPlayer) |
279 this._scrubberPlayer.cancel(); | 340 this._scrubberPlayer.cancel(); |
280 delete this._scrubberPlayer; | 341 delete this._scrubberPlayer; |
281 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(0)); | 342 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi llisToString(0)); |
343 this._updateControlButton(); | |
282 }, | 344 }, |
283 | 345 |
284 /** | 346 /** |
285 * @param {!WebInspector.Event} event | 347 * @param {!WebInspector.Event} event |
286 */ | 348 */ |
287 _animationCreated: function(event) | 349 _animationCreated: function(event) |
288 { | 350 { |
289 this._addAnimation(/** @type {!WebInspector.AnimationModel.AnimationPlay er} */ (event.data.player), event.data.resetTimeline) | 351 this._addAnimation(/** @type {!WebInspector.AnimationModel.AnimationPlay er} */ (event.data.player), event.data.resetTimeline) |
290 }, | 352 }, |
291 | 353 |
292 /** | 354 /** |
293 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation | 355 * @param {!WebInspector.AnimationModel.AnimationPlayer} animation |
294 * @param {boolean} resetTimeline | 356 * @param {boolean} resetTimeline |
295 */ | 357 */ |
296 _addAnimation: function(animation, resetTimeline) | 358 _addAnimation: function(animation, resetTimeline) |
297 { | 359 { |
298 /** | 360 /** |
299 * @param {?WebInspector.DOMNode} node | 361 * @param {?WebInspector.DOMNode} node |
300 * @this {WebInspector.AnimationTimeline} | 362 * @this {WebInspector.AnimationTimeline} |
301 */ | 363 */ |
302 function nodeResolved(node) | 364 function nodeResolved(node) |
303 { | 365 { |
366 if (!node) | |
367 return; | |
304 uiAnimation.setNode(node); | 368 uiAnimation.setNode(node); |
305 node[this._symbol] = nodeUI; | 369 node[this._symbol] = nodeUI; |
306 } | 370 } |
307 | 371 |
372 if (this._emptyTimelineMessage) { | |
373 this._emptyTimelineMessage.remove(); | |
374 delete this._emptyTimelineMessage; | |
375 } | |
376 | |
308 if (resetTimeline) | 377 if (resetTimeline) |
309 this._reset(); | 378 this._reset(); |
310 | 379 |
311 // Ignore Web Animations custom effects & groups | 380 // Ignore Web Animations custom effects & groups |
312 if (animation.type() === "WebAnimation" && animation.source().keyframesR ule().keyframes().length === 0) | 381 if (animation.type() === "WebAnimation" && animation.source().keyframesR ule().keyframes().length === 0) |
313 return; | 382 return; |
314 | 383 |
315 if (this._resizeWindow(animation)) | 384 if (this._resizeWindow(animation)) |
316 this.scheduleRedraw(); | 385 this.scheduleRedraw(); |
317 else | 386 else |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 var lastDraw = undefined; | 439 var lastDraw = undefined; |
371 for (var time = 0; time < this.duration(); time += gridSize) { | 440 for (var time = 0; time < this.duration(); time += gridSize) { |
372 var line = this._grid.createSVGChild("rect", "animation-timeline-gri d-line"); | 441 var line = this._grid.createSVGChild("rect", "animation-timeline-gri d-line"); |
373 line.setAttribute("x", time * this.pixelMsRatio()); | 442 line.setAttribute("x", time * this.pixelMsRatio()); |
374 line.setAttribute("y", 0); | 443 line.setAttribute("y", 0); |
375 line.setAttribute("height", "100%"); | 444 line.setAttribute("height", "100%"); |
376 line.setAttribute("width", 1); | 445 line.setAttribute("width", 1); |
377 } | 446 } |
378 for (var time = 0; time < this.duration(); time += gridSize) { | 447 for (var time = 0; time < this.duration(); time += gridSize) { |
379 var gridWidth = time * this.pixelMsRatio(); | 448 var gridWidth = time * this.pixelMsRatio(); |
380 if (time && (!lastDraw || gridWidth - lastDraw > 50)) { | 449 if (!lastDraw || gridWidth - lastDraw > 50) { |
381 lastDraw = gridWidth; | 450 lastDraw = gridWidth; |
382 var label = this._grid.createSVGChild("text", "animation-timelin e-grid-label"); | 451 var label = this._grid.createSVGChild("text", "animation-timelin e-grid-label"); |
383 label.setAttribute("x", gridWidth + 5); | 452 label.setAttribute("x", gridWidth + 5); |
384 label.setAttribute("y", 35); | 453 label.setAttribute("y", 35); |
385 label.textContent = WebInspector.UIString(Number.millisToString( time)); | 454 label.textContent = WebInspector.UIString(Number.millisToString( time)); |
386 } | 455 } |
387 } | 456 } |
388 }, | 457 }, |
389 | 458 |
390 scheduleRedraw: function() { | 459 scheduleRedraw: function() { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
465 this._timerMaskPlayer.currentTime = 0; | 534 this._timerMaskPlayer.currentTime = 0; |
466 }, | 535 }, |
467 | 536 |
468 /** | 537 /** |
469 * @param {!Object} timerPlayer | 538 * @param {!Object} timerPlayer |
470 */ | 539 */ |
471 _timerFinished: function(timerPlayer) | 540 _timerFinished: function(timerPlayer) |
472 { | 541 { |
473 if (this._timerSpinnerPlayer !== timerPlayer) | 542 if (this._timerSpinnerPlayer !== timerPlayer) |
474 return; | 543 return; |
475 this._timelineScrubber.classList.add("animation-timeline-end"); | 544 this._timelineScrubber.classList.remove("animation-timeline-capturing"); |
476 delete this._timerSpinnerPlayer; | 545 delete this._timerSpinnerPlayer; |
477 delete this._timerFillerPlayer; | 546 delete this._timerFillerPlayer; |
478 delete this._timerMaskPlayer; | 547 delete this._timerMaskPlayer; |
479 }, | 548 }, |
480 | 549 |
481 /** | 550 /** |
482 * @param {number=} time | 551 * @param {number=} time |
483 * @param {boolean=} timelineCapturing | 552 * @param {boolean=} timelineCapturing |
484 */ | 553 */ |
485 _animateTime: function(time, timelineCapturing) | 554 _animateTime: function(time, timelineCapturing) |
486 { | 555 { |
487 var oldPlayer = this._scrubberPlayer; | 556 var oldPlayer = this._scrubberPlayer; |
488 this._timelineScrubber.classList.toggle("animation-timeline-capturing", timelineCapturing); | 557 this._timelineScrubber.classList.toggle("animation-timeline-capturing", timelineCapturing); |
489 if (timelineCapturing) | 558 if (timelineCapturing) |
490 this._startTimerAnimation(); | 559 this._startTimerAnimation(); |
491 | 560 |
492 this._scrubberPlayer = this._timelineScrubber.animate([ | 561 this._scrubberPlayer = this._timelineScrubber.animate([ |
493 { transform: "translateX(0px)" }, | 562 { transform: "translateX(0px)" }, |
494 { transform: "translateX(" + (this.width() - this._scrubberRadius) + "px)" } | 563 { transform: "translateX(" + (this.width() - this._scrubberRadius) + "px)" } |
495 ], { duration: this.duration() - this._scrubberRadius / this.pixelMsRati o(), fill: "forwards" }); | 564 ], { duration: this.duration() - this._scrubberRadius / this.pixelMsRati o(), fill: "forwards" }); |
496 this._scrubberPlayer.playbackRate = this._playbackRate(); | 565 this._scrubberPlayer.playbackRate = this._playbackRate(); |
566 this._scrubberPlayer.onfinish = this._updateControlButton.bind(this); | |
567 this._updateControlButton(); | |
497 | 568 |
498 if (time !== undefined) | 569 if (time !== undefined) |
499 this._scrubberPlayer.currentTime = time; | 570 this._scrubberPlayer.currentTime = time; |
500 else if (oldPlayer.playState === "finished") | 571 else if (oldPlayer.playState === "finished") |
501 this._scrubberPlayer.finish(); | 572 this._scrubberPlayer.finish(); |
502 else | 573 else |
503 this._scrubberPlayer.startTime = oldPlayer.startTime; | 574 this._scrubberPlayer.startTime = oldPlayer.startTime; |
504 | 575 |
505 if (oldPlayer) | 576 if (oldPlayer) |
506 oldPlayer.cancel(); | 577 oldPlayer.cancel(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 var targets = WebInspector.targetManager.targets(); | 637 var targets = WebInspector.targetManager.targets(); |
567 for (var target of targets) | 638 for (var target of targets) |
568 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime() + currentTime)); | 639 target.animationAgent().setCurrentTime(/** @type {number} */(this.st artTime() + currentTime)); |
569 }, | 640 }, |
570 | 641 |
571 /** | 642 /** |
572 * @param {!Event} event | 643 * @param {!Event} event |
573 */ | 644 */ |
574 _scrubberDragEnd: function(event) | 645 _scrubberDragEnd: function(event) |
575 { | 646 { |
576 if (this._scrubberPlayer.currentTime < this.duration() - this._scrubberR adius / this.pixelMsRatio()) | 647 var currentTime = Math.max(0, this._scrubberPlayer.currentTime); |
577 this._scrubberPlayer.play(); | 648 this._scrubberPlayer.play(); |
649 this._scrubberPlayer.currentTime = currentTime; | |
578 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this)); | 650 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc rubber.bind(this)); |
579 var target = WebInspector.targetManager.mainTarget(); | 651 var target = WebInspector.targetManager.mainTarget(); |
580 if (target) | 652 if (target) |
581 target.animationModel.setPlaybackRate(this._playbackRate()); | 653 target.animationModel.setPlaybackRate(this._playbackRate()); |
654 this._updateControlButton(); | |
582 }, | 655 }, |
583 | 656 |
584 __proto__: WebInspector.VBox.prototype | 657 __proto__: WebInspector.VBox.prototype |
585 } | 658 } |
586 | 659 |
587 /** | 660 /** |
588 * @constructor | 661 * @constructor |
589 * @param {!WebInspector.AnimationModel.AnimationNode} animationNode | 662 * @param {!WebInspector.AnimationModel.AnimationNode} animationNode |
590 */ | 663 */ |
591 WebInspector.AnimationTimeline.NodeUI = function(animationNode) { | 664 WebInspector.AnimationTimeline.NodeUI = function(animationNode) { |
592 /** | 665 /** |
593 * @param {?WebInspector.DOMNode} node | 666 * @param {?WebInspector.DOMNode} node |
594 * @this {WebInspector.AnimationTimeline.NodeUI} | 667 * @this {WebInspector.AnimationTimeline.NodeUI} |
595 */ | 668 */ |
596 function nodeResolved(node) | 669 function nodeResolved(node) |
597 { | 670 { |
671 if (!node) | |
672 return; | |
598 this._node = node; | 673 this._node = node; |
599 this._description.appendChild(WebInspector.DOMPresentationUtils.linkifyN odeReference(node)); | 674 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, this._descript ion); |
600 this.element.addEventListener("click", WebInspector.Revealer.reveal.bind (WebInspector.Revealer, node, undefined), false); | 675 this.element.addEventListener("click", WebInspector.Revealer.reveal.bind (WebInspector.Revealer, node, undefined), false); |
601 } | 676 } |
602 | 677 |
603 this._rows = []; | 678 this._rows = []; |
604 this.element = createElementWithClass("div", "animation-node-row"); | 679 this.element = createElementWithClass("div", "animation-node-row"); |
605 this._description = this.element.createChild("div", "animation-node-descript ion"); | 680 this._description = this.element.createChild("div", "animation-node-descript ion"); |
606 animationNode.deferredNode().resolve(nodeResolved.bind(this)); | 681 animationNode.deferredNode().resolve(nodeResolved.bind(this)); |
607 this._timelineElement = this.element.createChild("div", "animation-node-time line"); | 682 this._timelineElement = this.element.createChild("div", "animation-node-time line"); |
608 } | 683 } |
609 | 684 |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1139 "Light Blue": WebInspector.Color.parse("#03A9F4"), | 1214 "Light Blue": WebInspector.Color.parse("#03A9F4"), |
1140 "Deep Orange": WebInspector.Color.parse("#FF5722"), | 1215 "Deep Orange": WebInspector.Color.parse("#FF5722"), |
1141 "Blue": WebInspector.Color.parse("#5677FC"), | 1216 "Blue": WebInspector.Color.parse("#5677FC"), |
1142 "Lime": WebInspector.Color.parse("#CDDC39"), | 1217 "Lime": WebInspector.Color.parse("#CDDC39"), |
1143 "Blue Grey": WebInspector.Color.parse("#607D8B"), | 1218 "Blue Grey": WebInspector.Color.parse("#607D8B"), |
1144 "Pink": WebInspector.Color.parse("#E91E63"), | 1219 "Pink": WebInspector.Color.parse("#E91E63"), |
1145 "Green": WebInspector.Color.parse("#0F9D58"), | 1220 "Green": WebInspector.Color.parse("#0F9D58"), |
1146 "Brown": WebInspector.Color.parse("#795548"), | 1221 "Brown": WebInspector.Color.parse("#795548"), |
1147 "Cyan": WebInspector.Color.parse("#00BCD4") | 1222 "Cyan": WebInspector.Color.parse("#00BCD4") |
1148 } | 1223 } |
OLD | NEW |