Changeset 243614 in webkit


Ignore:
Timestamp:
Mar 28, 2019 11:47:05 AM (5 years ago)
Author:
Joseph Pecoraro
Message:

Web Inspector: Show Resource Initiator in Network Tab detail views
https://bugs.webkit.org/show_bug.cgi?id=196316
<rdar://problem/49352679>

Reviewed by Devin Rousso.

  • UserInterface/Controllers/NetworkManager.js:

(WI.NetworkManager.prototype.resourceRequestWillBeSent):
(WI.NetworkManager.prototype.resourceRequestWasServedFromMemoryCache):
(WI.NetworkManager.prototype._initiatorCallFramesFromPayload):
Initialize call frames from the initiator payload.

  • UserInterface/Models/Resource.js:

(WI.Resource.prototype.get initiatorCallFrames):
Initialization and accessor.

  • UserInterface/Views/CallFrameTreeElement.js:

(WI.CallFrameTreeElement):
Selecting a native element won't do anything so just don't allow selection.

  • UserInterface/Views/ResourceHeadersContentView.css:

(.resource-headers .go-to-link):
(.resource-headers .call-stack):
(.resource-headers .call-stack:hover):
(@media (prefers-color-scheme: dark)):

  • UserInterface/Views/ResourceHeadersContentView.js:

(WI.ResourceHeadersContentView):
(WI.ResourceHeadersContentView.prototype.hidden):
(WI.ResourceHeadersContentView.prototype._refreshSummarySection):
Add an "Initiator" line in the summary with a way to view the whole
initiator backtrace if one exists.

Location:
trunk/Source/WebInspectorUI
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r243507 r243614  
     12019-03-28  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Show Resource Initiator in Network Tab detail views
     4        https://bugs.webkit.org/show_bug.cgi?id=196316
     5        <rdar://problem/49352679>
     6
     7        Reviewed by Devin Rousso.
     8
     9        * UserInterface/Controllers/NetworkManager.js:
     10        (WI.NetworkManager.prototype.resourceRequestWillBeSent):
     11        (WI.NetworkManager.prototype.resourceRequestWasServedFromMemoryCache):
     12        (WI.NetworkManager.prototype._initiatorCallFramesFromPayload):
     13        Initialize call frames from the initiator payload.
     14
     15        * UserInterface/Models/Resource.js:
     16        (WI.Resource.prototype.get initiatorCallFrames):
     17        Initialization and accessor.
     18
     19        * UserInterface/Views/CallFrameTreeElement.js:
     20        (WI.CallFrameTreeElement):
     21        Selecting a native element won't do anything so just don't allow selection.
     22
     23        * UserInterface/Views/ResourceHeadersContentView.css:
     24        (.resource-headers .go-to-link):
     25        (.resource-headers .call-stack):
     26        (.resource-headers .call-stack:hover):
     27        (@media (prefers-color-scheme: dark)):
     28        * UserInterface/Views/ResourceHeadersContentView.js:
     29        (WI.ResourceHeadersContentView):
     30        (WI.ResourceHeadersContentView.prototype.hidden):
     31        (WI.ResourceHeadersContentView.prototype._refreshSummarySection):
     32        Add an "Initiator" line in the summary with a way to view the whole
     33        initiator backtrace if one exists.
     34
    1352019-03-26  Devin Rousso  <drousso@apple.com>
    236
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/NetworkManager.js

    r242948 r243614  
    307307            requestSentTimestamp: elapsedTime,
    308308            requestSentWalltime: walltime,
     309            initiatorCallFrames: this._initiatorCallFramesFromPayload(initiator),
    309310            initiatorSourceCodeLocation: this._initiatorSourceCodeLocationFromPayload(initiator),
    310311            initiatorNode: this._initiatorNodeFromPayload(initiator),
     
    451452            requestMethod: "GET",
    452453            requestSentTimestamp: elapsedTime,
     454            initiatorCallFrames: this._initiatorCallFramesFromPayload(initiator),
    453455            initiatorSourceCodeLocation: this._initiatorSourceCodeLocationFromPayload(initiator),
    454456            initiatorNode: this._initiatorNodeFromPayload(initiator),
     
    763765    }
    764766
     767    _initiatorCallFramesFromPayload(initiatorPayload)
     768    {
     769        if (!initiatorPayload)
     770            return null;
     771
     772        let callFrames = initiatorPayload.stackTrace;
     773        if (!callFrames)
     774            return null;
     775       
     776        return callFrames.map((payload) => WI.CallFrame.fromPayload(WI.assumingMainTarget(), payload));
     777    }
     778
    765779    _initiatorSourceCodeLocationFromPayload(initiatorPayload)
    766780    {
  • trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js

    r243452 r243614  
    2727WI.Resource = class Resource extends WI.SourceCode
    2828{
    29     constructor(url, {mimeType, type, loaderIdentifier, targetId, requestIdentifier, requestMethod, requestHeaders, requestData, requestSentTimestamp, requestSentWalltime, initiatorSourceCodeLocation, initiatorNode, originalRequestWillBeSentTimestamp} = {})
     29    constructor(url, {mimeType, type, loaderIdentifier, targetId, requestIdentifier, requestMethod, requestHeaders, requestData, requestSentTimestamp, requestSentWalltime, initiatorCallFrames, initiatorSourceCodeLocation, initiatorNode, originalRequestWillBeSentTimestamp} = {})
    3030    {
    3131        super();
     
    5353        this._serverTimingEntries = null;
    5454        this._parentFrame = null;
     55        this._initiatorCallFrames = initiatorCallFrames || null;
    5556        this._initiatorSourceCodeLocation = initiatorSourceCodeLocation || null;
    5657        this._initiatorNode = initiatorNode || null;
     
    302303    get requestMethod() { return this._requestMethod; }
    303304    get requestData() { return this._requestData; }
     305    get initiatorCallFrames() { return this._initiatorCallFrames; }
    304306    get initiatorSourceCodeLocation() { return this._initiatorSourceCodeLocation; }
    305307    get initiatorNode() { return this._initiatorNode; }
  • trunk/Source/WebInspectorUI/UserInterface/Views/CallFrameTreeElement.js

    r224433 r243614  
    4545        if (this._callFrame.nativeCode || !this._callFrame.sourceCodeLocation) {
    4646            this.subtitle = "";
     47            this.selectable = false;
    4748            return;
    4849        }
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.css

    r238122 r243614  
    4848    color: var(--network-pseudo-header-color);
    4949}
     50
     51.resource-headers .go-to-link {
     52    -webkit-user-select: text;
     53}
     54
     55.resource-headers .pair.initiator > .value {
     56    display: inline-flex;
     57    align-items: center;
     58}
     59
     60.resource-headers .call-stack {
     61    position: relative;
     62    width: 16px;
     63    height: 13px;
     64    margin-left: 3px;
     65    content: url(../Images/CallStack.svg);
     66    opacity: 0.5;
     67    -webkit-user-select: none;
     68}
     69
     70.resource-headers .call-stack:hover {
     71    opacity: 0.8;
     72}
     73
     74@media (prefers-color-scheme: dark) {
     75    .resource-headers .call-stack {
     76        filter: invert();
     77    }
     78}
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceHeadersContentView.js

    r242018 r243614  
    4646        this._automaticallyRevealFirstSearchResult = false;
    4747        this._bouncyHighlightElement = null;
     48        this._popover = null;
     49        this._popoverCallStackIconElement = null;
    4850
    4951        this._redirectDetailsSections = [];
     
    119121            this._needsResponseHeadersRefresh = false;
    120122        }
     123    }
     124
     125    hidden()
     126    {
     127        super.hidden();
     128
     129        if (this._popover)
     130            this._popover.dismiss();
    121131    }
    122132
     
    252262        if (this._resource.remoteAddress)
    253263            this._summarySection.appendKeyValuePair(WI.UIString("Address"), this._resource.remoteAddress);
     264
     265        let initiatorLocation = this._resource.initiatorSourceCodeLocation;
     266        if (initiatorLocation) {
     267
     268            let fragment = document.createDocumentFragment();
     269
     270            const options = {
     271                dontFloat: true,
     272                ignoreSearchTab: true,
     273            };
     274            let link = WI.createSourceCodeLocationLink(initiatorLocation, options);
     275            fragment.appendChild(link);
     276
     277            let callFrames = this._resource.initiatorCallFrames;
     278            if (callFrames) {
     279                this._popoverCallStackIconElement = document.createElement("img");
     280                this._popoverCallStackIconElement.className = "call-stack";
     281                fragment.appendChild(this._popoverCallStackIconElement);
     282
     283                this._popoverCallStackIconElement.addEventListener("click", (event) => {
     284                    if (!this._popover) {
     285                        this._popover = new WI.Popover(this);
     286                        this._popover.windowResizeHandler = () => { this._presentPopoverBelowCallStackElement() };
     287                    }
     288
     289                    const selectable = false;
     290                    let callFramesTreeOutline = new WI.TreeOutline(selectable);
     291                    callFramesTreeOutline.disclosureButtons = false;
     292                    let callFrameTreeController = new WI.CallFrameTreeController(callFramesTreeOutline);
     293                    callFrameTreeController.callFrames = callFrames;
     294
     295                    let popoverContent = document.createElement("div");
     296                    popoverContent.appendChild(callFrameTreeController.treeOutline.element);
     297                    this._popover.content = popoverContent;
     298
     299                    this._presentPopoverBelowCallStackElement();
     300                });
     301            }
     302
     303            let pair = this._summarySection.appendKeyValuePair(WI.UIString("Initiator"), fragment);
     304            pair.classList.add("initiator");
     305
     306            if (this._popover && this._popover.visible)
     307                this._presentPopoverBelowCallStackElement();
     308        }
    254309    }
    255310
     
    469524    }
    470525
     526    _presentPopoverBelowCallStackElement()
     527    {
     528        let bounds = WI.Rect.rectFromClientRect(this._popoverCallStackIconElement.getBoundingClientRect());
     529        this._popover.present(bounds.pad(2), [WI.RectEdge.MAX_Y, WI.RectEdge.MIN_Y, WI.RectEdge.MAX_X]);
     530    }
     531
    471532    _resourceMetricsDidChange(event)
    472533    {
Note: See TracChangeset for help on using the changeset viewer.