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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.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 12 matching lines...) Expand all
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
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 * @interface 31 * @interface
32 */ 32 */
33 WebInspector.FlameChartDelegate = function() {}; 33 UI.FlameChartDelegate = function() {};
34 34
35 WebInspector.FlameChartDelegate.prototype = { 35 UI.FlameChartDelegate.prototype = {
36 /** 36 /**
37 * @param {number} startTime 37 * @param {number} startTime
38 * @param {number} endTime 38 * @param {number} endTime
39 */ 39 */
40 requestWindowTimes: function(startTime, endTime) {}, 40 requestWindowTimes: function(startTime, endTime) {},
41 41
42 /** 42 /**
43 * @param {number} startTime 43 * @param {number} startTime
44 * @param {number} endTime 44 * @param {number} endTime
45 */ 45 */
46 updateRangeSelection: function(startTime, endTime) {}, 46 updateRangeSelection: function(startTime, endTime) {},
47 }; 47 };
48 48
49 /** 49 /**
50 * @unrestricted 50 * @unrestricted
51 */ 51 */
52 WebInspector.FlameChart = class extends WebInspector.ChartViewport { 52 UI.FlameChart = class extends UI.ChartViewport {
53 /** 53 /**
54 * @param {!WebInspector.FlameChartDataProvider} dataProvider 54 * @param {!UI.FlameChartDataProvider} dataProvider
55 * @param {!WebInspector.FlameChartDelegate} flameChartDelegate 55 * @param {!UI.FlameChartDelegate} flameChartDelegate
56 * @param {!WebInspector.Setting=} groupExpansionSetting 56 * @param {!Common.Setting=} groupExpansionSetting
57 */ 57 */
58 constructor(dataProvider, flameChartDelegate, groupExpansionSetting) { 58 constructor(dataProvider, flameChartDelegate, groupExpansionSetting) {
59 super(); 59 super();
60 this.registerRequiredCSS('ui_lazy/flameChart.css'); 60 this.registerRequiredCSS('ui_lazy/flameChart.css');
61 this.contentElement.classList.add('flame-chart-main-pane'); 61 this.contentElement.classList.add('flame-chart-main-pane');
62 this._flameChartDelegate = flameChartDelegate; 62 this._flameChartDelegate = flameChartDelegate;
63 this._groupExpansionSetting = groupExpansionSetting; 63 this._groupExpansionSetting = groupExpansionSetting;
64 this._groupExpansionState = groupExpansionSetting && groupExpansionSetting.g et() || {}; 64 this._groupExpansionState = groupExpansionSetting && groupExpansionSetting.g et() || {};
65 65
66 this._dataProvider = dataProvider; 66 this._dataProvider = dataProvider;
67 this._calculator = new WebInspector.FlameChart.Calculator(dataProvider); 67 this._calculator = new UI.FlameChart.Calculator(dataProvider);
68 68
69 this._canvas = /** @type {!HTMLCanvasElement} */ (this.viewportElement.creat eChild('canvas')); 69 this._canvas = /** @type {!HTMLCanvasElement} */ (this.viewportElement.creat eChild('canvas'));
70 this._canvas.tabIndex = 1; 70 this._canvas.tabIndex = 1;
71 this.setDefaultFocusedElement(this._canvas); 71 this.setDefaultFocusedElement(this._canvas);
72 this._canvas.addEventListener('mousemove', this._onMouseMove.bind(this), fal se); 72 this._canvas.addEventListener('mousemove', this._onMouseMove.bind(this), fal se);
73 this._canvas.addEventListener('mouseout', this._onMouseOut.bind(this), false ); 73 this._canvas.addEventListener('mouseout', this._onMouseOut.bind(this), false );
74 this._canvas.addEventListener('click', this._onClick.bind(this), false); 74 this._canvas.addEventListener('click', this._onClick.bind(this), false);
75 this._canvas.addEventListener('keydown', this._onKeyDown.bind(this), false); 75 this._canvas.addEventListener('keydown', this._onKeyDown.bind(this), false);
76 76
77 this._entryInfo = this.viewportElement.createChild('div', 'flame-chart-entry -info'); 77 this._entryInfo = this.viewportElement.createChild('div', 'flame-chart-entry -info');
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 136
137 _resetCanvas() { 137 _resetCanvas() {
138 var ratio = window.devicePixelRatio; 138 var ratio = window.devicePixelRatio;
139 this._canvas.width = this._offsetWidth * ratio; 139 this._canvas.width = this._offsetWidth * ratio;
140 this._canvas.height = this._offsetHeight * ratio; 140 this._canvas.height = this._offsetHeight * ratio;
141 this._canvas.style.width = this._offsetWidth + 'px'; 141 this._canvas.style.width = this._offsetWidth + 'px';
142 this._canvas.style.height = this._offsetHeight + 'px'; 142 this._canvas.style.height = this._offsetHeight + 'px';
143 } 143 }
144 144
145 /** 145 /**
146 * @return {?WebInspector.FlameChart.TimelineData} 146 * @return {?UI.FlameChart.TimelineData}
147 */ 147 */
148 _timelineData() { 148 _timelineData() {
149 if (!this._dataProvider) 149 if (!this._dataProvider)
150 return null; 150 return null;
151 var timelineData = this._dataProvider.timelineData(); 151 var timelineData = this._dataProvider.timelineData();
152 if (timelineData !== this._rawTimelineData || timelineData.entryStartTimes.l ength !== this._rawTimelineDataLength) 152 if (timelineData !== this._rawTimelineData || timelineData.entryStartTimes.l ength !== this._rawTimelineDataLength)
153 this._processTimelineData(timelineData); 153 this._processTimelineData(timelineData);
154 return this._rawTimelineData; 154 return this._rawTimelineData;
155 } 155 }
156 156
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return; 203 return;
204 if (this._coordinatesToGroupIndex(event.offsetX, event.offsetY) >= 0) { 204 if (this._coordinatesToGroupIndex(event.offsetX, event.offsetY) >= 0) {
205 this.hideHighlight(); 205 this.hideHighlight();
206 this.viewportElement.style.cursor = 'pointer'; 206 this.viewportElement.style.cursor = 'pointer';
207 return; 207 return;
208 } 208 }
209 this._updateHighlight(); 209 this._updateHighlight();
210 } 210 }
211 211
212 _updateHighlight() { 212 _updateHighlight() {
213 var inDividersBar = this._lastMouseOffsetY < WebInspector.FlameChart.Divider sBarHeight; 213 var inDividersBar = this._lastMouseOffsetY < UI.FlameChart.DividersBarHeight ;
214 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPosition(t his._lastMouseOffsetX) : -1; 214 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPosition(t his._lastMouseOffsetX) : -1;
215 this._updateMarkerHighlight(); 215 this._updateMarkerHighlight();
216 216
217 var entryIndex = this._coordinatesToEntryIndex(this._lastMouseOffsetX, this. _lastMouseOffsetY); 217 var entryIndex = this._coordinatesToEntryIndex(this._lastMouseOffsetX, this. _lastMouseOffsetY);
218 if (entryIndex === -1) { 218 if (entryIndex === -1) {
219 this.hideHighlight(); 219 this.hideHighlight();
220 return; 220 return;
221 } 221 }
222 if (this.isDragging()) 222 if (this.isDragging())
223 return; 223 return;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // we skip the click. Otherwise we jump to the sources. 281 // we skip the click. Otherwise we jump to the sources.
282 const clickThreshold = 5; 282 const clickThreshold = 5;
283 if (this.maxDragOffset() > clickThreshold) 283 if (this.maxDragOffset() > clickThreshold)
284 return; 284 return;
285 var groupIndex = this._coordinatesToGroupIndex(event.offsetX, event.offsetY) ; 285 var groupIndex = this._coordinatesToGroupIndex(event.offsetX, event.offsetY) ;
286 if (groupIndex >= 0) { 286 if (groupIndex >= 0) {
287 this._toggleGroupVisibility(groupIndex); 287 this._toggleGroupVisibility(groupIndex);
288 return; 288 return;
289 } 289 }
290 this.hideRangeSelection(); 290 this.hideRangeSelection();
291 this.dispatchEventToListeners(WebInspector.FlameChart.Events.EntrySelected, this._highlightedEntryIndex); 291 this.dispatchEventToListeners(UI.FlameChart.Events.EntrySelected, this._high lightedEntryIndex);
292 } 292 }
293 293
294 /** 294 /**
295 * @param {number} groupIndex 295 * @param {number} groupIndex
296 */ 296 */
297 _toggleGroupVisibility(groupIndex) { 297 _toggleGroupVisibility(groupIndex) {
298 if (!this._isGroupCollapsible(groupIndex)) 298 if (!this._isGroupCollapsible(groupIndex))
299 return; 299 return;
300 var groups = this._rawTimelineData.groups; 300 var groups = this._rawTimelineData.groups;
301 var group = groups[groupIndex]; 301 var group = groups[groupIndex];
(...skipping 21 matching lines...) Expand all
323 * @param {!Event} e 323 * @param {!Event} e
324 */ 324 */
325 _onKeyDown(e) { 325 _onKeyDown(e) {
326 this._handleSelectionNavigation(e); 326 this._handleSelectionNavigation(e);
327 } 327 }
328 328
329 /** 329 /**
330 * @param {!Event} e 330 * @param {!Event} e
331 */ 331 */
332 _handleSelectionNavigation(e) { 332 _handleSelectionNavigation(e) {
333 if (!WebInspector.KeyboardShortcut.hasNoModifiers(e)) 333 if (!UI.KeyboardShortcut.hasNoModifiers(e))
334 return; 334 return;
335 if (this._selectedEntryIndex === -1) 335 if (this._selectedEntryIndex === -1)
336 return; 336 return;
337 var timelineData = this._timelineData(); 337 var timelineData = this._timelineData();
338 if (!timelineData) 338 if (!timelineData)
339 return; 339 return;
340 340
341 /** 341 /**
342 * @param {number} time 342 * @param {number} time
343 * @param {number} entryIndex 343 * @param {number} entryIndex
344 * @return {number} 344 * @return {number}
345 */ 345 */
346 function timeComparator(time, entryIndex) { 346 function timeComparator(time, entryIndex) {
347 return time - timelineData.entryStartTimes[entryIndex]; 347 return time - timelineData.entryStartTimes[entryIndex];
348 } 348 }
349 349
350 /** 350 /**
351 * @param {number} entry1 351 * @param {number} entry1
352 * @param {number} entry2 352 * @param {number} entry2
353 * @return {boolean} 353 * @return {boolean}
354 */ 354 */
355 function entriesIntersect(entry1, entry2) { 355 function entriesIntersect(entry1, entry2) {
356 var start1 = timelineData.entryStartTimes[entry1]; 356 var start1 = timelineData.entryStartTimes[entry1];
357 var start2 = timelineData.entryStartTimes[entry2]; 357 var start2 = timelineData.entryStartTimes[entry2];
358 var end1 = start1 + timelineData.entryTotalTimes[entry1]; 358 var end1 = start1 + timelineData.entryTotalTimes[entry1];
359 var end2 = start2 + timelineData.entryTotalTimes[entry2]; 359 var end2 = start2 + timelineData.entryTotalTimes[entry2];
360 return start1 < end2 && start2 < end1; 360 return start1 < end2 && start2 < end1;
361 } 361 }
362 362
363 var keys = WebInspector.KeyboardShortcut.Keys; 363 var keys = UI.KeyboardShortcut.Keys;
364 if (e.keyCode === keys.Left.code || e.keyCode === keys.Right.code) { 364 if (e.keyCode === keys.Left.code || e.keyCode === keys.Right.code) {
365 var level = timelineData.entryLevels[this._selectedEntryIndex]; 365 var level = timelineData.entryLevels[this._selectedEntryIndex];
366 var levelIndexes = this._timelineLevels[level]; 366 var levelIndexes = this._timelineLevels[level];
367 var indexOnLevel = levelIndexes.lowerBound(this._selectedEntryIndex); 367 var indexOnLevel = levelIndexes.lowerBound(this._selectedEntryIndex);
368 indexOnLevel += e.keyCode === keys.Left.code ? -1 : 1; 368 indexOnLevel += e.keyCode === keys.Left.code ? -1 : 1;
369 e.consume(true); 369 e.consume(true);
370 if (indexOnLevel >= 0 && indexOnLevel < levelIndexes.length) 370 if (indexOnLevel >= 0 && indexOnLevel < levelIndexes.length)
371 this.dispatchEventToListeners(WebInspector.FlameChart.Events.EntrySelect ed, levelIndexes[indexOnLevel]); 371 this.dispatchEventToListeners(UI.FlameChart.Events.EntrySelected, levelI ndexes[indexOnLevel]);
372 return; 372 return;
373 } 373 }
374 if (e.keyCode === keys.Up.code || e.keyCode === keys.Down.code) { 374 if (e.keyCode === keys.Up.code || e.keyCode === keys.Down.code) {
375 e.consume(true); 375 e.consume(true);
376 var level = timelineData.entryLevels[this._selectedEntryIndex]; 376 var level = timelineData.entryLevels[this._selectedEntryIndex];
377 level += e.keyCode === keys.Up.code ? -1 : 1; 377 level += e.keyCode === keys.Up.code ? -1 : 1;
378 if (level < 0 || level >= this._timelineLevels.length) 378 if (level < 0 || level >= this._timelineLevels.length)
379 return; 379 return;
380 var entryTime = timelineData.entryStartTimes[this._selectedEntryIndex] + 380 var entryTime = timelineData.entryStartTimes[this._selectedEntryIndex] +
381 timelineData.entryTotalTimes[this._selectedEntryIndex] / 2; 381 timelineData.entryTotalTimes[this._selectedEntryIndex] / 2;
382 var levelIndexes = this._timelineLevels[level]; 382 var levelIndexes = this._timelineLevels[level];
383 var indexOnLevel = levelIndexes.upperBound(entryTime, timeComparator) - 1; 383 var indexOnLevel = levelIndexes.upperBound(entryTime, timeComparator) - 1;
384 if (!entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLevel] )) { 384 if (!entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLevel] )) {
385 ++indexOnLevel; 385 ++indexOnLevel;
386 if (indexOnLevel >= levelIndexes.length || 386 if (indexOnLevel >= levelIndexes.length ||
387 !entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLeve l])) 387 !entriesIntersect(this._selectedEntryIndex, levelIndexes[indexOnLeve l]))
388 return; 388 return;
389 } 389 }
390 this.dispatchEventToListeners(WebInspector.FlameChart.Events.EntrySelected , levelIndexes[indexOnLevel]); 390 this.dispatchEventToListeners(UI.FlameChart.Events.EntrySelected, levelInd exes[indexOnLevel]);
391 } 391 }
392 } 392 }
393 393
394 /** 394 /**
395 * @param {number} x 395 * @param {number} x
396 * @return {number} 396 * @return {number}
397 */ 397 */
398 _cursorTime(x) { 398 _cursorTime(x) {
399 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTime + this._minimumBoundary; 399 return (x + this._pixelWindowLeft - this._paddingLeft) * this._pixelToTime + this._minimumBoundary;
400 } 400 }
(...skipping 27 matching lines...) Expand all
428 * @param {number} time 428 * @param {number} time
429 * @param {number} entryIndex 429 * @param {number} entryIndex
430 * @return {number} 430 * @return {number}
431 */ 431 */
432 function comparator(time, entryIndex) { 432 function comparator(time, entryIndex) {
433 return time - entryStartTimes[entryIndex]; 433 return time - entryStartTimes[entryIndex];
434 } 434 }
435 var indexOnLevel = Math.max(entryIndexes.upperBound(cursorTime, comparator) - 1, 0); 435 var indexOnLevel = Math.max(entryIndexes.upperBound(cursorTime, comparator) - 1, 0);
436 436
437 /** 437 /**
438 * @this {WebInspector.FlameChart} 438 * @this {UI.FlameChart}
439 * @param {number} entryIndex 439 * @param {number} entryIndex
440 * @return {boolean} 440 * @return {boolean}
441 */ 441 */
442 function checkEntryHit(entryIndex) { 442 function checkEntryHit(entryIndex) {
443 if (entryIndex === undefined) 443 if (entryIndex === undefined)
444 return false; 444 return false;
445 var startTime = entryStartTimes[entryIndex]; 445 var startTime = entryStartTimes[entryIndex];
446 var duration = entryTotalTimes[entryIndex]; 446 var duration = entryTotalTimes[entryIndex];
447 if (isNaN(duration)) { 447 if (isNaN(duration)) {
448 var dx = (startTime - cursorTime) / this._pixelToTime; 448 var dx = (startTime - cursorTime) / this._pixelToTime;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 var timelineData = this._timelineData(); 531 var timelineData = this._timelineData();
532 if (!timelineData) 532 if (!timelineData)
533 return; 533 return;
534 534
535 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d')); 535 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d'));
536 context.save(); 536 context.save();
537 var ratio = window.devicePixelRatio; 537 var ratio = window.devicePixelRatio;
538 var top = this.scrollOffset(); 538 var top = this.scrollOffset();
539 context.scale(ratio, ratio); 539 context.scale(ratio, ratio);
540 context.translate(0, -top); 540 context.translate(0, -top);
541 var defaultFont = '11px ' + WebInspector.fontFamily(); 541 var defaultFont = '11px ' + Host.fontFamily();
542 context.font = defaultFont; 542 context.font = defaultFont;
543 543
544 var timeWindowRight = this._timeWindowRight; 544 var timeWindowRight = this._timeWindowRight;
545 var timeWindowLeft = this._timeWindowLeft - this._paddingLeft / this._timeTo Pixel; 545 var timeWindowLeft = this._timeWindowLeft - this._paddingLeft / this._timeTo Pixel;
546 var entryTotalTimes = timelineData.entryTotalTimes; 546 var entryTotalTimes = timelineData.entryTotalTimes;
547 var entryStartTimes = timelineData.entryStartTimes; 547 var entryStartTimes = timelineData.entryStartTimes;
548 var entryLevels = timelineData.entryLevels; 548 var entryLevels = timelineData.entryLevels;
549 549
550 var titleIndices = []; 550 var titleIndices = [];
551 var markerIndices = []; 551 var markerIndices = [];
552 var textPadding = this._dataProvider.textPadding(); 552 var textPadding = this._dataProvider.textPadding();
553 var minTextWidth = 2 * textPadding + WebInspector.measureTextWidth(context, '\u2026'); 553 var minTextWidth = 2 * textPadding + UI.measureTextWidth(context, '\u2026');
554 var barHeight = this._barHeight; 554 var barHeight = this._barHeight;
555 var minVisibleBarLevel = Math.max(this._visibleLevelOffsets.upperBound(top) - 1, 0); 555 var minVisibleBarLevel = Math.max(this._visibleLevelOffsets.upperBound(top) - 1, 0);
556 556
557 /** @type {!Map<string, !Array<number>>} */ 557 /** @type {!Map<string, !Array<number>>} */
558 var colorBuckets = new Map(); 558 var colorBuckets = new Map();
559 for (var level = minVisibleBarLevel; level < this._dataProvider.maxStackDept h(); ++level) { 559 for (var level = minVisibleBarLevel; level < this._dataProvider.maxStackDept h(); ++level) {
560 if (this._levelToHeight(level) > top + height) 560 if (this._levelToHeight(level) > top + height)
561 break; 561 break;
562 if (!this._visibleLevels[level]) 562 if (!this._visibleLevels[level])
563 continue; 563 continue;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 var entryIndex = titleIndices[i]; 639 var entryIndex = titleIndices[i];
640 var entryStartTime = entryStartTimes[entryIndex]; 640 var entryStartTime = entryStartTimes[entryIndex];
641 var barX = this._timeToPositionClipped(entryStartTime); 641 var barX = this._timeToPositionClipped(entryStartTime);
642 var barRight = Math.min(this._timeToPositionClipped(entryStartTime + entry TotalTimes[entryIndex]), width) + 1; 642 var barRight = Math.min(this._timeToPositionClipped(entryStartTime + entry TotalTimes[entryIndex]), width) + 1;
643 var barWidth = barRight - barX; 643 var barWidth = barRight - barX;
644 var barLevel = entryLevels[entryIndex]; 644 var barLevel = entryLevels[entryIndex];
645 var barY = this._levelToHeight(barLevel); 645 var barY = this._levelToHeight(barLevel);
646 var text = this._dataProvider.entryTitle(entryIndex); 646 var text = this._dataProvider.entryTitle(entryIndex);
647 if (text && text.length) { 647 if (text && text.length) {
648 context.font = this._dataProvider.entryFont(entryIndex) || defaultFont; 648 context.font = this._dataProvider.entryFont(entryIndex) || defaultFont;
649 text = WebInspector.trimTextMiddle(context, text, barWidth - 2 * textPad ding); 649 text = UI.trimTextMiddle(context, text, barWidth - 2 * textPadding);
650 } 650 }
651 var unclippedBarX = this._timeToPosition(entryStartTime); 651 var unclippedBarX = this._timeToPosition(entryStartTime);
652 if (this._dataProvider.decorateEntry( 652 if (this._dataProvider.decorateEntry(
653 entryIndex, context, text, barX, barY, barWidth, barHeight, unclip pedBarX, this._timeToPixel)) 653 entryIndex, context, text, barX, barY, barWidth, barHeight, unclip pedBarX, this._timeToPixel))
654 continue; 654 continue;
655 if (!text || !text.length) 655 if (!text || !text.length)
656 continue; 656 continue;
657 context.fillStyle = this._dataProvider.textColor(entryIndex); 657 context.fillStyle = this._dataProvider.textColor(entryIndex);
658 context.fillText(text, barX + textPadding, barY + textBaseHeight); 658 context.fillText(text, barX + textPadding, barY + textBaseHeight);
659 } 659 }
660 660
661 this._drawFlowEvents(context, width, height); 661 this._drawFlowEvents(context, width, height);
662 662
663 context.restore(); 663 context.restore();
664 664
665 WebInspector.TimelineGrid.drawCanvasGrid(context, this._calculator, 3); 665 UI.TimelineGrid.drawCanvasGrid(context, this._calculator, 3);
666 this._drawMarkers(); 666 this._drawMarkers();
667 this._drawGroupHeaders(width, height); 667 this._drawGroupHeaders(width, height);
668 668
669 this._updateElementPosition(this._highlightElement, this._highlightedEntryIn dex); 669 this._updateElementPosition(this._highlightElement, this._highlightedEntryIn dex);
670 this._updateElementPosition(this._selectedElement, this._selectedEntryIndex) ; 670 this._updateElementPosition(this._selectedElement, this._selectedEntryIndex) ;
671 this._updateMarkerHighlight(); 671 this._updateMarkerHighlight();
672 } 672 }
673 673
674 /** 674 /**
675 * @param {number} width 675 * @param {number} width
676 * @param {number} height 676 * @param {number} height
677 */ 677 */
678 _drawGroupHeaders(width, height) { 678 _drawGroupHeaders(width, height) {
679 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d')); 679 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d'));
680 var top = this.scrollOffset(); 680 var top = this.scrollOffset();
681 var ratio = window.devicePixelRatio; 681 var ratio = window.devicePixelRatio;
682 var barHeight = this._barHeight; 682 var barHeight = this._barHeight;
683 var textBaseHeight = barHeight - this._dataProvider.textBaseline(); 683 var textBaseHeight = barHeight - this._dataProvider.textBaseline();
684 var groups = this._rawTimelineData.groups || []; 684 var groups = this._rawTimelineData.groups || [];
685 if (!groups.length) 685 if (!groups.length)
686 return; 686 return;
687 687
688 var groupOffsets = this._groupOffsets; 688 var groupOffsets = this._groupOffsets;
689 var lastGroupOffset = Array.prototype.peekLast.call(groupOffsets); 689 var lastGroupOffset = Array.prototype.peekLast.call(groupOffsets);
690 var colorUsage = WebInspector.ThemeSupport.ColorUsage; 690 var colorUsage = UI.ThemeSupport.ColorUsage;
691 691
692 context.save(); 692 context.save();
693 context.scale(ratio, ratio); 693 context.scale(ratio, ratio);
694 context.translate(0, -top); 694 context.translate(0, -top);
695 695
696 context.fillStyle = WebInspector.themeSupport.patchColor('#eee', colorUsage. Background); 696 context.fillStyle = UI.themeSupport.patchColor('#eee', colorUsage.Background );
697 forEachGroup.call(this, (offset, index, group) => { 697 forEachGroup.call(this, (offset, index, group) => {
698 var paddingHeight = group.style.padding; 698 var paddingHeight = group.style.padding;
699 if (paddingHeight < 5) 699 if (paddingHeight < 5)
700 return; 700 return;
701 context.fillRect(0, offset - paddingHeight + 2, width, paddingHeight - 4); 701 context.fillRect(0, offset - paddingHeight + 2, width, paddingHeight - 4);
702 }); 702 });
703 if (groups.length && lastGroupOffset < top + height) 703 if (groups.length && lastGroupOffset < top + height)
704 context.fillRect(0, lastGroupOffset + 2, width, top + height - lastGroupOf fset); 704 context.fillRect(0, lastGroupOffset + 2, width, top + height - lastGroupOf fset);
705 705
706 context.strokeStyle = WebInspector.themeSupport.patchColor('#bbb', colorUsag e.Background); 706 context.strokeStyle = UI.themeSupport.patchColor('#bbb', colorUsage.Backgrou nd);
707 context.beginPath(); 707 context.beginPath();
708 forEachGroup.call(this, (offset, index, group, isFirst) => { 708 forEachGroup.call(this, (offset, index, group, isFirst) => {
709 if (isFirst || group.style.padding < 4) 709 if (isFirst || group.style.padding < 4)
710 return; 710 return;
711 hLine(offset - 2.5); 711 hLine(offset - 2.5);
712 }); 712 });
713 hLine(lastGroupOffset + 0.5); 713 hLine(lastGroupOffset + 0.5);
714 context.stroke(); 714 context.stroke();
715 715
716 forEachGroup.call(this, (offset, index, group) => { 716 forEachGroup.call(this, (offset, index, group) => {
(...skipping 11 matching lines...) Expand all
728 nextGroup++; 728 nextGroup++;
729 var endLevel = nextGroup < groups.length ? groups[nextGroup].startLevel : this._dataProvider.maxStackDepth(); 729 var endLevel = nextGroup < groups.length ? groups[nextGroup].startLevel : this._dataProvider.maxStackDepth();
730 this._drawCollapsedOverviewForGroup(offset + 1, group.startLevel, endLevel ); 730 this._drawCollapsedOverviewForGroup(offset + 1, group.startLevel, endLevel );
731 }); 731 });
732 732
733 context.save(); 733 context.save();
734 forEachGroup.call(this, (offset, index, group) => { 734 forEachGroup.call(this, (offset, index, group) => {
735 context.font = group.style.font; 735 context.font = group.style.font;
736 if (this._isGroupCollapsible(index) && !group.expanded || group.style.shar eHeaderLine) { 736 if (this._isGroupCollapsible(index) && !group.expanded || group.style.shar eHeaderLine) {
737 var width = this._labelWidthForGroup(context, group); 737 var width = this._labelWidthForGroup(context, group);
738 context.fillStyle = WebInspector.Color.parse(group.style.backgroundColor ).setAlpha(0.7).asString(null); 738 context.fillStyle = Common.Color.parse(group.style.backgroundColor).setA lpha(0.7).asString(null);
739 context.fillRect( 739 context.fillRect(
740 this._headerLeftPadding - this._headerLabelXPadding, offset + this._ headerLabelYPadding, width, 740 this._headerLeftPadding - this._headerLabelXPadding, offset + this._ headerLabelYPadding, width,
741 barHeight - 2 * this._headerLabelYPadding); 741 barHeight - 2 * this._headerLabelYPadding);
742 } 742 }
743 context.fillStyle = group.style.color; 743 context.fillStyle = group.style.color;
744 context.fillText( 744 context.fillText(
745 group.name, Math.floor(this._expansionArrowIndent * (group.style.nesti ngLevel + 1) + this._arrowSide), 745 group.name, Math.floor(this._expansionArrowIndent * (group.style.nesti ngLevel + 1) + this._arrowSide),
746 offset + textBaseHeight); 746 offset + textBaseHeight);
747 }); 747 });
748 context.restore(); 748 context.restore();
749 749
750 context.fillStyle = WebInspector.themeSupport.patchColor('#6e6e6e', colorUsa ge.Foreground); 750 context.fillStyle = UI.themeSupport.patchColor('#6e6e6e', colorUsage.Foregro und);
751 context.beginPath(); 751 context.beginPath();
752 forEachGroup.call(this, (offset, index, group) => { 752 forEachGroup.call(this, (offset, index, group) => {
753 if (this._isGroupCollapsible(index)) 753 if (this._isGroupCollapsible(index))
754 drawExpansionArrow.call( 754 drawExpansionArrow.call(
755 this, this._expansionArrowIndent * (group.style.nestingLevel + 1), 755 this, this._expansionArrowIndent * (group.style.nestingLevel + 1),
756 offset + textBaseHeight - this._arrowSide / 2, !!group.expanded); 756 offset + textBaseHeight - this._arrowSide / 2, !!group.expanded);
757 }); 757 });
758 context.fill(); 758 context.fill();
759 759
760 context.strokeStyle = WebInspector.themeSupport.patchColor('#ddd', colorUsag e.Background); 760 context.strokeStyle = UI.themeSupport.patchColor('#ddd', colorUsage.Backgrou nd);
761 context.beginPath(); 761 context.beginPath();
762 context.stroke(); 762 context.stroke();
763 763
764 context.restore(); 764 context.restore();
765 765
766 /** 766 /**
767 * @param {number} y 767 * @param {number} y
768 */ 768 */
769 function hLine(y) { 769 function hLine(y) {
770 context.moveTo(0, y); 770 context.moveTo(0, y);
771 context.lineTo(width, y); 771 context.lineTo(width, y);
772 } 772 }
773 773
774 /** 774 /**
775 * @param {number} x 775 * @param {number} x
776 * @param {number} y 776 * @param {number} y
777 * @param {boolean} expanded 777 * @param {boolean} expanded
778 * @this {WebInspector.FlameChart} 778 * @this {UI.FlameChart}
779 */ 779 */
780 function drawExpansionArrow(x, y, expanded) { 780 function drawExpansionArrow(x, y, expanded) {
781 var arrowHeight = this._arrowSide * Math.sqrt(3) / 2; 781 var arrowHeight = this._arrowSide * Math.sqrt(3) / 2;
782 var arrowCenterOffset = Math.round(arrowHeight / 2); 782 var arrowCenterOffset = Math.round(arrowHeight / 2);
783 context.save(); 783 context.save();
784 context.translate(x, y); 784 context.translate(x, y);
785 context.rotate(expanded ? Math.PI / 2 : 0); 785 context.rotate(expanded ? Math.PI / 2 : 0);
786 context.moveTo(-arrowCenterOffset, -this._arrowSide / 2); 786 context.moveTo(-arrowCenterOffset, -this._arrowSide / 2);
787 context.lineTo(-arrowCenterOffset, this._arrowSide / 2); 787 context.lineTo(-arrowCenterOffset, this._arrowSide / 2);
788 context.lineTo(arrowHeight - arrowCenterOffset, 0); 788 context.lineTo(arrowHeight - arrowCenterOffset, 0);
789 context.restore(); 789 context.restore();
790 } 790 }
791 791
792 /** 792 /**
793 * @param {function(number, number, !WebInspector.FlameChart.Group, boolean) } callback 793 * @param {function(number, number, !UI.FlameChart.Group, boolean)} callback
794 * @this {WebInspector.FlameChart} 794 * @this {UI.FlameChart}
795 */ 795 */
796 function forEachGroup(callback) { 796 function forEachGroup(callback) {
797 /** @type !Array<{nestingLevel: number, visible: boolean}> */ 797 /** @type !Array<{nestingLevel: number, visible: boolean}> */
798 var groupStack = [{nestingLevel: -1, visible: true}]; 798 var groupStack = [{nestingLevel: -1, visible: true}];
799 for (var i = 0; i < groups.length; ++i) { 799 for (var i = 0; i < groups.length; ++i) {
800 var groupTop = groupOffsets[i]; 800 var groupTop = groupOffsets[i];
801 var group = groups[i]; 801 var group = groups[i];
802 if (groupTop - group.style.padding > top + height) 802 if (groupTop - group.style.padding > top + height)
803 break; 803 break;
804 var firstGroup = true; 804 var firstGroup = true;
805 while (groupStack.peekLast().nestingLevel >= group.style.nestingLevel) { 805 while (groupStack.peekLast().nestingLevel >= group.style.nestingLevel) {
806 groupStack.pop(); 806 groupStack.pop();
807 firstGroup = false; 807 firstGroup = false;
808 } 808 }
809 var parentGroupVisible = groupStack.peekLast().visible; 809 var parentGroupVisible = groupStack.peekLast().visible;
810 var thisGroupVisible = parentGroupVisible && (!this._isGroupCollapsible( i) || group.expanded); 810 var thisGroupVisible = parentGroupVisible && (!this._isGroupCollapsible( i) || group.expanded);
811 groupStack.push({nestingLevel: group.style.nestingLevel, visible: thisGr oupVisible}); 811 groupStack.push({nestingLevel: group.style.nestingLevel, visible: thisGr oupVisible});
812 if (!parentGroupVisible || groupTop + group.style.height < top) 812 if (!parentGroupVisible || groupTop + group.style.height < top)
813 continue; 813 continue;
814 callback(groupTop, i, group, firstGroup); 814 callback(groupTop, i, group, firstGroup);
815 } 815 }
816 } 816 }
817 } 817 }
818 818
819 /** 819 /**
820 * @param {!CanvasRenderingContext2D} context 820 * @param {!CanvasRenderingContext2D} context
821 * @param {!WebInspector.FlameChart.Group} group 821 * @param {!UI.FlameChart.Group} group
822 * @return {number} 822 * @return {number}
823 */ 823 */
824 _labelWidthForGroup(context, group) { 824 _labelWidthForGroup(context, group) {
825 return WebInspector.measureTextWidth(context, group.name) + this._expansionA rrowIndent * (group.style.nestingLevel + 1) + 825 return UI.measureTextWidth(context, group.name) + this._expansionArrowIndent * (group.style.nestingLevel + 1) +
826 2 * this._headerLabelXPadding; 826 2 * this._headerLabelXPadding;
827 } 827 }
828 828
829 /** 829 /**
830 * @param {number} y 830 * @param {number} y
831 * @param {number} startLevel 831 * @param {number} startLevel
832 * @param {number} endLevel 832 * @param {number} endLevel
833 */ 833 */
834 _drawCollapsedOverviewForGroup(y, startLevel, endLevel) { 834 _drawCollapsedOverviewForGroup(y, startLevel, endLevel) {
835 var range = new WebInspector.SegmentedRange(mergeCallback); 835 var range = new Common.SegmentedRange(mergeCallback);
836 var timeWindowRight = this._timeWindowRight; 836 var timeWindowRight = this._timeWindowRight;
837 var timeWindowLeft = this._timeWindowLeft - this._paddingLeft / this._timeTo Pixel; 837 var timeWindowLeft = this._timeWindowLeft - this._paddingLeft / this._timeTo Pixel;
838 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d')); 838 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d'));
839 var barHeight = this._barHeight - 2; 839 var barHeight = this._barHeight - 2;
840 var entryStartTimes = this._rawTimelineData.entryStartTimes; 840 var entryStartTimes = this._rawTimelineData.entryStartTimes;
841 var entryTotalTimes = this._rawTimelineData.entryTotalTimes; 841 var entryTotalTimes = this._rawTimelineData.entryTotalTimes;
842 842
843 for (var level = startLevel; level < endLevel; ++level) { 843 for (var level = startLevel; level < endLevel; ++level) {
844 var levelIndexes = this._timelineLevels[level]; 844 var levelIndexes = this._timelineLevels[level];
845 var rightIndexOnLevel = 845 var rightIndexOnLevel =
846 levelIndexes.lowerBound(timeWindowRight, (time, entryIndex) => time - entryStartTimes[entryIndex]) - 1; 846 levelIndexes.lowerBound(timeWindowRight, (time, entryIndex) => time - entryStartTimes[entryIndex]) - 1;
847 var lastDrawOffset = Infinity; 847 var lastDrawOffset = Infinity;
848 848
849 for (var entryIndexOnLevel = rightIndexOnLevel; entryIndexOnLevel >= 0; -- entryIndexOnLevel) { 849 for (var entryIndexOnLevel = rightIndexOnLevel; entryIndexOnLevel >= 0; -- entryIndexOnLevel) {
850 var entryIndex = levelIndexes[entryIndexOnLevel]; 850 var entryIndex = levelIndexes[entryIndexOnLevel];
851 var entryStartTime = entryStartTimes[entryIndex]; 851 var entryStartTime = entryStartTimes[entryIndex];
852 var startPosition = this._timeToPositionClipped(entryStartTime); 852 var startPosition = this._timeToPositionClipped(entryStartTime);
853 var entryEndTime = entryStartTime + entryTotalTimes[entryIndex]; 853 var entryEndTime = entryStartTime + entryTotalTimes[entryIndex];
854 if (isNaN(entryEndTime) || startPosition >= lastDrawOffset) 854 if (isNaN(entryEndTime) || startPosition >= lastDrawOffset)
855 continue; 855 continue;
856 if (entryEndTime <= timeWindowLeft) 856 if (entryEndTime <= timeWindowLeft)
857 break; 857 break;
858 lastDrawOffset = startPosition; 858 lastDrawOffset = startPosition;
859 var color = this._dataProvider.entryColor(entryIndex); 859 var color = this._dataProvider.entryColor(entryIndex);
860 range.append(new WebInspector.Segment(startPosition, this._timeToPositio nClipped(entryEndTime), color)); 860 range.append(new Common.Segment(startPosition, this._timeToPositionClipp ed(entryEndTime), color));
861 } 861 }
862 } 862 }
863 863
864 var segments = range.segments().slice().sort((a, b) => a.data.localeCompare( b.data)); 864 var segments = range.segments().slice().sort((a, b) => a.data.localeCompare( b.data));
865 var lastColor; 865 var lastColor;
866 context.beginPath(); 866 context.beginPath();
867 for (var i = 0; i < segments.length; ++i) { 867 for (var i = 0; i < segments.length; ++i) {
868 var segment = segments[i]; 868 var segment = segments[i];
869 if (lastColor !== segments[i].data) { 869 if (lastColor !== segments[i].data) {
870 context.fill(); 870 context.fill();
871 context.beginPath(); 871 context.beginPath();
872 lastColor = segments[i].data; 872 lastColor = segments[i].data;
873 context.fillStyle = lastColor; 873 context.fillStyle = lastColor;
874 } 874 }
875 context.rect(segment.begin, y, segment.end - segment.begin, barHeight); 875 context.rect(segment.begin, y, segment.end - segment.begin, barHeight);
876 } 876 }
877 context.fill(); 877 context.fill();
878 878
879 /** 879 /**
880 * @param {!WebInspector.Segment} a 880 * @param {!Common.Segment} a
881 * @param {!WebInspector.Segment} b 881 * @param {!Common.Segment} b
882 * @return {?WebInspector.Segment} 882 * @return {?Common.Segment}
883 */ 883 */
884 function mergeCallback(a, b) { 884 function mergeCallback(a, b) {
885 return a.data === b.data && a.end + 0.4 > b.end ? a : null; 885 return a.data === b.data && a.end + 0.4 > b.end ? a : null;
886 } 886 }
887 } 887 }
888 888
889 /** 889 /**
890 * @param {!CanvasRenderingContext2D} context 890 * @param {!CanvasRenderingContext2D} context
891 * @param {number} height 891 * @param {number} height
892 * @param {number} width 892 * @param {number} width
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 937
938 _drawMarkers() { 938 _drawMarkers() {
939 var markers = this._timelineData().markers; 939 var markers = this._timelineData().markers;
940 var left = this._markerIndexBeforeTime(this._calculator.minimumBoundary()); 940 var left = this._markerIndexBeforeTime(this._calculator.minimumBoundary());
941 var rightBoundary = this._calculator.maximumBoundary(); 941 var rightBoundary = this._calculator.maximumBoundary();
942 942
943 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d')); 943 var context = /** @type {!CanvasRenderingContext2D} */ (this._canvas.getCont ext('2d'));
944 context.save(); 944 context.save();
945 var ratio = window.devicePixelRatio; 945 var ratio = window.devicePixelRatio;
946 context.scale(ratio, ratio); 946 context.scale(ratio, ratio);
947 var height = WebInspector.FlameChart.DividersBarHeight - 1; 947 var height = UI.FlameChart.DividersBarHeight - 1;
948 for (var i = left; i < markers.length; i++) { 948 for (var i = left; i < markers.length; i++) {
949 var timestamp = markers[i].startTime(); 949 var timestamp = markers[i].startTime();
950 if (timestamp > rightBoundary) 950 if (timestamp > rightBoundary)
951 break; 951 break;
952 markers[i].draw(context, this._calculator.computePosition(timestamp), heig ht, this._timeToPixel); 952 markers[i].draw(context, this._calculator.computePosition(timestamp), heig ht, this._timeToPixel);
953 } 953 }
954 context.restore(); 954 context.restore();
955 } 955 }
956 956
957 _updateMarkerHighlight() { 957 _updateMarkerHighlight() {
958 var element = this._markerHighlighElement; 958 var element = this._markerHighlighElement;
959 if (element.parentElement) 959 if (element.parentElement)
960 element.remove(); 960 element.remove();
961 var markerIndex = this._highlightedMarkerIndex; 961 var markerIndex = this._highlightedMarkerIndex;
962 if (markerIndex === -1) 962 if (markerIndex === -1)
963 return; 963 return;
964 var marker = this._timelineData().markers[markerIndex]; 964 var marker = this._timelineData().markers[markerIndex];
965 var barX = this._timeToPositionClipped(marker.startTime()); 965 var barX = this._timeToPositionClipped(marker.startTime());
966 element.title = marker.title(); 966 element.title = marker.title();
967 var style = element.style; 967 var style = element.style;
968 style.left = barX + 'px'; 968 style.left = barX + 'px';
969 style.backgroundColor = marker.color(); 969 style.backgroundColor = marker.color();
970 this.viewportElement.appendChild(element); 970 this.viewportElement.appendChild(element);
971 } 971 }
972 972
973 /** 973 /**
974 * @param {?WebInspector.FlameChart.TimelineData} timelineData 974 * @param {?UI.FlameChart.TimelineData} timelineData
975 */ 975 */
976 _processTimelineData(timelineData) { 976 _processTimelineData(timelineData) {
977 if (!timelineData) { 977 if (!timelineData) {
978 this._timelineLevels = null; 978 this._timelineLevels = null;
979 this._visibleLevelOffsets = null; 979 this._visibleLevelOffsets = null;
980 this._visibleLevels = null; 980 this._visibleLevels = null;
981 this._groupOffsets = null; 981 this._groupOffsets = null;
982 this._rawTimelineData = null; 982 this._rawTimelineData = null;
983 this._rawTimelineDataLength = 0; 983 this._rawTimelineDataLength = 0;
984 return; 984 return;
(...skipping 26 matching lines...) Expand all
1011 } 1011 }
1012 1012
1013 _updateLevelPositions() { 1013 _updateLevelPositions() {
1014 var levelCount = this._dataProvider.maxStackDepth(); 1014 var levelCount = this._dataProvider.maxStackDepth();
1015 var groups = this._rawTimelineData.groups || []; 1015 var groups = this._rawTimelineData.groups || [];
1016 this._visibleLevelOffsets = new Uint32Array(levelCount + 1); 1016 this._visibleLevelOffsets = new Uint32Array(levelCount + 1);
1017 this._visibleLevels = new Uint16Array(levelCount); 1017 this._visibleLevels = new Uint16Array(levelCount);
1018 this._groupOffsets = new Uint32Array(groups.length + 1); 1018 this._groupOffsets = new Uint32Array(groups.length + 1);
1019 1019
1020 var groupIndex = -1; 1020 var groupIndex = -1;
1021 var currentOffset = WebInspector.FlameChart.DividersBarHeight; 1021 var currentOffset = UI.FlameChart.DividersBarHeight;
1022 var visible = true; 1022 var visible = true;
1023 /** @type !Array<{nestingLevel: number, visible: boolean}> */ 1023 /** @type !Array<{nestingLevel: number, visible: boolean}> */
1024 var groupStack = [{nestingLevel: -1, visible: true}]; 1024 var groupStack = [{nestingLevel: -1, visible: true}];
1025 for (var level = 0; level < levelCount; ++level) { 1025 for (var level = 0; level < levelCount; ++level) {
1026 while (groupIndex < groups.length - 1 && level === groups[groupIndex + 1]. startLevel) { 1026 while (groupIndex < groups.length - 1 && level === groups[groupIndex + 1]. startLevel) {
1027 ++groupIndex; 1027 ++groupIndex;
1028 var style = groups[groupIndex].style; 1028 var style = groups[groupIndex].style;
1029 var nextLevel = true; 1029 var nextLevel = true;
1030 while (groupStack.peekLast().nestingLevel >= style.nestingLevel) { 1030 while (groupStack.peekLast().nestingLevel >= style.nestingLevel) {
1031 groupStack.pop(); 1031 groupStack.pop();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 /** @type {!Map<string,!Map<string,number>>} */ 1200 /** @type {!Map<string,!Map<string,number>>} */
1201 this._textWidth = new Map(); 1201 this._textWidth = new Map();
1202 this.update(); 1202 this.update();
1203 } 1203 }
1204 1204
1205 _enabled() { 1205 _enabled() {
1206 return this._rawTimelineDataLength !== 0; 1206 return this._rawTimelineDataLength !== 0;
1207 } 1207 }
1208 }; 1208 };
1209 1209
1210 WebInspector.FlameChart.DividersBarHeight = 18; 1210 UI.FlameChart.DividersBarHeight = 18;
1211 1211
1212 WebInspector.FlameChart.MinimalTimeWindowMs = 0.5; 1212 UI.FlameChart.MinimalTimeWindowMs = 0.5;
1213 1213
1214 /** 1214 /**
1215 * @interface 1215 * @interface
1216 */ 1216 */
1217 WebInspector.FlameChartDataProvider = function() {}; 1217 UI.FlameChartDataProvider = function() {};
1218 1218
1219 /** 1219 /**
1220 * @typedef {!{name: string, startLevel: number, expanded: (boolean|undefined), style: !WebInspector.FlameChart.GroupStyle}} 1220 * @typedef {!{name: string, startLevel: number, expanded: (boolean|undefined), style: !UI.FlameChart.GroupStyle}}
1221 */ 1221 */
1222 WebInspector.FlameChart.Group; 1222 UI.FlameChart.Group;
1223 1223
1224 /** 1224 /**
1225 * @typedef {!{ 1225 * @typedef {!{
1226 * height: number, 1226 * height: number,
1227 * padding: number, 1227 * padding: number,
1228 * collapsible: boolean, 1228 * collapsible: boolean,
1229 * font: string, 1229 * font: string,
1230 * color: string, 1230 * color: string,
1231 * backgroundColor: string, 1231 * backgroundColor: string,
1232 * nestingLevel: number, 1232 * nestingLevel: number,
1233 * shareHeaderLine: (boolean|undefined), 1233 * shareHeaderLine: (boolean|undefined),
1234 * useFirstLineForOverview: (boolean|undefined) 1234 * useFirstLineForOverview: (boolean|undefined)
1235 * }} 1235 * }}
1236 */ 1236 */
1237 WebInspector.FlameChart.GroupStyle; 1237 UI.FlameChart.GroupStyle;
1238 1238
1239 /** 1239 /**
1240 * @unrestricted 1240 * @unrestricted
1241 */ 1241 */
1242 WebInspector.FlameChart.TimelineData = class { 1242 UI.FlameChart.TimelineData = class {
1243 /** 1243 /**
1244 * @param {!Array<number>|!Uint16Array} entryLevels 1244 * @param {!Array<number>|!Uint16Array} entryLevels
1245 * @param {!Array<number>|!Float32Array} entryTotalTimes 1245 * @param {!Array<number>|!Float32Array} entryTotalTimes
1246 * @param {!Array<number>|!Float64Array} entryStartTimes 1246 * @param {!Array<number>|!Float64Array} entryStartTimes
1247 * @param {?Array<!WebInspector.FlameChart.Group>} groups 1247 * @param {?Array<!UI.FlameChart.Group>} groups
1248 */ 1248 */
1249 constructor(entryLevels, entryTotalTimes, entryStartTimes, groups) { 1249 constructor(entryLevels, entryTotalTimes, entryStartTimes, groups) {
1250 this.entryLevels = entryLevels; 1250 this.entryLevels = entryLevels;
1251 this.entryTotalTimes = entryTotalTimes; 1251 this.entryTotalTimes = entryTotalTimes;
1252 this.entryStartTimes = entryStartTimes; 1252 this.entryStartTimes = entryStartTimes;
1253 this.groups = groups; 1253 this.groups = groups;
1254 /** @type {!Array.<!WebInspector.FlameChartMarker>} */ 1254 /** @type {!Array.<!UI.FlameChartMarker>} */
1255 this.markers = []; 1255 this.markers = [];
1256 this.flowStartTimes = []; 1256 this.flowStartTimes = [];
1257 this.flowStartLevels = []; 1257 this.flowStartLevels = [];
1258 this.flowEndTimes = []; 1258 this.flowEndTimes = [];
1259 this.flowEndLevels = []; 1259 this.flowEndLevels = [];
1260 } 1260 }
1261 }; 1261 };
1262 1262
1263 WebInspector.FlameChartDataProvider.prototype = { 1263 UI.FlameChartDataProvider.prototype = {
1264 /** 1264 /**
1265 * @return {number} 1265 * @return {number}
1266 */ 1266 */
1267 barHeight: function() {}, 1267 barHeight: function() {},
1268 1268
1269 /** 1269 /**
1270 * @return {number} 1270 * @return {number}
1271 */ 1271 */
1272 minimumBoundary: function() {}, 1272 minimumBoundary: function() {},
1273 1273
1274 /** 1274 /**
1275 * @return {number} 1275 * @return {number}
1276 */ 1276 */
1277 totalTime: function() {}, 1277 totalTime: function() {},
1278 1278
1279 /** 1279 /**
1280 * @param {number} value 1280 * @param {number} value
1281 * @param {number=} precision 1281 * @param {number=} precision
1282 * @return {string} 1282 * @return {string}
1283 */ 1283 */
1284 formatValue: function(value, precision) {}, 1284 formatValue: function(value, precision) {},
1285 1285
1286 /** 1286 /**
1287 * @return {number} 1287 * @return {number}
1288 */ 1288 */
1289 maxStackDepth: function() {}, 1289 maxStackDepth: function() {},
1290 1290
1291 /** 1291 /**
1292 * @return {?WebInspector.FlameChart.TimelineData} 1292 * @return {?UI.FlameChart.TimelineData}
1293 */ 1293 */
1294 timelineData: function() {}, 1294 timelineData: function() {},
1295 1295
1296 /** 1296 /**
1297 * @param {number} entryIndex 1297 * @param {number} entryIndex
1298 * @return {?Element} 1298 * @return {?Element}
1299 */ 1299 */
1300 prepareHighlightedEntryInfo: function(entryIndex) {}, 1300 prepareHighlightedEntryInfo: function(entryIndex) {},
1301 1301
1302 /** 1302 /**
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 1361
1362 /** 1362 /**
1363 * @return {number} 1363 * @return {number}
1364 */ 1364 */
1365 paddingLeft: function() {}, 1365 paddingLeft: function() {},
1366 }; 1366 };
1367 1367
1368 /** 1368 /**
1369 * @interface 1369 * @interface
1370 */ 1370 */
1371 WebInspector.FlameChartMarker = function() {}; 1371 UI.FlameChartMarker = function() {};
1372 1372
1373 WebInspector.FlameChartMarker.prototype = { 1373 UI.FlameChartMarker.prototype = {
1374 /** 1374 /**
1375 * @return {number} 1375 * @return {number}
1376 */ 1376 */
1377 startTime: function() {}, 1377 startTime: function() {},
1378 1378
1379 /** 1379 /**
1380 * @return {string} 1380 * @return {string}
1381 */ 1381 */
1382 color: function() {}, 1382 color: function() {},
1383 1383
1384 /** 1384 /**
1385 * @return {string} 1385 * @return {string}
1386 */ 1386 */
1387 title: function() {}, 1387 title: function() {},
1388 1388
1389 /** 1389 /**
1390 * @param {!CanvasRenderingContext2D} context 1390 * @param {!CanvasRenderingContext2D} context
1391 * @param {number} x 1391 * @param {number} x
1392 * @param {number} height 1392 * @param {number} height
1393 * @param {number} pixelsPerMillisecond 1393 * @param {number} pixelsPerMillisecond
1394 */ 1394 */
1395 draw: function(context, x, height, pixelsPerMillisecond) {}, 1395 draw: function(context, x, height, pixelsPerMillisecond) {},
1396 }; 1396 };
1397 1397
1398 /** @enum {symbol} */ 1398 /** @enum {symbol} */
1399 WebInspector.FlameChart.Events = { 1399 UI.FlameChart.Events = {
1400 EntrySelected: Symbol('EntrySelected') 1400 EntrySelected: Symbol('EntrySelected')
1401 }; 1401 };
1402 1402
1403 /** 1403 /**
1404 * @unrestricted 1404 * @unrestricted
1405 */ 1405 */
1406 WebInspector.FlameChart.ColorGenerator = class { 1406 UI.FlameChart.ColorGenerator = class {
1407 /** 1407 /**
1408 * @param {!{min: number, max: number}|number=} hueSpace 1408 * @param {!{min: number, max: number}|number=} hueSpace
1409 * @param {!{min: number, max: number, count: (number|undefined)}|number=} sat Space 1409 * @param {!{min: number, max: number, count: (number|undefined)}|number=} sat Space
1410 * @param {!{min: number, max: number, count: (number|undefined)}|number=} lig htnessSpace 1410 * @param {!{min: number, max: number, count: (number|undefined)}|number=} lig htnessSpace
1411 * @param {!{min: number, max: number, count: (number|undefined)}|number=} alp haSpace 1411 * @param {!{min: number, max: number, count: (number|undefined)}|number=} alp haSpace
1412 */ 1412 */
1413 constructor(hueSpace, satSpace, lightnessSpace, alphaSpace) { 1413 constructor(hueSpace, satSpace, lightnessSpace, alphaSpace) {
1414 this._hueSpace = hueSpace || {min: 0, max: 360}; 1414 this._hueSpace = hueSpace || {min: 0, max: 360};
1415 this._satSpace = satSpace || 67; 1415 this._satSpace = satSpace || 67;
1416 this._lightnessSpace = lightnessSpace || 80; 1416 this._lightnessSpace = lightnessSpace || 80;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1461 _indexToValueInSpace(index, space) { 1461 _indexToValueInSpace(index, space) {
1462 if (typeof space === 'number') 1462 if (typeof space === 'number')
1463 return space; 1463 return space;
1464 var count = space.count || space.max - space.min; 1464 var count = space.count || space.max - space.min;
1465 index %= count; 1465 index %= count;
1466 return space.min + Math.floor(index / (count - 1) * (space.max - space.min)) ; 1466 return space.min + Math.floor(index / (count - 1) * (space.max - space.min)) ;
1467 } 1467 }
1468 }; 1468 };
1469 1469
1470 /** 1470 /**
1471 * @implements {WebInspector.TimelineGrid.Calculator} 1471 * @implements {UI.TimelineGrid.Calculator}
1472 * @unrestricted 1472 * @unrestricted
1473 */ 1473 */
1474 WebInspector.FlameChart.Calculator = class { 1474 UI.FlameChart.Calculator = class {
1475 /** 1475 /**
1476 * @param {!WebInspector.FlameChartDataProvider} dataProvider 1476 * @param {!UI.FlameChartDataProvider} dataProvider
1477 */ 1477 */
1478 constructor(dataProvider) { 1478 constructor(dataProvider) {
1479 this._dataProvider = dataProvider; 1479 this._dataProvider = dataProvider;
1480 this._paddingLeft = 0; 1480 this._paddingLeft = 0;
1481 } 1481 }
1482 1482
1483 /** 1483 /**
1484 * @override 1484 * @override
1485 * @return {number} 1485 * @return {number}
1486 */ 1486 */
1487 paddingLeft() { 1487 paddingLeft() {
1488 return this._paddingLeft; 1488 return this._paddingLeft;
1489 } 1489 }
1490 1490
1491 /** 1491 /**
1492 * @param {!WebInspector.FlameChart} mainPane 1492 * @param {!UI.FlameChart} mainPane
1493 */ 1493 */
1494 _updateBoundaries(mainPane) { 1494 _updateBoundaries(mainPane) {
1495 this._totalTime = mainPane._dataProvider.totalTime(); 1495 this._totalTime = mainPane._dataProvider.totalTime();
1496 this._zeroTime = mainPane._dataProvider.minimumBoundary(); 1496 this._zeroTime = mainPane._dataProvider.minimumBoundary();
1497 this._minimumBoundaries = this._zeroTime + mainPane._windowLeft * this._tota lTime; 1497 this._minimumBoundaries = this._zeroTime + mainPane._windowLeft * this._tota lTime;
1498 this._maximumBoundaries = this._zeroTime + mainPane._windowRight * this._tot alTime; 1498 this._maximumBoundaries = this._zeroTime + mainPane._windowRight * this._tot alTime;
1499 this._paddingLeft = mainPane._paddingLeft; 1499 this._paddingLeft = mainPane._paddingLeft;
1500 this._width = mainPane._offsetWidth - this._paddingLeft; 1500 this._width = mainPane._offsetWidth - this._paddingLeft;
1501 this._timeToPixel = this._width / this.boundarySpan(); 1501 this._timeToPixel = this._width / this.boundarySpan();
1502 } 1502 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 } 1545 }
1546 1546
1547 /** 1547 /**
1548 * @override 1548 * @override
1549 * @return {number} 1549 * @return {number}
1550 */ 1550 */
1551 boundarySpan() { 1551 boundarySpan() {
1552 return this._maximumBoundaries - this._minimumBoundaries; 1552 return this._maximumBoundaries - this._minimumBoundaries;
1553 } 1553 }
1554 }; 1554 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698