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

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

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

Powered by Google App Engine
This is Rietveld 408576698