| OLD | NEW |
| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 WebInspector.ChartViewport.call(this); | 59 WebInspector.ChartViewport.call(this); |
| 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 WebInspector.FlameChart.Calculator(dataProvider); |
| 68 | 68 |
| 69 this._canvas = /** @type {!HTMLCanvasElement} */ (this.contentElement.create
Child("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.contentElement.createChild("div", "flame-chart-entry-
info"); | 77 this._entryInfo = this.viewportElement.createChild("div", "flame-chart-entry
-info"); |
| 78 this._markerHighlighElement = this.contentElement.createChild("div", "flame-
chart-marker-highlight-element"); | 78 this._markerHighlighElement = this.viewportElement.createChild("div", "flame
-chart-marker-highlight-element"); |
| 79 this._highlightElement = this.contentElement.createChild("div", "flame-chart
-highlight-element"); | 79 this._highlightElement = this.viewportElement.createChild("div", "flame-char
t-highlight-element"); |
| 80 this._selectedElement = this.contentElement.createChild("div", "flame-chart-
selected-element"); | 80 this._selectedElement = this.viewportElement.createChild("div", "flame-chart
-selected-element"); |
| 81 | 81 |
| 82 this._windowLeft = 0.0; | 82 this._windowLeft = 0.0; |
| 83 this._windowRight = 1.0; | 83 this._windowRight = 1.0; |
| 84 this._timeWindowLeft = 0; | 84 this._timeWindowLeft = 0; |
| 85 this._timeWindowRight = Infinity; | 85 this._timeWindowRight = Infinity; |
| 86 this._rangeSelectionStart = 0; | 86 this._rangeSelectionStart = 0; |
| 87 this._rangeSelectionEnd = 0; | 87 this._rangeSelectionEnd = 0; |
| 88 this._barHeight = dataProvider.barHeight(); | 88 this._barHeight = dataProvider.barHeight(); |
| 89 this._paddingLeft = this._dataProvider.paddingLeft(); | 89 this._paddingLeft = this._dataProvider.paddingLeft(); |
| 90 var markerPadding = 2; | 90 var markerPadding = 2; |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 { | 491 { |
| 492 if (this._highlightedEntryIndex === entryIndex) | 492 if (this._highlightedEntryIndex === entryIndex) |
| 493 return; | 493 return; |
| 494 this._highlightedEntryIndex = entryIndex; | 494 this._highlightedEntryIndex = entryIndex; |
| 495 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); | 495 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); |
| 496 }, | 496 }, |
| 497 | 497 |
| 498 hideHighlight: function() | 498 hideHighlight: function() |
| 499 { | 499 { |
| 500 this._entryInfo.removeChildren(); | 500 this._entryInfo.removeChildren(); |
| 501 this._canvas.style.cursor = "default"; | |
| 502 this._highlightedEntryIndex = -1; | 501 this._highlightedEntryIndex = -1; |
| 503 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); | 502 this._updateElementPosition(this._highlightElement, this._highlightedEnt
ryIndex); |
| 504 }, | 503 }, |
| 505 | 504 |
| 506 _resetCanvas: function() | 505 _resetCanvas: function() |
| 507 { | 506 { |
| 508 var ratio = window.devicePixelRatio; | 507 var ratio = window.devicePixelRatio; |
| 509 this._canvas.width = this._offsetWidth * ratio; | 508 this._canvas.width = this._offsetWidth * ratio; |
| 510 this._canvas.height = this._offsetHeight * ratio; | 509 this._canvas.height = this._offsetHeight * ratio; |
| 511 this._canvas.style.width = this._offsetWidth + "px"; | 510 this._canvas.style.width = this._offsetWidth + "px"; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 _onMouseMove: function(event) | 569 _onMouseMove: function(event) |
| 571 { | 570 { |
| 572 this._lastMouseOffsetX = event.offsetX; | 571 this._lastMouseOffsetX = event.offsetX; |
| 573 this._lastMouseOffsetY = event.offsetY; | 572 this._lastMouseOffsetY = event.offsetY; |
| 574 if (!this._enabled()) | 573 if (!this._enabled()) |
| 575 return; | 574 return; |
| 576 if (this.isDragging()) | 575 if (this.isDragging()) |
| 577 return; | 576 return; |
| 578 if (this._coordinatesToGroupIndex(event.offsetX, event.offsetY) >= 0) { | 577 if (this._coordinatesToGroupIndex(event.offsetX, event.offsetY) >= 0) { |
| 579 this.hideHighlight(); | 578 this.hideHighlight(); |
| 580 this._canvas.style.cursor = "pointer"; | 579 this.viewportElement.style.cursor = "pointer"; |
| 581 return; | 580 return; |
| 582 } | 581 } |
| 583 this._updateHighlight(); | 582 this._updateHighlight(); |
| 584 }, | 583 }, |
| 585 | 584 |
| 586 _updateHighlight: function() | 585 _updateHighlight: function() |
| 587 { | 586 { |
| 588 var inDividersBar = this._lastMouseOffsetY < WebInspector.FlameChart.Div
idersBarHeight; | 587 var inDividersBar = this._lastMouseOffsetY < WebInspector.FlameChart.Div
idersBarHeight; |
| 589 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPositi
on(this._lastMouseOffsetX) : -1; | 588 this._highlightedMarkerIndex = inDividersBar ? this._markerIndexAtPositi
on(this._lastMouseOffsetX) : -1; |
| 590 this._updateMarkerHighlight(); | 589 this._updateMarkerHighlight(); |
| 591 | 590 |
| 592 var entryIndex = this._coordinatesToEntryIndex(this._lastMouseOffsetX, t
his._lastMouseOffsetY); | 591 var entryIndex = this._coordinatesToEntryIndex(this._lastMouseOffsetX, t
his._lastMouseOffsetY); |
| 593 if (entryIndex === -1) { | 592 if (entryIndex === -1) { |
| 594 this.hideHighlight(); | 593 this.hideHighlight(); |
| 595 return; | 594 return; |
| 596 } | 595 } |
| 596 if (this.isDragging()) |
| 597 return; |
| 597 this._updatePopover(entryIndex); | 598 this._updatePopover(entryIndex); |
| 598 this._canvas.style.cursor = this._dataProvider.canJumpToEntry(entryIndex
) ? "pointer" : "default"; | 599 this.viewportElement.style.cursor = this._dataProvider.canJumpToEntry(en
tryIndex) ? "pointer" : "default"; |
| 599 this.highlightEntry(entryIndex); | 600 this.highlightEntry(entryIndex); |
| 600 }, | 601 }, |
| 601 | 602 |
| 602 _onMouseOut: function() | 603 _onMouseOut: function() |
| 603 { | 604 { |
| 604 this._lastMouseOffsetX = -1; | 605 this._lastMouseOffsetX = -1; |
| 605 this._lastMouseOffsetY = -1; | 606 this._lastMouseOffsetY = -1; |
| 606 this.hideHighlight(); | 607 this.hideHighlight(); |
| 607 }, | 608 }, |
| 608 | 609 |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1348 element.remove(); | 1349 element.remove(); |
| 1349 var markerIndex = this._highlightedMarkerIndex; | 1350 var markerIndex = this._highlightedMarkerIndex; |
| 1350 if (markerIndex === -1) | 1351 if (markerIndex === -1) |
| 1351 return; | 1352 return; |
| 1352 var marker = this._timelineData().markers[markerIndex]; | 1353 var marker = this._timelineData().markers[markerIndex]; |
| 1353 var barX = this._timeToPositionClipped(marker.startTime()); | 1354 var barX = this._timeToPositionClipped(marker.startTime()); |
| 1354 element.title = marker.title(); | 1355 element.title = marker.title(); |
| 1355 var style = element.style; | 1356 var style = element.style; |
| 1356 style.left = barX + "px"; | 1357 style.left = barX + "px"; |
| 1357 style.backgroundColor = marker.color(); | 1358 style.backgroundColor = marker.color(); |
| 1358 this.contentElement.appendChild(element); | 1359 this.viewportElement.appendChild(element); |
| 1359 }, | 1360 }, |
| 1360 | 1361 |
| 1361 /** | 1362 /** |
| 1362 * @param {?WebInspector.FlameChart.TimelineData} timelineData | 1363 * @param {?WebInspector.FlameChart.TimelineData} timelineData |
| 1363 */ | 1364 */ |
| 1364 _processTimelineData: function(timelineData) | 1365 _processTimelineData: function(timelineData) |
| 1365 { | 1366 { |
| 1366 if (!timelineData) { | 1367 if (!timelineData) { |
| 1367 this._timelineLevels = null; | 1368 this._timelineLevels = null; |
| 1368 this._visibleLevelOffsets = null; | 1369 this._visibleLevelOffsets = null; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1389 levelIndexes[level][entryCounters[level]++] = i; | 1390 levelIndexes[level][entryCounters[level]++] = i; |
| 1390 } | 1391 } |
| 1391 this._timelineLevels = levelIndexes; | 1392 this._timelineLevels = levelIndexes; |
| 1392 var groups = this._rawTimelineData.groups || []; | 1393 var groups = this._rawTimelineData.groups || []; |
| 1393 for (var i = 0; i < groups.length; ++i) { | 1394 for (var i = 0; i < groups.length; ++i) { |
| 1394 var expanded = this._groupExpansionState[groups[i].name]; | 1395 var expanded = this._groupExpansionState[groups[i].name]; |
| 1395 if (expanded !== undefined) | 1396 if (expanded !== undefined) |
| 1396 groups[i].expanded = expanded; | 1397 groups[i].expanded = expanded; |
| 1397 } | 1398 } |
| 1398 this._updateLevelPositions(); | 1399 this._updateLevelPositions(); |
| 1400 this._updateHeight(); |
| 1399 }, | 1401 }, |
| 1400 | 1402 |
| 1401 _updateLevelPositions: function() | 1403 _updateLevelPositions: function() |
| 1402 { | 1404 { |
| 1403 var levelCount = this._dataProvider.maxStackDepth(); | 1405 var levelCount = this._dataProvider.maxStackDepth(); |
| 1404 var groups = this._rawTimelineData.groups || []; | 1406 var groups = this._rawTimelineData.groups || []; |
| 1405 this._visibleLevelOffsets = new Uint32Array(levelCount + 1); | 1407 this._visibleLevelOffsets = new Uint32Array(levelCount + 1); |
| 1406 this._visibleLevels = new Uint16Array(levelCount); | 1408 this._visibleLevels = new Uint16Array(levelCount); |
| 1407 this._groupOffsets = new Uint32Array(groups.length + 1); | 1409 this._groupOffsets = new Uint32Array(groups.length + 1); |
| 1408 | 1410 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 var barWidth = barRight - barX; | 1497 var barWidth = barRight - barX; |
| 1496 var barCenter = barX + barWidth / 2; | 1498 var barCenter = barX + barWidth / 2; |
| 1497 barWidth = Math.max(barWidth, elementMinWidth); | 1499 barWidth = Math.max(barWidth, elementMinWidth); |
| 1498 barX = barCenter - barWidth / 2; | 1500 barX = barCenter - barWidth / 2; |
| 1499 var barY = this._levelToHeight(timelineData.entryLevels[entryIndex]) - t
his.scrollOffset(); | 1501 var barY = this._levelToHeight(timelineData.entryLevels[entryIndex]) - t
his.scrollOffset(); |
| 1500 var style = element.style; | 1502 var style = element.style; |
| 1501 style.left = barX + "px"; | 1503 style.left = barX + "px"; |
| 1502 style.top = barY + "px"; | 1504 style.top = barY + "px"; |
| 1503 style.width = barWidth + "px"; | 1505 style.width = barWidth + "px"; |
| 1504 style.height = this._barHeight - 1 + "px"; | 1506 style.height = this._barHeight - 1 + "px"; |
| 1505 this.contentElement.appendChild(element); | 1507 this.viewportElement.appendChild(element); |
| 1506 }, | 1508 }, |
| 1507 | 1509 |
| 1508 /** | 1510 /** |
| 1509 * @param {number} time | 1511 * @param {number} time |
| 1510 * @return {number} | 1512 * @return {number} |
| 1511 */ | 1513 */ |
| 1512 _timeToPositionClipped: function(time) | 1514 _timeToPositionClipped: function(time) |
| 1513 { | 1515 { |
| 1514 return Number.constrain(this._timeToPosition(time), 0, this._offsetWidth
); | 1516 return Number.constrain(this._timeToPosition(time), 0, this._offsetWidth
); |
| 1515 }, | 1517 }, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 this.update(); | 1662 this.update(); |
| 1661 }, | 1663 }, |
| 1662 | 1664 |
| 1663 _enabled: function() | 1665 _enabled: function() |
| 1664 { | 1666 { |
| 1665 return this._rawTimelineDataLength !== 0; | 1667 return this._rawTimelineDataLength !== 0; |
| 1666 }, | 1668 }, |
| 1667 | 1669 |
| 1668 __proto__: WebInspector.ChartViewport.prototype | 1670 __proto__: WebInspector.ChartViewport.prototype |
| 1669 } | 1671 } |
| OLD | NEW |