Title: [189385] trunk/Source/WebInspectorUI
Revision
189385
Author
[email protected]
Date
2015-09-04 14:07:37 -0700 (Fri, 04 Sep 2015)

Log Message

Web Inspector: Clean up and modernize DOMTreeManager
https://bugs.webkit.org/show_bug.cgi?id=148821

Patch by Joseph Pecoraro <[email protected]> on 2015-09-04
Reviewed by Timothy Hatcher.

* UserInterface/Controllers/DOMTreeManager.js:
(WebInspector.DOMTreeManager.prototype.requestDocument.onDocumentAvailable):
(WebInspector.DOMTreeManager.prototype.requestDocument):
(WebInspector.DOMTreeManager.prototype.pushNodeByPathToFrontend):
(WebInspector.DOMTreeManager.prototype._wrapClientCallback):
(WebInspector.DOMTreeManager.prototype._attributeModified):
(WebInspector.DOMTreeManager.prototype._attributeRemoved):
(WebInspector.DOMTreeManager.prototype._inlineStyleInvalidated):
(WebInspector.DOMTreeManager.prototype._loadNodeAttributes):
(WebInspector.DOMTreeManager.prototype.cancelSearch):
(WebInspector.DOMTreeManager.prototype.querySelector):
(WebInspector.DOMTreeManager.prototype.querySelectorAll):
(WebInspector.DOMTreeManager.prototype.highlightDOMNode):
(WebInspector.DOMTreeManager.prototype._buildHighlightConfig):
Cleanup and modernize where appropriate.

* UserInterface/Views/SearchSidebarPanel.js:
(WebInspector.SearchSidebarPanel.prototype.performSearch):
Callback is now required.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (189384 => 189385)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-09-04 21:04:13 UTC (rev 189384)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-09-04 21:07:37 UTC (rev 189385)
@@ -1,3 +1,30 @@
+2015-09-04  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: Clean up and modernize DOMTreeManager
+        https://bugs.webkit.org/show_bug.cgi?id=148821
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Controllers/DOMTreeManager.js:
+        (WebInspector.DOMTreeManager.prototype.requestDocument.onDocumentAvailable):
+        (WebInspector.DOMTreeManager.prototype.requestDocument):
+        (WebInspector.DOMTreeManager.prototype.pushNodeByPathToFrontend):
+        (WebInspector.DOMTreeManager.prototype._wrapClientCallback):
+        (WebInspector.DOMTreeManager.prototype._attributeModified):
+        (WebInspector.DOMTreeManager.prototype._attributeRemoved):
+        (WebInspector.DOMTreeManager.prototype._inlineStyleInvalidated):
+        (WebInspector.DOMTreeManager.prototype._loadNodeAttributes):
+        (WebInspector.DOMTreeManager.prototype.cancelSearch):
+        (WebInspector.DOMTreeManager.prototype.querySelector):
+        (WebInspector.DOMTreeManager.prototype.querySelectorAll):
+        (WebInspector.DOMTreeManager.prototype.highlightDOMNode):
+        (WebInspector.DOMTreeManager.prototype._buildHighlightConfig):
+        Cleanup and modernize where appropriate.
+
+        * UserInterface/Views/SearchSidebarPanel.js:
+        (WebInspector.SearchSidebarPanel.prototype.performSearch):
+        Callback is now required.
+
 2015-09-04  Matt Baker  <[email protected]>
 
         Web Inspector: Render Frames "Other" task filter checkbox misaligned with text

Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js (189384 => 189385)


--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js	2015-09-04 21:04:13 UTC (rev 189384)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js	2015-09-04 21:07:37 UTC (rev 189385)
@@ -59,8 +59,7 @@
     requestDocument(callback)
     {
         if (this._document) {
-            if (callback)
-                callback(this._document);
+            callback(this._document);
             return;
         }
 
@@ -76,12 +75,10 @@
             if (!error)
                 this._setDocument(root);
 
-            for (var i = 0; i < this._pendingDocumentRequestCallbacks.length; ++i) {
-                var callback = this._pendingDocumentRequestCallbacks[i];
-                if (callback)
-                    callback(this._document);
-            }
-            delete this._pendingDocumentRequestCallbacks;
+            for (let callback of this._pendingDocumentRequestCallbacks)
+                callback(this._document);
+
+            this._pendingDocumentRequestCallbacks = null;
         }
 
         DOMAgent.getDocument(onDocumentAvailable.bind(this));
@@ -94,8 +91,7 @@
 
     pushNodeByPathToFrontend(path, callback)
     {
-        var callbackCast = callback;
-        this._dispatchWhenDocumentAvailable(DOMAgent.pushNodeByPathToFrontend.bind(DOMAgent, path), callbackCast);
+        this._dispatchWhenDocumentAvailable(DOMAgent.pushNodeByPathToFrontend.bind(DOMAgent, path), callback);
     }
 
     // Private
@@ -103,7 +99,8 @@
     _wrapClientCallback(callback)
     {
         if (!callback)
-            return;
+            return null;
+
         return function(error, result) {
             if (error)
                 console.error("Error during DOMAgent operation: " + error);
@@ -132,6 +129,7 @@
         var node = this._idToDOMNode[nodeId];
         if (!node)
             return;
+
         node._setAttribute(name, value);
         this.dispatchEventToListeners(WebInspector.DOMTreeManager.Event.AttributeModified, {node, name});
         node.dispatchEventToListeners(WebInspector.DOMNode.Event.AttributeModified, {name});
@@ -142,6 +140,7 @@
         var node = this._idToDOMNode[nodeId];
         if (!node)
             return;
+
         node._removeAttribute(name);
         this.dispatchEventToListeners(WebInspector.DOMTreeManager.Event.AttributeRemoved, {node, name});
         node.dispatchEventToListeners(WebInspector.DOMNode.Event.AttributeRemoved, {name});
@@ -149,8 +148,8 @@
 
     _inlineStyleInvalidated(nodeIds)
     {
-        for (var i = 0; i < nodeIds.length; ++i)
-            this._attributeLoadNodeIds[nodeIds[i]] = true;
+        for (var nodeId of nodeIds)
+            this._attributeLoadNodeIds[nodeId] = true;
         if ("_loadNodeAttributesTimeout" in this)
             return;
         this._loadNodeAttributesTimeout = setTimeout(this._loadNodeAttributes.bind(this), 0);
@@ -172,10 +171,10 @@
             }
         }
 
-        delete this._loadNodeAttributesTimeout;
+        this._loadNodeAttributesTimeout = undefined;
 
         for (var nodeId in this._attributeLoadNodeIds) {
-            var nodeIdAsNumber = parseInt(nodeId, 10);
+            var nodeIdAsNumber = parseInt(nodeId);
             DOMAgent.getAttributes(nodeIdAsNumber, callback.bind(this, nodeIdAsNumber));
         }
         this._attributeLoadNodeIds = {};
@@ -371,27 +370,25 @@
     {
         if (this._searchId) {
             DOMAgent.discardSearchResults(this._searchId);
-            delete this._searchId;
+            this._searchId = undefined;
         }
     }
 
     querySelector(nodeId, selectors, callback)
     {
-        var callbackCast = callback;
-        DOMAgent.querySelector(nodeId, selectors, this._wrapClientCallback(callbackCast));
+        DOMAgent.querySelector(nodeId, selectors, this._wrapClientCallback(callback));
     }
 
     querySelectorAll(nodeId, selectors, callback)
     {
-        var callbackCast = callback;
-        DOMAgent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(callbackCast));
+        DOMAgent.querySelectorAll(nodeId, selectors, this._wrapClientCallback(callback));
     }
 
     highlightDOMNode(nodeId, mode)
     {
         if (this._hideDOMNodeHighlightTimeout) {
             clearTimeout(this._hideDOMNodeHighlightTimeout);
-            delete this._hideDOMNodeHighlightTimeout;
+            this._hideDOMNodeHighlightTimeout = undefined;
         }
 
         this._highlightedDOMNodeId = nodeId;
@@ -450,10 +447,10 @@
         DOMAgent.setInspectModeEnabled(enabled, this._buildHighlightConfig(), callback.bind(this));
     }
 
-    _buildHighlightConfig(mode)
+    _buildHighlightConfig(mode = "all")
     {
-        mode = mode || "all";
-        var highlightConfig = { showInfo: mode === "all" };
+        let highlightConfig = {showInfo: mode === "all"};
+
         if (mode === "all" || mode === "content")
             highlightConfig.contentColor = {r: 111, g: 168, b: 220, a: 0.66};
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js (189384 => 189385)


--- trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js	2015-09-04 21:04:13 UTC (rev 189384)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js	2015-09-04 21:07:37 UTC (rev 189385)
@@ -268,7 +268,7 @@
         }
 
         if (window.DOMAgent)
-            WebInspector.domTreeManager.requestDocument();
+            WebInspector.domTreeManager.requestDocument(function(){});
 
         if (window.PageAgent)
             PageAgent.searchInResources(searchQuery, isCaseSensitive, isRegex, resourcesCallback.bind(this));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to