Title: [143595] trunk/Source/WebCore
Revision
143595
Author
[email protected]
Date
2013-02-21 06:15:22 -0800 (Thu, 21 Feb 2013)

Log Message

Web Inspector: [Canvas] Remove arrays of DataGrid nodes from the View
https://bugs.webkit.org/show_bug.cgi?id=110325

Reviewed by Pavel Feldman.

Remove arrays of DataGrid nodes from the CanvasProfileView and use live DataGrid instead.
This is a prerequisite to support a non-fixed layered tree in the grid (for example, to hide
a single frame group node, or to combine several draw call groups into a pattern group).
Drive-by: added an assert to injected canvas module.

* inspector/InjectedScriptCanvasModuleSource.js:
* inspector/front-end/CanvasProfileView.js:
(WebInspector.CanvasProfileView):
(WebInspector.CanvasProfileView.prototype.dispose):
(WebInspector.CanvasProfileView.prototype._didReceiveTraceLog):
(WebInspector.CanvasProfileView.prototype._requestTraceLog):
(WebInspector.CanvasProfileView.prototype._selectedCallIndex):
(WebInspector.CanvasProfileView.prototype._peekLastRecursively):
(WebInspector.CanvasProfileView.prototype._appendCallNodes):
(WebInspector.CanvasProfileView.prototype.):
(WebInspector.CanvasProfileView.prototype.splitDrawCallGroup):
(WebInspector.CanvasProfileView.prototype._appendCallNodesToFrameNode):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (143594 => 143595)


--- trunk/Source/WebCore/ChangeLog	2013-02-21 14:13:46 UTC (rev 143594)
+++ trunk/Source/WebCore/ChangeLog	2013-02-21 14:15:22 UTC (rev 143595)
@@ -1,3 +1,28 @@
+2013-02-21  Andrey Adaikin  <[email protected]>
+
+        Web Inspector: [Canvas] Remove arrays of DataGrid nodes from the View
+        https://bugs.webkit.org/show_bug.cgi?id=110325
+
+        Reviewed by Pavel Feldman.
+
+        Remove arrays of DataGrid nodes from the CanvasProfileView and use live DataGrid instead.
+        This is a prerequisite to support a non-fixed layered tree in the grid (for example, to hide
+        a single frame group node, or to combine several draw call groups into a pattern group).
+        Drive-by: added an assert to injected canvas module.
+
+        * inspector/InjectedScriptCanvasModuleSource.js:
+        * inspector/front-end/CanvasProfileView.js:
+        (WebInspector.CanvasProfileView):
+        (WebInspector.CanvasProfileView.prototype.dispose):
+        (WebInspector.CanvasProfileView.prototype._didReceiveTraceLog):
+        (WebInspector.CanvasProfileView.prototype._requestTraceLog):
+        (WebInspector.CanvasProfileView.prototype._selectedCallIndex):
+        (WebInspector.CanvasProfileView.prototype._peekLastRecursively):
+        (WebInspector.CanvasProfileView.prototype._appendCallNodes):
+        (WebInspector.CanvasProfileView.prototype.):
+        (WebInspector.CanvasProfileView.prototype.splitDrawCallGroup):
+        (WebInspector.CanvasProfileView.prototype._appendCallNodesToFrameNode):
+
 2013-02-21  Alexander Pavlov  <[email protected]>
 
         Web Inspector: Local/session storage tree items in the Resources panel after page refresh are not shown

Modified: trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js (143594 => 143595)


--- trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js	2013-02-21 14:13:46 UTC (rev 143594)
+++ trunk/Source/WebCore/inspector/InjectedScriptCanvasModuleSource.js	2013-02-21 14:15:22 UTC (rev 143595)
@@ -1926,6 +1926,8 @@
                 break;
         }
 
+        console.assert(replayContext, "Failed to create a WebGLRenderingContext for the replay.");
+
         var gl = /** @type {!WebGLRenderingContext} */ (Resource.wrappedObject(replayContext));
         this.setWrappedObject(gl);
 

Modified: trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js (143594 => 143595)


--- trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js	2013-02-21 14:13:46 UTC (rev 143594)
+++ trunk/Source/WebCore/inspector/front-end/CanvasProfileView.js	2013-02-21 14:15:22 UTC (rev 143595)
@@ -87,15 +87,8 @@
     this._logGrid.show(logGridContainer);
     this._logGrid.addEventListener(WebInspector.DataGrid.Events.SelectedNode, this._replayTraceLog.bind(this));
 
-    /** @type {!Array.<WebInspector.DataGridNode>} */
-    this._logGridNodes = [];
-    /** @type {!Array.<WebInspector.DataGridNode>} */
-    this._drawCallGroups = [];
-    /** @type {!Array.<WebInspector.DataGridNode>} */
-    this._frameGroups = [];
-
     this._splitView.show(this.element);
-    this._requestTraceLog();
+    this._requestTraceLog(0);
 }
 
 /**
@@ -107,9 +100,6 @@
 WebInspector.CanvasProfileView.prototype = {
     dispose: function()
     {
-        this._logGridNodes = [];
-        this._drawCallGroupNodes = [];
-        this._frameGroups = [];
         this._linkifier.reset();
     },
 
@@ -283,24 +273,29 @@
         this._enableWaitIcon(false);
         if (error || !traceLog)
             return;
+        var callNodes = [];
         var calls = traceLog.calls;
+        var index = traceLog.startOffset;
         for (var i = 0, n = calls.length; i < n; ++i) {
             var call = calls[i];
             this._requestReplayContextInfo(call.contextId);
-            var index = traceLog.startOffset + i;
-            var gridNode = this._createCallNode(index, call);
-            this._appendCallNode(gridNode);
+            var gridNode = this._createCallNode(index++, call);
+            callNodes.push(gridNode);
         }
+        this._appendCallNodes(callNodes);
         if (traceLog.alive)
-            setTimeout(this._requestTraceLog.bind(this), WebInspector.CanvasProfileView.TraceLogPollingInterval);
+            setTimeout(this._requestTraceLog.bind(this, index), WebInspector.CanvasProfileView.TraceLogPollingInterval);
         this._profile._updateCapturingStatus(traceLog);
         this._onReplayLastStepClick(); // Automatically replay the last step.
     },
 
-    _requestTraceLog: function()
+    /**
+     * @param {number} offset
+     */
+    _requestTraceLog: function(offset)
     {
         this._enableWaitIcon(true);
-        CanvasAgent.getTraceLog(this._traceLogId, this._logGridNodes.length, undefined, this._didReceiveTraceLog.bind(this));
+        CanvasAgent.getTraceLog(this._traceLogId, offset, undefined, this._didReceiveTraceLog.bind(this));
     },
 
     /**
@@ -332,103 +327,110 @@
     _selectedCallIndex: function()
     {
         var node = this._logGrid.selectedNode;
-        while (node) {
-            if (typeof node.index === "number")
-                return node.index;
-            node = node.children.peekLast();
-        }
-        return -1;
+        return node ? this._peekLastRecursively(node).index : -1;
     },
 
     /**
-     * @return {number}
+     * @param {!WebInspector.DataGridNode} node
+     * @return {!WebInspector.DataGridNode}
      */
-    _selectedDrawCallGroupIndex: function()
+    _peekLastRecursively: function(node)
     {
-        for (var node = this._logGrid.selectedNode; node; node = node.children.peekLast()) {
-            if (typeof node.drawCallGroupIndex === "number")
-                return node.drawCallGroupIndex;
-        }
-        for (var node = this._logGrid.selectedNode; node; node = node.parent) {
-            if (typeof node.drawCallGroupIndex === "number")
-                return node.drawCallGroupIndex;
-        }
-        return -1;
+        var lastChild;
+        while ((lastChild = node.children.peekLast()))
+            node = /** @type {!WebInspector.DataGridNode} */ (lastChild);
+        return node;
     },
 
     /**
-     * @param {!WebInspector.DataGridNode} gridNode
+     * @param {!Array.<!WebInspector.DataGridNode>} callNodes
      */
-    _appendCallNode: function(gridNode)
+    _appendCallNodes: function(callNodes)
     {
-        var drawCallGroup = this._drawCallGroups.peekLast();
-        if (drawCallGroup) {
-            var lastNode = drawCallGroup.children.peekLast();
-            if (lastNode && (lastNode.call.isDrawingCall || lastNode.call.isFrameEndCall))
-                drawCallGroup = null;
+        var rootNode = this._logGrid.rootNode();
+        var frameNode = /** @type {WebInspector.DataGridNode} */ (rootNode.children.peekLast());
+        if (frameNode && this._peekLastRecursively(frameNode).call.isFrameEndCall)
+            frameNode = null;
+        for (var i = 0, n = callNodes.length; i < n; ++i) {
+            if (!frameNode) {
+                var index = rootNode.children.length;
+                var data = ""
+                data[0] = "";
+                data[1] = "Frame #" + (index + 1);
+                data[2] = "";
+                frameNode = new WebInspector.DataGridNode(data);
+                frameNode.selectable = true;
+                rootNode.appendChild(frameNode);
+            }
+            var nextFrameCallIndex = i + 1;
+            while (nextFrameCallIndex < n && !callNodes[nextFrameCallIndex - 1].call.isFrameEndCall)
+                ++nextFrameCallIndex;
+            this._appendCallNodesToFrameNode(frameNode, callNodes, i, nextFrameCallIndex);
+            i = nextFrameCallIndex - 1;
+            frameNode = null;
         }
-        if (!drawCallGroup) {
-            var index = this._drawCallGroups.length;
-            var data = ""
-            data[0] = "";
-            data[1] = "Draw call group #" + (index + 1);
-            data[2] = "";
-            drawCallGroup = new WebInspector.DataGridNode(data);
-            drawCallGroup.selectable = true;
-            drawCallGroup.drawCallGroupIndex = index;
-            this._drawCallGroups.push(drawCallGroup);
-            this._appendDrawCallGroup(drawCallGroup);
-        }
-        drawCallGroup.appendChild(gridNode);
-        if (gridNode.call.isFrameEndCall)
-            this._maybeMergeLastDrawCallGroups();
     },
 
     /**
-     * @param {!WebInspector.DataGridNode} drawCallGroup
+     * @param {!WebInspector.DataGridNode} frameNode
+     * @param {!Array.<!WebInspector.DataGridNode>} callNodes
+     * @param {number} fromIndex
+     * @param {number} toIndex not inclusive
      */
-    _appendDrawCallGroup: function(drawCallGroup)
+    _appendCallNodesToFrameNode: function(frameNode, callNodes, fromIndex, toIndex)
     {
-        var frameGroup = this._frameGroups.peekLast();
-        if (frameGroup) {
-            var lastDrawCallGroup = frameGroup.children.peekLast();
-            var lastNode = lastDrawCallGroup && lastDrawCallGroup.children.peekLast();
-            if (lastNode && lastNode.call.isFrameEndCall)
-                frameGroup = null;
-        }
-        if (!frameGroup) {
-            var index = this._frameGroups.length;
+        function appendDrawCallGroup()
+        {
+            var index = this._drawCallGroupsCount || 0;
             var data = ""
             data[0] = "";
-            data[1] = "Frame #" + (index + 1);
+            data[1] = "Draw call group #" + (index + 1);
             data[2] = "";
-            frameGroup = new WebInspector.DataGridNode(data);
-            frameGroup.selectable = true;
-            frameGroup.frameGroupIndex = index;
-            this._frameGroups.push(frameGroup);
-            this._logGrid.rootNode().appendChild(frameGroup);
+            var node = new WebInspector.DataGridNode(data);
+            node.selectable = true;
+            this._drawCallGroupsCount = index + 1;
+            frameNode.appendChild(node);
+            return node;
         }
-        frameGroup.appendChild(drawCallGroup);
-    },
 
-    _maybeMergeLastDrawCallGroups: function()
-    {
-        var frameGroup = this._frameGroups.peekLast();
-        if (!frameGroup)
-            return;
-        var groups = frameGroup.children.length;
-        if (groups < 2)
-            return;
-        var src = "" - 1]
-        for (var i = 0, n = src.children.length; i < n; ++i) {
-            if (src.children[i].call.isDrawingCall)
-                return;
+        function splitDrawCallGroup(drawCallGroup)
+        {
+            var splitIndex = 0;
+            var splitNode;
+            while ((splitNode = drawCallGroup.children[splitIndex])) {
+                if (splitNode.call.isDrawingCall)
+                    break;
+                ++splitIndex;
+            }
+            var newDrawCallGroup = appendDrawCallGroup();
+            var lastNode;
+            while ((lastNode = drawCallGroup.children[splitIndex + 1]))
+                newDrawCallGroup.appendChild(lastNode);
+            return newDrawCallGroup;
         }
-        var dst = frameGroup.children[groups - 2];
-        while (src.children.length)
-            dst.appendChild(src.children[0]);
-        frameGroup.removeChild(src);
-        this._drawCallGroups.pop();
+
+        var drawCallGroup = frameNode.children.peekLast();
+        var groupHasDrawCall = false;
+        if (drawCallGroup) {
+            for (var i = 0, n = drawCallGroup.children.length; i < n; ++i) {
+                if (drawCallGroup.children[i].call.isDrawingCall) {
+                    groupHasDrawCall = true;
+                    break;
+                }
+            }
+        } else
+            drawCallGroup = appendDrawCallGroup();
+
+        for (var i = fromIndex; i < toIndex; ++i) {
+            var node = callNodes[i];
+            drawCallGroup.appendChild(node);
+            if (node.call.isDrawingCall) {
+                if (groupHasDrawCall)
+                    drawCallGroup = splitDrawCallGroup(drawCallGroup);
+                else
+                    groupHasDrawCall = true;
+            }
+        }
     },
 
     /**
@@ -464,7 +466,6 @@
         node.index = index;
         node.selectable = true;
         node.call = call;
-        this._logGridNodes[index] = node;
         return node;
     },
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to