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("animation/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"); |
| 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.Animation>} */ | 35 /** @type {!Map.<string, !WebInspector.AnimationModel.Animation>} */ |
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 */ | 124 */ |
120 _createHeader: function() | 125 _createHeader: function() |
121 { | 126 { |
122 /** | 127 /** |
123 * @param {!Event} event | 128 * @param {!Event} event |
124 * @this {WebInspector.AnimationTimeline} | 129 * @this {WebInspector.AnimationTimeline} |
125 */ | 130 */ |
126 function playbackSliderInputHandler(event) | 131 function playbackSliderInputHandler(event) |
127 { | 132 { |
128 this._underlyingPlaybackRate = WebInspector.AnimationTimeline.Global
PlaybackRates[event.target.value]; | 133 this._underlyingPlaybackRate = WebInspector.AnimationTimeline.Global
PlaybackRates[event.target.value]; |
129 this._setPlaybackRate(this._playbackRate()); | 134 this._updatePlaybackControls(); |
130 this._playbackLabel.textContent = this._underlyingPlaybackRate + "✕"
; | |
131 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); | |
132 if (this._scrubberPlayer) | |
133 this._scrubberPlayer.playbackRate = this._playbackRate(); | |
134 } | 135 } |
135 | 136 |
136 var container = createElementWithClass("div", "animation-timeline-header
"); | 137 var container = createElementWithClass("div", "animation-timeline-header
"); |
137 var controls = container.createChild("div", "animation-controls"); | 138 var controls = container.createChild("div", "animation-controls"); |
138 container.createChild("div", "animation-timeline-markers"); | 139 container.createChild("div", "animation-timeline-markers"); |
139 | 140 |
140 var toolbar = new WebInspector.Toolbar(controls); | 141 var toolbar = new WebInspector.Toolbar(controls); |
141 toolbar.element.classList.add("animation-controls-toolbar"); | 142 toolbar.element.classList.add("animation-controls-toolbar"); |
142 this._pauseButton = new WebInspector.ToolbarButton(WebInspector.UIString
("Pause timeline"), "pause-toolbar-item"); | 143 this._controlButton = new WebInspector.ToolbarButton(WebInspector.UIStri
ng("Replay timeline"), "replay-outline-toolbar-item"); |
143 this._pauseButton.addEventListener("click", this._togglePause.bind(this)
); | 144 this._controlButton.addEventListener("click", this._controlButtonToggle.
bind(this)); |
144 toolbar.appendToolbarItem(this._pauseButton); | 145 toolbar.appendToolbarItem(this._controlButton); |
145 var replayButton = new WebInspector.ToolbarButton(WebInspector.UIString(
"Replay timeline"), "replay-toolbar-item"); | |
146 replayButton.addEventListener("click", this._replay.bind(this)); | |
147 toolbar.appendToolbarItem(replayButton); | |
148 | 146 |
149 this._playbackLabel = controls.createChild("div", "animation-playback-la
bel"); | 147 this._playbackLabel = controls.createChild("span", "animation-playback-l
abel"); |
150 this._playbackLabel.createTextChild("1x"); | 148 this._playbackLabel.createTextChild("1x"); |
151 | 149 |
152 this._playbackSlider = controls.createChild("input", "animation-playback
-slider"); | 150 this._playbackSlider = controls.createChild("input", "animation-playback
-slider"); |
153 this._playbackSlider.type = "range"; | 151 this._playbackSlider.type = "range"; |
154 this._playbackSlider.min = 0; | 152 this._playbackSlider.min = 0; |
155 this._playbackSlider.max = WebInspector.AnimationTimeline.GlobalPlayback
Rates.length - 1; | 153 this._playbackSlider.max = WebInspector.AnimationTimeline.GlobalPlayback
Rates.length - 1; |
156 this._playbackSlider.value = this._playbackSlider.max; | 154 this._playbackSlider.value = this._playbackSlider.max; |
157 this._playbackSlider.addEventListener("input", playbackSliderInputHandle
r.bind(this)); | 155 this._playbackSlider.addEventListener("input", playbackSliderInputHandle
r.bind(this)); |
158 this._updateAnimationsPlaybackRate(); | 156 this._updateAnimationsPlaybackRate(); |
159 | 157 |
160 return container; | 158 return container; |
161 }, | 159 }, |
162 | 160 |
| 161 _updatePlaybackControls: function() |
| 162 { |
| 163 this._playbackLabel.textContent = this._underlyingPlaybackRate + "x"; |
| 164 var playbackSliderValue = 0; |
| 165 for (var rate of WebInspector.AnimationTimeline.GlobalPlaybackRates) { |
| 166 if (this._underlyingPlaybackRate > rate) |
| 167 playbackSliderValue++; |
| 168 } |
| 169 this._playbackSlider.value = playbackSliderValue; |
| 170 |
| 171 for (var target of WebInspector.targetManager.targets(WebInspector.Targe
t.Type.Page)) |
| 172 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(this.
_playbackRate()); |
| 173 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); |
| 174 if (this._scrubberPlayer) |
| 175 this._scrubberPlayer.playbackRate = this._playbackRate(); |
| 176 }, |
| 177 |
| 178 _controlButtonToggle: function() |
| 179 { |
| 180 if (this._emptyTimelineMessage) |
| 181 return; |
| 182 if (this._controlButton.element.classList.contains("play-outline-toolbar
-item")) |
| 183 this._togglePause(false); |
| 184 else if (this._controlButton.element.classList.contains("replay-outline-
toolbar-item")) |
| 185 this._replay(); |
| 186 else |
| 187 this._togglePause(true); |
| 188 this._updateControlButton(); |
| 189 }, |
| 190 |
| 191 _updateControlButton: function() |
| 192 { |
| 193 this._controlButton.element.classList.remove("play-outline-toolbar-item"
); |
| 194 this._controlButton.element.classList.remove("replay-outline-toolbar-ite
m"); |
| 195 this._controlButton.element.classList.remove("pause-outline-toolbar-item
"); |
| 196 if (this._paused) { |
| 197 this._controlButton.element.classList.add("play-outline-toolbar-item
"); |
| 198 this._controlButton.setTitle(WebInspector.UIString("Play timeline"))
; |
| 199 } else if (!this._scrubberPlayer || this._scrubberPlayer.currentTime >=
this.duration() - this._scrubberRadius / this.pixelMsRatio()) { |
| 200 this._controlButton.element.classList.add("replay-outline-toolbar-it
em"); |
| 201 this._controlButton.setTitle(WebInspector.UIString("Replay timeline"
)); |
| 202 } else { |
| 203 this._controlButton.element.classList.add("pause-outline-toolbar-ite
m"); |
| 204 this._controlButton.setTitle(WebInspector.UIString("Pause timeline")
); |
| 205 } |
| 206 }, |
| 207 |
163 _updateAnimationsPlaybackRate: function() | 208 _updateAnimationsPlaybackRate: function() |
164 { | 209 { |
165 /** | 210 /** |
166 * @param {?Protocol.Error} error | 211 * @param {?Protocol.Error} error |
167 * @param {number} playbackRate | 212 * @param {number} playbackRate |
168 * @this {WebInspector.AnimationTimeline} | 213 * @this {WebInspector.AnimationTimeline} |
169 */ | 214 */ |
170 function setPlaybackRate(error, playbackRate) | 215 function setPlaybackRate(error, playbackRate) |
171 { | 216 { |
172 if (playbackRate === 0) { | 217 if (playbackRate === 0) { |
173 playbackRate = 1; | 218 playbackRate = 1; |
174 target.animationAgent().setPlaybackRate(1); | 219 if (target) |
| 220 WebInspector.AnimationModel.fromTarget(target).setPlaybackRa
te(1); |
175 } | 221 } |
176 this._underlyingPlaybackRate = playbackRate; | 222 this._underlyingPlaybackRate = playbackRate; |
177 this._playbackSlider.value = WebInspector.AnimationTimeline.GlobalPl
aybackRates.indexOf(playbackRate); | 223 this._updatePlaybackControls(); |
178 this._playbackLabel.textContent = playbackRate + "✕"; | |
179 } | 224 } |
180 | 225 |
181 var target = WebInspector.targetManager.mainTarget(); | 226 delete this._paused; |
182 if (target) | 227 for (var target of WebInspector.targetManager.targets(WebInspector.Targe
t.Type.Page)) |
183 target.animationAgent().getPlaybackRate(setPlaybackRate.bind(this)); | 228 target.animationAgent().getPlaybackRate(setPlaybackRate.bind(this)); |
184 }, | 229 }, |
185 | 230 |
186 /** | 231 /** |
187 * @return {number} | 232 * @return {number} |
188 */ | 233 */ |
189 _playbackRate: function() | 234 _playbackRate: function() |
190 { | 235 { |
191 return this._paused ? 0 : this._underlyingPlaybackRate; | 236 return this._paused ? 0 : this._underlyingPlaybackRate; |
192 }, | 237 }, |
193 | 238 |
194 _togglePause: function() | 239 /** |
| 240 * @param {boolean} pause |
| 241 */ |
| 242 _togglePause: function(pause) |
195 { | 243 { |
196 this._paused = !this._paused; | 244 this._paused = pause; |
197 this._setPlaybackRate(this._playbackRate()); | 245 for (var target of WebInspector.targetManager.targets(WebInspector.Targe
t.Type.Page)) |
| 246 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(this.
_playbackRate()); |
198 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); | 247 WebInspector.userMetrics.AnimationsPlaybackRateChanged.record(); |
199 this._pauseButton.element.classList.toggle("pause-toolbar-item"); | |
200 this._pauseButton.element.classList.toggle("play-toolbar-item"); | |
201 if (this._scrubberPlayer) | 248 if (this._scrubberPlayer) |
202 this._scrubberPlayer.playbackRate = this._playbackRate(); | 249 this._scrubberPlayer.playbackRate = this._playbackRate(); |
203 }, | 250 }, |
204 | 251 |
205 _replay: function() | 252 _replay: function() |
206 { | 253 { |
207 if (this.startTime() === undefined) | 254 if (this.startTime() === undefined) |
208 return; | 255 return; |
209 for (var target of WebInspector.targetManager.targets(WebInspector.Targe
t.Type.Page)) | 256 for (var target of WebInspector.targetManager.targets(WebInspector.Targe
t.Type.Page)) |
210 target.animationAgent().setCurrentTime(/** @type {number} */(this.st
artTime())); | 257 target.animationAgent().setCurrentTime(/** @type {number} */(this.st
artTime())); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 * @param {!WebInspector.Event} event | 308 * @param {!WebInspector.Event} event |
262 */ | 309 */ |
263 _mainFrameNavigated: function(event) | 310 _mainFrameNavigated: function(event) |
264 { | 311 { |
265 this._reset(); | 312 this._reset(); |
266 this._updateAnimationsPlaybackRate(); | 313 this._updateAnimationsPlaybackRate(); |
267 if (this._scrubberPlayer) | 314 if (this._scrubberPlayer) |
268 this._scrubberPlayer.cancel(); | 315 this._scrubberPlayer.cancel(); |
269 delete this._scrubberPlayer; | 316 delete this._scrubberPlayer; |
270 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi
llisToString(0)); | 317 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi
llisToString(0)); |
| 318 this._updateControlButton(); |
271 }, | 319 }, |
272 | 320 |
273 /** | 321 /** |
274 * @param {!WebInspector.Event} event | 322 * @param {!WebInspector.Event} event |
275 */ | 323 */ |
276 _animationCreated: function(event) | 324 _animationCreated: function(event) |
277 { | 325 { |
278 this._addAnimation(/** @type {!WebInspector.AnimationModel.Animation} */
(event.data.player), event.data.resetTimeline) | 326 this._addAnimation(/** @type {!WebInspector.AnimationModel.Animation} */
(event.data.player), event.data.resetTimeline) |
279 }, | 327 }, |
280 | 328 |
281 /** | 329 /** |
282 * @param {!WebInspector.AnimationModel.Animation} animation | 330 * @param {!WebInspector.AnimationModel.Animation} animation |
283 * @param {boolean} resetTimeline | 331 * @param {boolean} resetTimeline |
284 */ | 332 */ |
285 _addAnimation: function(animation, resetTimeline) | 333 _addAnimation: function(animation, resetTimeline) |
286 { | 334 { |
287 /** | 335 /** |
288 * @param {?WebInspector.DOMNode} node | 336 * @param {?WebInspector.DOMNode} node |
289 * @this {WebInspector.AnimationTimeline} | 337 * @this {WebInspector.AnimationTimeline} |
290 */ | 338 */ |
291 function nodeResolved(node) | 339 function nodeResolved(node) |
292 { | 340 { |
| 341 if (!node) |
| 342 return; |
293 uiAnimation.setNode(node); | 343 uiAnimation.setNode(node); |
294 node[this._symbol] = nodeUI; | 344 node[this._symbol] = nodeUI; |
295 } | 345 } |
296 | 346 |
| 347 if (this._emptyTimelineMessage) { |
| 348 this._emptyTimelineMessage.remove(); |
| 349 delete this._emptyTimelineMessage; |
| 350 } |
| 351 |
297 if (resetTimeline) | 352 if (resetTimeline) |
298 this._reset(); | 353 this._reset(); |
299 | 354 |
300 // Ignore Web Animations custom effects & groups | 355 // Ignore Web Animations custom effects & groups |
301 if (animation.type() === "WebAnimation" && animation.source().keyframesR
ule().keyframes().length === 0) | 356 if (animation.type() === "WebAnimation" && animation.source().keyframesR
ule().keyframes().length === 0) |
302 return; | 357 return; |
303 | 358 |
304 if (this._resizeWindow(animation)) | 359 if (this._resizeWindow(animation)) |
305 this.scheduleRedraw(); | 360 this.scheduleRedraw(); |
306 | 361 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 var lastDraw = undefined; | 412 var lastDraw = undefined; |
358 for (var time = 0; time < this.duration(); time += gridSize) { | 413 for (var time = 0; time < this.duration(); time += gridSize) { |
359 var line = this._grid.createSVGChild("rect", "animation-timeline-gri
d-line"); | 414 var line = this._grid.createSVGChild("rect", "animation-timeline-gri
d-line"); |
360 line.setAttribute("x", time * this.pixelMsRatio()); | 415 line.setAttribute("x", time * this.pixelMsRatio()); |
361 line.setAttribute("y", 0); | 416 line.setAttribute("y", 0); |
362 line.setAttribute("height", "100%"); | 417 line.setAttribute("height", "100%"); |
363 line.setAttribute("width", 1); | 418 line.setAttribute("width", 1); |
364 } | 419 } |
365 for (var time = 0; time < this.duration(); time += gridSize) { | 420 for (var time = 0; time < this.duration(); time += gridSize) { |
366 var gridWidth = time * this.pixelMsRatio(); | 421 var gridWidth = time * this.pixelMsRatio(); |
367 if (time && (!lastDraw || gridWidth - lastDraw > 50)) { | 422 if (!lastDraw || gridWidth - lastDraw > 50) { |
368 lastDraw = gridWidth; | 423 lastDraw = gridWidth; |
369 var label = this._grid.createSVGChild("text", "animation-timelin
e-grid-label"); | 424 var label = this._grid.createSVGChild("text", "animation-timelin
e-grid-label"); |
370 label.setAttribute("x", gridWidth + 5); | 425 label.setAttribute("x", gridWidth + 5); |
371 label.setAttribute("y", 35); | 426 label.setAttribute("y", 35); |
372 label.textContent = WebInspector.UIString(Number.millisToString(
time)); | 427 label.textContent = WebInspector.UIString(Number.millisToString(
time)); |
373 } | 428 } |
374 } | 429 } |
375 }, | 430 }, |
376 | 431 |
377 scheduleRedraw: function() { | 432 scheduleRedraw: function() { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 */ | 490 */ |
436 _animateTime: function(time) | 491 _animateTime: function(time) |
437 { | 492 { |
438 var oldPlayer = this._scrubberPlayer; | 493 var oldPlayer = this._scrubberPlayer; |
439 | 494 |
440 this._scrubberPlayer = this._timelineScrubber.animate([ | 495 this._scrubberPlayer = this._timelineScrubber.animate([ |
441 { transform: "translateX(0px)" }, | 496 { transform: "translateX(0px)" }, |
442 { transform: "translateX(" + (this.width() - this._scrubberRadius)
+ "px)" } | 497 { transform: "translateX(" + (this.width() - this._scrubberRadius)
+ "px)" } |
443 ], { duration: this.duration() - this._scrubberRadius / this.pixelMsRati
o(), fill: "forwards" }); | 498 ], { duration: this.duration() - this._scrubberRadius / this.pixelMsRati
o(), fill: "forwards" }); |
444 this._scrubberPlayer.playbackRate = this._playbackRate(); | 499 this._scrubberPlayer.playbackRate = this._playbackRate(); |
| 500 this._scrubberPlayer.onfinish = this._updateControlButton.bind(this); |
| 501 this._updateControlButton(); |
445 | 502 |
446 if (time !== undefined) | 503 if (time !== undefined) |
447 this._scrubberPlayer.currentTime = time; | 504 this._scrubberPlayer.currentTime = time; |
448 else if (oldPlayer.playState === "finished") | 505 else if (oldPlayer.playState === "finished") |
449 this._scrubberPlayer.finish(); | 506 this._scrubberPlayer.finish(); |
450 else | 507 else |
451 this._scrubberPlayer.startTime = oldPlayer.startTime; | 508 this._scrubberPlayer.startTime = oldPlayer.startTime; |
452 | 509 |
453 if (oldPlayer) | 510 if (oldPlayer) |
454 oldPlayer.cancel(); | 511 oldPlayer.cancel(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 _scrubberDragStart: function(event) | 544 _scrubberDragStart: function(event) |
488 { | 545 { |
489 if (!this._scrubberPlayer) | 546 if (!this._scrubberPlayer) |
490 return false; | 547 return false; |
491 | 548 |
492 this._originalScrubberTime = this._scrubberPlayer.currentTime; | 549 this._originalScrubberTime = this._scrubberPlayer.currentTime; |
493 this._timelineScrubber.classList.remove("animation-timeline-end"); | 550 this._timelineScrubber.classList.remove("animation-timeline-end"); |
494 this._scrubberPlayer.pause(); | 551 this._scrubberPlayer.pause(); |
495 this._originalMousePosition = new WebInspector.Geometry.Point(event.x, e
vent.y); | 552 this._originalMousePosition = new WebInspector.Geometry.Point(event.x, e
vent.y); |
496 | 553 |
497 this._setPlaybackRate(0); | 554 this._togglePause(true); |
| 555 this._updateControlButton(); |
498 return true; | 556 return true; |
499 }, | 557 }, |
500 | 558 |
501 /** | 559 /** |
502 * @param {!Event} event | 560 * @param {!Event} event |
503 */ | 561 */ |
504 _scrubberDragMove: function(event) | 562 _scrubberDragMove: function(event) |
505 { | 563 { |
506 var delta = event.x - this._originalMousePosition.x; | 564 var delta = event.x - this._originalMousePosition.x; |
507 this._scrubberPlayer.currentTime = Math.min(this._originalScrubberTime +
delta / this.pixelMsRatio(), this.duration() - this._scrubberRadius / this.pixe
lMsRatio()); | 565 this._scrubberPlayer.currentTime = Math.min(this._originalScrubberTime +
delta / this.pixelMsRatio(), this.duration() - this._scrubberRadius / this.pixe
lMsRatio()); |
508 var currentTime = Math.max(0, Math.round(this._scrubberPlayer.currentTim
e)); | 566 var currentTime = Math.max(0, Math.round(this._scrubberPlayer.currentTim
e)); |
509 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi
llisToString(currentTime)); | 567 this._timelineScrubberHead.textContent = WebInspector.UIString(Number.mi
llisToString(currentTime)); |
510 for (var target of WebInspector.targetManager.targets(WebInspector.Targe
t.Type.Page)) | 568 for (var target of WebInspector.targetManager.targets(WebInspector.Targe
t.Type.Page)) |
511 target.animationAgent().setCurrentTime(/** @type {number} */(this.st
artTime() + currentTime)); | 569 target.animationAgent().setCurrentTime(/** @type {number} */(this.st
artTime() + currentTime)); |
512 }, | 570 }, |
513 | 571 |
514 /** | 572 /** |
515 * @param {!Event} event | 573 * @param {!Event} event |
516 */ | 574 */ |
517 _scrubberDragEnd: function(event) | 575 _scrubberDragEnd: function(event) |
518 { | 576 { |
519 if (this._scrubberPlayer.currentTime < this.duration() - this._scrubberR
adius / this.pixelMsRatio()) | 577 var currentTime = Math.max(0, this._scrubberPlayer.currentTime); |
520 this._scrubberPlayer.play(); | 578 this._scrubberPlayer.play(); |
| 579 this._scrubberPlayer.currentTime = currentTime; |
521 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc
rubber.bind(this)); | 580 this._timelineScrubberHead.window().requestAnimationFrame(this._updateSc
rubber.bind(this)); |
522 this._setPlaybackRate(this._playbackRate()); | |
523 }, | |
524 | |
525 /** | |
526 * @param {number} playbackRate | |
527 */ | |
528 _setPlaybackRate: function(playbackRate) | |
529 { | |
530 var target = WebInspector.targetManager.mainTarget(); | |
531 if (target) | |
532 WebInspector.AnimationModel.fromTarget(target).setPlaybackRate(playb
ackRate); | |
533 }, | 581 }, |
534 | 582 |
535 __proto__: WebInspector.VBox.prototype | 583 __proto__: WebInspector.VBox.prototype |
536 } | 584 } |
537 | 585 |
538 /** | 586 /** |
539 * @constructor | 587 * @constructor |
540 * @param {!WebInspector.AnimationModel.AnimationEffect} animationEffect | 588 * @param {!WebInspector.AnimationModel.AnimationEffect} animationEffect |
541 */ | 589 */ |
542 WebInspector.AnimationTimeline.NodeUI = function(animationEffect) { | 590 WebInspector.AnimationTimeline.NodeUI = function(animationEffect) { |
543 /** | 591 /** |
544 * @param {?WebInspector.DOMNode} node | 592 * @param {?WebInspector.DOMNode} node |
545 * @this {WebInspector.AnimationTimeline.NodeUI} | 593 * @this {WebInspector.AnimationTimeline.NodeUI} |
546 */ | 594 */ |
547 function nodeResolved(node) | 595 function nodeResolved(node) |
548 { | 596 { |
| 597 if (!node) |
| 598 return; |
549 this._node = node; | 599 this._node = node; |
550 this._description.appendChild(WebInspector.DOMPresentationUtils.linkifyN
odeReference(node)); | 600 WebInspector.DOMPresentationUtils.decorateNodeLabel(node, this._descript
ion); |
551 this.element.addEventListener("click", WebInspector.Revealer.reveal.bind
(WebInspector.Revealer, node, undefined), false); | 601 this.element.addEventListener("click", WebInspector.Revealer.reveal.bind
(WebInspector.Revealer, node, undefined), false); |
552 } | 602 } |
553 | 603 |
554 this._rows = []; | 604 this._rows = []; |
555 this.element = createElementWithClass("div", "animation-node-row"); | 605 this.element = createElementWithClass("div", "animation-node-row"); |
556 this._description = this.element.createChild("div", "animation-node-descript
ion"); | 606 this._description = this.element.createChild("div", "animation-node-descript
ion"); |
557 animationEffect.deferredNode().resolve(nodeResolved.bind(this)); | 607 animationEffect.deferredNode().resolve(nodeResolved.bind(this)); |
558 this._timelineElement = this.element.createChild("div", "animation-node-time
line"); | 608 this._timelineElement = this.element.createChild("div", "animation-node-time
line"); |
559 } | 609 } |
560 | 610 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
975 | 1025 |
976 // Commit changes | 1026 // Commit changes |
977 if (this._mouseEventType === WebInspector.AnimationUI.MouseEvents.Keyfra
meMove) { | 1027 if (this._mouseEventType === WebInspector.AnimationUI.MouseEvents.Keyfra
meMove) { |
978 this._keyframes[this._keyframeMoved].setOffset(this._offset(this._ke
yframeMoved)); | 1028 this._keyframes[this._keyframeMoved].setOffset(this._offset(this._ke
yframeMoved)); |
979 } else { | 1029 } else { |
980 var delay = this._delay(); | 1030 var delay = this._delay(); |
981 var duration = this._duration(); | 1031 var duration = this._duration(); |
982 this._setDelay(delay); | 1032 this._setDelay(delay); |
983 this._setDuration(duration); | 1033 this._setDuration(duration); |
984 if (this._animation.type() !== "CSSAnimation") { | 1034 if (this._animation.type() !== "CSSAnimation") { |
985 var target = WebInspector.targetManager.mainTarget(); | 1035 for (var target of WebInspector.targetManager.targets(WebInspect
or.Target.Type.Page)) |
986 if (target) | |
987 target.animationAgent().setTiming(this._animation.id(), dura
tion, delay); | 1036 target.animationAgent().setTiming(this._animation.id(), dura
tion, delay); |
988 } | 1037 } |
989 } | 1038 } |
990 | 1039 |
991 this._movementInMs = 0; | 1040 this._movementInMs = 0; |
992 this.redraw(); | 1041 this.redraw(); |
993 | 1042 |
994 this._parentElement.ownerDocument.removeEventListener("mousemove", this.
_mouseMoveHandler); | 1043 this._parentElement.ownerDocument.removeEventListener("mousemove", this.
_mouseMoveHandler); |
995 this._parentElement.ownerDocument.removeEventListener("mouseup", this._m
ouseUpHandler); | 1044 this._parentElement.ownerDocument.removeEventListener("mouseup", this._m
ouseUpHandler); |
996 delete this._mouseMoveHandler; | 1045 delete this._mouseMoveHandler; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 EndpointsClickRegionSize: 10, | 1133 EndpointsClickRegionSize: 10, |
1085 GridCanvasHeight: 40 | 1134 GridCanvasHeight: 40 |
1086 } | 1135 } |
1087 | 1136 |
1088 WebInspector.AnimationUI.Colors = { | 1137 WebInspector.AnimationUI.Colors = { |
1089 "Purple": WebInspector.Color.parse("#9C27B0"), | 1138 "Purple": WebInspector.Color.parse("#9C27B0"), |
1090 "Light Blue": WebInspector.Color.parse("#03A9F4"), | 1139 "Light Blue": WebInspector.Color.parse("#03A9F4"), |
1091 "Deep Orange": WebInspector.Color.parse("#FF5722"), | 1140 "Deep Orange": WebInspector.Color.parse("#FF5722"), |
1092 "Blue": WebInspector.Color.parse("#5677FC"), | 1141 "Blue": WebInspector.Color.parse("#5677FC"), |
1093 "Lime": WebInspector.Color.parse("#CDDC39"), | 1142 "Lime": WebInspector.Color.parse("#CDDC39"), |
1094 "Blue Grey": WebInspector.Color.parse("#607D8B"), | |
1095 "Pink": WebInspector.Color.parse("#E91E63"), | 1143 "Pink": WebInspector.Color.parse("#E91E63"), |
1096 "Green": WebInspector.Color.parse("#0F9D58"), | 1144 "Green": WebInspector.Color.parse("#0F9D58"), |
1097 "Brown": WebInspector.Color.parse("#795548"), | 1145 "Brown": WebInspector.Color.parse("#795548"), |
1098 "Cyan": WebInspector.Color.parse("#00BCD4") | 1146 "Cyan": WebInspector.Color.parse("#00BCD4") |
1099 } | 1147 } |
OLD | NEW |