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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/TimelineOverviewPane.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @unrestricted 32 * @unrestricted
33 */ 33 */
34 WebInspector.TimelineOverviewPane = class extends WebInspector.VBox { 34 UI.TimelineOverviewPane = class extends UI.VBox {
35 /** 35 /**
36 * @param {string} prefix 36 * @param {string} prefix
37 */ 37 */
38 constructor(prefix) { 38 constructor(prefix) {
39 super(); 39 super();
40 this.element.id = prefix + '-overview-pane'; 40 this.element.id = prefix + '-overview-pane';
41 41
42 this._overviewCalculator = new WebInspector.TimelineOverviewCalculator(); 42 this._overviewCalculator = new UI.TimelineOverviewCalculator();
43 this._overviewGrid = new WebInspector.OverviewGrid(prefix); 43 this._overviewGrid = new UI.OverviewGrid(prefix);
44 this.element.appendChild(this._overviewGrid.element); 44 this.element.appendChild(this._overviewGrid.element);
45 this._cursorArea = this._overviewGrid.element.createChild('div', 'overview-g rid-cursor-area'); 45 this._cursorArea = this._overviewGrid.element.createChild('div', 'overview-g rid-cursor-area');
46 this._cursorElement = this._overviewGrid.element.createChild('div', 'overvie w-grid-cursor-position'); 46 this._cursorElement = this._overviewGrid.element.createChild('div', 'overvie w-grid-cursor-position');
47 this._cursorArea.addEventListener('mousemove', this._onMouseMove.bind(this), true); 47 this._cursorArea.addEventListener('mousemove', this._onMouseMove.bind(this), true);
48 this._cursorArea.addEventListener('mouseleave', this._hideCursor.bind(this), true); 48 this._cursorArea.addEventListener('mouseleave', this._hideCursor.bind(this), true);
49 49
50 this._overviewGrid.setResizeEnabled(false); 50 this._overviewGrid.setResizeEnabled(false);
51 this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.WindowC hanged, this._onWindowChanged, this); 51 this._overviewGrid.addEventListener(UI.OverviewGrid.Events.WindowChanged, th is._onWindowChanged, this);
52 this._overviewGrid.addEventListener(WebInspector.OverviewGrid.Events.Click, this._onClick, this); 52 this._overviewGrid.addEventListener(UI.OverviewGrid.Events.Click, this._onCl ick, this);
53 this._overviewControls = []; 53 this._overviewControls = [];
54 this._markers = new Map(); 54 this._markers = new Map();
55 55
56 this._popoverHelper = new WebInspector.PopoverHelper(this._cursorArea); 56 this._popoverHelper = new UI.PopoverHelper(this._cursorArea);
57 this._popoverHelper.initializeCallbacks( 57 this._popoverHelper.initializeCallbacks(
58 this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this._o nHidePopover.bind(this)); 58 this._getPopoverAnchor.bind(this), this._showPopover.bind(this), this._o nHidePopover.bind(this));
59 this._popoverHelper.setTimeout(0); 59 this._popoverHelper.setTimeout(0);
60 60
61 this._updateThrottler = new WebInspector.Throttler(100); 61 this._updateThrottler = new Common.Throttler(100);
62 62
63 this._cursorEnabled = false; 63 this._cursorEnabled = false;
64 this._cursorPosition = 0; 64 this._cursorPosition = 0;
65 this._lastWidth = 0; 65 this._lastWidth = 0;
66 } 66 }
67 67
68 /** 68 /**
69 * @param {!Element} element 69 * @param {!Element} element
70 * @param {!Event} event 70 * @param {!Event} event
71 * @return {!Element|!AnchorBox|undefined} 71 * @return {!Element|!AnchorBox|undefined}
72 */ 72 */
73 _getPopoverAnchor(element, event) { 73 _getPopoverAnchor(element, event) {
74 return this._cursorArea; 74 return this._cursorArea;
75 } 75 }
76 76
77 /** 77 /**
78 * @param {!Element} anchor 78 * @param {!Element} anchor
79 * @param {!WebInspector.Popover} popover 79 * @param {!UI.Popover} popover
80 */ 80 */
81 _showPopover(anchor, popover) { 81 _showPopover(anchor, popover) {
82 this._buildPopoverContents().then(maybeShowPopover.bind(this)); 82 this._buildPopoverContents().then(maybeShowPopover.bind(this));
83 /** 83 /**
84 * @this {WebInspector.TimelineOverviewPane} 84 * @this {UI.TimelineOverviewPane}
85 * @param {!DocumentFragment} fragment 85 * @param {!DocumentFragment} fragment
86 */ 86 */
87 function maybeShowPopover(fragment) { 87 function maybeShowPopover(fragment) {
88 if (!fragment.firstChild) 88 if (!fragment.firstChild)
89 return; 89 return;
90 var content = new WebInspector.TimelineOverviewPane.PopoverContents(); 90 var content = new UI.TimelineOverviewPane.PopoverContents();
91 this._popoverContents = content.contentElement.createChild('div'); 91 this._popoverContents = content.contentElement.createChild('div');
92 this._popoverContents.appendChild(fragment); 92 this._popoverContents.appendChild(fragment);
93 this._popover = popover; 93 this._popover = popover;
94 popover.showView(content, this._cursorElement); 94 popover.showView(content, this._cursorElement);
95 } 95 }
96 } 96 }
97 97
98 _onHidePopover() { 98 _onHidePopover() {
99 this._popover = null; 99 this._popover = null;
100 this._popoverContents = null; 100 this._popoverContents = null;
101 } 101 }
102 102
103 /** 103 /**
104 * @param {!Event} event 104 * @param {!Event} event
105 */ 105 */
106 _onMouseMove(event) { 106 _onMouseMove(event) {
107 if (!this._cursorEnabled) 107 if (!this._cursorEnabled)
108 return; 108 return;
109 this._cursorPosition = event.offsetX + event.target.offsetLeft; 109 this._cursorPosition = event.offsetX + event.target.offsetLeft;
110 this._cursorElement.style.left = this._cursorPosition + 'px'; 110 this._cursorElement.style.left = this._cursorPosition + 'px';
111 this._cursorElement.style.visibility = 'visible'; 111 this._cursorElement.style.visibility = 'visible';
112 if (!this._popover) 112 if (!this._popover)
113 return; 113 return;
114 this._buildPopoverContents().then(updatePopover.bind(this)); 114 this._buildPopoverContents().then(updatePopover.bind(this));
115 this._popover.positionElement(this._cursorElement); 115 this._popover.positionElement(this._cursorElement);
116 116
117 /** 117 /**
118 * @param {!DocumentFragment} fragment 118 * @param {!DocumentFragment} fragment
119 * @this {WebInspector.TimelineOverviewPane} 119 * @this {UI.TimelineOverviewPane}
120 */ 120 */
121 function updatePopover(fragment) { 121 function updatePopover(fragment) {
122 if (!this._popoverContents) 122 if (!this._popoverContents)
123 return; 123 return;
124 this._popoverContents.removeChildren(); 124 this._popoverContents.removeChildren();
125 this._popoverContents.appendChild(fragment); 125 this._popoverContents.appendChild(fragment);
126 } 126 }
127 } 127 }
128 128
129 /** 129 /**
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 */ 170 */
171 onResize() { 171 onResize() {
172 var width = this.element.offsetWidth; 172 var width = this.element.offsetWidth;
173 if (width === this._lastWidth) 173 if (width === this._lastWidth)
174 return; 174 return;
175 this._lastWidth = width; 175 this._lastWidth = width;
176 this.scheduleUpdate(); 176 this.scheduleUpdate();
177 } 177 }
178 178
179 /** 179 /**
180 * @param {!Array.<!WebInspector.TimelineOverview>} overviewControls 180 * @param {!Array.<!UI.TimelineOverview>} overviewControls
181 */ 181 */
182 setOverviewControls(overviewControls) { 182 setOverviewControls(overviewControls) {
183 for (var i = 0; i < this._overviewControls.length; ++i) 183 for (var i = 0; i < this._overviewControls.length; ++i)
184 this._overviewControls[i].dispose(); 184 this._overviewControls[i].dispose();
185 185
186 for (var i = 0; i < overviewControls.length; ++i) { 186 for (var i = 0; i < overviewControls.length; ++i) {
187 overviewControls[i].setCalculator(this._overviewCalculator); 187 overviewControls[i].setCalculator(this._overviewCalculator);
188 overviewControls[i].show(this._overviewGrid.element); 188 overviewControls[i].show(this._overviewGrid.element);
189 } 189 }
190 this._overviewControls = overviewControls; 190 this._overviewControls = overviewControls;
191 this._update(); 191 this._update();
192 } 192 }
193 193
194 /** 194 /**
195 * @param {number} minimumBoundary 195 * @param {number} minimumBoundary
196 * @param {number} maximumBoundary 196 * @param {number} maximumBoundary
197 */ 197 */
198 setBounds(minimumBoundary, maximumBoundary) { 198 setBounds(minimumBoundary, maximumBoundary) {
199 this._overviewCalculator.setBounds(minimumBoundary, maximumBoundary); 199 this._overviewCalculator.setBounds(minimumBoundary, maximumBoundary);
200 this._overviewGrid.setResizeEnabled(true); 200 this._overviewGrid.setResizeEnabled(true);
201 this._cursorEnabled = true; 201 this._cursorEnabled = true;
202 } 202 }
203 203
204 scheduleUpdate() { 204 scheduleUpdate() {
205 this._updateThrottler.schedule(process.bind(this)); 205 this._updateThrottler.schedule(process.bind(this));
206 /** 206 /**
207 * @this {WebInspector.TimelineOverviewPane} 207 * @this {UI.TimelineOverviewPane}
208 * @return {!Promise.<undefined>} 208 * @return {!Promise.<undefined>}
209 */ 209 */
210 function process() { 210 function process() {
211 this._update(); 211 this._update();
212 return Promise.resolve(); 212 return Promise.resolve();
213 } 213 }
214 } 214 }
215 215
216 _update() { 216 _update() {
217 if (!this.isShowing()) 217 if (!this.isShowing())
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 this._cursorEnabled = false; 257 this._cursorEnabled = false;
258 this._hideCursor(); 258 this._hideCursor();
259 this._markers = new Map(); 259 this._markers = new Map();
260 for (var i = 0; i < this._overviewControls.length; ++i) 260 for (var i = 0; i < this._overviewControls.length; ++i)
261 this._overviewControls[i].reset(); 261 this._overviewControls[i].reset();
262 this._popoverHelper.hidePopover(); 262 this._popoverHelper.hidePopover();
263 this._update(); 263 this._update();
264 } 264 }
265 265
266 /** 266 /**
267 * @param {!WebInspector.Event} event 267 * @param {!Common.Event} event
268 */ 268 */
269 _onClick(event) { 269 _onClick(event) {
270 var domEvent = /** @type {!Event} */ (event.data); 270 var domEvent = /** @type {!Event} */ (event.data);
271 for (var overviewControl of this._overviewControls) { 271 for (var overviewControl of this._overviewControls) {
272 if (overviewControl.onClick(domEvent)) { 272 if (overviewControl.onClick(domEvent)) {
273 event.preventDefault(); 273 event.preventDefault();
274 return; 274 return;
275 } 275 }
276 } 276 }
277 } 277 }
278 278
279 /** 279 /**
280 * @param {!WebInspector.Event} event 280 * @param {!Common.Event} event
281 */ 281 */
282 _onWindowChanged(event) { 282 _onWindowChanged(event) {
283 if (this._muteOnWindowChanged) 283 if (this._muteOnWindowChanged)
284 return; 284 return;
285 // Always use first control as a time converter. 285 // Always use first control as a time converter.
286 if (!this._overviewControls.length) 286 if (!this._overviewControls.length)
287 return; 287 return;
288 var windowTimes = 288 var windowTimes =
289 this._overviewControls[0].windowTimes(this._overviewGrid.windowLeft(), t his._overviewGrid.windowRight()); 289 this._overviewControls[0].windowTimes(this._overviewGrid.windowLeft(), t his._overviewGrid.windowRight());
290 this._windowStartTime = windowTimes.startTime; 290 this._windowStartTime = windowTimes.startTime;
291 this._windowEndTime = windowTimes.endTime; 291 this._windowEndTime = windowTimes.endTime;
292 this.dispatchEventToListeners(WebInspector.TimelineOverviewPane.Events.Windo wChanged, windowTimes); 292 this.dispatchEventToListeners(UI.TimelineOverviewPane.Events.WindowChanged, windowTimes);
293 } 293 }
294 294
295 /** 295 /**
296 * @param {number} startTime 296 * @param {number} startTime
297 * @param {number} endTime 297 * @param {number} endTime
298 */ 298 */
299 requestWindowTimes(startTime, endTime) { 299 requestWindowTimes(startTime, endTime) {
300 if (startTime === this._windowStartTime && endTime === this._windowEndTime) 300 if (startTime === this._windowStartTime && endTime === this._windowEndTime)
301 return; 301 return;
302 this._windowStartTime = startTime; 302 this._windowStartTime = startTime;
303 this._windowEndTime = endTime; 303 this._windowEndTime = endTime;
304 this._updateWindow(); 304 this._updateWindow();
305 this.dispatchEventToListeners( 305 this.dispatchEventToListeners(
306 WebInspector.TimelineOverviewPane.Events.WindowChanged, {startTime: star tTime, endTime: endTime}); 306 UI.TimelineOverviewPane.Events.WindowChanged, {startTime: startTime, end Time: endTime});
307 } 307 }
308 308
309 _updateWindow() { 309 _updateWindow() {
310 if (!this._overviewControls.length) 310 if (!this._overviewControls.length)
311 return; 311 return;
312 var windowBoundaries = this._overviewControls[0].windowBoundaries(this._wind owStartTime, this._windowEndTime); 312 var windowBoundaries = this._overviewControls[0].windowBoundaries(this._wind owStartTime, this._windowEndTime);
313 this._muteOnWindowChanged = true; 313 this._muteOnWindowChanged = true;
314 this._overviewGrid.setWindow(windowBoundaries.left, windowBoundaries.right); 314 this._overviewGrid.setWindow(windowBoundaries.left, windowBoundaries.right);
315 this._muteOnWindowChanged = false; 315 this._muteOnWindowChanged = false;
316 } 316 }
317 }; 317 };
318 318
319 /** @enum {symbol} */ 319 /** @enum {symbol} */
320 WebInspector.TimelineOverviewPane.Events = { 320 UI.TimelineOverviewPane.Events = {
321 WindowChanged: Symbol('WindowChanged') 321 WindowChanged: Symbol('WindowChanged')
322 }; 322 };
323 323
324 /** 324 /**
325 * @unrestricted 325 * @unrestricted
326 */ 326 */
327 WebInspector.TimelineOverviewPane.PopoverContents = class extends WebInspector.V Box { 327 UI.TimelineOverviewPane.PopoverContents = class extends UI.VBox {
328 constructor() { 328 constructor() {
329 super(true); 329 super(true);
330 this.contentElement.classList.add('timeline-overview-popover'); 330 this.contentElement.classList.add('timeline-overview-popover');
331 } 331 }
332 }; 332 };
333 333
334 /** 334 /**
335 * @implements {WebInspector.TimelineGrid.Calculator} 335 * @implements {UI.TimelineGrid.Calculator}
336 * @unrestricted 336 * @unrestricted
337 */ 337 */
338 WebInspector.TimelineOverviewCalculator = class { 338 UI.TimelineOverviewCalculator = class {
339 constructor() { 339 constructor() {
340 this.reset(); 340 this.reset();
341 } 341 }
342 342
343 /** 343 /**
344 * @override 344 * @override
345 * @return {number} 345 * @return {number}
346 */ 346 */
347 paddingLeft() { 347 paddingLeft() {
348 return this._paddingLeft; 348 return this._paddingLeft;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 * @return {number} 426 * @return {number}
427 */ 427 */
428 boundarySpan() { 428 boundarySpan() {
429 return this._maximumBoundary - this._minimumBoundary; 429 return this._maximumBoundary - this._minimumBoundary;
430 } 430 }
431 }; 431 };
432 432
433 /** 433 /**
434 * @interface 434 * @interface
435 */ 435 */
436 WebInspector.TimelineOverview = function() {}; 436 UI.TimelineOverview = function() {};
437 437
438 WebInspector.TimelineOverview.prototype = { 438 UI.TimelineOverview.prototype = {
439 /** 439 /**
440 * @param {!Element} parentElement 440 * @param {!Element} parentElement
441 * @param {?Element=} insertBefore 441 * @param {?Element=} insertBefore
442 */ 442 */
443 show: function(parentElement, insertBefore) {}, 443 show: function(parentElement, insertBefore) {},
444 444
445 update: function() {}, 445 update: function() {},
446 446
447 dispose: function() {}, 447 dispose: function() {},
448 448
(...skipping 24 matching lines...) Expand all
473 * @return {!{left: number, right: number}} 473 * @return {!{left: number, right: number}}
474 */ 474 */
475 windowBoundaries: function(startTime, endTime) {}, 475 windowBoundaries: function(startTime, endTime) {},
476 476
477 timelineStarted: function() {}, 477 timelineStarted: function() {},
478 478
479 timelineStopped: function() {}, 479 timelineStopped: function() {},
480 }; 480 };
481 481
482 /** 482 /**
483 * @implements {WebInspector.TimelineOverview} 483 * @implements {UI.TimelineOverview}
484 * @unrestricted 484 * @unrestricted
485 */ 485 */
486 WebInspector.TimelineOverviewBase = class extends WebInspector.VBox { 486 UI.TimelineOverviewBase = class extends UI.VBox {
487 constructor() { 487 constructor() {
488 super(); 488 super();
489 /** @type {?WebInspector.TimelineOverviewCalculator} */ 489 /** @type {?UI.TimelineOverviewCalculator} */
490 this._calculator = null; 490 this._calculator = null;
491 this._canvas = this.element.createChild('canvas', 'fill'); 491 this._canvas = this.element.createChild('canvas', 'fill');
492 this._context = this._canvas.getContext('2d'); 492 this._context = this._canvas.getContext('2d');
493 } 493 }
494 494
495 /** 495 /**
496 * @override 496 * @override
497 */ 497 */
498 update() { 498 update() {
499 this.resetCanvas(); 499 this.resetCanvas();
(...skipping 27 matching lines...) Expand all
527 timelineStarted() { 527 timelineStarted() {
528 } 528 }
529 529
530 /** 530 /**
531 * @override 531 * @override
532 */ 532 */
533 timelineStopped() { 533 timelineStopped() {
534 } 534 }
535 535
536 /** 536 /**
537 * @param {!WebInspector.TimelineOverviewCalculator} calculator 537 * @param {!UI.TimelineOverviewCalculator} calculator
538 */ 538 */
539 setCalculator(calculator) { 539 setCalculator(calculator) {
540 this._calculator = calculator; 540 this._calculator = calculator;
541 } 541 }
542 542
543 /** 543 /**
544 * @override 544 * @override
545 * @param {!Event} event 545 * @param {!Event} event
546 * @return {boolean} 546 * @return {boolean}
547 */ 547 */
(...skipping 27 matching lines...) Expand all
575 left: haveRecords && startTime ? Math.min((startTime - absoluteMin) / time Span, 1) : 0, 575 left: haveRecords && startTime ? Math.min((startTime - absoluteMin) / time Span, 1) : 0,
576 right: haveRecords && endTime < Infinity ? (endTime - absoluteMin) / timeS pan : 1 576 right: haveRecords && endTime < Infinity ? (endTime - absoluteMin) / timeS pan : 1
577 }; 577 };
578 } 578 }
579 579
580 resetCanvas() { 580 resetCanvas() {
581 this._canvas.width = this.element.clientWidth * window.devicePixelRatio; 581 this._canvas.width = this.element.clientWidth * window.devicePixelRatio;
582 this._canvas.height = this.element.clientHeight * window.devicePixelRatio; 582 this._canvas.height = this.element.clientHeight * window.devicePixelRatio;
583 } 583 }
584 }; 584 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698