[chromium] Web Inspector: highlight DOM nodes from detached DOM trees.
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 18:20:40 +0000 (18:20 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jan 2012 18:20:40 +0000 (18:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=76545

Reviewed by Yury Semikhatsky.

* inspector/front-end/DetailedHeapshotGridNodes.js:
(WebInspector.HeapSnapshotGenericObjectNode):
(WebInspector.HeapSnapshotGenericObjectNode.prototype.get data):
* inspector/front-end/HeapSnapshot.js:
(WebInspector.HeapSnapshotNode.prototype.get isNativeRoot):
(WebInspector.HeapSnapshotNode.prototype.get isDetachedDOMTree):
(WebInspector.HeapSnapshot.prototype._init):
(WebInspector.HeapSnapshot.prototype._markDetachedDOMTreeNodes):
(WebInspector.HeapSnapshot.prototype._markQueriableHeapObjects):
(WebInspector.HeapSnapshot.prototype._calculateFlags):
* inspector/front-end/heapProfiler.css:
(.detached-dom-tree-node):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105292 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/inspector/front-end/DetailedHeapshotGridNodes.js
Source/WebCore/inspector/front-end/HeapSnapshot.js
Source/WebCore/inspector/front-end/heapProfiler.css

index 2cde2d0..9a296af 100644 (file)
@@ -1,3 +1,23 @@
+2012-01-18  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        [chromium] Web Inspector: highlight DOM nodes from detached DOM trees.
+        https://bugs.webkit.org/show_bug.cgi?id=76545
+
+        Reviewed by Yury Semikhatsky.
+
+        * inspector/front-end/DetailedHeapshotGridNodes.js:
+        (WebInspector.HeapSnapshotGenericObjectNode):
+        (WebInspector.HeapSnapshotGenericObjectNode.prototype.get data):
+        * inspector/front-end/HeapSnapshot.js:
+        (WebInspector.HeapSnapshotNode.prototype.get isNativeRoot):
+        (WebInspector.HeapSnapshotNode.prototype.get isDetachedDOMTree):
+        (WebInspector.HeapSnapshot.prototype._init):
+        (WebInspector.HeapSnapshot.prototype._markDetachedDOMTreeNodes):
+        (WebInspector.HeapSnapshot.prototype._markQueriableHeapObjects):
+        (WebInspector.HeapSnapshot.prototype._calculateFlags):
+        * inspector/front-end/heapProfiler.css:
+        (.detached-dom-tree-node):
+
 2012-01-18  Pavel Feldman  <pfeldman@google.com>
 
         Web Inspector: there should be a way to set HTML for given frame.
index 7b147ea..e052918 100644 (file)
@@ -188,6 +188,8 @@ WebInspector.HeapSnapshotGenericObjectNode = function(tree, node)
         this.hasHoverMessage = true;
     } else if (node.flags & tree.snapshot.nodeFlags.canBeQueried)
         this.hasHoverMessage = true;
+    if (node.flags & tree.snapshot.nodeFlags.detachedDOMTreeNode)
+        this.detachedDOMTreeNode = true;
 };
 
 WebInspector.HeapSnapshotGenericObjectNode.prototype = {
@@ -259,6 +261,8 @@ WebInspector.HeapSnapshotGenericObjectNode.prototype = {
         };
         if (this.hasHoverMessage)
             valueStyle += " highlight";
+        if (this.detachedDOMTreeNode)
+            valueStyle += " detached-dom-tree-node";
         data["object"] = { valueStyle: valueStyle, value: value + " @" + this.snapshotNodeId };
 
         var view = this.dataGrid.snapshotView;
index 11e889a..a44d4ca 100644 (file)
@@ -571,6 +571,16 @@ WebInspector.HeapSnapshotNode.prototype = {
         return this.name.substr(0, 9) === "DOMWindow";
     },
 
+    get isNativeRoot()
+    {
+        return this.name === "(Native objects)";
+    },
+
+    get isDetachedDOMTree()
+    {
+        return this.className === "Detached DOM tree";
+    },
+
     get isRoot()
     {
         return this.nodeIndex === this._snapshot._rootNodeIndex;
@@ -710,7 +720,10 @@ WebInspector.HeapSnapshot.prototype = {
         this._edgeInvisibleType = this._edgeTypes.length;
         this._edgeTypes.push("invisible");
 
-        this._nodeFlags = { canBeQueried: 1 };
+        this._nodeFlags = { // bit flags
+            canBeQueried: 1,
+            detachedDOMTreeNode: 2,
+        };
 
         this._markInvisibleEdges();
     },
@@ -1037,13 +1050,37 @@ WebInspector.HeapSnapshot.prototype = {
         return a < b ? -1 : (a > b ? 1 : 0);
     },
 
-    _calculateFlags: function()
+    _markDetachedDOMTreeNodes: function()
+    {
+        var flag = this._nodeFlags.detachedDOMTreeNode;
+        var nativeRoot;
+        for (var iter = this.rootNode.edges; iter.hasNext(); iter.next()) {
+            var node = iter.edge.node;
+            if (node.isNativeRoot) {
+                nativeRoot = node;
+                break;
+            }
+        }
+
+        if (!nativeRoot)
+            return;
+
+        for (var iter = nativeRoot.edges; iter.hasNext(); iter.next()) {
+            var node = iter.edge.node;
+            if (node.isDetachedDOMTree) {
+                for (var edgesIter = node.edges; edgesIter.hasNext(); edgesIter.next())
+                    this._flags[edgesIter.edge.node.nodeIndex] |= flag;
+            }
+        }
+    },
+
+    _markQueriableHeapObjects: function()
     {
-        var flag = this._nodeFlags.canBeQueried;
-        this._flags = new Array(this.nodeCount);
         // Allow runtime properties query for objects accessible from DOMWindow objects
         // via regular properties, and for DOM wrappers. Trying to access random objects
         // can cause a crash due to insonsistent state of internal properties of wrappers.
+        var flag = this._nodeFlags.canBeQueried;
+
         var list = [];
         for (var iter = this.rootNode.edges; iter.hasNext(); iter.next()) {
             if (iter.edge.node.isDOMWindow)
@@ -1052,9 +1089,9 @@ WebInspector.HeapSnapshot.prototype = {
 
         while (list.length) {
             var node = list.pop();
-            if (this._flags[node.nodeIndex])
+            if (this._flags[node.nodeIndex] & flag)
                 continue;
-            this._flags[node.nodeIndex] = flag;
+            this._flags[node.nodeIndex] |= flag;
             for (var iter = node.edges; iter.hasNext(); iter.next()) {
                 var edge = iter.edge;
                 var node = edge.node;
@@ -1072,6 +1109,13 @@ WebInspector.HeapSnapshot.prototype = {
         }
     },
 
+    _calculateFlags: function()
+    {
+        this._flags = new Array(this.nodeCount);
+        this._markDetachedDOMTreeNodes();
+        this._markQueriableHeapObjects();
+    },
+
     baseSnapshotHasNode: function(baseSnapshotId, className, nodeId)
     {
         return this._baseNodeIds[baseSnapshotId][className].binaryIndexOf(nodeId, this._numbersComparator) !== -1;
index 0b396f4..10e2022 100644 (file)
@@ -120,6 +120,10 @@ body.inactive .heap-snapshot-sidebar-tree-item.wait.selected .icon {
     position: static;
 }
 
+.detached-dom-tree-node {
+    background-color: #FF9999;
+}
+
 .detailed-heapshot-view .console-formatted-string {
     white-space: nowrap;
 }