Chromium Code Reviews| Index: Source/devtools/front_end/layers/PaintProfilerView.js |
| diff --git a/Source/devtools/front_end/layers/PaintProfilerView.js b/Source/devtools/front_end/layers/PaintProfilerView.js |
| index 99282c122866e40842b2eb1140e0a5aa78637702..0159d50a518f1d5aa87995e0ef8ae89ba9b9b97b 100644 |
| --- a/Source/devtools/front_end/layers/PaintProfilerView.js |
| +++ b/Source/devtools/front_end/layers/PaintProfilerView.js |
| @@ -32,19 +32,20 @@ |
| * @constructor |
| * @param {!WebInspector.LayerTreeModel} model |
| * @param {!WebInspector.Layers3DView} layers3DView |
| - * @extends {WebInspector.VBox} |
| + * @extends {WebInspector.PanelWithSidebarTree} |
|
caseq
2014/06/05 11:14:24
You can't make it a panel, since it's not really a
malch
2014/06/05 12:41:09
Done.
|
| */ |
| WebInspector.PaintProfilerView = function(model, layers3DView) |
| { |
| - WebInspector.VBox.call(this); |
| - this.element.classList.add("paint-profiler-view"); |
| + WebInspector.PanelWithSidebarTree.call(this, "paint-profiler-view", 225); |
| + this.sidebarElement().classList.add("outline-disclosure"); |
| + this._panelSplitView.addEventListener(WebInspector.SplitView.Events.SidebarSizeChanged, this.onResize, this); |
| this._model = model; |
| this._layers3DView = layers3DView; |
| - this._canvas = this.element.createChild("canvas", "fill"); |
| + this._canvas = this.mainElement().createChild("canvas", "fill"); |
| this._context = this._canvas.getContext("2d"); |
| - this._selectionWindow = new WebInspector.OverviewGrid.Window(this.element, this.element); |
| + this._selectionWindow = new WebInspector.OverviewGrid.Window(this.mainElement(), this.mainElement()); |
| this._selectionWindow.addEventListener(WebInspector.OverviewGrid.Events.WindowChanged, this._onWindowChanged, this); |
| this._innerBarWidth = 4 * window.devicePixelRatio; |
| @@ -63,8 +64,8 @@ WebInspector.PaintProfilerView.prototype = { |
| _update: function() |
| { |
| - this._canvas.width = this.element.clientWidth * window.devicePixelRatio; |
| - this._canvas.height = this.element.clientHeight * window.devicePixelRatio; |
| + this._canvas.width = this.mainElement().clientWidth * window.devicePixelRatio; |
| + this._canvas.height = this.mainElement().clientHeight * window.devicePixelRatio; |
| this._samplesPerBar = 0; |
| if (!this._profiles || !this._profiles.length) |
| return; |
| @@ -130,6 +131,23 @@ WebInspector.PaintProfilerView.prototype = { |
| var stepLeft = Math.max(0, barLeft * this._samplesPerBar); |
| var stepRight = Math.min(barRight * this._samplesPerBar, this._profiles[0].length); |
| this._snapshot.requestImage(stepLeft, stepRight, this._layers3DView.showImageForLayer.bind(this._layers3DView, this._layer)); |
| + this._updateLog(stepLeft, stepRight); |
| + }, |
| + |
| + /** |
| + * @param {number=} stepLeft |
| + * @param {number=} stepRight |
| + */ |
| + _updateLog: function(stepLeft, stepRight) |
| + { |
| + var log = this._log; |
| + stepLeft = stepLeft || 0; |
| + stepRight = stepRight || log.length - 1; |
| + this.sidebarTree.removeChildren(); |
| + for (var i = stepLeft; i <= stepRight; ++i) { |
| + var node = new WebInspector.LogTreeElement(log[i]); |
| + this.sidebarTree.appendChild(node); |
| + } |
| }, |
| _reset: function() |
| @@ -161,19 +179,92 @@ WebInspector.PaintProfilerView.prototype = { |
| return; |
| } |
| snapshot.requestImage(null, null, this._layers3DView.showImageForLayer.bind(this._layers3DView, this._layer)); |
| - snapshot.profile(onProfileDone.bind(this)); |
| + snapshot.profile(onProfileDone.bind(this, snapshot)); |
| } |
| /** |
| + * @param {!WebInspector.PaintProfilerSnapshot=} snapshot |
| * @param {!Array.<!LayerTreeAgent.PaintProfile>=} profiles |
| * @this {WebInspector.PaintProfilerView} |
| */ |
| - function onProfileDone(profiles) |
| + function onProfileDone(snapshot, profiles) |
| { |
| this._profiles = profiles; |
| + snapshot.commandLog(onCommandLogDone.bind(this)); |
| + } |
| + |
| + /** |
| + * @param {!Array.<!Object>=} log |
| + * @this {WebInspector.PaintProfilerView} |
| + */ |
| + function onCommandLogDone(log) |
| + { |
| + this._log = log; |
| + this._updateLog(); |
| this._update(); |
| } |
| }, |
| - __proto__: WebInspector.VBox.prototype |
| + __proto__: WebInspector.PanelWithSidebarTree.prototype |
| +}; |
| + |
| +/** |
| + * @constructor |
| + * @param {!Object} logItem |
| + * @extends {TreeElement} |
| + */ |
| +WebInspector.LogTreeElement = function(logItem) |
| +{ |
| + TreeElement.call(this, "", logItem); |
| + this._update(); |
| +} |
| + |
| +WebInspector.LogTreeElement.prototype = { |
| + /** |
| + * @param {!Object} param |
| + * @param {string} name |
| + * @return {string} |
| + */ |
| + _paramToString: function(param, name) |
| + { |
| + if (typeof param !== "object") |
| + return typeof param === "string" && param.length > 100 ? name : JSON.stringify(param); |
| + var str = ""; |
| + var keyCount = 0; |
| + for (var key in param) { |
| + if (++keyCount > 4 || typeof param[key] === "object" || (typeof param[key] === "string" && param[key].length > 100)) |
| + return name; |
| + if (str) |
| + str += ", "; |
| + str += param[key]; |
| + } |
| + return str; |
| + }, |
| + |
| + /** |
| + * @param {!Object} params |
| + * @return {string} |
| + */ |
| + _paramsToString: function(params) |
| + { |
| + var str = ""; |
| + for (var key in params) { |
| + if (str) |
| + str += ", "; |
| + str += this._paramToString(params[key], key); |
| + } |
| + return str; |
| + }, |
| + |
| + _update: function() |
| + { |
| + var logItem = (this.representedObject); |
|
caseq
2014/06/05 11:14:24
remove redundant brackets
malch
2014/06/05 12:41:09
Done.
|
| + var title = document.createDocumentFragment(); |
| + title.textContent = logItem.method; |
| + if (logItem.params) |
| + title.textContent += "(" + this._paramsToString(logItem.params) + ")"; |
| + this.title = title; |
| + }, |
| + |
| + __proto__: TreeElement.prototype |
| }; |