Diff
Modified: trunk/Source/WebCore/ChangeLog (138244 => 138245)
--- trunk/Source/WebCore/ChangeLog 2012-12-20 12:43:56 UTC (rev 138244)
+++ trunk/Source/WebCore/ChangeLog 2012-12-20 13:01:42 UTC (rev 138245)
@@ -1,3 +1,52 @@
+2012-12-20 Yury Semikhatsky <yu...@chromium.org>
+
+ Web Inspector: extract native heap graph representation into a separate file
+ https://bugs.webkit.org/show_bug.cgi?id=105524
+
+ Reviewed by Alexander Pavlov.
+
+ Moved native heap graph parser into NativeHeapGraph.js, renamed NativeHeapGraphNode to NativeHeapGraph.Node
+ and NativeHeapGraphEdge to NativeHeapGraph.Edge
+ Removed unused pie chart view.
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/InspectorMemoryAgent.cpp:
+ (WebCore::InspectorMemoryAgent::getProcessMemoryDistribution): fixed optional parameter handling
+ * WebCore.gypi:
+ * inspector/InspectorMemoryAgent.cpp:
+ (WebCore::InspectorMemoryAgent::getProcessMemoryDistribution):
+ * inspector/compile-front-end.py:
+ * inspector/front-end/NativeHeapGraph.js: Added.
+ (WebInspector.NativeHeapGraph):
+ (WebInspector.NativeHeapGraph.prototype.rootNodes):
+ (WebInspector.NativeHeapGraph.prototype._calculateNodeEdgeIndexes):
+ (WebInspector.NativeHeapGraph.prototype._addDummyNode):
+ (WebInspector.NativeHeapGraph.Edge):
+ (WebInspector.NativeHeapGraph.Edge.prototype.type):
+ (WebInspector.NativeHeapGraph.Edge.prototype.name):
+ (WebInspector.NativeHeapGraph.Edge.prototype.target):
+ (WebInspector.NativeHeapGraph.Edge.prototype._getStringField):
+ (WebInspector.NativeHeapGraph.Edge.prototype.toString):
+ (WebInspector.NativeHeapGraph.Node):
+ (WebInspector.NativeHeapGraph.Node.prototype.id):
+ (WebInspector.NativeHeapGraph.Node.prototype.type):
+ (WebInspector.NativeHeapGraph.Node.prototype.size):
+ (WebInspector.NativeHeapGraph.Node.prototype.className):
+ (WebInspector.NativeHeapGraph.Node.prototype.name):
+ (WebInspector.NativeHeapGraph.Node.prototype.hasReferencedNodes):
+ (WebInspector.NativeHeapGraph.Node.prototype.referencedNodes):
+ (WebInspector.NativeHeapGraph.Node.prototype.outgoingEdges):
+ (WebInspector.NativeHeapGraph.Node.prototype.targetOfEdge):
+ (WebInspector.NativeHeapGraph.Node.prototype.targetsOfAllEdges):
+ (WebInspector.NativeHeapGraph.Node.prototype._firstEdgePoistion):
+ (WebInspector.NativeHeapGraph.Node.prototype._afterLastEdgePosition):
+ (WebInspector.NativeHeapGraph.Node.prototype._getStringField):
+ (WebInspector.NativeHeapGraph.Node.prototype.toString):
+ * inspector/front-end/NativeMemorySnapshotView.js:
+ * inspector/front-end/ProfilesPanel.js:
+ * inspector/front-end/WebKit.qrc:
+
2012-12-20 Eugene Klyuchnikov <eustas....@gmail.com>
Web Inspector: Timeline: enhance short-records filter.
Modified: trunk/Source/WebCore/WebCore.gypi (138244 => 138245)
--- trunk/Source/WebCore/WebCore.gypi 2012-12-20 12:43:56 UTC (rev 138244)
+++ trunk/Source/WebCore/WebCore.gypi 2012-12-20 13:01:42 UTC (rev 138245)
@@ -5322,6 +5322,7 @@
'inspector/front-end/HeapSnapshotProxy.js',
'inspector/front-end/HeapSnapshotView.js',
'inspector/front-end/HeapSnapshotWorkerDispatcher.js',
+ 'inspector/front-end/NativeHeapGraph.js',
'inspector/front-end/NativeMemorySnapshotView.js',
'inspector/front-end/ProfileDataGridTree.js',
'inspector/front-end/ProfilesPanel.js',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (138244 => 138245)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-12-20 12:43:56 UTC (rev 138244)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-12-20 13:01:42 UTC (rev 138245)
@@ -76753,6 +76753,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\NativeHeapGraph.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\NativeMemorySnapshotView.js"
>
</File>
Modified: trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp (138244 => 138245)
--- trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp 2012-12-20 12:43:56 UTC (rev 138244)
+++ trunk/Source/WebCore/inspector/InspectorMemoryAgent.cpp 2012-12-20 13:01:42 UTC (rev 138245)
@@ -539,7 +539,7 @@
void InspectorMemoryAgent::getProcessMemoryDistribution(ErrorString*, const bool* reportGraph, RefPtr<InspectorMemoryBlock>& processMemory, RefPtr<InspectorObject>& graph)
{
OwnPtr<HeapGraphSerializer> graphSerializer;
- if (reportGraph)
+ if (reportGraph && *reportGraph)
graphSerializer = adoptPtr(new HeapGraphSerializer());
MemoryInstrumentationClientImpl memoryInstrumentationClient(graphSerializer.get());
m_inspectorClient->getAllocatedObjects(memoryInstrumentationClient.allocatedObjects());
Modified: trunk/Source/WebCore/inspector/compile-front-end.py (138244 => 138245)
--- trunk/Source/WebCore/inspector/compile-front-end.py 2012-12-20 12:43:56 UTC (rev 138244)
+++ trunk/Source/WebCore/inspector/compile-front-end.py 2012-12-20 13:01:42 UTC (rev 138245)
@@ -330,6 +330,7 @@
"HeapSnapshotView.js",
"HeapSnapshotWorker.js",
"HeapSnapshotWorkerDispatcher.js",
+ "NativeHeapGraph.js",
"NativeMemorySnapshotView.js",
"ProfileDataGridTree.js",
"ProfilesPanel.js",
Added: trunk/Source/WebCore/inspector/front-end/NativeHeapGraph.js (0 => 138245)
--- trunk/Source/WebCore/inspector/front-end/NativeHeapGraph.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/NativeHeapGraph.js 2012-12-20 13:01:42 UTC (rev 138245)
@@ -0,0 +1,261 @@
+/*
+ * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/**
+ * @constructor
+ */
+WebInspector.NativeHeapGraph = function(rawGraph)
+{
+ this._rawGraph = rawGraph;
+
+ this._nodeFieldCount = 5;
+ this._nodeTypeOffset = 0;
+ this._nodeSizeOffset = 1;
+ this._nodeClassNameOffset = 2;
+ this._nodeNameOffset = 3;
+ this._nodeEdgeCountOffset = 4;
+ this._nodeFirstEdgeOffset = this._nodeEdgeCountOffset;
+
+ this._edgeFieldCount = 3;
+ this._edgeTypeOffset = 0;
+ this._edgeTargetOffset = 1;
+ this._edgeNameOffset = 2;
+
+ this._nodeCount = rawGraph.nodes.length / this._nodeFieldCount;
+ this._nodes = rawGraph.nodes;
+ this._edges = rawGraph.edges;
+ this._strings = rawGraph.strings;
+
+ this._calculateNodeEdgeIndexes();
+}
+
+WebInspector.NativeHeapGraph.prototype = {
+ rootNodes: function()
+ {
+ var nodeHasIncomingEdges = new Uint8Array(this._nodeCount);
+ var edges = this._edges;
+ var edgesLength = edges.length;
+ var edgeFieldCount = this._edgeFieldCount;
+ var nodeFieldCount = this._nodeFieldCount;
+ for (var i = this._edgeTargetOffset; i < edgesLength; i += edgeFieldCount) {
+ var targetIndex = edges[i];
+ nodeHasIncomingEdges[targetIndex] = 1;
+ }
+ var roots = [];
+ var nodeCount = nodeHasIncomingEdges.length;
+ for (var i = 0; i < nodeCount; i++) {
+ if (!nodeHasIncomingEdges[i])
+ roots.push(new WebInspector.NativeHeapGraph.Node(this, i * nodeFieldCount));
+ }
+ return roots;
+ },
+
+ _calculateNodeEdgeIndexes: function()
+ {
+ var nodes = this._nodes;
+ var nodeFieldCount = this._nodeFieldCount;
+ var nodeLength = nodes.length;
+ var firstEdgeIndex = 0;
+ for (var i = this._nodeEdgeCountOffset; i < nodeLength; i += nodeFieldCount) {
+ var count = nodes[i];
+ nodes[i] = firstEdgeIndex;
+ firstEdgeIndex += count;
+ }
+ this._addDummyNode();
+ },
+
+ _addDummyNode: function()
+ {
+ var firstEdgePosition = this._nodes.length + this._nodeFirstEdgeOffset;
+ for (var i = 0; i < this._nodeFieldCount; i++)
+ this._nodes.push(0);
+ this._nodes[firstEdgePosition] = this._edges.length;
+ }
+}
+
+
+/**
+ * @constructor
+ * @param {WebInspector.NativeHeapGraph} graph
+ * @param {number} position
+ */
+WebInspector.NativeHeapGraph.Edge = function(graph, position)
+{
+ this._graph = graph;
+ this._position = position;
+}
+
+WebInspector.NativeHeapGraph.Edge.prototype = {
+ type: function()
+ {
+ return this._getStringField(this._graph._edgeTypeOffset);
+ },
+
+ name: function()
+ {
+ return this._getStringField(this._graph._edgeNameOffset);
+ },
+
+ target: function()
+ {
+ var edges = this._graph._edges;
+ var targetPosition = edges[this._position + this._graph._edgeTargetOffset] * this._graph._nodeFieldCount;
+ return new WebInspector.NativeHeapGraph.Node(this._graph, targetPosition);
+ },
+
+ _getStringField: function(offset)
+ {
+ var typeIndex = this._graph._edges[this._position + offset];
+ return this._graph._rawGraph.strings[typeIndex];
+ },
+
+ toString: function()
+ {
+ return "Edge#" + this._position + " -" + this.name() + "-> " + this.target();
+ }
+
+}
+
+
+/**
+ * @constructor
+ * @param {WebInspector.NativeHeapGraph} graph
+ * @param {number} position
+ */
+WebInspector.NativeHeapGraph.Node = function(graph, position)
+{
+ this._graph = graph;
+ this._position = position;
+}
+
+WebInspector.NativeHeapGraph.Node.prototype = {
+ id: function()
+ {
+ return this._position / this._graph._nodeFieldCount;
+ },
+
+ type: function()
+ {
+ return this._getStringField(this._graph._nodeTypeOffset);
+ },
+
+ size: function()
+ {
+ return this._graph._nodes[this._position + this._graph._nodeSizeOffset];
+ },
+
+ className: function()
+ {
+ return this._getStringField(this._graph._nodeClassNameOffset);
+ },
+
+ name: function()
+ {
+ return this._getStringField(this._graph._nodeNameOffset);
+ },
+
+ hasReferencedNodes: function()
+ {
+ return this._afterLastEdgePosition() > this._firstEdgePoistion();
+ },
+
+ referencedNodes: function()
+ {
+ var edges = this._graph._edges;
+ var nodes = this._graph._nodes;
+ var edgeFieldCount = this._graph._edgeFieldCount;
+ var nodeFieldCount = this._graph._nodeFieldCount;
+
+ var firstEdgePosition = this._firstEdgePoistion();
+ var afterLastEdgePosition = this._afterLastEdgePosition();
+ var result = [];
+ for (var i = firstEdgePosition + this._graph._edgeTargetOffset; i < afterLastEdgePosition; i += edgeFieldCount)
+ result.push(new WebInspector.NativeHeapGraph.Node(this._graph, edges[i] * nodeFieldCount));
+ return result;
+ },
+
+ outgoingEdges: function()
+ {
+ var edges = this._graph._edges;
+ var edgeFieldCount = this._graph._edgeFieldCount;
+
+ var firstEdgePosition = this._firstEdgePoistion();
+ var afterLastEdgePosition = this._afterLastEdgePosition();
+ var result = [];
+ for (var i = firstEdgePosition; i < afterLastEdgePosition; i += edgeFieldCount)
+ result.push(new WebInspector.NativeHeapGraph.Edge(this._graph, i));
+ return result;
+ },
+
+ targetOfEdge: function(edgeName)
+ {
+ return this.targetsOfAllEdges(edgeName)[0];
+ },
+
+ targetsOfAllEdges: function(edgeName)
+ {
+ var edges = this._graph._edges;
+ var edgeFieldCount = this._graph._edgeFieldCount;
+
+ var firstEdgePosition = this._firstEdgePoistion();
+ var afterLastEdgePosition = this._afterLastEdgePosition();
+
+ var edge = new WebInspector.NativeHeapGraph.Edge(this._graph, firstEdgePosition)
+ var result = [];
+ for (var i = firstEdgePosition; i < afterLastEdgePosition; i += edgeFieldCount) {
+ edge._position = i;
+ if (edge.name() === edgeName)
+ result.push(edge.target());
+ }
+ return result;
+ },
+
+ _firstEdgePoistion: function()
+ {
+ return this._graph._nodes[this._position + this._graph._nodeFirstEdgeOffset] * this._graph._edgeFieldCount;
+ },
+
+ _afterLastEdgePosition: function()
+ {
+ return this._graph._nodes[this._position + this._graph._nodeFieldCount + this._graph._nodeFirstEdgeOffset] * this._graph._edgeFieldCount;
+ },
+
+ _getStringField: function(offset)
+ {
+ var typeIndex = this._graph._nodes[this._position + offset];
+ return this._graph._rawGraph.strings[typeIndex];
+ },
+
+ toString: function()
+ {
+ return "Node#" + this.id() + " " + this.name() + "(" + this.className() + ")";
+ }
+}
Property changes on: trunk/Source/WebCore/inspector/front-end/NativeHeapGraph.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js (138244 => 138245)
--- trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js 2012-12-20 12:43:56 UTC (rev 138244)
+++ trunk/Source/WebCore/inspector/front-end/NativeMemorySnapshotView.js 2012-12-20 13:01:42 UTC (rev 138245)
@@ -326,238 +326,6 @@
/**
* @constructor
- * @param {WebInspector.NativeHeapGraph} graph
- * @param {number} position
- */
-WebInspector.NativeHeapGraphEdge = function(graph, position)
-{
- this._graph = graph;
- this._position = position;
-}
-
-WebInspector.NativeHeapGraphEdge.prototype = {
- type: function()
- {
- return this._getStringField(this._graph._edgeTypeOffset);
- },
-
- name: function()
- {
- return this._getStringField(this._graph._edgeNameOffset);
- },
-
- target: function()
- {
- var edges = this._graph._edges;
- var targetPosition = edges[this._position + this._graph._edgeTargetOffset] * this._graph._nodeFieldCount;
- return new WebInspector.NativeHeapGraphNode(this._graph, targetPosition);
- },
-
- _getStringField: function(offset)
- {
- var typeIndex = this._graph._edges[this._position + offset];
- return this._graph._rawGraph.strings[typeIndex];
- },
-
- toString: function()
- {
- return "Edge#" + this._position + " -" + this.name() + "-> " + this.target();
- }
-
-}
-
-
-/**
- * @constructor
- * @param {WebInspector.NativeHeapGraph} graph
- * @param {number} position
- */
-WebInspector.NativeHeapGraphNode = function(graph, position)
-{
- this._graph = graph;
- this._position = position;
-}
-
-WebInspector.NativeHeapGraphNode.prototype = {
- id: function()
- {
- return this._position / this._graph._nodeFieldCount;
- },
-
- type: function()
- {
- return this._getStringField(this._graph._nodeTypeOffset);
- },
-
- size: function()
- {
- return this._graph._nodes[this._position + this._graph._nodeSizeOffset];
- },
-
- className: function()
- {
- return this._getStringField(this._graph._nodeClassNameOffset);
- },
-
- name: function()
- {
- return this._getStringField(this._graph._nodeNameOffset);
- },
-
- hasReferencedNodes: function()
- {
- return this._afterLastEdgePosition() > this._firstEdgePoistion();
- },
-
- referencedNodes: function()
- {
- var edges = this._graph._edges;
- var nodes = this._graph._nodes;
- var edgeFieldCount = this._graph._edgeFieldCount;
- var nodeFieldCount = this._graph._nodeFieldCount;
-
- var firstEdgePosition = this._firstEdgePoistion();
- var afterLastEdgePosition = this._afterLastEdgePosition();
- var result = [];
- for (var i = firstEdgePosition + this._graph._edgeTargetOffset; i < afterLastEdgePosition; i += edgeFieldCount)
- result.push(new WebInspector.NativeHeapGraphNode(this._graph, edges[i] * nodeFieldCount));
- return result;
- },
-
- outgoingEdges: function()
- {
- var edges = this._graph._edges;
- var edgeFieldCount = this._graph._edgeFieldCount;
-
- var firstEdgePosition = this._firstEdgePoistion();
- var afterLastEdgePosition = this._afterLastEdgePosition();
- var result = [];
- for (var i = firstEdgePosition; i < afterLastEdgePosition; i += edgeFieldCount)
- result.push(new WebInspector.NativeHeapGraphEdge(this._graph, i));
- return result;
- },
-
- targetOfEdge: function(edgeName)
- {
- return this.targetsOfAllEdges(edgeName)[0];
- },
-
- targetsOfAllEdges: function(edgeName)
- {
- var edges = this._graph._edges;
- var edgeFieldCount = this._graph._edgeFieldCount;
-
- var firstEdgePosition = this._firstEdgePoistion();
- var afterLastEdgePosition = this._afterLastEdgePosition();
-
- var edge = new WebInspector.NativeHeapGraphEdge(this._graph, firstEdgePosition)
- var result = [];
- for (var i = firstEdgePosition; i < afterLastEdgePosition; i += edgeFieldCount) {
- edge._position = i;
- if (edge.name() === edgeName)
- result.push(edge.target());
- }
- return result;
- },
-
- _firstEdgePoistion: function()
- {
- return this._graph._nodes[this._position + this._graph._nodeFirstEdgeOffset] * this._graph._edgeFieldCount;
- },
-
- _afterLastEdgePosition: function()
- {
- return this._graph._nodes[this._position + this._graph._nodeFieldCount + this._graph._nodeFirstEdgeOffset] * this._graph._edgeFieldCount;
- },
-
- _getStringField: function(offset)
- {
- var typeIndex = this._graph._nodes[this._position + offset];
- return this._graph._rawGraph.strings[typeIndex];
- },
-
- toString: function()
- {
- return "Node#" + this.id() + " " + this.name() + "(" + this.className() + ")";
- }
-}
-
-
-/**
- * @constructor
- */
-WebInspector.NativeHeapGraph = function(rawGraph)
-{
- this._rawGraph = rawGraph;
-
- this._nodeFieldCount = 5;
- this._nodeTypeOffset = 0;
- this._nodeSizeOffset = 1;
- this._nodeClassNameOffset = 2;
- this._nodeNameOffset = 3;
- this._nodeEdgeCountOffset = 4;
- this._nodeFirstEdgeOffset = this._nodeEdgeCountOffset;
-
- this._edgeFieldCount = 3;
- this._edgeTypeOffset = 0;
- this._edgeTargetOffset = 1;
- this._edgeNameOffset = 2;
-
- this._nodeCount = rawGraph.nodes.length / this._nodeFieldCount;
- this._nodes = rawGraph.nodes;
- this._edges = rawGraph.edges;
- this._strings = rawGraph.strings;
-
- this._calculateNodeEdgeIndexes();
-}
-
-WebInspector.NativeHeapGraph.prototype = {
- rootNodes: function()
- {
- var nodeHasIncomingEdges = new Uint8Array(this._nodeCount);
- var edges = this._edges;
- var edgesLength = edges.length;
- var edgeFieldCount = this._edgeFieldCount;
- var nodeFieldCount = this._nodeFieldCount;
- for (var i = this._edgeTargetOffset; i < edgesLength; i += edgeFieldCount) {
- var targetIndex = edges[i];
- nodeHasIncomingEdges[targetIndex] = 1;
- }
- var roots = [];
- var nodeCount = nodeHasIncomingEdges.length;
- for (var i = 0; i < nodeCount; i++) {
- if (!nodeHasIncomingEdges[i])
- roots.push(new WebInspector.NativeHeapGraphNode(this, i * nodeFieldCount));
- }
- return roots;
- },
-
- _calculateNodeEdgeIndexes: function()
- {
- var nodes = this._nodes;
- var nodeFieldCount = this._nodeFieldCount;
- var nodeLength = nodes.length;
- var firstEdgeIndex = 0;
- for (var i = this._nodeEdgeCountOffset; i < nodeLength; i += nodeFieldCount) {
- var count = nodes[i];
- nodes[i] = firstEdgeIndex;
- firstEdgeIndex += count;
- }
- this._addDummyNode();
- },
-
- _addDummyNode: function()
- {
- var firstEdgePosition = this._nodes.length + this._nodeFirstEdgeOffset;
- for (var i = 0; i < this._nodeFieldCount; i++)
- this._nodes.push(0);
- this._nodes[firstEdgePosition] = this._edges.length;
- }
-}
-
-
-/**
- * @constructor
* @extends {WebInspector.DataGrid}
* @param {WebInspector.NativeHeapGraph} nativeHeapGraph
*/
@@ -609,7 +377,7 @@
/**
* @constructor
* @extends {WebInspector.DataGridNode}
- * @param {WebInspector.NativeHeapGraphNode} node
+ * @param {WebInspector.NativeHeapGraph.Node} node
*/
WebInspector.NativeHeapGraphDataGridNode = function(node)
{
@@ -826,139 +594,7 @@
/**
* @constructor
* @extends {WebInspector.View}
- * @param {MemoryAgent.MemoryBlock} memorySnapshot
*/
-WebInspector.NativeMemoryPieChart = function(memorySnapshot)
-{
- WebInspector.View.call(this);
- this._memorySnapshot = memorySnapshot;
- this.element = document.createElement("div");
- this.element.addStyleClass("memory-pie-chart-container");
- this._memoryBlockList = this.element.createChild("div", "memory-blocks-list");
-
- this._canvasContainer = this.element.createChild("div", "memory-pie-chart");
- this._canvas = this._canvasContainer.createChild("canvas");
- this._addBlockLabels(memorySnapshot, true);
-}
-
-WebInspector.NativeMemoryPieChart.prototype = {
- /**
- * @override
- */
- onResize: function()
- {
- this._updateSize();
- this._paint();
- },
-
- _updateSize: function()
- {
- var width = this._canvasContainer.clientWidth - 5;
- var height = this._canvasContainer.clientHeight - 5;
- this._canvas.width = width;
- this._canvas.height = height;
- },
-
- _addBlockLabels: function(memoryBlock, includeChildren)
- {
- var viewProperties = WebInspector.MemoryBlockViewProperties._forMemoryBlock(memoryBlock);
- var title = viewProperties._description + ": " + Number.bytesToString(memoryBlock.size);
-
- var swatchElement = this._memoryBlockList.createChild("div", "item");
- swatchElement.createChild("div", "swatch").style.backgroundColor = viewProperties._fillStyle;
- swatchElement.createChild("span", "title").textContent = title;
-
- if (!memoryBlock.children || !includeChildren)
- return;
- for (var i = 0; i < memoryBlock.children.length; i++)
- this._addBlockLabels(memoryBlock.children[i], false);
- },
-
- _paint: function()
- {
- this._clear();
- var width = this._canvas.width;
- var height = this._canvas.height;
-
- var x = width / 2;
- var y = height / 2;
- var radius = 200;
-
- var ctx = this._canvas.getContext("2d");
- ctx.beginPath();
- ctx.arc(x, y, radius, 0, Math.PI*2, false);
- ctx.lineWidth = 1;
- ctx.strokeStyle = "rgba(130, 130, 130, 0.8)";
- ctx.stroke();
- ctx.closePath();
-
- var currentAngle = 0;
- var memoryBlock = this._memorySnapshot;
-
- function paintPercentAndLabel(fraction, title, midAngle)
- {
- ctx.beginPath();
- ctx.font = "13px Arial";
- ctx.fillStyle = "rgba(10, 10, 10, 0.8)";
-
- var textX = x + (radius + 10) * Math.cos(midAngle);
- var textY = y + (radius + 10) * Math.sin(midAngle);
- var relativeOffset = -Math.cos(midAngle) / Math.sin(Math.PI / 12);
- relativeOffset = Number.constrain(relativeOffset, -1, 1);
- var metrics = ctx.measureText(title);
- textX -= metrics.width * (relativeOffset + 1) / 2;
- textY += 5;
- ctx.fillText(title, textX, textY);
-
- // Do not print percentage if the sector is too narrow.
- if (fraction > 0.03) {
- textX = x + radius * Math.cos(midAngle) / 2;
- textY = y + radius * Math.sin(midAngle) / 2;
- ctx.fillText((100 * fraction).toFixed(0) + "%", textX - 8, textY + 5);
- }
-
- ctx.closePath();
- }
-
- if (!memoryBlock.children)
- return;
- var total = memoryBlock.size;
- for (var i = 0; i < memoryBlock.children.length; i++) {
- var child = memoryBlock.children[i];
- if (!child.size)
- continue;
- var viewProperties = WebInspector.MemoryBlockViewProperties._forMemoryBlock(child);
- var angleSpan = Math.PI * 2 * (child.size / total);
- ctx.beginPath();
- ctx.moveTo(x, y);
- ctx.lineTo(x + radius * Math.cos(currentAngle), y + radius * Math.sin(currentAngle));
- ctx.arc(x, y, radius, currentAngle, currentAngle + angleSpan, false);
- ctx.lineWidth = 0.5;
- ctx.lineTo(x, y);
- ctx.fillStyle = viewProperties._fillStyle;
- ctx.strokeStyle = "rgba(100, 100, 100, 0.8)";
- ctx.fill();
- ctx.stroke();
- ctx.closePath();
-
- paintPercentAndLabel(child.size / total, viewProperties._description, currentAngle + angleSpan / 2);
-
- currentAngle += angleSpan;
- }
- },
-
- _clear: function() {
- var ctx = this._canvas.getContext("2d");
- ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
- },
-
- __proto__: WebInspector.View.prototype
-}
-
-/**
- * @constructor
- * @extends {WebInspector.View}
- */
WebInspector.NativeMemoryBarChart = function()
{
WebInspector.View.call(this);
Modified: trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js (138244 => 138245)
--- trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2012-12-20 12:43:56 UTC (rev 138244)
+++ trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2012-12-20 13:01:42 UTC (rev 138245)
@@ -1377,6 +1377,7 @@
importScript("HeapSnapshotProxy.js");
importScript("HeapSnapshotView.js");
importScript("HeapSnapshotWorkerDispatcher.js");
+importScript("NativeHeapGraph.js");
importScript("NativeMemorySnapshotView.js");
importScript("ProfileLauncherView.js");
importScript("TopDownProfileDataGridTree.js");
Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (138244 => 138245)
--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2012-12-20 12:43:56 UTC (rev 138244)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2012-12-20 13:01:42 UTC (rev 138245)
@@ -106,6 +106,7 @@
<file>MemoryStatistics.js</file>
<file>MetricsSidebarPane.js</file>
<file>NativeBreakpointsSidebarPane.js</file>
+ <file>NativeHeapGraph.js</file>
<file>NativeMemorySnapshotView.js</file>
<file>NavigatorOverlayController.js</file>
<file>NavigatorView.js</file>