Changeset 194785 in webkit


Ignore:
Timestamp:
Jan 8, 2016, 1:33:59 PM (10 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: Initiated section of Resource Details Sidebar should not display as empty and should update as the list changes
https://bugs.webkit.org/show_bug.cgi?id=152907
<rdar://problem/24109927>

Patch by Joseph Pecoraro <Joseph Pecoraro> on 2016-01-08
Reviewed by Timothy Hatcher.

  • UserInterface/Models/Resource.js:

(WebInspector.Resource.prototype.addInitiatedResource):
Dispatch an event when the list of initiated resources changes.

  • UserInterface/Views/ResourceDetailsSidebarPanel.js:

(WebInspector.ResourceDetailsSidebarPanel.prototype.set resource):
Add/remove event listeners for initiated resources changes to refresh
the related resources section.

(WebInspector.ResourceDetailsSidebarPanel.prototype.refresh):
(WebInspector.ResourceDetailsSidebarPanel.prototype._refreshURL):
(WebInspector.ResourceDetailsSidebarPanel.prototype._refreshRelatedResourcesSection):
Show/hide the related resources section depending on if we have something or not.

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r194776 r194785  
     12016-01-08  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Initiated section of Resource Details Sidebar should not display as empty and should update as the list changes
     4        https://bugs.webkit.org/show_bug.cgi?id=152907
     5        <rdar://problem/24109927>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        * UserInterface/Models/Resource.js:
     10        (WebInspector.Resource.prototype.addInitiatedResource):
     11        Dispatch an event when the list of initiated resources changes.
     12
     13        * UserInterface/Views/ResourceDetailsSidebarPanel.js:
     14        (WebInspector.ResourceDetailsSidebarPanel.prototype.set resource):
     15        Add/remove event listeners for initiated resources changes to refresh
     16        the related resources section.
     17
     18        (WebInspector.ResourceDetailsSidebarPanel.prototype.refresh):
     19        (WebInspector.ResourceDetailsSidebarPanel.prototype._refreshURL):
     20        (WebInspector.ResourceDetailsSidebarPanel.prototype._refreshRelatedResourcesSection):
     21        Show/hide the related resources section depending on if we have something or not.
     22
    1232016-01-08  Joseph Pecoraro  <pecoraro@apple.com>
    224
  • trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js

    r194776 r194785  
    231231
    232232        this._initiatedResources.push(resource);
     233
     234        this.dispatchEventToListeners(WebInspector.Resource.Event.InitiatedResourcesDidChange);
    233235    }
    234236
     
    694696    SizeDidChange: "resource-size-did-change",
    695697    TransferSizeDidChange: "resource-transfer-size-did-change",
    696     CacheStatusDidChange: "resource-cached-did-change"
     698    CacheStatusDidChange: "resource-cached-did-change",
     699    InitiatedResourcesDidChange: "resource-initiated-resources-did-change",
    697700};
    698701
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceDetailsSidebarPanel.js

    r194506 r194785  
    158158            this._resource.removeEventListener(WebInspector.Resource.Event.SizeDidChange, this._refreshDecodedSize, this);
    159159            this._resource.removeEventListener(WebInspector.Resource.Event.TransferSizeDidChange, this._refreshTransferSize, this);
     160            this._resource.removeEventListener(WebInspector.Resource.Event.InitiatedResourcesDidChange, this._refreshRelatedResourcesSection, this);
    160161        }
    161162
     
    171172            this._resource.addEventListener(WebInspector.Resource.Event.SizeDidChange, this._refreshDecodedSize, this);
    172173            this._resource.addEventListener(WebInspector.Resource.Event.TransferSizeDidChange, this._refreshTransferSize, this);
     174            this._resource.addEventListener(WebInspector.Resource.Event.InitiatedResourcesDidChange, this._refreshRelatedResourcesSection, this);
    173175        }
    174176
     
    190192        this._refreshImageSizeSection();
    191193        this._refreshRequestDataSection();
     194        this._refreshRelatedResourcesSection();
    192195    }
    193196
     
    216219        }
    217220
    218         let initiatorLocation = this._resource.initiatorSourceCodeLocation;
    219         this._initiatorRow.value = initiatorLocation ? WebInspector.createSourceCodeLocationLink(initiatorLocation, true) : null;
    220 
    221         let initiatedResources = this._resource.initiatedResources;
    222         if (initiatedResources.length) {
    223             let resourceLinkContainer = document.createElement("div");
    224             for (let resource of initiatedResources)
    225                 resourceLinkContainer.appendChild(WebInspector.createResourceLink(resource));
    226 
    227             this._initiatedRow.value = resourceLinkContainer;
    228         } else
    229             this._initiatedRow.value = null;
    230 
    231221        if (urlComponents.queryString) {
    232222            // Ensure the "Query Parameters" section is displayed, right after the "Request & Response" section.
     
    242232    }
    243233
     234    _refreshRelatedResourcesSection()
     235    {
     236        // Hide the section if we don't have anything to show.
     237        let groups = this._locationSection.groups;
     238        let isSectionVisible = groups.includes(this._relatedResourcesGroup);
     239        if (!this._resource.initiatorSourceCodeLocation && !this._resource.initiatedResources.length) {
     240            if (isSectionVisible) {
     241                groups.remove(this._relatedResourcesGroup);
     242                this._locationSection.groups = groups;
     243            }
     244            return;
     245        }
     246
     247        if (!isSectionVisible) {
     248            groups.push(this._relatedResourcesGroup);
     249            this._locationSection.groups = groups;
     250        }
     251
     252        let initiatorLocation = this._resource.initiatorSourceCodeLocation;
     253        this._initiatorRow.value = initiatorLocation ? WebInspector.createSourceCodeLocationLink(initiatorLocation, true) : null;
     254
     255        let initiatedResources = this._resource.initiatedResources;
     256        if (initiatedResources.length) {
     257            let resourceLinkContainer = document.createElement("div");
     258            for (let resource of initiatedResources)
     259                resourceLinkContainer.appendChild(WebInspector.createResourceLink(resource));
     260
     261            this._initiatedRow.value = resourceLinkContainer;
     262        } else
     263            this._initiatedRow.value = null;
     264    }
     265
    244266    _refreshResourceType()
    245267    {
Note: See TracChangeset for help on using the changeset viewer.