Title: [191612] trunk/Source/WebInspectorUI
Revision
191612
Author
[email protected]
Date
2015-10-26 16:53:54 -0700 (Mon, 26 Oct 2015)

Log Message

Web Inspector: Cleanup sidebar panels, reduce `delete` and use Maps instead of objects
https://bugs.webkit.org/show_bug.cgi?id=150548

Reviewed by Timothy Hatcher.

* UserInterface/Views/LayerTreeDetailsSidebarPanel.js:
(WebInspector.LayerTreeDetailsSidebarPanel):
(WebInspector.LayerTreeDetailsSidebarPanel.prototype._updateDataGrid):
(WebInspector.LayerTreeDetailsSidebarPanel.prototype._dataGridNodeForLayer):

* UserInterface/Views/NavigationSidebarPanel.js:
(WebInspector.NavigationSidebarPanel):
(WebInspector.NavigationSidebarPanel.restoreStateFromCookie.finalAttemptToRestoreViewStateFromCookie):
(WebInspector.NavigationSidebarPanel.restoreStateFromCookie):
(WebInspector.NavigationSidebarPanel.prototype.applyFiltersToTreeElement):
(WebInspector.NavigationSidebarPanel.prototype._updateContentOverflowShadowVisibility):
(WebInspector.NavigationSidebarPanel.prototype._checkElementsForPendingViewStateCookie):
Switched to using Symbol() to set external properties on tree elements.

* UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
(WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):

* UserInterface/Views/StorageSidebarPanel.js:
(WebInspector.StorageSidebarPanel):
(WebInspector.StorageSidebarPanel.prototype._addDatabase):
(WebInspector.StorageSidebarPanel.prototype._addIndexedDatabase):
(WebInspector.StorageSidebarPanel.prototype._addFrameManifest):
(WebInspector.StorageSidebarPanel.prototype._storageCleared):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (191611 => 191612)


--- trunk/Source/WebInspectorUI/ChangeLog	2015-10-26 23:51:36 UTC (rev 191611)
+++ trunk/Source/WebInspectorUI/ChangeLog	2015-10-26 23:53:54 UTC (rev 191612)
@@ -1,3 +1,34 @@
+2015-10-26  Matt Baker  <[email protected]>
+
+        Web Inspector: Cleanup sidebar panels, reduce `delete` and use Maps instead of objects
+        https://bugs.webkit.org/show_bug.cgi?id=150548
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/LayerTreeDetailsSidebarPanel.js:
+        (WebInspector.LayerTreeDetailsSidebarPanel):
+        (WebInspector.LayerTreeDetailsSidebarPanel.prototype._updateDataGrid):
+        (WebInspector.LayerTreeDetailsSidebarPanel.prototype._dataGridNodeForLayer):
+
+        * UserInterface/Views/NavigationSidebarPanel.js:
+        (WebInspector.NavigationSidebarPanel):
+        (WebInspector.NavigationSidebarPanel.restoreStateFromCookie.finalAttemptToRestoreViewStateFromCookie):
+        (WebInspector.NavigationSidebarPanel.restoreStateFromCookie):
+        (WebInspector.NavigationSidebarPanel.prototype.applyFiltersToTreeElement):
+        (WebInspector.NavigationSidebarPanel.prototype._updateContentOverflowShadowVisibility):
+        (WebInspector.NavigationSidebarPanel.prototype._checkElementsForPendingViewStateCookie):
+        Switched to using Symbol() to set external properties on tree elements.
+
+        * UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
+        (WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):
+
+        * UserInterface/Views/StorageSidebarPanel.js:
+        (WebInspector.StorageSidebarPanel):
+        (WebInspector.StorageSidebarPanel.prototype._addDatabase):
+        (WebInspector.StorageSidebarPanel.prototype._addIndexedDatabase):
+        (WebInspector.StorageSidebarPanel.prototype._addFrameManifest):
+        (WebInspector.StorageSidebarPanel.prototype._storageCleared):
+
 2015-10-24  Nikita Vasilyev  <[email protected]>
 
         Unreviewed, rolling out r191419.

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js (191611 => 191612)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js	2015-10-26 23:51:36 UTC (rev 191611)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js	2015-10-26 23:53:54 UTC (rev 191612)
@@ -29,7 +29,7 @@
     {
         super("layer-tree", WebInspector.UIString("Layers"), WebInspector.UIString("Layer"));
 
-        this._dataGridNodesByLayerId = {};
+        this._dataGridNodesByLayerId = new Map;
 
         this.element.classList.add("layer-tree");
 
@@ -258,26 +258,25 @@
 
     _updateDataGrid(layerForNode, childLayers)
     {
-        var dataGrid = this._dataGrid;
+        let dataGrid = this._dataGrid;
+        let mutations = WebInspector.layerTreeManager.layerTreeMutations(this._childLayers, childLayers);
 
-        var mutations = WebInspector.layerTreeManager.layerTreeMutations(this._childLayers, childLayers);
-
         mutations.removals.forEach(function(layer) {
-            var node = this._dataGridNodesByLayerId[layer.layerId];
+            let node = this._dataGridNodesByLayerId.get(layer.layerId);
             if (node) {
                 dataGrid.removeChild(node);
-                delete this._dataGridNodesByLayerId[layer.layerId];
+                this._dataGridNodesByLayerId.delete(layer.layerId);
             }
         }, this);
 
         mutations.additions.forEach(function(layer) {
-            var node = this._dataGridNodeForLayer(layer);
+            let node = this._dataGridNodeForLayer(layer);
             if (node)
                 dataGrid.appendChild(node);
         }, this);
 
         mutations.preserved.forEach(function(layer) {
-            var node = this._dataGridNodesByLayerId[layer.layerId];
+            let node = this._dataGridNodesByLayerId.get(layer.layerId);
             if (node)
                 node.layer = layer;
         }, this);
@@ -289,10 +288,9 @@
 
     _dataGridNodeForLayer(layer)
     {
-        var node = new WebInspector.LayerTreeDataGridNode(layer);
+        let node = new WebInspector.LayerTreeDataGridNode(layer);
+        this._dataGridNodesByLayerId.set(layer.layerId, node);
 
-        this._dataGridNodesByLayerId[layer.layerId] = node;
-
         return node;
     }
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js (191611 => 191612)


--- trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js	2015-10-26 23:51:36 UTC (rev 191611)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js	2015-10-26 23:53:54 UTC (rev 191612)
@@ -74,6 +74,9 @@
             WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ChildFrameWasRemoved, this._checkForStaleResources, this);
             WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ResourceWasRemoved, this._checkForStaleResources, this);
         }
+
+        this._pendingViewStateCookie = null;
+        this._restoringState = false;
     }
 
     // Public
@@ -239,12 +242,12 @@
 
         function finalAttemptToRestoreViewStateFromCookie()
         {
-            delete this._finalAttemptToRestoreViewStateTimeout;
+            this._finalAttemptToRestoreViewStateTimeout = undefined;
 
             this._checkOutlinesForPendingViewStateCookie(true);
 
-            delete this._pendingViewStateCookie;
-            delete this._restoringState;
+            this._pendingViewStateCookie = null;
+            this._restoringState = false;
         }
 
         // If the specific tree element wasn't found, we may need to wait for the resources
@@ -329,8 +332,8 @@
             treeElement.hidden = false;
 
             // If this tree element was expanded during filtering, collapse it again.
-            if (treeElement.expanded && treeElement.__wasExpandedDuringFiltering) {
-                delete treeElement.__wasExpandedDuringFiltering;
+            if (treeElement.expanded && treeElement[WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol]) {
+                treeElement[WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol] = false;
                 treeElement.collapse();
             }
 
@@ -388,8 +391,8 @@
             makeVisible();
 
             // If this tree element didn't match a built-in filter and was expanded earlier during filtering, collapse it again.
-            if (!flags.expandTreeElement && treeElement.expanded && treeElement.__wasExpandedDuringFiltering) {
-                delete treeElement.__wasExpandedDuringFiltering;
+            if (!flags.expandTreeElement && treeElement.expanded && treeElement[WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol]) {
+                treeElement[WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol] = false;
                 treeElement.collapse();
             }
 
@@ -464,7 +467,7 @@
 
     _updateContentOverflowShadowVisibility()
     {
-        delete this._updateContentOverflowShadowVisibilityIdentifier;
+        this._updateContentOverflowShadowVisibilityIdentifier = undefined;
 
         var scrollHeight = this.contentElement.scrollHeight;
         var offsetHeight = this.contentElement.offsetHeight;
@@ -698,22 +701,24 @@
         if (matchedElement) {
             this.showDefaultContentViewForTreeElement(matchedElement);
 
-            delete this._pendingViewStateCookie;
+            this._pendingViewStateCookie = null;
 
             // Delay clearing the restoringState flag until the next runloop so listeners
             // checking for it in this runloop still know state was being restored.
             setTimeout(function() {
-                delete this._restoringState;
+                this._restoringState = false;
             }.bind(this));
 
             if (this._finalAttemptToRestoreViewStateTimeout) {
                 clearTimeout(this._finalAttemptToRestoreViewStateTimeout);
-                delete this._finalAttemptToRestoreViewStateTimeout;
+                this._finalAttemptToRestoreViewStateTimeout = undefined;
             }
         }
     }
 };
 
+WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol = Symbol("was-expanded-during-filtering");
+
 WebInspector.NavigationSidebarPanel.OverflowShadowElementStyleClassName = "overflow-shadow";
 WebInspector.NavigationSidebarPanel.TopOverflowShadowElementStyleClassName = "top";
 WebInspector.NavigationSidebarPanel.ContentTreeOutlineElementHiddenStyleClassName = "hidden";

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js (191611 => 191612)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js	2015-10-26 23:51:36 UTC (rev 191611)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js	2015-10-26 23:53:54 UTC (rev 191612)
@@ -160,9 +160,9 @@
         let detailsSections = [];
         let foundLocalScope = false;
 
-        let sectionCountByType = {};
-        for (var type in WebInspector.ScopeChainNode.Type)
-            sectionCountByType[WebInspector.ScopeChainNode.Type[type]] = 0;
+        let sectionCountByType = new Map;
+        for (let type in WebInspector.ScopeChainNode.Type)
+            sectionCountByType.set(WebInspector.ScopeChainNode.Type[type], 0);
 
         let scopeChain = callFrame.scopeChain;
         for (let scope of scopeChain) {
@@ -170,7 +170,8 @@
             let extraPropertyDescriptor = null;
             let collapsedByDefault = false;
 
-            ++sectionCountByType[scope.type];
+            let count = sectionCountByType.get(scope.type);
+            sectionCountByType.set(scope.type, ++count);
 
             switch (scope.type) {
                 case WebInspector.ScopeChainNode.Type.Local:
@@ -209,7 +210,7 @@
                     break;
             }
 
-            let detailsSectionIdentifier = scope.type + "-" + sectionCountByType[scope.type];
+            let detailsSectionIdentifier = scope.type + "-" + sectionCountByType.get(scope.type);
 
             let scopePropertyPath = WebInspector.PropertyPath.emptyPropertyPathForScope(scope.object);
             let objectTree = new WebInspector.ObjectTreeView(scope.object, WebInspector.ObjectTreeView.Mode.Properties, scopePropertyPath);

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/StorageSidebarPanel.js (191611 => 191612)


--- trunk/Source/WebInspectorUI/UserInterface/Views/StorageSidebarPanel.js	2015-10-26 23:51:36 UTC (rev 191611)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/StorageSidebarPanel.js	2015-10-26 23:53:54 UTC (rev 191612)
@@ -65,15 +65,15 @@
         this._sessionStorageRootTreeElement = null;
 
         this._databaseRootTreeElement = null;
-        this._databaseHostTreeElementMap = {};
+        this._databaseHostTreeElementMap = new Map;
 
         this._indexedDatabaseRootTreeElement = null;
-        this._indexedDatabaseHostTreeElementMap = {};
+        this._indexedDatabaseHostTreeElementMap = new Map;
 
         this._cookieStorageRootTreeElement = null;
 
         this._applicationCacheRootTreeElement = null;
-        this._applicationCacheURLTreeElementMap = {};
+        this._applicationCacheURLTreeElementMap = new Map;
 
         WebInspector.storageManager.addEventListener(WebInspector.StorageManager.Event.CookieStorageObjectWasAdded, this._cookieStorageObjectWasAdded, this);
         WebInspector.storageManager.addEventListener(WebInspector.StorageManager.Event.DOMStorageObjectWasAdded, this._domStorageObjectWasAdded, this);
@@ -211,13 +211,15 @@
     {
         console.assert(database instanceof WebInspector.DatabaseObject);
 
-        if (!this._databaseHostTreeElementMap[database.host]) {
-            this._databaseHostTreeElementMap[database.host] = new WebInspector.DatabaseHostTreeElement(database.host);
-            this._databaseRootTreeElement = this._addStorageChild(this._databaseHostTreeElementMap[database.host], this._databaseRootTreeElement, WebInspector.UIString("Databases"));
+        let databaseHostElement = this._databaseHostTreeElementMap.get(database.host);
+        if (!databaseHostElement) {
+            databaseHostElement = new WebInspector.DatabaseHostTreeElement(database.host);
+            this._databaseHostTreeElementMap.set(database.host, databaseHostElement);
+            this._databaseRootTreeElement = this._addStorageChild(treeElement, this._databaseRootTreeElement, WebInspector.UIString("Databases"));
         }
 
-        var databaseElement = new WebInspector.DatabaseTreeElement(database);
-        this._databaseHostTreeElementMap[database.host].appendChild(databaseElement);
+        let databaseElement = new WebInspector.DatabaseTreeElement(database);
+        databaseHostElement.append(databaseElement);
     }
 
     _databaseWasInspected(event)
@@ -236,13 +238,15 @@
     {
         console.assert(indexedDatabase instanceof WebInspector.IndexedDatabase);
 
-        if (!this._indexedDatabaseHostTreeElementMap[indexedDatabase.host]) {
-            this._indexedDatabaseHostTreeElementMap[indexedDatabase.host] = new WebInspector.IndexedDatabaseHostTreeElement(indexedDatabase.host);
-            this._indexedDatabaseRootTreeElement = this._addStorageChild(this._indexedDatabaseHostTreeElementMap[indexedDatabase.host], this._indexedDatabaseRootTreeElement, WebInspector.UIString("Indexed Databases"));
+        let indexedDatabaseHostElement = this._indexedDatabaseHostTreeElementMap.get(indexedDatabase.host);
+        if (!indexedDatabaseHostElement) {
+            indexedDatabaseHostElement = new WebInspector.IndexedDatabaseHostTreeElement(indexedDatabase.host);
+            this._indexedDatabaseHostTreeElementMap.set(indexedDatabase.host, indexedDatabaseHostElement);
+            this._indexedDatabaseRootTreeElement = this._addStorageChild(indexedDatabaseHostElement, this._indexedDatabaseRootTreeElement, WebInspector.UIString("Indexed Databases"));
         }
 
-        var indexedDatabaseElement = new WebInspector.IndexedDatabaseTreeElement(indexedDatabase);
-        this._indexedDatabaseHostTreeElementMap[indexedDatabase.host].appendChild(indexedDatabaseElement);
+        let indexedDatabaseElement = new WebInspector.IndexedDatabaseTreeElement(indexedDatabase);
+        indexedDatabaseHostElement.append(indexedDatabaseElement);
     }
 
     _cookieStorageObjectWasAdded(event)
@@ -267,15 +271,17 @@
     {
         console.assert(frameManifest instanceof WebInspector.ApplicationCacheFrame);
 
-        var manifest = frameManifest.manifest;
-        var manifestURL = manifest.manifestURL;
-        if (!this._applicationCacheURLTreeElementMap[manifestURL]) {
-            this._applicationCacheURLTreeElementMap[manifestURL] = new WebInspector.ApplicationCacheManifestTreeElement(manifest);
-            this._applicationCacheRootTreeElement = this._addStorageChild(this._applicationCacheURLTreeElementMap[manifestURL], this._applicationCacheRootTreeElement, WebInspector.UIString("Application Cache"));
+        let manifest = frameManifest.manifest;
+        let manifestURL = manifest.manifestURL;
+        let applicationCacheManifestElement = this._applicationCacheURLTreeElementMap.get(manifestURL);
+        if (!applicationCacheManifestElement) {
+            applicationCacheManifestElement = new WebInspector.ApplicationCacheManifestTreeElement(manifest);
+            this._applicationCacheURLTreeElementMap.set(manifestURL, applicationCacheManifestElement);
+            this._applicationCacheRootTreeElement = this._addStorageChild(applicationCacheManifestElement, this._applicationCacheRootTreeElement, WebInspector.UIString("Application Cache"));
         }
 
-        var frameCacheElement = new WebInspector.ApplicationCacheFrameTreeElement(frameManifest);
-        this._applicationCacheURLTreeElementMap[manifestURL].appendChild(frameCacheElement);
+        let frameCacheElement = new WebInspector.ApplicationCacheFrameTreeElement(frameManifest);
+        applicationCacheManifestElement.append(frameCacheElement);
     }
 
     _frameManifestRemoved(event)
@@ -353,12 +359,12 @@
         this._localStorageRootTreeElement = null;
         this._sessionStorageRootTreeElement = null;
         this._databaseRootTreeElement = null;
-        this._databaseHostTreeElementMap = {};
+        this._databaseHostTreeElementMap.clear();
         this._indexedDatabaseRootTreeElement = null;
-        this._indexedDatabaseHostTreeElementMap = {};
+        this._indexedDatabaseHostTreeElementMap.clear();
         this._cookieStorageRootTreeElement = null;
         this._applicationCacheRootTreeElement = null;
-        this._applicationCacheURLTreeElementMap = {};
+        this._applicationCacheURLTreeElementMap.clear();
     }
 
     _scopeBarSelectionDidChange(event)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to