Changeset 191612 in webkit


Ignore:
Timestamp:
Oct 26, 2015, 4:53:54 PM (10 years ago)
Author:
Matt Baker
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):

Location:
trunk/Source/WebInspectorUI
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r191539 r191612  
     12015-10-26  Matt Baker  <mattbaker@apple.com>
     2
     3        Web Inspector: Cleanup sidebar panels, reduce `delete` and use Maps instead of objects
     4        https://bugs.webkit.org/show_bug.cgi?id=150548
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Views/LayerTreeDetailsSidebarPanel.js:
     9        (WebInspector.LayerTreeDetailsSidebarPanel):
     10        (WebInspector.LayerTreeDetailsSidebarPanel.prototype._updateDataGrid):
     11        (WebInspector.LayerTreeDetailsSidebarPanel.prototype._dataGridNodeForLayer):
     12
     13        * UserInterface/Views/NavigationSidebarPanel.js:
     14        (WebInspector.NavigationSidebarPanel):
     15        (WebInspector.NavigationSidebarPanel.restoreStateFromCookie.finalAttemptToRestoreViewStateFromCookie):
     16        (WebInspector.NavigationSidebarPanel.restoreStateFromCookie):
     17        (WebInspector.NavigationSidebarPanel.prototype.applyFiltersToTreeElement):
     18        (WebInspector.NavigationSidebarPanel.prototype._updateContentOverflowShadowVisibility):
     19        (WebInspector.NavigationSidebarPanel.prototype._checkElementsForPendingViewStateCookie):
     20        Switched to using Symbol() to set external properties on tree elements.
     21
     22        * UserInterface/Views/ScopeChainDetailsSidebarPanel.js:
     23        (WebInspector.ScopeChainDetailsSidebarPanel.prototype._generateCallFramesSection):
     24
     25        * UserInterface/Views/StorageSidebarPanel.js:
     26        (WebInspector.StorageSidebarPanel):
     27        (WebInspector.StorageSidebarPanel.prototype._addDatabase):
     28        (WebInspector.StorageSidebarPanel.prototype._addIndexedDatabase):
     29        (WebInspector.StorageSidebarPanel.prototype._addFrameManifest):
     30        (WebInspector.StorageSidebarPanel.prototype._storageCleared):
     31
    1322015-10-24  Nikita Vasilyev  <nvasilyev@apple.com>
    233
  • trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js

    r188530 r191612  
    3030        super("layer-tree", WebInspector.UIString("Layers"), WebInspector.UIString("Layer"));
    3131
    32         this._dataGridNodesByLayerId = {};
     32        this._dataGridNodesByLayerId = new Map;
    3333
    3434        this.element.classList.add("layer-tree");
     
    259259    _updateDataGrid(layerForNode, childLayers)
    260260    {
    261         var dataGrid = this._dataGrid;
    262 
    263         var mutations = WebInspector.layerTreeManager.layerTreeMutations(this._childLayers, childLayers);
     261        let dataGrid = this._dataGrid;
     262        let mutations = WebInspector.layerTreeManager.layerTreeMutations(this._childLayers, childLayers);
    264263
    265264        mutations.removals.forEach(function(layer) {
    266             var node = this._dataGridNodesByLayerId[layer.layerId];
     265            let node = this._dataGridNodesByLayerId.get(layer.layerId);
    267266            if (node) {
    268267                dataGrid.removeChild(node);
    269                 delete this._dataGridNodesByLayerId[layer.layerId];
     268                this._dataGridNodesByLayerId.delete(layer.layerId);
    270269            }
    271270        }, this);
    272271
    273272        mutations.additions.forEach(function(layer) {
    274             var node = this._dataGridNodeForLayer(layer);
     273            let node = this._dataGridNodeForLayer(layer);
    275274            if (node)
    276275                dataGrid.appendChild(node);
     
    278277
    279278        mutations.preserved.forEach(function(layer) {
    280             var node = this._dataGridNodesByLayerId[layer.layerId];
     279            let node = this._dataGridNodesByLayerId.get(layer.layerId);
    281280            if (node)
    282281                node.layer = layer;
     
    290289    _dataGridNodeForLayer(layer)
    291290    {
    292         var node = new WebInspector.LayerTreeDataGridNode(layer);
    293 
    294         this._dataGridNodesByLayerId[layer.layerId] = node;
     291        let node = new WebInspector.LayerTreeDataGridNode(layer);
     292        this._dataGridNodesByLayerId.set(layer.layerId, node);
    295293
    296294        return node;
  • trunk/Source/WebInspectorUI/UserInterface/Views/NavigationSidebarPanel.js

    r191488 r191612  
    7575            WebInspector.Frame.addEventListener(WebInspector.Frame.Event.ResourceWasRemoved, this._checkForStaleResources, this);
    7676        }
     77
     78        this._pendingViewStateCookie = null;
     79        this._restoringState = false;
    7780    }
    7881
     
    240243        function finalAttemptToRestoreViewStateFromCookie()
    241244        {
    242             delete this._finalAttemptToRestoreViewStateTimeout;
     245            this._finalAttemptToRestoreViewStateTimeout = undefined;
    243246
    244247            this._checkOutlinesForPendingViewStateCookie(true);
    245248
    246             delete this._pendingViewStateCookie;
    247             delete this._restoringState;
     249            this._pendingViewStateCookie = null;
     250            this._restoringState = false;
    248251        }
    249252
     
    330333
    331334            // If this tree element was expanded during filtering, collapse it again.
    332             if (treeElement.expanded && treeElement.__wasExpandedDuringFiltering) {
    333                 delete treeElement.__wasExpandedDuringFiltering;
     335            if (treeElement.expanded && treeElement[WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol]) {
     336                treeElement[WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol] = false;
    334337                treeElement.collapse();
    335338            }
     
    389392
    390393            // If this tree element didn't match a built-in filter and was expanded earlier during filtering, collapse it again.
    391             if (!flags.expandTreeElement && treeElement.expanded && treeElement.__wasExpandedDuringFiltering) {
    392                 delete treeElement.__wasExpandedDuringFiltering;
     394            if (!flags.expandTreeElement && treeElement.expanded && treeElement[WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol]) {
     395                treeElement[WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol] = false;
    393396                treeElement.collapse();
    394397            }
     
    465468    _updateContentOverflowShadowVisibility()
    466469    {
    467         delete this._updateContentOverflowShadowVisibilityIdentifier;
     470        this._updateContentOverflowShadowVisibilityIdentifier = undefined;
    468471
    469472        var scrollHeight = this.contentElement.scrollHeight;
     
    699702            this.showDefaultContentViewForTreeElement(matchedElement);
    700703
    701             delete this._pendingViewStateCookie;
     704            this._pendingViewStateCookie = null;
    702705
    703706            // Delay clearing the restoringState flag until the next runloop so listeners
    704707            // checking for it in this runloop still know state was being restored.
    705708            setTimeout(function() {
    706                 delete this._restoringState;
     709                this._restoringState = false;
    707710            }.bind(this));
    708711
    709712            if (this._finalAttemptToRestoreViewStateTimeout) {
    710713                clearTimeout(this._finalAttemptToRestoreViewStateTimeout);
    711                 delete this._finalAttemptToRestoreViewStateTimeout;
     714                this._finalAttemptToRestoreViewStateTimeout = undefined;
    712715            }
    713716        }
    714717    }
    715718};
     719
     720WebInspector.NavigationSidebarPanel.WasExpandedDuringFilteringSymbol = Symbol("was-expanded-during-filtering");
    716721
    717722WebInspector.NavigationSidebarPanel.OverflowShadowElementStyleClassName = "overflow-shadow";
  • trunk/Source/WebInspectorUI/UserInterface/Views/ScopeChainDetailsSidebarPanel.js

    r188407 r191612  
    161161        let foundLocalScope = false;
    162162
    163         let sectionCountByType = {};
    164         for (var type in WebInspector.ScopeChainNode.Type)
    165             sectionCountByType[WebInspector.ScopeChainNode.Type[type]] = 0;
     163        let sectionCountByType = new Map;
     164        for (let type in WebInspector.ScopeChainNode.Type)
     165            sectionCountByType.set(WebInspector.ScopeChainNode.Type[type], 0);
    166166
    167167        let scopeChain = callFrame.scopeChain;
     
    171171            let collapsedByDefault = false;
    172172
    173             ++sectionCountByType[scope.type];
     173            let count = sectionCountByType.get(scope.type);
     174            sectionCountByType.set(scope.type, ++count);
    174175
    175176            switch (scope.type) {
     
    210211            }
    211212
    212             let detailsSectionIdentifier = scope.type + "-" + sectionCountByType[scope.type];
     213            let detailsSectionIdentifier = scope.type + "-" + sectionCountByType.get(scope.type);
    213214
    214215            let scopePropertyPath = WebInspector.PropertyPath.emptyPropertyPathForScope(scope.object);
  • trunk/Source/WebInspectorUI/UserInterface/Views/StorageSidebarPanel.js

    r187872 r191612  
    6666
    6767        this._databaseRootTreeElement = null;
    68         this._databaseHostTreeElementMap = {};
     68        this._databaseHostTreeElementMap = new Map;
    6969
    7070        this._indexedDatabaseRootTreeElement = null;
    71         this._indexedDatabaseHostTreeElementMap = {};
     71        this._indexedDatabaseHostTreeElementMap = new Map;
    7272
    7373        this._cookieStorageRootTreeElement = null;
    7474
    7575        this._applicationCacheRootTreeElement = null;
    76         this._applicationCacheURLTreeElementMap = {};
     76        this._applicationCacheURLTreeElementMap = new Map;
    7777
    7878        WebInspector.storageManager.addEventListener(WebInspector.StorageManager.Event.CookieStorageObjectWasAdded, this._cookieStorageObjectWasAdded, this);
     
    212212        console.assert(database instanceof WebInspector.DatabaseObject);
    213213
    214         if (!this._databaseHostTreeElementMap[database.host]) {
    215             this._databaseHostTreeElementMap[database.host] = new WebInspector.DatabaseHostTreeElement(database.host);
    216             this._databaseRootTreeElement = this._addStorageChild(this._databaseHostTreeElementMap[database.host], this._databaseRootTreeElement, WebInspector.UIString("Databases"));
    217         }
    218 
    219         var databaseElement = new WebInspector.DatabaseTreeElement(database);
    220         this._databaseHostTreeElementMap[database.host].appendChild(databaseElement);
     214        let databaseHostElement = this._databaseHostTreeElementMap.get(database.host);
     215        if (!databaseHostElement) {
     216            databaseHostElement = new WebInspector.DatabaseHostTreeElement(database.host);
     217            this._databaseHostTreeElementMap.set(database.host, databaseHostElement);
     218            this._databaseRootTreeElement = this._addStorageChild(treeElement, this._databaseRootTreeElement, WebInspector.UIString("Databases"));
     219        }
     220
     221        let databaseElement = new WebInspector.DatabaseTreeElement(database);
     222        databaseHostElement.append(databaseElement);
    221223    }
    222224
     
    237239        console.assert(indexedDatabase instanceof WebInspector.IndexedDatabase);
    238240
    239         if (!this._indexedDatabaseHostTreeElementMap[indexedDatabase.host]) {
    240             this._indexedDatabaseHostTreeElementMap[indexedDatabase.host] = new WebInspector.IndexedDatabaseHostTreeElement(indexedDatabase.host);
    241             this._indexedDatabaseRootTreeElement = this._addStorageChild(this._indexedDatabaseHostTreeElementMap[indexedDatabase.host], this._indexedDatabaseRootTreeElement, WebInspector.UIString("Indexed Databases"));
    242         }
    243 
    244         var indexedDatabaseElement = new WebInspector.IndexedDatabaseTreeElement(indexedDatabase);
    245         this._indexedDatabaseHostTreeElementMap[indexedDatabase.host].appendChild(indexedDatabaseElement);
     241        let indexedDatabaseHostElement = this._indexedDatabaseHostTreeElementMap.get(indexedDatabase.host);
     242        if (!indexedDatabaseHostElement) {
     243            indexedDatabaseHostElement = new WebInspector.IndexedDatabaseHostTreeElement(indexedDatabase.host);
     244            this._indexedDatabaseHostTreeElementMap.set(indexedDatabase.host, indexedDatabaseHostElement);
     245            this._indexedDatabaseRootTreeElement = this._addStorageChild(indexedDatabaseHostElement, this._indexedDatabaseRootTreeElement, WebInspector.UIString("Indexed Databases"));
     246        }
     247
     248        let indexedDatabaseElement = new WebInspector.IndexedDatabaseTreeElement(indexedDatabase);
     249        indexedDatabaseHostElement.append(indexedDatabaseElement);
    246250    }
    247251
     
    268272        console.assert(frameManifest instanceof WebInspector.ApplicationCacheFrame);
    269273
    270         var manifest = frameManifest.manifest;
    271         var manifestURL = manifest.manifestURL;
    272         if (!this._applicationCacheURLTreeElementMap[manifestURL]) {
    273             this._applicationCacheURLTreeElementMap[manifestURL] = new WebInspector.ApplicationCacheManifestTreeElement(manifest);
    274             this._applicationCacheRootTreeElement = this._addStorageChild(this._applicationCacheURLTreeElementMap[manifestURL], this._applicationCacheRootTreeElement, WebInspector.UIString("Application Cache"));
    275         }
    276 
    277         var frameCacheElement = new WebInspector.ApplicationCacheFrameTreeElement(frameManifest);
    278         this._applicationCacheURLTreeElementMap[manifestURL].appendChild(frameCacheElement);
     274        let manifest = frameManifest.manifest;
     275        let manifestURL = manifest.manifestURL;
     276        let applicationCacheManifestElement = this._applicationCacheURLTreeElementMap.get(manifestURL);
     277        if (!applicationCacheManifestElement) {
     278            applicationCacheManifestElement = new WebInspector.ApplicationCacheManifestTreeElement(manifest);
     279            this._applicationCacheURLTreeElementMap.set(manifestURL, applicationCacheManifestElement);
     280            this._applicationCacheRootTreeElement = this._addStorageChild(applicationCacheManifestElement, this._applicationCacheRootTreeElement, WebInspector.UIString("Application Cache"));
     281        }
     282
     283        let frameCacheElement = new WebInspector.ApplicationCacheFrameTreeElement(frameManifest);
     284        applicationCacheManifestElement.append(frameCacheElement);
    279285    }
    280286
     
    354360        this._sessionStorageRootTreeElement = null;
    355361        this._databaseRootTreeElement = null;
    356         this._databaseHostTreeElementMap = {};
     362        this._databaseHostTreeElementMap.clear();
    357363        this._indexedDatabaseRootTreeElement = null;
    358         this._indexedDatabaseHostTreeElementMap = {};
     364        this._indexedDatabaseHostTreeElementMap.clear();
    359365        this._cookieStorageRootTreeElement = null;
    360366        this._applicationCacheRootTreeElement = null;
    361         this._applicationCacheURLTreeElementMap = {};
     367        this._applicationCacheURLTreeElementMap.clear();
    362368    }
    363369
Note: See TracChangeset for help on using the changeset viewer.