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

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

Issue 2747553002: [DevTools] Rework Popover API (Closed)
Patch Set: await Created 3 years, 9 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
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 * @implements {SDK.SDKModelObserver<!Animation.AnimationModel>} 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);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 var button = playbackRateControl.createChild('div', 'animation-playback-ra te-button'); 124 var button = playbackRateControl.createChild('div', 'animation-playback-ra te-button');
125 button.textContent = playbackRate ? Common.UIString(playbackRate * 100 + ' %') : Common.UIString('Pause'); 125 button.textContent = playbackRate ? Common.UIString(playbackRate * 100 + ' %') : Common.UIString('Pause');
126 button.playbackRate = playbackRate; 126 button.playbackRate = playbackRate;
127 button.addEventListener('click', this._setPlaybackRate.bind(this, playback Rate)); 127 button.addEventListener('click', this._setPlaybackRate.bind(this, playback Rate));
128 button.title = Common.UIString('Set speed to ') + button.textContent; 128 button.title = Common.UIString('Set speed to ') + button.textContent;
129 this._playbackRateButtons.push(button); 129 this._playbackRateButtons.push(button);
130 } 130 }
131 this._updatePlaybackControls(); 131 this._updatePlaybackControls();
132 132
133 this._previewContainer = this.contentElement.createChild('div', 'animation-t imeline-buffer'); 133 this._previewContainer = this.contentElement.createChild('div', 'animation-t imeline-buffer');
134 this._popoverHelper = new UI.PopoverHelper(this._previewContainer, true); 134 this._popoverHelper = new UI.PopoverHelper(this._previewContainer, true, thi s._getPopoverContent.bind(this));
135 this._popoverHelper.initializeCallbacks(
136 this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this._o nHidePopover.bind(this));
137 this._popoverHelper.setTimeout(0); 135 this._popoverHelper.setTimeout(0);
138 var emptyBufferHint = this.contentElement.createChild('div', 'animation-time line-buffer-hint'); 136 var emptyBufferHint = this.contentElement.createChild('div', 'animation-time line-buffer-hint');
139 emptyBufferHint.textContent = Common.UIString('Listening for animations...') ; 137 emptyBufferHint.textContent = Common.UIString('Listening for animations...') ;
140 var container = this.contentElement.createChild('div', 'animation-timeline-h eader'); 138 var container = this.contentElement.createChild('div', 'animation-timeline-h eader');
141 var controls = container.createChild('div', 'animation-controls'); 139 var controls = container.createChild('div', 'animation-controls');
142 this._currentTime = controls.createChild('div', 'animation-timeline-current- time monospace'); 140 this._currentTime = controls.createChild('div', 'animation-timeline-current- time monospace');
143 141
144 var toolbar = new UI.Toolbar('animation-controls-toolbar', controls); 142 var toolbar = new UI.Toolbar('animation-controls-toolbar', controls);
145 this._controlButton = new UI.ToolbarToggle(Common.UIString('Replay timeline' ), 'largeicon-replay-animation'); 143 this._controlButton = new UI.ToolbarToggle(Common.UIString('Replay timeline' ), 'largeicon-replay-animation');
146 this._controlState = Animation.AnimationTimeline._ControlState.Replay; 144 this._controlState = Animation.AnimationTimeline._ControlState.Replay;
147 this._controlButton.setToggled(true); 145 this._controlButton.setToggled(true);
148 this._controlButton.addEventListener(UI.ToolbarButton.Events.Click, this._co ntrolButtonToggle.bind(this)); 146 this._controlButton.addEventListener(UI.ToolbarButton.Events.Click, this._co ntrolButtonToggle.bind(this));
149 toolbar.appendToolbarItem(this._controlButton); 147 toolbar.appendToolbarItem(this._controlButton);
150 148
151 var gridHeader = container.createChild('div', 'animation-grid-header'); 149 var gridHeader = container.createChild('div', 'animation-grid-header');
152 UI.installDragHandle( 150 UI.installDragHandle(
153 gridHeader, this._repositionScrubber.bind(this), this._scrubberDragMove. bind(this), 151 gridHeader, this._repositionScrubber.bind(this), this._scrubberDragMove. bind(this),
154 this._scrubberDragEnd.bind(this), 'text'); 152 this._scrubberDragEnd.bind(this), 'text');
155 container.appendChild(this._createScrubber()); 153 container.appendChild(this._createScrubber());
156 UI.installDragHandle( 154 UI.installDragHandle(
157 this._timelineScrubberLine, this._scrubberDragStart.bind(this), this._sc rubberDragMove.bind(this), 155 this._timelineScrubberLine, this._scrubberDragStart.bind(this), this._sc rubberDragMove.bind(this),
158 this._scrubberDragEnd.bind(this), 'col-resize'); 156 this._scrubberDragEnd.bind(this), 'col-resize');
159 this._currentTime.textContent = ''; 157 this._currentTime.textContent = '';
160 158
161 return container; 159 return container;
162 } 160 }
163 161
164 /** 162 /**
165 * @param {!Element} element
166 * @param {!Event} event 163 * @param {!Event} event
167 * @return {!Element|!AnchorBox|undefined} 164 * @return {?UI.PopoverContent}
168 */ 165 */
169 _getPopoverAnchor(element, event) { 166 _getPopoverContent(event) {
170 if (element.isDescendant(this._previewContainer)) 167 var element = event.target;
171 return element; 168 if (!element.isDescendant(this._previewContainer))
172 } 169 return null;
173 170
174 /** 171 return {
175 * @param {!Element|!AnchorBox} anchor 172 box: event.target.boxInWindow(),
176 * @param {!UI.GlassPane} popover 173 show: popover => {
177 * @return {!Promise<boolean>} 174 var animGroup;
178 */ 175 for (var group of this._previewMap.keysArray()) {
179 _showPopover(anchor, popover) { 176 if (this._previewMap.get(group).element === element.parentElement)
180 var animGroup; 177 animGroup = group;
181 for (var group of this._previewMap.keysArray()) { 178 }
182 if (this._previewMap.get(group).element === anchor.parentElement) 179 console.assert(animGroup);
183 animGroup = group; 180 var screenshots = animGroup.screenshots();
184 } 181 if (!screenshots.length)
185 console.assert(animGroup); 182 return Promise.resolve(false);
186 var screenshots = animGroup.screenshots();
187 if (!screenshots.length)
188 return Promise.resolve(false);
189 183
190 var fulfill; 184 var fulfill;
191 var promise = new Promise(x => fulfill = x); 185 var promise = new Promise(x => fulfill = x);
192 if (!screenshots[0].complete) 186 if (!screenshots[0].complete)
193 screenshots[0].onload = onFirstScreenshotLoaded.bind(null, screenshots); 187 screenshots[0].onload = onFirstScreenshotLoaded.bind(null, screenshots );
194 else 188 else
195 onFirstScreenshotLoaded(screenshots); 189 onFirstScreenshotLoaded(screenshots);
196 return promise; 190 return promise;
197 191
198 /** 192 /**
199 * @param {!Array.<!Image>} screenshots 193 * @param {!Array.<!Image>} screenshots
200 */ 194 */
201 function onFirstScreenshotLoaded(screenshots) { 195 function onFirstScreenshotLoaded(screenshots) {
202 new Animation.AnimationScreenshotPopover(screenshots).show(popover.content Element); 196 new Animation.AnimationScreenshotPopover(screenshots).show(popover.con tentElement);
203 fulfill(true); 197 fulfill(true);
204 } 198 }
205 } 199 }
206 200 };
207 _onHidePopover() {
208 } 201 }
209 202
210 _togglePauseAll() { 203 _togglePauseAll() {
211 this._allPaused = !this._allPaused; 204 this._allPaused = !this._allPaused;
212 this._pauseButton.setToggled(this._allPaused); 205 this._pauseButton.setToggled(this._allPaused);
213 this._setPlaybackRate(this._playbackRate); 206 this._setPlaybackRate(this._playbackRate);
214 this._pauseButton.setTitle(this._allPaused ? Common.UIString('Resume all') : Common.UIString('Pause all')); 207 this._pauseButton.setTitle(this._allPaused ? Common.UIString('Resume all') : Common.UIString('Pause all'));
215 } 208 }
216 209
217 /** 210 /**
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 static parse(text) { 726 static parse(text) {
734 var match = text.match(/^steps\((\d+), (start|middle)\)$/); 727 var match = text.match(/^steps\((\d+), (start|middle)\)$/);
735 if (match) 728 if (match)
736 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1 ], 10), match[2]); 729 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1 ], 10), match[2]);
737 match = text.match(/^steps\((\d+)\)$/); 730 match = text.match(/^steps\((\d+)\)$/);
738 if (match) 731 if (match)
739 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1 ], 10), 'end'); 732 return new Animation.AnimationTimeline.StepTimingFunction(parseInt(match[1 ], 10), 'end');
740 return null; 733 return null;
741 } 734 }
742 }; 735 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698