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..c576ceb753417de3ead6a39c0e40f7d2924b6fbc 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(); |
| } |
| @@ -278,8 +277,7 @@ WebInspector.PaintProfilerCommandLogView.prototype = { |
| stepRight = stepRight || this._log.length - 1; |
| this.sidebarTree.removeChildren(); |
| for (var i = stepLeft; i <= stepRight; ++i) { |
| - var node = new WebInspector.LogTreeElement(this, this._log[i]); |
| - this.sidebarTree.appendChild(node); |
| + WebInspector.LogTreeElement.appendLogItem(this.sidebarTree, this, this._log[i]); |
|
caseq
2014/07/31 13:00:11
Let's make it an instance method of PaintProfilerC
malch
2014/07/31 13:55:54
Done.
|
| } |
| }, |
| @@ -289,35 +287,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 +309,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()) |
| @@ -356,7 +331,7 @@ WebInspector.PaintProfilerCommandLogView.prototype = { |
| */ |
| WebInspector.LogTreeElement = function(ownerView, logItem) |
| { |
| - TreeElement.call(this, "", logItem); |
| + TreeElement.call(this, "yo", logItem); |
|
caseq
2014/07/31 13:00:11
yo!
malch
2014/07/31 13:55:53
Done.
|
| this._ownerView = ownerView; |
| this._update(); |
| } |
| @@ -403,11 +378,9 @@ 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; |
| + textContent += "(" + this._paramsToString(logItem.params) + ")"; |
|
caseq
2014/07/31 13:00:11
just inline above line + this one into the below c
malch
2014/07/31 13:55:54
Done.
|
| + title.createTextChild(textContent); |
| this.title = title; |
| }, |
| @@ -445,6 +418,79 @@ WebInspector.LogTreeElement.prototype = { |
| }; |
| /** |
| + * @param {!TreeOutline} treeOutline |
| + * @param {!WebInspector.PaintProfilerCommandLogView} ownerView |
| + * @param {!WebInspector.PaintProfilerLogItem} logItem |
| + */ |
| +WebInspector.LogTreeElement.appendLogItem = function(treeOutline, ownerView, logItem) |
| +{ |
| + var first = new WebInspector.LogTreeElement(ownerView, logItem); |
| + treeOutline.appendChild(first); |
| + for (var param in logItem.params) |
| + WebInspector.LogPropertyTreeElement.appendLogPropertyItem(first, param, logItem.params[param]); |
| +}; |
| + |
| +/** |
| + * @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) |
|
caseq
2014/07/31 13:48:39
make it _private and move just after LogPropertyTr
malch
2014/07/31 13:55:53
Done.
|
| +{ |
| + 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() |