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

Side by Side Diff: Source/devtools/front_end/components/FlameChart.js

Issue 671463002: DevTools: make flame chart a web component. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: test fixed Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/components/HelpScreen.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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("components/flameChart.css"); 54 this.contentElement.appendChild(WebInspector.View.createStyleElement("compon ents/flameChart.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 this._selectionOverlay = this.element.createChild("div", "flame-chart-select ion-overlay hidden"); 78 this._selectionOverlay = this.contentElement.createChild("div", "flame-chart -selection-overlay hidden");
79 this._selectedTimeSpanLabel = this._selectionOverlay.createChild("div", "tim e-span"); 79 this._selectedTimeSpanLabel = this._selectionOverlay.createChild("div", "tim e-span");
80 80
81 this._dataProvider = dataProvider; 81 this._dataProvider = dataProvider;
82 82
83 this._windowLeft = 0.0; 83 this._windowLeft = 0.0;
84 this._windowRight = 1.0; 84 this._windowRight = 1.0;
85 this._windowWidth = 1.0; 85 this._windowWidth = 1.0;
86 this._timeWindowLeft = 0; 86 this._timeWindowLeft = 0;
87 this._timeWindowRight = Infinity; 87 this._timeWindowRight = Infinity;
88 this._barHeight = dataProvider.barHeight(); 88 this._barHeight = dataProvider.barHeight();
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 if (element.parentElement) 1026 if (element.parentElement)
1027 element.remove(); 1027 element.remove();
1028 var markerIndex = this._highlightedMarkerIndex; 1028 var markerIndex = this._highlightedMarkerIndex;
1029 if (markerIndex === -1) 1029 if (markerIndex === -1)
1030 return; 1030 return;
1031 var barX = this._timeToPosition(this._timelineData().markerTimestamps[ma rkerIndex]); 1031 var barX = this._timeToPosition(this._timelineData().markerTimestamps[ma rkerIndex]);
1032 element.title = this._dataProvider.markerTitle(markerIndex); 1032 element.title = this._dataProvider.markerTitle(markerIndex);
1033 var style = element.style; 1033 var style = element.style;
1034 style.left = barX + "px"; 1034 style.left = barX + "px";
1035 style.backgroundColor = this._dataProvider.markerColor(markerIndex); 1035 style.backgroundColor = this._dataProvider.markerColor(markerIndex);
1036 this.element.appendChild(element); 1036 this.contentElement.appendChild(element);
1037 }, 1037 },
1038 1038
1039 /** 1039 /**
1040 * @param {?WebInspector.FlameChart.TimelineData} timelineData 1040 * @param {?WebInspector.FlameChart.TimelineData} timelineData
1041 */ 1041 */
1042 _processTimelineData: function(timelineData) 1042 _processTimelineData: function(timelineData)
1043 { 1043 {
1044 if (!timelineData) { 1044 if (!timelineData) {
1045 this._timelineLevels = null; 1045 this._timelineLevels = null;
1046 this._rawTimelineData = null; 1046 this._rawTimelineData = null;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 var barRight = this._timeToPosition(timeRange.endTime); 1088 var barRight = this._timeToPosition(timeRange.endTime);
1089 if (barRight === 0 || barX === this._canvas.width) 1089 if (barRight === 0 || barX === this._canvas.width)
1090 return; 1090 return;
1091 var barWidth = Math.max(barRight - barX, this._minWidth); 1091 var barWidth = Math.max(barRight - barX, this._minWidth);
1092 var barY = this._levelToHeight(timelineData.entryLevels[entryIndex]) - t his._scrollTop; 1092 var barY = this._levelToHeight(timelineData.entryLevels[entryIndex]) - t his._scrollTop;
1093 var style = element.style; 1093 var style = element.style;
1094 style.left = barX + "px"; 1094 style.left = barX + "px";
1095 style.top = barY + "px"; 1095 style.top = barY + "px";
1096 style.width = barWidth + "px"; 1096 style.width = barWidth + "px";
1097 style.height = this._barHeight + "px"; 1097 style.height = this._barHeight + "px";
1098 this.element.appendChild(element); 1098 this.contentElement.appendChild(element);
1099 }, 1099 },
1100 1100
1101 /** 1101 /**
1102 * @param {number} time 1102 * @param {number} time
1103 */ 1103 */
1104 _timeToPosition: function(time) 1104 _timeToPosition: function(time)
1105 { 1105 {
1106 var value = Math.floor((time - this._minimumBoundary) * this._timeToPixe l) - this._pixelWindowLeft + this._paddingLeft; 1106 var value = Math.floor((time - this._minimumBoundary) * this._timeToPixe l) - this._pixelWindowLeft + this._paddingLeft;
1107 return Math.min(this._canvas.width, Math.max(0, value)); 1107 return Math.min(this._canvas.width, Math.max(0, value));
1108 }, 1108 },
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 onResize: function() 1207 onResize: function()
1208 { 1208 {
1209 this._updateScrollBar(); 1209 this._updateScrollBar();
1210 this.scheduleUpdate(); 1210 this.scheduleUpdate();
1211 }, 1211 },
1212 1212
1213 _updateScrollBar: function() 1213 _updateScrollBar: function()
1214 { 1214 {
1215 var showScroll = this._totalHeight > this._offsetHeight; 1215 var showScroll = this._totalHeight > this._offsetHeight;
1216 this._vScrollElement.classList.toggle("hidden", !showScroll); 1216 this._vScrollElement.classList.toggle("hidden", !showScroll);
1217 this._offsetWidth = this.element.offsetWidth - (WebInspector.isMac() ? 0 : this._vScrollElement.offsetWidth); 1217 this._offsetWidth = this.contentElement.offsetWidth - (WebInspector.isMa c() ? 0 : this._vScrollElement.offsetWidth);
1218 this._offsetHeight = this.element.offsetHeight; 1218 this._offsetHeight = this.contentElement.offsetHeight;
1219 }, 1219 },
1220 1220
1221 scheduleUpdate: function() 1221 scheduleUpdate: function()
1222 { 1222 {
1223 if (this._updateTimerId || this._cancelWindowTimesAnimation) 1223 if (this._updateTimerId || this._cancelWindowTimesAnimation)
1224 return; 1224 return;
1225 this._updateTimerId = requestAnimationFrame(this.update.bind(this)); 1225 this._updateTimerId = requestAnimationFrame(this.update.bind(this));
1226 }, 1226 },
1227 1227
1228 update: function() 1228 update: function()
(...skipping 11 matching lines...) Expand all
1240 { 1240 {
1241 this._highlightedMarkerIndex = -1; 1241 this._highlightedMarkerIndex = -1;
1242 this._highlightedEntryIndex = -1; 1242 this._highlightedEntryIndex = -1;
1243 this._selectedEntryIndex = -1; 1243 this._selectedEntryIndex = -1;
1244 this._textWidth = {}; 1244 this._textWidth = {};
1245 this.update(); 1245 this.update();
1246 }, 1246 },
1247 1247
1248 __proto__: WebInspector.HBox.prototype 1248 __proto__: WebInspector.HBox.prototype
1249 } 1249 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/components/HelpScreen.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698