Title: [217749] trunk/Source/WebInspectorUI
Revision
217749
Author
[email protected]
Date
2017-06-02 20:37:53 -0700 (Fri, 02 Jun 2017)

Log Message

Web Inspector: Use initialLayout for DetailsSidebarPanel classes
https://bugs.webkit.org/show_bug.cgi?id=172381

Reviewed by Timothy Hatcher.

* UserInterface/Views/ApplicationCacheDetailsSidebarPanel.js:
(WebInspector.ApplicationCacheDetailsSidebarPanel):
(WebInspector.ApplicationCacheDetailsSidebarPanel.prototype.initialLayout): Added.
(WebInspector.ApplicationCacheDetailsSidebarPanel.prototype.layout):
* UserInterface/Views/DOMNodeDetailsSidebarPanel.js:
(WebInspector.DOMNodeDetailsSidebarPanel):
(WebInspector.DOMNodeDetailsSidebarPanel.prototype.initialLayout): Added.
(WebInspector.DOMNodeDetailsSidebarPanel.prototype.layout):
* UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js:
(WebInspector.IndexedDatabaseDetailsSidebarPanel):
(WebInspector.IndexedDatabaseDetailsSidebarPanel.prototype.initialLayout): Added.
(WebInspector.IndexedDatabaseDetailsSidebarPanel.prototype.layout):
* UserInterface/Views/LayerTreeDetailsSidebarPanel.js:
(WebInspector.LayerTreeDetailsSidebarPanel):
(WebInspector.LayerTreeDetailsSidebarPanel.prototype.initialLayout): Added.
(WebInspector.LayerTreeDetailsSidebarPanel.prototype.layout):
* UserInterface/Views/ProbeDetailsSidebarPanel.js:
(WebInspector.ProbeDetailsSidebarPanel):
(WebInspector.ProbeDetailsSidebarPanel.prototype.initialLayout): Added.
* UserInterface/Views/ResourceDetailsSidebarPanel.js:
(WebInspector.ResourceDetailsSidebarPanel):
(WebInspector.ResourceDetailsSidebarPanel.prototype.set resource):
(WebInspector.ResourceDetailsSidebarPanel.prototype.initialLayout): Added.
(WebInspector.ResourceDetailsSidebarPanel.prototype.layout):
(WebInspector.ResourceDetailsSidebarPanel.prototype._applyResourceEventListeners):

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (217748 => 217749)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-06-03 02:27:27 UTC (rev 217748)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-06-03 03:37:53 UTC (rev 217749)
@@ -1,5 +1,38 @@
 2017-06-02  Devin Rousso  <[email protected]>
 
+        Web Inspector: Use initialLayout for DetailsSidebarPanel classes
+        https://bugs.webkit.org/show_bug.cgi?id=172381
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Views/ApplicationCacheDetailsSidebarPanel.js:
+        (WebInspector.ApplicationCacheDetailsSidebarPanel):
+        (WebInspector.ApplicationCacheDetailsSidebarPanel.prototype.initialLayout): Added.
+        (WebInspector.ApplicationCacheDetailsSidebarPanel.prototype.layout):
+        * UserInterface/Views/DOMNodeDetailsSidebarPanel.js:
+        (WebInspector.DOMNodeDetailsSidebarPanel):
+        (WebInspector.DOMNodeDetailsSidebarPanel.prototype.initialLayout): Added.
+        (WebInspector.DOMNodeDetailsSidebarPanel.prototype.layout):
+        * UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js:
+        (WebInspector.IndexedDatabaseDetailsSidebarPanel):
+        (WebInspector.IndexedDatabaseDetailsSidebarPanel.prototype.initialLayout): Added.
+        (WebInspector.IndexedDatabaseDetailsSidebarPanel.prototype.layout):
+        * UserInterface/Views/LayerTreeDetailsSidebarPanel.js:
+        (WebInspector.LayerTreeDetailsSidebarPanel):
+        (WebInspector.LayerTreeDetailsSidebarPanel.prototype.initialLayout): Added.
+        (WebInspector.LayerTreeDetailsSidebarPanel.prototype.layout):
+        * UserInterface/Views/ProbeDetailsSidebarPanel.js:
+        (WebInspector.ProbeDetailsSidebarPanel):
+        (WebInspector.ProbeDetailsSidebarPanel.prototype.initialLayout): Added.
+        * UserInterface/Views/ResourceDetailsSidebarPanel.js:
+        (WebInspector.ResourceDetailsSidebarPanel):
+        (WebInspector.ResourceDetailsSidebarPanel.prototype.set resource):
+        (WebInspector.ResourceDetailsSidebarPanel.prototype.initialLayout): Added.
+        (WebInspector.ResourceDetailsSidebarPanel.prototype.layout):
+        (WebInspector.ResourceDetailsSidebarPanel.prototype._applyResourceEventListeners):
+
+2017-06-02  Devin Rousso  <[email protected]>
+
         Web Inspector: The CodeMirror instance in the ConsolePrompt does't need to be refreshed each time it is shown
         https://bugs.webkit.org/show_bug.cgi?id=172608
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ApplicationCacheDetailsSidebarPanel.js (217748 => 217749)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ApplicationCacheDetailsSidebarPanel.js	2017-06-03 02:27:27 UTC (rev 217748)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ApplicationCacheDetailsSidebarPanel.js	2017-06-03 03:37:53 UTC (rev 217749)
@@ -32,26 +32,6 @@
         this.element.classList.add("application-cache");
 
         this._applicationCacheFrame = null;
-
-        this._locationManifestURLRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Manifest URL"));
-        this._locationFrameURLRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Frame URL"));
-
-        this._locationGroup = new WebInspector.DetailsSectionGroup([this._locationManifestURLRow, this._locationFrameURLRow]);
-
-        this._locationSection = new WebInspector.DetailsSection("application-cache-location", WebInspector.UIString("Location"), [this._locationGroup]);
-
-        this._onlineRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Online"));
-        this._statusRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Status"));
-
-        this._statusGroup = new WebInspector.DetailsSectionGroup([this._onlineRow, this._statusRow]);
-
-        this._statusSection = new WebInspector.DetailsSection("application-cache-status", WebInspector.UIString("Status"), [this._statusGroup]);
-
-        this.contentView.element.appendChild(this._locationSection.element);
-        this.contentView.element.appendChild(this._statusSection.element);
-
-        WebInspector.applicationCacheManager.addEventListener(WebInspector.ApplicationCacheManager.Event.NetworkStateUpdated, this._networkStateUpdated, this);
-        WebInspector.applicationCacheManager.addEventListener(WebInspector.ApplicationCacheManager.Event.FrameManifestStatusChanged, this._frameManifestStatusChanged, this);
     }
 
     // Public
@@ -94,8 +74,33 @@
 
     // Protected
 
+    initialLayout()
+    {
+        super.initialLayout();
+
+        this._locationManifestURLRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Manifest URL"));
+        this._locationFrameURLRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Frame URL"));
+
+        let locationGroup = new WebInspector.DetailsSectionGroup([this._locationManifestURLRow, this._locationFrameURLRow]);
+        let locationSection = new WebInspector.DetailsSection("application-cache-location", WebInspector.UIString("Location"), [locationGroup]);
+
+        this._onlineRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Online"));
+        this._statusRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Status"));
+
+        let statusGroup = new WebInspector.DetailsSectionGroup([this._onlineRow, this._statusRow]);
+        let statusSection = new WebInspector.DetailsSection("application-cache-status", WebInspector.UIString("Status"), [statusGroup]);
+
+        this.contentView.element.appendChild(locationSection.element);
+        this.contentView.element.appendChild(statusSection.element);
+
+        WebInspector.applicationCacheManager.addEventListener(WebInspector.ApplicationCacheManager.Event.NetworkStateUpdated, this._networkStateUpdated, this);
+        WebInspector.applicationCacheManager.addEventListener(WebInspector.ApplicationCacheManager.Event.FrameManifestStatusChanged, this._frameManifestStatusChanged, this);
+    }
+
     layout()
     {
+        super.layout();
+
         if (!this.applicationCacheFrame)
             return;
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js (217748 => 217749)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js	2017-06-03 02:27:27 UTC (rev 217748)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js	2017-06-03 03:37:53 UTC (rev 217749)
@@ -29,17 +29,24 @@
     {
         super("dom-node-details", WebInspector.UIString("Node"), WebInspector.UIString("Node"));
 
-        WebInspector.domTreeManager.addEventListener(WebInspector.DOMTreeManager.Event.AttributeModified, this._attributesChanged, this);
-        WebInspector.domTreeManager.addEventListener(WebInspector.DOMTreeManager.Event.AttributeRemoved, this._attributesChanged, this);
-        WebInspector.domTreeManager.addEventListener(WebInspector.DOMTreeManager.Event.CharacterDataModified, this._characterDataModified, this);
-        WebInspector.domTreeManager.addEventListener(WebInspector.DOMTreeManager.Event.CustomElementStateChanged, this._customElementStateChanged, this);
-
         this._eventListenerGroupingMethodSetting = new WebInspector.Setting("dom-node-event-listener-grouping-method", WebInspector.DOMNodeDetailsSidebarPanel.EventListenerGroupingMethod.Event);
 
         this.element.classList.add("dom-node");
 
         this._nodeRemoteObject = null;
+    }
 
+    // Protected
+
+    initialLayout()
+    {
+        super.initialLayout();
+
+        WebInspector.domTreeManager.addEventListener(WebInspector.DOMTreeManager.Event.AttributeModified, this._attributesChanged, this);
+        WebInspector.domTreeManager.addEventListener(WebInspector.DOMTreeManager.Event.AttributeRemoved, this._attributesChanged, this);
+        WebInspector.domTreeManager.addEventListener(WebInspector.DOMTreeManager.Event.CharacterDataModified, this._characterDataModified, this);
+        WebInspector.domTreeManager.addEventListener(WebInspector.DOMTreeManager.Event.CustomElementStateChanged, this._customElementStateChanged, this);
+
         this._identityNodeTypeRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Type"));
         this._identityNodeNameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name"));
         this._identityNodeValueRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Value"));
@@ -121,10 +128,10 @@
         }
     }
 
-    // Protected
-
     layout()
     {
+        super.layout();
+
         if (!this.domNode)
             return;
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js (217748 => 217749)


--- trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js	2017-06-03 02:27:27 UTC (rev 217748)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/IndexedDatabaseDetailsSidebarPanel.js	2017-06-03 03:37:53 UTC (rev 217749)
@@ -34,29 +34,6 @@
         this._database = null;
         this._objectStore = null;
         this._index = null;
-
-        this._databaseNameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name"));
-        this._databaseVersionRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Version"));
-        this._databaseSecurityOriginRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Security Origin"));
-        this._databaseGroup = new WebInspector.DetailsSectionGroup([this._databaseNameRow, this._databaseVersionRow, this._databaseSecurityOriginRow]);
-        this._databaseSection = new WebInspector.DetailsSection("indexed-database-database", WebInspector.UIString("Database"), [this._databaseGroup]);
-
-        this._objectStoreNameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name"));
-        this._objectStoreKeyPathRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Key Path"));
-        this._objectStoreAutoIncrementRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Auto Increment"));
-        this._objectStoreGroup = new WebInspector.DetailsSectionGroup([this._objectStoreNameRow, this._objectStoreKeyPathRow, this._objectStoreAutoIncrementRow]);
-        this._objectStoreSection = new WebInspector.DetailsSection("indexed-database-object-store", WebInspector.UIString("Object Store"), [this._objectStoreGroup]);
-
-        this._indexNameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name"));
-        this._indexKeyPathRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Key Path"));
-        this._indexUniqueRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Unique"));
-        this._indexMultiEntryRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Multi-Entry"));
-        this._indexGroup = new WebInspector.DetailsSectionGroup([this._indexNameRow, this._indexKeyPathRow, this._indexUniqueRow, this._indexMultiEntryRow]);
-        this._indexSection = new WebInspector.DetailsSection("indexed-database-index", WebInspector.UIString("Index"), [this._indexGroup]);
-
-        this.contentView.element.appendChild(this._databaseSection.element);
-        this.contentView.element.appendChild(this._objectStoreSection.element);
-        this.contentView.element.appendChild(this._indexSection.element);
     }
 
     // Public
@@ -93,8 +70,38 @@
 
     // Protected
 
+    initialLayout()
+    {
+        super.initialLayout();
+
+        this._databaseNameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name"));
+        this._databaseVersionRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Version"));
+        this._databaseSecurityOriginRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Security Origin"));
+        let databaseGroup = new WebInspector.DetailsSectionGroup([this._databaseNameRow, this._databaseVersionRow, this._databaseSecurityOriginRow]);
+        this._databaseSection = new WebInspector.DetailsSection("indexed-database-database", WebInspector.UIString("Database"), [databaseGroup]);
+
+        this._objectStoreNameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name"));
+        this._objectStoreKeyPathRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Key Path"));
+        this._objectStoreAutoIncrementRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Auto Increment"));
+        let objectStoreGroup = new WebInspector.DetailsSectionGroup([this._objectStoreNameRow, this._objectStoreKeyPathRow, this._objectStoreAutoIncrementRow]);
+        this._objectStoreSection = new WebInspector.DetailsSection("indexed-database-object-store", WebInspector.UIString("Object Store"), [objectStoreGroup]);
+
+        this._indexNameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name"));
+        this._indexKeyPathRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Key Path"));
+        this._indexUniqueRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Unique"));
+        this._indexMultiEntryRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Multi-Entry"));
+        let indexGroup = new WebInspector.DetailsSectionGroup([this._indexNameRow, this._indexKeyPathRow, this._indexUniqueRow, this._indexMultiEntryRow]);
+        this._indexSection = new WebInspector.DetailsSection("indexed-database-index", WebInspector.UIString("Index"), [indexGroup]);
+
+        this.contentView.element.appendChild(this._databaseSection.element);
+        this.contentView.element.appendChild(this._objectStoreSection.element);
+        this.contentView.element.appendChild(this._indexSection.element);
+    }
+
     layout()
     {
+        super.layout();
+
         if (!this._database)
             this._databaseSection.element.hidden = true;
         else {

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js (217748 => 217749)


--- trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js	2017-06-03 02:27:27 UTC (rev 217748)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/LayerTreeDetailsSidebarPanel.js	2017-06-03 03:37:53 UTC (rev 217749)
@@ -32,12 +32,6 @@
         this._dataGridNodesByLayerId = new Map;
 
         this.element.classList.add("layer-tree");
-
-        WebInspector.showShadowDOMSetting.addEventListener(WebInspector.Setting.Event.Changed, this._showShadowDOMSettingChanged, this);
-
-        this._buildLayerInfoSection();
-        this._buildDataGridSection();
-        this._buildBottomBar();
     }
 
     // DetailsSidebarPanel Overrides.
@@ -67,8 +61,21 @@
 
     // Protected
 
+    initialLayout()
+    {
+        super.initialLayout();
+
+        WebInspector.showShadowDOMSetting.addEventListener(WebInspector.Setting.Event.Changed, this._showShadowDOMSettingChanged, this);
+
+        this._buildLayerInfoSection();
+        this._buildDataGridSection();
+        this._buildBottomBar();
+    }
+
     layout()
     {
+        super.layout();
+
         if (!this.domNode)
             return;
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ProbeDetailsSidebarPanel.js (217748 => 217749)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ProbeDetailsSidebarPanel.js	2017-06-03 02:27:27 UTC (rev 217748)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ProbeDetailsSidebarPanel.js	2017-06-03 03:37:53 UTC (rev 217749)
@@ -30,15 +30,8 @@
     {
         super("probe", WebInspector.UIString("Probes"), WebInspector.UIString("Probes"));
 
-        WebInspector.probeManager.addEventListener(WebInspector.ProbeManager.Event.ProbeSetAdded, this._probeSetAdded, this);
-        WebInspector.probeManager.addEventListener(WebInspector.ProbeManager.Event.ProbeSetRemoved, this._probeSetRemoved, this);
-
         this._probeSetSections = new Map;
         this._inspectedProbeSets = [];
-
-        // Initialize sidebar sections for probe sets that already exist.
-        for (var probeSet of WebInspector.probeManager.probeSets)
-            this._probeSetAdded(probeSet);
     }
 
     // Public
@@ -93,6 +86,18 @@
 
     // Protected
 
+    initialLayout()
+    {
+        super.initialLayout();
+
+        WebInspector.probeManager.addEventListener(WebInspector.ProbeManager.Event.ProbeSetAdded, this._probeSetAdded, this);
+        WebInspector.probeManager.addEventListener(WebInspector.ProbeManager.Event.ProbeSetRemoved, this._probeSetRemoved, this);
+
+        // Initialize sidebar sections for probe sets that already exist.
+        for (var probeSet of WebInspector.probeManager.probeSets)
+            this._probeSetAdded(probeSet);
+    }
+
     sizeDidChange()
     {
         super.sizeDidChange();

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js (217748 => 217749)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js	2017-06-03 02:27:27 UTC (rev 217748)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js	2017-06-03 03:37:53 UTC (rev 217749)
@@ -32,7 +32,84 @@
         this.element.classList.add("resource");
 
         this._resource = null;
+    }
 
+    // Public
+
+    inspect(objects)
+    {
+        // Convert to a single item array if needed.
+        if (!(objects instanceof Array))
+            objects = [objects];
+
+        var resourceToInspect = null;
+
+        // Iterate over the objects to find a WebInspector.Resource to inspect.
+        for (let object of objects) {
+            if (object instanceof WebInspector.Resource) {
+                resourceToInspect = object;
+                break;
+            }
+
+            if (object instanceof WebInspector.Frame) {
+                resourceToInspect = object.mainResource;
+                break;
+            }
+
+            // FIXME: <https://webkit.org/b/164427> Web Inspector: WorkerTarget's mainResource should be a Resource not a Script
+            // If that was the case, then we could just have WorkerTreeElement contain the Resource and not a Script.
+            if (object instanceof WebInspector.Script && object.isMainResource() && object.resource) {
+                resourceToInspect = object.resource;
+                break;
+            }
+        }
+
+        this.resource = resourceToInspect;
+
+        return !!this._resource;
+    }
+
+    get resource()
+    {
+        return this._resource;
+    }
+
+    set resource(resource)
+    {
+        if (resource === this._resource)
+            return;
+
+        if (this._resource) {
+            this._resource.removeEventListener(WebInspector.Resource.Event.URLDidChange, this._refreshURL, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.MIMETypeDidChange, this._refreshMIMEType, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.TypeDidChange, this._refreshResourceType, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.LoadingDidFail, this._refreshErrorReason, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.RequestHeadersDidChange, this._refreshRequestHeaders, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.ResponseReceived, this._refreshRequestAndResponse, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.CacheStatusDidChange, this._refreshRequestAndResponse, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.SizeDidChange, this._refreshDecodedSize, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.TransferSizeDidChange, this._refreshTransferSize, this);
+            this._resource.removeEventListener(WebInspector.Resource.Event.InitiatedResourcesDidChange, this._refreshRelatedResourcesSection, this);
+        }
+
+        this._resource = resource;
+
+        if (this._resource) {
+            if (this.parentSidebar)
+                this._applyResourceEventListeners();
+            else
+                this._needsToApplyResourceEventListeners = true;
+        }
+
+        this.needsLayout();
+    }
+
+    // Protected
+
+    initialLayout()
+    {
+        super.initialLayout();
+
         this._typeMIMETypeRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("MIME Type"));
         this._typeResourceTypeRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Resource Type"));
 
@@ -115,88 +192,18 @@
         this.contentView.element.appendChild(this._requestAndResponseSection.element);
         this.contentView.element.appendChild(this._requestHeadersSection.element);
         this.contentView.element.appendChild(this._responseHeadersSection.element);
-    }
 
-    // Public
+        if (this._needsToApplyResourceEventListeners) {
+            this._applyResourceEventListeners();
 
-    inspect(objects)
-    {
-        // Convert to a single item array if needed.
-        if (!(objects instanceof Array))
-            objects = [objects];
-
-        var resourceToInspect = null;
-
-        // Iterate over the objects to find a WebInspector.Resource to inspect.
-        for (let object of objects) {
-            if (object instanceof WebInspector.Resource) {
-                resourceToInspect = object;
-                break;
-            }
-
-            if (object instanceof WebInspector.Frame) {
-                resourceToInspect = object.mainResource;
-                break;
-            }
-
-            // FIXME: <https://webkit.org/b/164427> Web Inspector: WorkerTarget's mainResource should be a Resource not a Script
-            // If that was the case, then we could just have WorkerTreeElement contain the Resource and not a Script.
-            if (object instanceof WebInspector.Script && object.isMainResource() && object.resource) {
-                resourceToInspect = object.resource;
-                break;
-            }
+            this._needsToApplyResourceEventListeners = false;
         }
-
-        this.resource = resourceToInspect;
-
-        return !!this._resource;
     }
 
-    get resource()
+    layout()
     {
-        return this._resource;
-    }
+        super.layout();
 
-    set resource(resource)
-    {
-        if (resource === this._resource)
-            return;
-
-        if (this._resource) {
-            this._resource.removeEventListener(WebInspector.Resource.Event.URLDidChange, this._refreshURL, this);
-            this._resource.removeEventListener(WebInspector.Resource.Event.MIMETypeDidChange, this._refreshMIMEType, this);
-            this._resource.removeEventListener(WebInspector.Resource.Event.TypeDidChange, this._refreshResourceType, this);
-            this._resource.removeEventListener(WebInspector.Resource.Event.LoadingDidFail, this._refreshErrorReason, this);
-            this._resource.removeEventListener(WebInspector.Resource.Event.RequestHeadersDidChange, this._refreshRequestHeaders, this);
-            this._resource.removeEventListener(WebInspector.Resource.Event.ResponseReceived, this._refreshRequestAndResponse, this);
-            this._resource.removeEventListener(WebInspector.Resource.Event.CacheStatusDidChange, this._refreshRequestAndResponse, this);
-            this._resource.removeEventListener(WebInspector.Resource.Event.SizeDidChange, this._refreshDecodedSize, this);
-            this._resource.removeEventListener(WebInspector.Resource.Event.TransferSizeDidChange, this._refreshTransferSize, this);
-            this._resource.removeEventListener(WebInspector.Resource.Event.InitiatedResourcesDidChange, this._refreshRelatedResourcesSection, this);
-        }
-
-        this._resource = resource;
-
-        if (this._resource) {
-            this._resource.addEventListener(WebInspector.Resource.Event.URLDidChange, this._refreshURL, this);
-            this._resource.addEventListener(WebInspector.Resource.Event.MIMETypeDidChange, this._refreshMIMEType, this);
-            this._resource.addEventListener(WebInspector.Resource.Event.TypeDidChange, this._refreshResourceType, this);
-            this._resource.addEventListener(WebInspector.Resource.Event.LoadingDidFail, this._refreshErrorReason, this);
-            this._resource.addEventListener(WebInspector.Resource.Event.RequestHeadersDidChange, this._refreshRequestHeaders, this);
-            this._resource.addEventListener(WebInspector.Resource.Event.ResponseReceived, this._refreshRequestAndResponse, this);
-            this._resource.addEventListener(WebInspector.Resource.Event.CacheStatusDidChange, this._refreshRequestAndResponse, this);
-            this._resource.addEventListener(WebInspector.Resource.Event.SizeDidChange, this._refreshDecodedSize, this);
-            this._resource.addEventListener(WebInspector.Resource.Event.TransferSizeDidChange, this._refreshTransferSize, this);
-            this._resource.addEventListener(WebInspector.Resource.Event.InitiatedResourcesDidChange, this._refreshRelatedResourcesSection, this);
-        }
-
-        this.needsLayout();
-    }
-
-    // Protected
-
-    layout()
-    {
         if (!this._resource)
             return;
 
@@ -600,4 +607,18 @@
 
         this._requestDataSection.groups = [new WebInspector.DetailsSectionGroup(rows)];
     }
+
+    _applyResourceEventListeners()
+    {
+        this._resource.addEventListener(WebInspector.Resource.Event.URLDidChange, this._refreshURL, this);
+        this._resource.addEventListener(WebInspector.Resource.Event.MIMETypeDidChange, this._refreshMIMEType, this);
+        this._resource.addEventListener(WebInspector.Resource.Event.TypeDidChange, this._refreshResourceType, this);
+        this._resource.addEventListener(WebInspector.Resource.Event.LoadingDidFail, this._refreshErrorReason, this);
+        this._resource.addEventListener(WebInspector.Resource.Event.RequestHeadersDidChange, this._refreshRequestHeaders, this);
+        this._resource.addEventListener(WebInspector.Resource.Event.ResponseReceived, this._refreshRequestAndResponse, this);
+        this._resource.addEventListener(WebInspector.Resource.Event.CacheStatusDidChange, this._refreshRequestAndResponse, this);
+        this._resource.addEventListener(WebInspector.Resource.Event.SizeDidChange, this._refreshDecodedSize, this);
+        this._resource.addEventListener(WebInspector.Resource.Event.TransferSizeDidChange, this._refreshTransferSize, this);
+        this._resource.addEventListener(WebInspector.Resource.Event.InitiatedResourcesDidChange, this._refreshRelatedResourcesSection, this);
+    }
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to