Title: [188679] trunk/Source/WebInspectorUI
Revision
188679
Author
commit-qu...@webkit.org
Date
2015-08-19 21:09:14 -0700 (Wed, 19 Aug 2015)

Log Message

Web Inspector: DOMTree leaks on main resource changes
https://bugs.webkit.org/show_bug.cgi?id=148158

Patch by Joseph Pecoraro <pecor...@apple.com> on 2015-08-19
Reviewed by Timothy Hatcher.

* UserInterface/Models/DOMTree.js:
(WebInspector.DOMTree.prototype.disconnect):
Add a way to disconnect the DOMTree and allow it to get garbage collected.

(WebInspector.DOMTree.prototype.invalidate.performInvalidate):
(WebInspector.DOMTree.prototype.invalidate):
(WebInspector.DOMTree.prototype._requestRootDOMNode):
(WebInspector.DOMTree.prototype._framePageExecutionContextChanged):
Remove some uses of the delete operator.

* UserInterface/Models/Frame.js:
(WebInspector.Frame.prototype.removeChildFrame):
(WebInspector.Frame.prototype.removeAllChildFrames):
(WebInspector.Frame.prototype._detachFromParentFrame):
When a frame gets removed from its parent, disconnect its DOMTree.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (188678 => 188679)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-08-20 02:38:20 UTC (rev 188678)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-08-20 04:09:14 UTC (rev 188679)
@@ -1,3 +1,26 @@
+2015-08-19  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: DOMTree leaks on main resource changes
+        https://bugs.webkit.org/show_bug.cgi?id=148158
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/DOMTree.js:
+        (WebInspector.DOMTree.prototype.disconnect):
+        Add a way to disconnect the DOMTree and allow it to get garbage collected.
+
+        (WebInspector.DOMTree.prototype.invalidate.performInvalidate):
+        (WebInspector.DOMTree.prototype.invalidate):
+        (WebInspector.DOMTree.prototype._requestRootDOMNode):
+        (WebInspector.DOMTree.prototype._framePageExecutionContextChanged):
+        Remove some uses of the delete operator.
+
+        * UserInterface/Models/Frame.js:
+        (WebInspector.Frame.prototype.removeChildFrame):
+        (WebInspector.Frame.prototype.removeAllChildFrames):
+        (WebInspector.Frame.prototype._detachFromParentFrame):
+        When a frame gets removed from its parent, disconnect its DOMTree.
+
 2015-08-19  Devin Rousso  <drou...@apple.com>
 
         Web Inspector: The first style in the Rules panel for pseudo-elements needs padding

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/DOMTree.js (188678 => 188679)


--- trunk/Source/WebInspectorUI/UserInterface/Models/DOMTree.js	2015-08-20 02:38:20 UTC (rev 188678)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/DOMTree.js	2015-08-20 04:09:14 UTC (rev 188679)
@@ -67,6 +67,12 @@
         return Object.keys(this._flowMap).length;
     }
 
+    disconnect()
+    {
+        WebInspector.domTreeManager.removeEventListener(null, null, this);
+        this._frame.removeEventListener(null, null, this);
+    }
+
     invalidate()
     {
         // Set to null so it is fetched again next time requestRootDOMNode is called.
@@ -74,14 +80,14 @@
 
         // Clear the pending callbacks. It is the responsibility of the client to listen for
         // the RootDOMNodeInvalidated event and request the root DOM node again.
-        delete this._pendingRootDOMNodeRequests;
+        this._pendingRootDOMNodeRequests = null;
 
         if (this._invalidateTimeoutIdentifier)
             return;
 
         function performInvalidate()
         {
-            delete this._invalidateTimeoutIdentifier;
+            this._invalidateTimeoutIdentifier = undefined;
 
             this.dispatchEventToListeners(WebInspector.DOMTree.Event.RootDOMNodeInvalidated);
         }
@@ -197,7 +203,7 @@
 
             for (var i = 0; i < this._pendingRootDOMNodeRequests.length; ++i)
                 this._pendingRootDOMNodeRequests[i](this._rootDOMNode);
-            delete this._pendingRootDOMNodeRequests;
+            this._pendingRootDOMNodeRequests = null;
         }
 
         // For the main frame we can use the more straight forward requestDocument function. For
@@ -242,7 +248,7 @@
             console.assert(this._frame.pageExecutionContext);
             console.assert(this._pendingRootDOMNodeRequests && this._pendingRootDOMNodeRequests.length);
 
-            delete this._rootDOMNodeRequestWaitingForExecutionContext;
+            this._rootDOMNodeRequestWaitingForExecutionContext = false;
 
             this._requestRootDOMNode();
         }

Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js (188678 => 188679)


--- trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js	2015-08-20 02:38:20 UTC (rev 188678)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Frame.js	2015-08-20 04:09:14 UTC (rev 188679)
@@ -331,7 +331,7 @@
         this._childFrames.remove(childFrame);
         delete this._childFrameIdentifierMap[childFrame._id];
 
-        childFrame._parentFrame = null;
+        childFrame._detachFromParentFrame();
 
         this.dispatchEventToListeners(WebInspector.Frame.Event.ChildFrameWasRemoved, {childFrame});
     }
@@ -341,8 +341,8 @@
         if (!this._childFrames.length)
             return;
 
-        for (var i = 0; i < this._childFrames.length; ++i)
-            this._childFrames[i]._parentFrame = null;
+        for (let childFrame of this._childFrames)
+            childFrame._detachFromParentFrame();
 
         this._childFrames = [];
         this._childFrameIdentifierMap = {};
@@ -446,6 +446,16 @@
 
     // Private
 
+    _detachFromParentFrame()
+    {
+        if (this._domTree) {
+            this._domTree.disconnect();
+            this._domTree = null;
+        }
+
+        this._parentFrame = null;
+    }
+
     _isProvisionalResource(resource)
     {
         return (resource.loaderIdentifier && this._provisionalLoaderIdentifier && resource.loaderIdentifier === this._provisionalLoaderIdentifier);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to