Diff
Modified: trunk/Source/WebCore/ChangeLog (142861 => 142862)
--- trunk/Source/WebCore/ChangeLog 2013-02-14 10:14:24 UTC (rev 142861)
+++ trunk/Source/WebCore/ChangeLog 2013-02-14 10:22:21 UTC (rev 142862)
@@ -1,3 +1,64 @@
+2013-02-14 Yury Semikhatsky <yu...@chromium.org>
+
+ Web Inspector: extract DOM counters graph implementation into its own class
+ https://bugs.webkit.org/show_bug.cgi?id=109796
+
+ Reviewed by Alexander Pavlov.
+
+ Extracted DOM counters graph implementation into DOMCountersGraph.js leaving
+ in MemoryStatistics.js only common parts shared with NativeMemoryGraph.js
+ Added some closure annotations and converted object literals into classes
+ with named constructors.
+
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * inspector/compile-front-end.py:
+ * inspector/front-end/DOMCountersGraph.js: Added.
+ (WebInspector.DOMCountersGraph):
+ (WebInspector.DOMCounterUI):
+ (WebInspector.DOMCountersGraph.Counter):
+ (WebInspector.DOMCounterUI.prototype.setRange):
+ (WebInspector.DOMCounterUI.prototype.updateCurrentValue):
+ (WebInspector.DOMCounterUI.prototype.clearCurrentValueAndMarker):
+ (WebInspector.DOMCounterUI.prototype.saveImageUnderMarker):
+ (WebInspector.DOMCounterUI.prototype.restoreImageUnderMarker):
+ (WebInspector.DOMCounterUI.prototype.discardImageUnderMarker):
+ (WebInspector.DOMCountersGraph.prototype._createCurrentValuesBar):
+ (WebInspector.DOMCountersGraph.prototype._createCounterUIList):
+ (WebInspector.DOMCountersGraph.prototype._createCounterUIList.getNodeCount):
+ (WebInspector.DOMCountersGraph.prototype._createCounterUIList.getListenerCount):
+ (WebInspector.DOMCountersGraph.prototype._canvasHeight):
+ (WebInspector.DOMCountersGraph.prototype._onRecordAdded):
+ (WebInspector.DOMCountersGraph.prototype._draw):
+ (WebInspector.DOMCountersGraph.prototype._restoreImageUnderMarker):
+ (WebInspector.DOMCountersGraph.prototype._saveImageUnderMarker):
+ (WebInspector.DOMCountersGraph.prototype._drawMarker):
+ (WebInspector.DOMCountersGraph.prototype._drawGraph):
+ (WebInspector.DOMCountersGraph.prototype._discardImageUnderMarker):
+ * inspector/front-end/MemoryStatistics.js:
+ (WebInspector.MemoryStatistics):
+ (WebInspector.MemoryStatistics.Counter):
+ (WebInspector.MemoryStatistics.prototype._createCurrentValuesBar):
+ (WebInspector.MemoryStatistics.prototype._createCounterUIList):
+ (WebInspector.MemoryStatistics.prototype.setTopPosition):
+ (WebInspector.MemoryStatistics.prototype._canvasHeight):
+ (WebInspector.MemoryStatistics.prototype._onRecordAdded):
+ (WebInspector.MemoryStatistics.prototype._draw):
+ (WebInspector.MemoryStatistics.prototype._onClick):
+ (WebInspector.MemoryStatistics.prototype._onMouseOut):
+ (WebInspector.MemoryStatistics.prototype._onMouseOver):
+ (WebInspector.MemoryStatistics.prototype._onMouseMove):
+ (WebInspector.MemoryStatistics.prototype._restoreImageUnderMarker):
+ (WebInspector.MemoryStatistics.prototype._drawMarker):
+ (WebInspector.MemoryStatistics.prototype._discardImageUnderMarker):
+ * inspector/front-end/NativeMemoryGraph.js:
+ (WebInspector.NativeMemoryGraph.Counter):
+ (WebInspector.NativeMemoryGraph.prototype._onRecordAdded.addStatistics):
+ (WebInspector.NativeMemoryGraph.prototype._onRecordAdded):
+ (WebInspector.NativeMemoryGraph.prototype._draw):
+ * inspector/front-end/TimelinePanel.js:
+ * inspector/front-end/WebKit.qrc:
+
2013-02-14 Aivo Paas <aivop...@gmail.com>
Updating mouse cursor on style changes without emitting fake mousemove event
Modified: trunk/Source/WebCore/WebCore.gypi (142861 => 142862)
--- trunk/Source/WebCore/WebCore.gypi 2013-02-14 10:14:24 UTC (rev 142861)
+++ trunk/Source/WebCore/WebCore.gypi 2013-02-14 10:22:21 UTC (rev 142862)
@@ -5180,6 +5180,7 @@
'inspector/front-end/Dialog.js',
'inspector/front-end/DOMAgent.js',
'inspector/front-end/DOMBreakpointsSidebarPane.js',
+ 'inspector/front-end/DOMCountersGraph.js',
'inspector/front-end/DOMExtension.js',
'inspector/front-end/DOMPresentationUtils.js',
'inspector/front-end/DOMStorage.js',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (142861 => 142862)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2013-02-14 10:14:24 UTC (rev 142861)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2013-02-14 10:22:21 UTC (rev 142862)
@@ -77190,6 +77190,10 @@
>
</File>
<File
+ RelativePath="..\inspector\front-end\DOMCountersGraph.js"
+ >
+ </File>
+ <File
RelativePath="..\inspector\front-end\DOMExtension.js"
>
</File>
Modified: trunk/Source/WebCore/inspector/compile-front-end.py (142861 => 142862)
--- trunk/Source/WebCore/inspector/compile-front-end.py 2013-02-14 10:14:24 UTC (rev 142861)
+++ trunk/Source/WebCore/inspector/compile-front-end.py 2013-02-14 10:22:21 UTC (rev 142862)
@@ -277,6 +277,7 @@
"name": "timeline",
"dependencies": ["components"],
"sources": [
+ "DOMCountersGraph.js",
"MemoryStatistics.js",
"NativeMemoryGraph.js",
"TimelineModel.js",
Added: trunk/Source/WebCore/inspector/front-end/DOMCountersGraph.js (0 => 142862)
--- trunk/Source/WebCore/inspector/front-end/DOMCountersGraph.js (rev 0)
+++ trunk/Source/WebCore/inspector/front-end/DOMCountersGraph.js 2013-02-14 10:22:21 UTC (rev 142862)
@@ -0,0 +1,323 @@
+/*
+ * Copyright (C) 2013 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
+ * @extends {WebInspector.MemoryStatistics}
+ * @param {WebInspector.TimelinePanel} timelinePanel
+ * @param {WebInspector.TimelineModel} model
+ * @param {number} sidebarWidth
+ */
+WebInspector.DOMCountersGraph = function(timelinePanel, model, sidebarWidth)
+{
+ WebInspector.MemoryStatistics.call(this, timelinePanel, model, sidebarWidth);
+ TimelineAgent.setIncludeDomCounters(true);
+}
+
+/**
+ * @constructor
+ * @extends {WebInspector.CounterUIBase}
+ * @param {WebInspector.DOMCountersGraph} memoryCountersPane
+ * @param {string} title
+ * @param {string} currentValueLabel
+ * @param {Array.<number>} rgb
+ * @param {function(WebInspector.DOMCountersGraph.Counter):number} valueGetter
+ */
+WebInspector.DOMCounterUI = function(memoryCountersPane, title, currentValueLabel, rgb, valueGetter)
+{
+ var swatchColor = "rgb(" + rgb.join(",") + ")";
+ WebInspector.CounterUIBase.call(this, memoryCountersPane, title, swatchColor, valueGetter)
+ this._range = this._swatch.element.createChild("span");
+
+ this._value = memoryCountersPane._currentValuesBar.createChild("span", "memory-counter-value");
+ this._value.style.color = swatchColor;
+ this._currentValueLabel = currentValueLabel;
+
+ this.graphColor = "rgba(" + rgb.join(",") + ",0.8)";
+ this.graphYValues = [];
+}
+
+/**
+ * @constructor
+ * @extends {WebInspector.MemoryStatistics.Counter}
+ * @param {number} time
+ * @param {number} documentCount
+ * @param {number} nodeCount
+ * @param {number} listenerCount
+ */
+WebInspector.DOMCountersGraph.Counter = function(time, documentCount, nodeCount, listenerCount)
+{
+ WebInspector.MemoryStatistics.Counter.call(this, time);
+ this.documentCount = documentCount;
+ this.nodeCount = nodeCount;
+ this.listenerCount = listenerCount;
+}
+
+WebInspector.DOMCounterUI.prototype = {
+ /**
+ * @param {number} minValue
+ * @param {number} maxValue
+ */
+ setRange: function(minValue, maxValue)
+ {
+ this._range.textContent = WebInspector.UIString("[ %d - %d ]", minValue, maxValue);
+ },
+
+ updateCurrentValue: function(countersEntry)
+ {
+ this._value.textContent = WebInspector.UIString(this._currentValueLabel, this.valueGetter(countersEntry));
+ },
+
+ clearCurrentValueAndMarker: function(ctx)
+ {
+ this._value.textContent = "";
+ this.restoreImageUnderMarker(ctx);
+ },
+
+ /**
+ * @param {CanvasRenderingContext2D} ctx
+ * @param {number} x
+ * @param {number} y
+ * @param {number} radius
+ */
+ saveImageUnderMarker: function(ctx, x, y, radius)
+ {
+ const w = radius + 1;
+ var imageData = ctx.getImageData(x - w, y - w, 2 * w, 2 * w);
+ this._imageUnderMarker = {
+ x: x - w,
+ y: y - w,
+ imageData: imageData
+ };
+ },
+
+ /**
+ * @param {CanvasRenderingContext2D} ctx
+ */
+ restoreImageUnderMarker: function(ctx)
+ {
+ if (!this.visible)
+ return;
+ if (this._imageUnderMarker)
+ ctx.putImageData(this._imageUnderMarker.imageData, this._imageUnderMarker.x, this._imageUnderMarker.y);
+ this.discardImageUnderMarker();
+ },
+
+ discardImageUnderMarker: function()
+ {
+ delete this._imageUnderMarker;
+ },
+
+ __proto__: WebInspector.CounterUIBase.prototype
+}
+
+
+WebInspector.DOMCountersGraph.prototype = {
+ _createCurrentValuesBar: function()
+ {
+ this._currentValuesBar = this._canvasContainer.createChild("div");
+ this._currentValuesBar.id = "counter-values-bar";
+ this._canvasContainer.addStyleClass("dom-counters");
+ },
+
+ /**
+ * @return {Array.<WebInspector.DOMCounterUI>}
+ */
+ _createCounterUIList: function()
+ {
+ function getDocumentCount(entry)
+ {
+ return entry.documentCount;
+ }
+ function getNodeCount(entry)
+ {
+ return entry.nodeCount;
+ }
+ function getListenerCount(entry)
+ {
+ return entry.listenerCount;
+ }
+ return [
+ new WebInspector.DOMCounterUI(this, "Document Count", "Documents: %d", [100, 0, 0], getDocumentCount),
+ new WebInspector.DOMCounterUI(this, "DOM Node Count", "Nodes: %d", [0, 100, 0], getNodeCount),
+ new WebInspector.DOMCounterUI(this, "Event Listener Count", "Listeners: %d", [0, 0, 100], getListenerCount)
+ ];
+ },
+
+ _canvasHeight: function()
+ {
+ return this._canvasContainer.offsetHeight - this._currentValuesBar.offsetHeight;
+ },
+
+ /**
+ * @param {WebInspector.Event} event
+ */
+ _onRecordAdded: function(event)
+ {
+ function addStatistics(record)
+ {
+ var counters = record["counters"];
+ if (!counters)
+ return;
+ this._counters.push(new WebInspector.DOMCountersGraph.Counter(
+ record.endTime || record.startTime,
+ counters["documents"],
+ counters["nodes"],
+ counters["jsEventListeners"]
+ ));
+ }
+ WebInspector.TimelinePresentationModel.forAllRecords([event.data], null, addStatistics.bind(this));
+ },
+
+ _draw: function()
+ {
+ WebInspector.MemoryStatistics.prototype._draw.call(this);
+ for (var i = 0; i < this._counterUI.length; i++)
+ this._drawGraph(this._counterUI[i]);
+ },
+
+ /**
+ * @param {CanvasRenderingContext2D} ctx
+ */
+ _restoreImageUnderMarker: function(ctx)
+ {
+ for (var i = 0; i < this._counterUI.length; i++) {
+ var counterUI = this._counterUI[i];
+ if (!counterUI.visible)
+ continue;
+ counterUI.restoreImageUnderMarker(ctx);
+ }
+ },
+
+ /**
+ * @param {CanvasRenderingContext2D} ctx
+ * @param {number} x
+ * @param {number} index
+ */
+ _saveImageUnderMarker: function(ctx, x, index)
+ {
+ const radius = 2;
+ for (var i = 0; i < this._counterUI.length; i++) {
+ var counterUI = this._counterUI[i];
+ if (!counterUI.visible)
+ continue;
+ var y = counterUI.graphYValues[index];
+ counterUI.saveImageUnderMarker(ctx, x, y, radius);
+ }
+ },
+
+ /**
+ * @param {CanvasRenderingContext2D} ctx
+ * @param {number} x
+ * @param {number} index
+ */
+ _drawMarker: function(ctx, x, index)
+ {
+ this._saveImageUnderMarker(ctx, x, index);
+ const radius = 2;
+ for (var i = 0; i < this._counterUI.length; i++) {
+ var counterUI = this._counterUI[i];
+ if (!counterUI.visible)
+ continue;
+ var y = counterUI.graphYValues[index];
+ ctx.beginPath();
+ ctx.arc(x, y, radius, 0, Math.PI * 2, true);
+ ctx.lineWidth = 1;
+ ctx.fillStyle = counterUI.graphColor;
+ ctx.strokeStyle = counterUI.graphColor;
+ ctx.fill();
+ ctx.stroke();
+ ctx.closePath();
+ }
+ },
+
+ /**
+ * @param {WebInspector.CounterUIBase} counterUI
+ */
+ _drawGraph: function(counterUI)
+ {
+ var canvas = this._canvas;
+ var ctx = canvas.getContext("2d");
+ var width = canvas.width;
+ var height = this._clippedHeight;
+ var originY = this._originY;
+ var valueGetter = counterUI.valueGetter;
+
+ if (!this._counters.length)
+ return;
+
+ var maxValue;
+ var minValue;
+ for (var i = this._minimumIndex; i <= this._maximumIndex; i++) {
+ var value = valueGetter(this._counters[i]);
+ if (minValue === undefined || value < minValue)
+ minValue = value;
+ if (maxValue === undefined || value > maxValue)
+ maxValue = value;
+ }
+
+ counterUI.setRange(minValue, maxValue);
+
+ if (!counterUI.visible)
+ return;
+
+ var yValues = counterUI.graphYValues;
+ yValues.length = this._counters.length;
+
+ var maxYRange = maxValue - minValue;
+ var yFactor = maxYRange ? height / (maxYRange) : 1;
+
+ ctx.beginPath();
+ var currentY = originY + (height - (valueGetter(this._counters[this._minimumIndex]) - minValue) * yFactor);
+ ctx.moveTo(0, currentY);
+ for (var i = this._minimumIndex; i <= this._maximumIndex; i++) {
+ var x = this._counters[i].x;
+ ctx.lineTo(x, currentY);
+ currentY = originY + (height - (valueGetter(this._counters[i]) - minValue) * yFactor);
+ ctx.lineTo(x, currentY);
+
+ yValues[i] = currentY;
+ }
+ ctx.lineTo(width, currentY);
+ ctx.lineWidth = 1;
+ ctx.strokeStyle = counterUI.graphColor;
+ ctx.stroke();
+ ctx.closePath();
+ },
+
+ _discardImageUnderMarker: function()
+ {
+ for (var i = 0; i < this._counterUI.length; i++)
+ this._counterUI[i].discardImageUnderMarker();
+ },
+
+ __proto__: WebInspector.MemoryStatistics.prototype
+}
+
Property changes on: trunk/Source/WebCore/inspector/front-end/DOMCountersGraph.js
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js (142861 => 142862)
--- trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js 2013-02-14 10:14:24 UTC (rev 142861)
+++ trunk/Source/WebCore/inspector/front-end/MemoryStatistics.js 2013-02-14 10:22:21 UTC (rev 142862)
@@ -67,8 +67,15 @@
// Populate sidebar
this._memorySidebarView.sidebarElement.createChild("div", "sidebar-tree sidebar-tree-section").textContent = WebInspector.UIString("COUNTERS");
this._counterUI = this._createCounterUIList();
+}
- TimelineAgent.setIncludeDomCounters(true);
+/**
+ * @constructor
+ * @param {number} time
+ */
+WebInspector.MemoryStatistics.Counter = function(time)
+{
+ this.time = time;
}
/**
@@ -159,96 +166,15 @@
},
}
-/**
- * @constructor
- * @extends {WebInspector.CounterUIBase}
- */
-WebInspector.DOMCounterUI = function(memoryCountersPane, title, currentValueLabel, rgb, valueGetter)
-{
- var swatchColor = "rgb(" + rgb.join(",") + ")";
- WebInspector.CounterUIBase.call(this, memoryCountersPane, title, swatchColor, valueGetter)
- this._range = this._swatch.element.createChild("span");
-
- this._value = memoryCountersPane._currentValuesBar.createChild("span", "memory-counter-value");
- this._value.style.color = swatchColor;
- this._currentValueLabel = currentValueLabel;
-
- this.graphColor = "rgba(" + rgb.join(",") + ",0.8)";
- this.graphYValues = [];
-}
-
-WebInspector.DOMCounterUI.prototype = {
- setRange: function(minValue, maxValue)
- {
- this._range.textContent = WebInspector.UIString("[ %d - %d ]", minValue, maxValue);
- },
-
- updateCurrentValue: function(countersEntry)
- {
- this._value.textContent = WebInspector.UIString(this._currentValueLabel, this.valueGetter(countersEntry));
- },
-
- clearCurrentValueAndMarker: function(ctx)
- {
- this._value.textContent = "";
- this.restoreImageUnderMarker(ctx);
- },
-
- saveImageUnderMarker: function(ctx, x, y, radius)
- {
- const w = radius + 1;
- var imageData = ctx.getImageData(x - w, y - w, 2 * w, 2 * w);
- this._imageUnderMarker = {
- x: x - w,
- y: y - w,
- imageData: imageData };
- },
-
- restoreImageUnderMarker: function(ctx)
- {
- if (!this.visible)
- return;
- if (this._imageUnderMarker)
- ctx.putImageData(this._imageUnderMarker.imageData, this._imageUnderMarker.x, this._imageUnderMarker.y);
- this.discardImageUnderMarker();
- },
-
- discardImageUnderMarker: function()
- {
- delete this._imageUnderMarker;
- },
-
- __proto__: WebInspector.CounterUIBase.prototype
-}
-
-
WebInspector.MemoryStatistics.prototype = {
_createCurrentValuesBar: function()
{
- this._currentValuesBar = this._canvasContainer.createChild("div");
- this._currentValuesBar.id = "counter-values-bar";
- this._canvasContainer.addStyleClass("dom-counters");
+ throw new Error("Not implemented");
},
_createCounterUIList: function()
{
- function getDocumentCount(entry)
- {
- return entry.documentCount;
- }
- function getNodeCount(entry)
- {
- return entry.nodeCount;
- }
- function getListenerCount(entry)
- {
- return entry.listenerCount;
- }
- return [
- new WebInspector.DOMCounterUI(this, "Document Count", "Documents: %d", [100,0,0], getDocumentCount),
- new WebInspector.DOMCounterUI(this, "DOM Node Count", "Nodes: %d", [0,100,0], getNodeCount),
- new WebInspector.DOMCounterUI(this, "Event Listener Count", "Listeners: %d", [0,0,100], getListenerCount)
- ];
+ throw new Error("Not implemented");
},
_onRecordsCleared: function()
@@ -256,17 +182,26 @@
this._counters = [];
},
+ /**
+ * @param {WebInspector.TimelineGrid} timelineGrid
+ */
setMainTimelineGrid: function(timelineGrid)
{
this._mainTimelineGrid = timelineGrid;
},
- setTopPosition: function(top)
+ /**
+ * @param {number} top
+ */
+ setTopPosition: function(top)
{
this._memorySidebarView.element.style.top = top + "px";
this._updateSize();
},
+ /**
+ * @param {number} width
+ */
setSidebarWidth: function(width)
{
if (this._ignoreSidebarResize)
@@ -276,6 +211,9 @@
this._ignoreSidebarResize = false;
},
+ /**
+ * @param {WebInspector.Event} event
+ */
_sidebarResized: function(event)
{
if (this._ignoreSidebarResize)
@@ -287,7 +225,7 @@
_canvasHeight: function()
{
- return this._canvasContainer.offsetHeight - this._currentValuesBar.offsetHeight;
+ throw new Error("Not implemented");
},
_updateSize: function()
@@ -300,22 +238,12 @@
this._canvas.height = height;
},
+ /**
+ * @param {WebInspector.Event} event
+ */
_onRecordAdded: function(event)
{
- var statistics = this._counters;
- function addStatistics(record)
- {
- var counters = record["counters"];
- if (!counters)
- return;
- statistics.push({
- time: record.endTime || record.startTime,
- documentCount: counters["documents"],
- nodeCount: counters["nodes"],
- listenerCount: counters["jsEventListeners"]
- });
- }
- WebInspector.TimelinePresentationModel.forAllRecords([event.data], null, addStatistics);
+ throw new Error("Not implemented");
},
_draw: function()
@@ -325,8 +253,6 @@
this._clear();
this._setVerticalClip(10, this._canvas.height - 20);
- for (var i = 0; i < this._counterUI.length; i++)
- this._drawGraph(this._counterUI[i]);
},
_calculateVisibleIndexes: function()
@@ -357,7 +283,10 @@
this._maxTime = end;
},
- _onClick: function(event)
+ /**
+ * @param {MouseEvent} event
+ */
+ _onClick: function(event)
{
var x = event.x - event.target.offsetParent.offsetLeft;
var i = this._recordIndexAt(x);
@@ -366,7 +295,10 @@
this._timelinePanel.revealRecordAt(counter.time / 1000);
},
- _onMouseOut: function(event)
+ /**
+ * @param {MouseEvent} event
+ */
+ _onMouseOut: function(event)
{
delete this._markerXPosition;
@@ -374,18 +306,27 @@
this._clearCurrentValueAndMarker(ctx);
},
+ /**
+ * @param {CanvasRenderingContext2D} ctx
+ */
_clearCurrentValueAndMarker: function(ctx)
{
for (var i = 0; i < this._counterUI.length; i++)
this._counterUI[i].clearCurrentValueAndMarker(ctx);
},
- _onMouseOver: function(event)
+ /**
+ * @param {MouseEvent} event
+ */
+ _onMouseOver: function(event)
{
this._onMouseMove(event);
},
- _onMouseMove: function(event)
+ /**
+ * @param {MouseEvent} event
+ */
+ _onMouseMove: function(event)
{
var x = event.x - event.target.offsetParent.offsetLeft
this._markerXPosition = x;
@@ -432,44 +373,12 @@
_restoreImageUnderMarker: function(ctx)
{
- for (var i = 0; i < this._counterUI.length; i++) {
- var counterUI = this._counterUI[i];
- if (!counterUI.visible)
- continue;
- counterUI.restoreImageUnderMarker(ctx);
- }
+ throw new Error("Not implemented");
},
- _saveImageUnderMarker: function(ctx, x, index)
- {
- const radius = 2;
- for (var i = 0; i < this._counterUI.length; i++) {
- var counterUI = this._counterUI[i];
- if (!counterUI.visible)
- continue;
- var y = counterUI.graphYValues[index];
- counterUI.saveImageUnderMarker(ctx, x, y, radius);
- }
- },
-
_drawMarker: function(ctx, x, index)
{
- this._saveImageUnderMarker(ctx, x, index);
- const radius = 2;
- for (var i = 0; i < this._counterUI.length; i++) {
- var counterUI = this._counterUI[i];
- if (!counterUI.visible)
- continue;
- var y = counterUI.graphYValues[index];
- ctx.beginPath();
- ctx.arc(x, y, radius, 0, Math.PI*2, true);
- ctx.lineWidth = 1;
- ctx.fillStyle = counterUI.graphColor;
- ctx.strokeStyle = counterUI.graphColor;
- ctx.fill();
- ctx.stroke();
- ctx.closePath();
- }
+ throw new Error("Not implemented");
},
visible: function()
@@ -524,57 +433,6 @@
this._counters[this._maximumIndex].x = width;
},
- _drawGraph: function(counterUI)
- {
- var canvas = this._canvas;
- var ctx = canvas.getContext("2d");
- var width = canvas.width;
- var height = this._clippedHeight;
- var originY = this._originY;
- var valueGetter = counterUI.valueGetter;
-
- if (!this._counters.length)
- return;
-
- var maxValue;
- var minValue;
- for (var i = this._minimumIndex; i <= this._maximumIndex; i++) {
- var value = valueGetter(this._counters[i]);
- if (minValue === undefined || value < minValue)
- minValue = value;
- if (maxValue === undefined || value > maxValue)
- maxValue = value;
- }
-
- counterUI.setRange(minValue, maxValue);
-
- if (!counterUI.visible)
- return;
-
- var yValues = counterUI.graphYValues;
- yValues.length = this._counters.length;
-
- var maxYRange = maxValue - minValue;
- var yFactor = maxYRange ? height / (maxYRange) : 1;
-
- ctx.beginPath();
- var currentY = originY + (height - (valueGetter(this._counters[this._minimumIndex])- minValue) * yFactor);
- ctx.moveTo(0, currentY);
- for (var i = this._minimumIndex; i <= this._maximumIndex; i++) {
- var x = this._counters[i].x;
- ctx.lineTo(x, currentY);
- currentY = originY + (height - (valueGetter(this._counters[i])- minValue) * yFactor);
- ctx.lineTo(x, currentY);
-
- yValues[i] = currentY;
- }
- ctx.lineTo(width, currentY);
- ctx.lineWidth = 1;
- ctx.strokeStyle = counterUI.graphColor;
- ctx.stroke();
- ctx.closePath();
- },
-
_clear: function() {
var ctx = this._canvas.getContext("2d");
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
@@ -583,8 +441,7 @@
_discardImageUnderMarker: function()
{
- for (var i = 0; i < this._counterUI.length; i++)
- this._counterUI[i].discardImageUnderMarker();
+ throw new Error("Not implemented");
}
}
Modified: trunk/Source/WebCore/inspector/front-end/NativeMemoryGraph.js (142861 => 142862)
--- trunk/Source/WebCore/inspector/front-end/NativeMemoryGraph.js 2013-02-14 10:14:24 UTC (rev 142861)
+++ trunk/Source/WebCore/inspector/front-end/NativeMemoryGraph.js 2013-02-14 10:22:21 UTC (rev 142862)
@@ -43,7 +43,21 @@
/**
* @constructor
+ * @extends {WebInspector.MemoryStatistics.Counter}
+ */
+WebInspector.NativeMemoryGraph.Counter = function(time, nativeCounters)
+{
+ WebInspector.MemoryStatistics.Counter.call(this, time);
+ this.nativeCounters = nativeCounters;
+}
+
+/**
+ * @constructor
* @extends {WebInspector.CounterUIBase}
+ * @param {WebInspector.NativeMemoryGraph} memoryCountersPane
+ * @param {string} title
+ * @param {Array.<number>} hsl
+ * @param {function(WebInspector.NativeMemoryGraph.Counter):number} valueGetter
*/
WebInspector.NativeMemoryCounterUI = function(memoryCountersPane, title, hsl, valueGetter)
{
@@ -149,22 +163,18 @@
}
nativeCounters["Other"] = nativeCounters["PrivateBytes"] - knownSize;
- statistics.push({
- time: record.endTime || record.startTime,
- nativeCounters: nativeCounters
- });
+ statistics.push(new WebInspector.NativeMemoryGraph.Counter(
+ record.endTime || record.startTime,
+ nativeCounters
+ ));
}
WebInspector.TimelinePresentationModel.forAllRecords([event.data], null, addStatistics);
},
_draw: function()
{
- this._calculateVisibleIndexes();
- this._calculateXValues();
- this._clear();
+ WebInspector.MemoryStatistics.prototype._draw.call(this);
- this._setVerticalClip(10, this._canvas.height - 20);
-
var maxValue = this._maxCounterValue();
this._resetTotalValues();
Modified: trunk/Source/WebCore/inspector/front-end/TimelinePanel.js (142861 => 142862)
--- trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2013-02-14 10:14:24 UTC (rev 142861)
+++ trunk/Source/WebCore/inspector/front-end/TimelinePanel.js 2013-02-14 10:22:21 UTC (rev 142862)
@@ -30,6 +30,7 @@
*/
importScript("MemoryStatistics.js");
+importScript("DOMCountersGraph.js");
importScript("NativeMemoryGraph.js");
importScript("TimelineModel.js");
importScript("TimelineOverviewPane.js");
@@ -79,7 +80,7 @@
if (WebInspector.experimentsSettings.nativeMemoryTimeline.isEnabled())
this._memoryStatistics = new WebInspector.NativeMemoryGraph(this, this._model, this.splitView.sidebarWidth());
else
- this._memoryStatistics = new WebInspector.MemoryStatistics(this, this._model, this.splitView.sidebarWidth());
+ this._memoryStatistics = new WebInspector.DOMCountersGraph(this, this._model, this.splitView.sidebarWidth());
WebInspector.settings.memoryCounterGraphsHeight = WebInspector.settings.createSetting("memoryCounterGraphsHeight", 150);
var itemsTreeElement = new WebInspector.SidebarSectionTreeElement(WebInspector.UIString("RECORDS"), {}, true);
Modified: trunk/Source/WebCore/inspector/front-end/WebKit.qrc (142861 => 142862)
--- trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2013-02-14 10:14:24 UTC (rev 142861)
+++ trunk/Source/WebCore/inspector/front-end/WebKit.qrc 2013-02-14 10:22:21 UTC (rev 142862)
@@ -54,6 +54,7 @@
<file>DirectoryContentView.js</file>
<file>DOMAgent.js</file>
<file>DOMBreakpointsSidebarPane.js</file>
+ <file>DOMCountersGraph.js</file>
<file>DOMExtension.js</file>
<file>DOMPresentationUtils.js</file>
<file>DOMStorage.js</file>