| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 /** | 44 /** |
| 45 * @constructor | 45 * @constructor |
| 46 * @extends {WebInspector.HBox} | 46 * @extends {WebInspector.HBox} |
| 47 * @param {!WebInspector.FlameChartDataProvider} dataProvider | 47 * @param {!WebInspector.FlameChartDataProvider} dataProvider |
| 48 * @param {!WebInspector.FlameChartDelegate} flameChartDelegate | 48 * @param {!WebInspector.FlameChartDelegate} flameChartDelegate |
| 49 * @param {boolean} isTopDown | 49 * @param {boolean} isTopDown |
| 50 */ | 50 */ |
| 51 WebInspector.FlameChart = function(dataProvider, flameChartDelegate, isTopDown) | 51 WebInspector.FlameChart = function(dataProvider, flameChartDelegate, isTopDown) |
| 52 { | 52 { |
| 53 WebInspector.HBox.call(this); | 53 WebInspector.HBox.call(this, true); |
| 54 this.registerRequiredCSS("flameChart.css"); | 54 this.contentElement.appendChild(WebInspector.View.createStyleElement("flameC
hart.css")); |
| 55 this.element.classList.add("flame-chart-main-pane"); | 55 this.contentElement.classList.add("flame-chart-main-pane"); |
| 56 this._flameChartDelegate = flameChartDelegate; | 56 this._flameChartDelegate = flameChartDelegate; |
| 57 this._isTopDown = isTopDown; | 57 this._isTopDown = isTopDown; |
| 58 | 58 |
| 59 this._calculator = new WebInspector.FlameChart.Calculator(); | 59 this._calculator = new WebInspector.FlameChart.Calculator(); |
| 60 | 60 |
| 61 this._canvas = this.element.createChild("canvas"); | 61 this._canvas = this.contentElement.createChild("canvas"); |
| 62 this._canvas.tabIndex = 1; | 62 this._canvas.tabIndex = 1; |
| 63 this.setDefaultFocusedElement(this._canvas); | 63 this.setDefaultFocusedElement(this._canvas); |
| 64 this._canvas.addEventListener("mousemove", this._onMouseMove.bind(this), fal
se); | 64 this._canvas.addEventListener("mousemove", this._onMouseMove.bind(this), fal
se); |
| 65 this._canvas.addEventListener("mousewheel", this._onMouseWheel.bind(this), f
alse); | 65 this._canvas.addEventListener("mousewheel", this._onMouseWheel.bind(this), f
alse); |
| 66 this._canvas.addEventListener("click", this._onClick.bind(this), false); | 66 this._canvas.addEventListener("click", this._onClick.bind(this), false); |
| 67 this._canvas.addEventListener("keydown", this._onKeyDown.bind(this), false); | 67 this._canvas.addEventListener("keydown", this._onKeyDown.bind(this), false); |
| 68 WebInspector.installDragHandle(this._canvas, this._startCanvasDragging.bind(
this), this._canvasDragging.bind(this), this._endCanvasDragging.bind(this), "mov
e", null); | 68 WebInspector.installDragHandle(this._canvas, this._startCanvasDragging.bind(
this), this._canvasDragging.bind(this), this._endCanvasDragging.bind(this), "mov
e", null); |
| 69 | 69 |
| 70 this._vScrollElement = this.element.createChild("div", "flame-chart-v-scroll
"); | 70 this._vScrollElement = this.contentElement.createChild("div", "flame-chart-v
-scroll"); |
| 71 this._vScrollContent = this._vScrollElement.createChild("div"); | 71 this._vScrollContent = this._vScrollElement.createChild("div"); |
| 72 this._vScrollElement.addEventListener("scroll", this.scheduleUpdate.bind(thi
s), false); | 72 this._vScrollElement.addEventListener("scroll", this.scheduleUpdate.bind(thi
s), false); |
| 73 | 73 |
| 74 this._entryInfo = this.element.createChild("div", "profile-entry-info"); | 74 this._entryInfo = this.contentElement.createChild("div", "flame-chart-entry-
info"); |
| 75 this._markerHighlighElement = this.element.createChild("div", "flame-chart-m
arker-highlight-element"); | 75 this._markerHighlighElement = this.contentElement.createChild("div", "flame-
chart-marker-highlight-element"); |
| 76 this._highlightElement = this.element.createChild("div", "flame-chart-highli
ght-element"); | 76 this._highlightElement = this.contentElement.createChild("div", "flame-chart
-highlight-element"); |
| 77 this._selectedElement = this.element.createChild("div", "flame-chart-selecte
d-element"); | 77 this._selectedElement = this.contentElement.createChild("div", "flame-chart-
selected-element"); |
| 78 | 78 |
| 79 this._dataProvider = dataProvider; | 79 this._dataProvider = dataProvider; |
| 80 | 80 |
| 81 this._windowLeft = 0.0; | 81 this._windowLeft = 0.0; |
| 82 this._windowRight = 1.0; | 82 this._windowRight = 1.0; |
| 83 this._windowWidth = 1.0; | 83 this._windowWidth = 1.0; |
| 84 this._timeWindowLeft = 0; | 84 this._timeWindowLeft = 0; |
| 85 this._timeWindowRight = Infinity; | 85 this._timeWindowRight = Infinity; |
| 86 this._barHeight = dataProvider.barHeight(); | 86 this._barHeight = dataProvider.barHeight(); |
| 87 this._barHeightDelta = this._isTopDown ? -this._barHeight : this._barHeight; | 87 this._barHeightDelta = this._isTopDown ? -this._barHeight : this._barHeight; |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 if (element.parentElement) | 965 if (element.parentElement) |
| 966 element.remove(); | 966 element.remove(); |
| 967 var markerIndex = this._highlightedMarkerIndex; | 967 var markerIndex = this._highlightedMarkerIndex; |
| 968 if (markerIndex === -1) | 968 if (markerIndex === -1) |
| 969 return; | 969 return; |
| 970 var barX = this._timeToPosition(this._timelineData().markerTimestamps[ma
rkerIndex]); | 970 var barX = this._timeToPosition(this._timelineData().markerTimestamps[ma
rkerIndex]); |
| 971 element.title = this._dataProvider.markerTitle(markerIndex); | 971 element.title = this._dataProvider.markerTitle(markerIndex); |
| 972 var style = element.style; | 972 var style = element.style; |
| 973 style.left = barX + "px"; | 973 style.left = barX + "px"; |
| 974 style.backgroundColor = this._dataProvider.markerColor(markerIndex); | 974 style.backgroundColor = this._dataProvider.markerColor(markerIndex); |
| 975 this.element.appendChild(element); | 975 this.contentElement.appendChild(element); |
| 976 }, | 976 }, |
| 977 | 977 |
| 978 /** | 978 /** |
| 979 * @param {?WebInspector.FlameChart.TimelineData} timelineData | 979 * @param {?WebInspector.FlameChart.TimelineData} timelineData |
| 980 */ | 980 */ |
| 981 _processTimelineData: function(timelineData) | 981 _processTimelineData: function(timelineData) |
| 982 { | 982 { |
| 983 if (!timelineData) { | 983 if (!timelineData) { |
| 984 this._timelineLevels = null; | 984 this._timelineLevels = null; |
| 985 this._rawTimelineData = null; | 985 this._rawTimelineData = null; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 var barRight = this._timeToPosition(timeRange.endTime); | 1027 var barRight = this._timeToPosition(timeRange.endTime); |
| 1028 if (barRight === 0 || barX === this._canvas.width) | 1028 if (barRight === 0 || barX === this._canvas.width) |
| 1029 return; | 1029 return; |
| 1030 var barWidth = Math.max(barRight - barX, this._minWidth); | 1030 var barWidth = Math.max(barRight - barX, this._minWidth); |
| 1031 var barY = this._levelToHeight(timelineData.entryLevels[entryIndex]) - t
his._scrollTop; | 1031 var barY = this._levelToHeight(timelineData.entryLevels[entryIndex]) - t
his._scrollTop; |
| 1032 var style = element.style; | 1032 var style = element.style; |
| 1033 style.left = barX + "px"; | 1033 style.left = barX + "px"; |
| 1034 style.top = barY + "px"; | 1034 style.top = barY + "px"; |
| 1035 style.width = barWidth + "px"; | 1035 style.width = barWidth + "px"; |
| 1036 style.height = this._barHeight + "px"; | 1036 style.height = this._barHeight + "px"; |
| 1037 this.element.appendChild(element); | 1037 this.contentElement.appendChild(element); |
| 1038 }, | 1038 }, |
| 1039 | 1039 |
| 1040 /** | 1040 /** |
| 1041 * @param {number} time | 1041 * @param {number} time |
| 1042 */ | 1042 */ |
| 1043 _timeToPosition: function(time) | 1043 _timeToPosition: function(time) |
| 1044 { | 1044 { |
| 1045 var value = Math.floor((time - this._minimumBoundary) * this._timeToPixe
l) - this._pixelWindowLeft + this._paddingLeft; | 1045 var value = Math.floor((time - this._minimumBoundary) * this._timeToPixe
l) - this._pixelWindowLeft + this._paddingLeft; |
| 1046 return Math.min(this._canvas.width, Math.max(0, value)); | 1046 return Math.min(this._canvas.width, Math.max(0, value)); |
| 1047 }, | 1047 }, |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 onResize: function() | 1146 onResize: function() |
| 1147 { | 1147 { |
| 1148 this._updateScrollBar(); | 1148 this._updateScrollBar(); |
| 1149 this.scheduleUpdate(); | 1149 this.scheduleUpdate(); |
| 1150 }, | 1150 }, |
| 1151 | 1151 |
| 1152 _updateScrollBar: function() | 1152 _updateScrollBar: function() |
| 1153 { | 1153 { |
| 1154 var showScroll = this._totalHeight > this._offsetHeight; | 1154 var showScroll = this._totalHeight > this._offsetHeight; |
| 1155 this._vScrollElement.classList.toggle("hidden", !showScroll); | 1155 this._vScrollElement.classList.toggle("hidden", !showScroll); |
| 1156 this._offsetWidth = this.element.offsetWidth - (WebInspector.isMac() ? 0
: this._vScrollElement.offsetWidth); | 1156 this._offsetWidth = this.contentElement.offsetWidth - (WebInspector.isMa
c() ? 0 : this._vScrollElement.offsetWidth); |
| 1157 this._offsetHeight = this.element.offsetHeight; | 1157 this._offsetHeight = this.contentElement.offsetHeight; |
| 1158 }, | 1158 }, |
| 1159 | 1159 |
| 1160 scheduleUpdate: function() | 1160 scheduleUpdate: function() |
| 1161 { | 1161 { |
| 1162 if (this._updateTimerId || this._cancelWindowTimesAnimation) | 1162 if (this._updateTimerId || this._cancelWindowTimesAnimation) |
| 1163 return; | 1163 return; |
| 1164 this._updateTimerId = requestAnimationFrame(this.update.bind(this)); | 1164 this._updateTimerId = requestAnimationFrame(this.update.bind(this)); |
| 1165 }, | 1165 }, |
| 1166 | 1166 |
| 1167 update: function() | 1167 update: function() |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1179 { | 1179 { |
| 1180 this._highlightedMarkerIndex = -1; | 1180 this._highlightedMarkerIndex = -1; |
| 1181 this._highlightedEntryIndex = -1; | 1181 this._highlightedEntryIndex = -1; |
| 1182 this._selectedEntryIndex = -1; | 1182 this._selectedEntryIndex = -1; |
| 1183 this._textWidth = {}; | 1183 this._textWidth = {}; |
| 1184 this.update(); | 1184 this.update(); |
| 1185 }, | 1185 }, |
| 1186 | 1186 |
| 1187 __proto__: WebInspector.HBox.prototype | 1187 __proto__: WebInspector.HBox.prototype |
| 1188 } | 1188 } |
| OLD | NEW |