Chromium Code Reviews| Index: Source/devtools/front_end/timeline/PaintProfilerView.js |
| diff --git a/Source/devtools/front_end/timeline/PaintProfilerView.js b/Source/devtools/front_end/timeline/PaintProfilerView.js |
| index e71c33b97c097225103d0c4c508919603ddd2067..83dd23f7092e6a1b5a57db281a90e2b896f5ddbb 100644 |
| --- a/Source/devtools/front_end/timeline/PaintProfilerView.js |
| +++ b/Source/devtools/front_end/timeline/PaintProfilerView.js |
| @@ -245,13 +245,12 @@ WebInspector.PaintProfilerCommandLogView = function() |
| { |
| WebInspector.VBox.call(this); |
| this.setMinimumSize(100, 25); |
| - this.element.classList.add("outline-disclosure"); |
| - var sidebarTreeElement = this.element.createChild("ol", "sidebar-tree"); |
| + this.element.classList.add("outline-disclosure", "profiler-log-view", "section"); |
| + var sidebarTreeElement = this.element.createChild("ol", "sidebar-tree properties monospace"); |
| sidebarTreeElement.addEventListener("mousemove", this._onMouseMove.bind(this), false); |
| sidebarTreeElement.addEventListener("mouseout", this._onMouseMove.bind(this), false); |
| sidebarTreeElement.addEventListener("contextmenu", this._onContextMenu.bind(this), true); |
| this.sidebarTree = new TreeOutline(sidebarTreeElement); |
| - this._popoverHelper = new WebInspector.ObjectPopoverHelper(this.element, this._getHoverAnchor.bind(this), this._resolveObjectForPopover.bind(this), undefined, true); |
| this._reset(); |
| } |
| @@ -269,6 +268,18 @@ WebInspector.PaintProfilerCommandLogView.prototype = { |
| }, |
| /** |
| + * @param {!TreeOutline} treeOutline |
| + * @param {!WebInspector.PaintProfilerLogItem} logItem |
| + */ |
| + _appendLogItem: function(treeOutline, logItem) |
| + { |
| + var first = new WebInspector.LogTreeElement(this, logItem); |
| + treeOutline.appendChild(first); |
| + // for (var param in logItem.params) |
|
caseq
2014/07/31 13:48:39
please remove
malch
2014/07/31 13:55:54
Done.
|
| + // WebInspector.LogPropertyTreeElement.appendLogPropertyItem(first, param, logItem.params[param]); |
| + }, |
| + |
| + /** |
| * @param {number=} stepLeft |
| * @param {number=} stepRight |
| */ |
| @@ -278,8 +289,7 @@ WebInspector.PaintProfilerCommandLogView.prototype = { |
| stepRight = stepRight || this._log.length - 1; |
| this.sidebarTree.removeChildren(); |
| for (var i = stepLeft; i <= stepRight; ++i) { |
|
caseq
2014/07/31 13:48:39
{} are redundant
malch
2014/07/31 13:55:54
Done.
|
| - var node = new WebInspector.LogTreeElement(this, this._log[i]); |
| - this.sidebarTree.appendChild(node); |
| + this._appendLogItem(this.sidebarTree, this._log[i]); |
| } |
| }, |
| @@ -289,35 +299,12 @@ WebInspector.PaintProfilerCommandLogView.prototype = { |
| }, |
| /** |
| - * @param {!Element} target |
| - * @return {!Element} |
| - */ |
| - _getHoverAnchor: function(target) |
| - { |
| - return /** @type {!Element} */ (target.enclosingNodeOrSelfWithNodeName("span")); |
| - }, |
| - |
| - /** |
| - * @param {!Element} element |
| - * @param {function(!WebInspector.RemoteObject, boolean, !Element=):undefined} showCallback |
| - */ |
| - _resolveObjectForPopover: function(element, showCallback) |
| - { |
| - var liElement = element.enclosingNodeOrSelfWithNodeName("li"); |
| - var logItem = liElement.treeElement.representedObject; |
| - var obj = {"method": logItem.method}; |
| - if (logItem.params) |
| - obj.params = logItem.params; |
| - showCallback(WebInspector.RemoteObject.fromLocalObject(obj), false); |
| - }, |
| - |
| - /** |
| * @param {?Event} event |
| */ |
| _onMouseMove: function(event) |
| { |
| var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.pageY); |
| - if (node === this._lastHoveredNode) |
| + if (node === this._lastHoveredNode || !(node instanceof WebInspector.LogTreeElement)) |
| return; |
| if (this._lastHoveredNode) |
| this._lastHoveredNode.setHovered(false); |
| @@ -334,7 +321,7 @@ WebInspector.PaintProfilerCommandLogView.prototype = { |
| if (!this._target) |
| return; |
| var node = this.sidebarTree.treeElementFromPoint(event.pageX, event.pageY); |
| - if (!node || !node.representedObject) |
| + if (!node || !node.representedObject || !(node instanceof WebInspector.LogTreeElement)) |
| return; |
| var logItem = /** @type {!WebInspector.PaintProfilerLogItem} */ (node.representedObject); |
| if (!logItem.nodeId()) |
| @@ -358,10 +345,26 @@ WebInspector.LogTreeElement = function(ownerView, logItem) |
| { |
| TreeElement.call(this, "", logItem); |
| this._ownerView = ownerView; |
| - this._update(); |
| + this._filled = false; |
| } |
| WebInspector.LogTreeElement.prototype = { |
| + onattach: function() |
| + { |
| + this._update(); |
| + if (this.representedObject.params) |
| + this.hasChildren = true; |
| + }, |
| + |
| + onexpand: function() |
| + { |
| + if (this._filled) |
| + return; |
| + this._filled = true; |
| + for (var param in this.representedObject.params) |
| + WebInspector.LogPropertyTreeElement.appendLogPropertyItem(this, param, this.representedObject.params[param]); |
| + }, |
| + |
| /** |
| * @param {!Object} param |
| * @param {string} name |
| @@ -403,11 +406,7 @@ WebInspector.LogTreeElement.prototype = { |
| var logItem = this.representedObject; |
| var title = document.createDocumentFragment(); |
| title.createChild("div", "selection"); |
| - var span = title.createChild("span"); |
| - var textContent = logItem.method; |
| - if (logItem.params) |
| - textContent += "(" + this._paramsToString(logItem.params) + ")"; |
| - span.textContent = textContent; |
| + title.createTextChild(logItem.method + "(" + this._paramsToString(logItem.params) + ")"); |
| this.title = title; |
| }, |
| @@ -445,6 +444,66 @@ WebInspector.LogTreeElement.prototype = { |
| }; |
| /** |
| + * @constructor |
| + * @param {!{name: string, value}} property |
| + * @extends {TreeElement} |
| + */ |
| +WebInspector.LogPropertyTreeElement = function(property) |
| +{ |
| + TreeElement.call(this, "", property); |
| +}; |
| + |
| +WebInspector.LogPropertyTreeElement.prototype = { |
| + onattach: function() |
| + { |
| + this._update(); |
| + }, |
| + |
| + /** |
| + * @param {*} value |
| + * @return {string} |
| + */ |
| + _type: function(value) |
| + { |
| + return value === null ? "null" : typeof value; |
| + }, |
| + |
| + _update: function() |
| + { |
| + var property = this.representedObject; |
| + var title = document.createDocumentFragment(); |
| + title.createChild("div", "selection"); |
| + var nameElement = title.createChild("span", "name"); |
| + nameElement.textContent = property.name; |
| + var separatorElement = title.createChild("span", "separator"); |
| + separatorElement.textContent = ": "; |
| + if (property.value === null || typeof property.value !== "object") { |
| + var valueElement = title.createChild("span", "value"); |
| + valueElement.textContent = JSON.stringify(property.value); |
| + valueElement.classList.add("console-formatted-" + this._type(property.value)); |
| + } |
| + this.title = title; |
| + }, |
| + |
| + __proto__: TreeElement.prototype |
| +}; |
| + |
| +/** |
| + * @param {!TreeElement} element |
| + * @param {string} name |
| + * @param {*} value |
| + */ |
| +WebInspector.LogPropertyTreeElement.appendLogPropertyItem = function(element, name, value) |
| +{ |
| + var treeElement = new WebInspector.LogPropertyTreeElement({name: name, value: value}); |
| + element.appendChild(treeElement); |
| + if (value && typeof value === "object") { |
| + for (var property in value) |
| + WebInspector.LogPropertyTreeElement.appendLogPropertyItem(treeElement, property, value[property]); |
| + } |
| +}; |
| + |
| +/** |
| * @return {!Object.<string, !WebInspector.PaintProfilerCategory>} |
| */ |
| WebInspector.PaintProfilerView.categories = function() |