Web Inspector: no way to navigate from Resource tree element to its entry in Network Tab
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Nov 2017 21:08:01 +0000 (21:08 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Nov 2017 21:08:01 +0000 (21:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179328
<rdar://problem/35367294>

Reviewed by Brian Burg.

* Localizations/en.lproj/localizedStrings.js:
New reveal in network tab string.

* UserInterface/Base/Main.js:
(WI.isShowingNetworkTab):
Utility to know if the network tab is showing.

* UserInterface/Views/ContextMenuUtilities.js:
(WI.appendContextMenuItemsForSourceCode):
(showResourceWithOptions):
(WI.appendContextMenuItemsForURL):
Generalize context menus for just a URL.

* UserInterface/Views/TabBrowser.js:
(WI.TabBrowser.prototype.bestTabContentViewForRepresentedObject):
Support more tab ignore options, this is starting to get icky. We may want to
move to just a preferredTab approach, since that is what some of these want.

* UserInterface/Views/DOMTreeElement.js:
(WI.DOMTreeElement.prototype._populateTagContextMenu):
Make use of new ContextMenu utility to add menu items for a URL.

* UserInterface/Views/NetworkTabContentView.js:
(WI.NetworkTabContentView.prototype.showRepresentedObject):
* UserInterface/Views/NetworkTableContentView.js:
(WI.NetworkTableContentView.prototype.showRepresentedObject):
Handle showing a Resource in the NetworkTab. We immediately show
the details view for it, otherwise we fallback to the list view.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224508 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Views/ContextMenuUtilities.js
Source/WebInspectorUI/UserInterface/Views/DOMTreeElement.js
Source/WebInspectorUI/UserInterface/Views/NetworkTabContentView.js
Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js
Source/WebInspectorUI/UserInterface/Views/TabBrowser.js

index 6156dca..4c591cc 100644 (file)
@@ -1,5 +1,42 @@
 2017-11-06  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: no way to navigate from Resource tree element to its entry in Network Tab
+        https://bugs.webkit.org/show_bug.cgi?id=179328
+        <rdar://problem/35367294>
+
+        Reviewed by Brian Burg.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        New reveal in network tab string.
+
+        * UserInterface/Base/Main.js:
+        (WI.isShowingNetworkTab):
+        Utility to know if the network tab is showing.
+
+        * UserInterface/Views/ContextMenuUtilities.js:
+        (WI.appendContextMenuItemsForSourceCode):
+        (showResourceWithOptions):
+        (WI.appendContextMenuItemsForURL):
+        Generalize context menus for just a URL.
+
+        * UserInterface/Views/TabBrowser.js:
+        (WI.TabBrowser.prototype.bestTabContentViewForRepresentedObject):
+        Support more tab ignore options, this is starting to get icky. We may want to
+        move to just a preferredTab approach, since that is what some of these want.
+
+        * UserInterface/Views/DOMTreeElement.js:
+        (WI.DOMTreeElement.prototype._populateTagContextMenu):
+        Make use of new ContextMenu utility to add menu items for a URL.
+
+        * UserInterface/Views/NetworkTabContentView.js:
+        (WI.NetworkTabContentView.prototype.showRepresentedObject):
+        * UserInterface/Views/NetworkTableContentView.js:
+        (WI.NetworkTableContentView.prototype.showRepresentedObject):
+        Handle showing a Resource in the NetworkTab. We immediately show
+        the details view for it, otherwise we fallback to the list view.
+
+2017-11-06  Joseph Pecoraro  <pecoraro@apple.com>
+
         Uncaught Exception: TypeError: null is not an object (evaluating 'mimeType.endsWith')
         https://bugs.webkit.org/show_bug.cgi?id=179325
         <rdar://problem/35366896>
index 2cabc37..d1d7b87 100644 (file)
@@ -779,6 +779,7 @@ localizedStrings["Reveal Breakpoint"] = "Reveal Breakpoint";
 localizedStrings["Reveal in DOM Tree"] = "Reveal in DOM Tree";
 localizedStrings["Reveal in Debugger Tab"] = "Reveal in Debugger Tab";
 localizedStrings["Reveal in Elements Tab"] = "Reveal in Elements Tab";
+localizedStrings["Reveal in Network Tab"] = "Reveal in Network Tab";
 localizedStrings["Reveal in Original Resource"] = "Reveal in Original Resource";
 localizedStrings["Reveal in Resources Tab"] = "Reveal in Resources Tab";
 localizedStrings["Right"] = "Right";
index 8b88277..7114a85 100644 (file)
@@ -993,6 +993,11 @@ WI.showNetworkTab = function()
     this.tabBrowser.showTabForContentView(tabContentView);
 };
 
+WI.isShowingNetworkTab = function()
+{
+    return this.tabBrowser.selectedTabContentView instanceof WI.NetworkTabContentView;
+};
+
 WI.showTimelineTab = function()
 {
     var tabContentView = this.tabBrowser.bestTabContentViewForClass(WI.TimelineTabContentView);
index a089f5e..4650f5e 100644 (file)
@@ -42,26 +42,7 @@ WI.appendContextMenuItemsForSourceCode = function(contextMenu, sourceCodeOrLocat
 
     contextMenu.appendSeparator();
 
-    if (sourceCode.url) {
-        contextMenu.appendItem(WI.UIString("Open in New Tab"), () => {
-            const frame = null;
-            WI.openURL(sourceCode.url, frame, {alwaysOpenExternally: true});
-        });
-
-        if (WI.frameResourceManager.resourceForURL(sourceCode.url) && !WI.isShowingResourcesTab()) {
-            contextMenu.appendItem(WI.UIString("Reveal in Resources Tab"), () => {
-                const options = {ignoreNetworkTab: true};
-                if (location)
-                    WI.showSourceCodeLocation(location, options);
-                else
-                    WI.showSourceCode(sourceCode, options);
-            });
-        }
-
-        contextMenu.appendItem(WI.UIString("Copy Link Address"), () => {
-            InspectorFrontendHost.copyText(sourceCode.url);
-        });
-    }
+    WI.appendContextMenuItemsForURL(contextMenu, sourceCode.url, {sourceCode, location});
 
     if (sourceCode instanceof WI.Resource) {
         if (sourceCode.urlComponents.scheme !== "data") {
@@ -99,6 +80,44 @@ WI.appendContextMenuItemsForSourceCode = function(contextMenu, sourceCodeOrLocat
     }
 };
 
+WI.appendContextMenuItemsForURL = function(contextMenu, url, options)
+{
+    if (!url)
+        return;
+
+    let {sourceCode, location, frame} = options;
+    function showResourceWithOptions(options) {
+        if (location)
+            WI.showSourceCodeLocation(location, options);
+        else if (sourceCode)
+            WI.showSourceCode(sourceCode, options);
+        else
+            WI.openURL(url, frame, options);
+    }
+
+    contextMenu.appendItem(WI.UIString("Open in New Tab"), () => {
+        const frame = null;
+        WI.openURL(url, frame, {alwaysOpenExternally: true});
+    });
+
+    if (WI.frameResourceManager.resourceForURL(url)) {
+        if (!WI.isShowingResourcesTab()) {
+            contextMenu.appendItem(WI.UIString("Reveal in Resources Tab"), () => {
+                showResourceWithOptions({ignoreNetworkTab: true, ignoreSearchTab: true});
+            });
+        }
+        if (!WI.isShowingNetworkTab()) {
+            contextMenu.appendItem(WI.UIString("Reveal in Network Tab"), () => {
+                showResourceWithOptions({ignoreResourcesTab: true, ignoreDebuggerTab: true, ignoreSearchTab: true});
+            });
+        }
+    }
+
+    contextMenu.appendItem(WI.UIString("Copy Link Address"), () => {
+        InspectorFrontendHost.copyText(sourceCode.url);
+    });
+};
+
 WI.appendContextMenuItemsForDOMNode = function(contextMenu, domNode, options = {})
 {
     console.assert(contextMenu instanceof WI.ContextMenu);
index c16ed7d..ca79901 100644 (file)
@@ -739,27 +739,8 @@ WI.DOMTreeElement = class DOMTreeElement extends WI.TreeElement
 
         if (event.target && event.target.tagName === "A") {
             let url = event.target.href;
-
-            contextMenu.appendItem(WI.UIString("Open in New Tab"), () => {
-                const frame = null;
-                WI.openURL(url, frame, {alwaysOpenExternally: true});
-            });
-
-            if (WI.frameResourceManager.resourceForURL(url)) {
-                contextMenu.appendItem(WI.UIString("Reveal in Resources Tab"), () => {
-                    let frame = WI.frameResourceManager.frameForIdentifier(node.frameIdentifier);
-
-                    const options = {
-                        ignoreNetworkTab: true,
-                        ignoreSearchTab: true,
-                    };
-                    WI.openURL(url, frame, options);
-                });
-            }
-
-            contextMenu.appendItem(WI.UIString("Copy Link Address"), () => {
-                InspectorFrontendHost.copyText(url);
-            });
+            let frame = WI.frameResourceManager.frameForIdentifier(node.frameIdentifier);
+            WI.appendContextMenuItemsForURL(contextMenu, url, {frame});
         }
 
         contextMenu.appendSeparator();
index 524f80b..e3cf908 100644 (file)
@@ -98,6 +98,12 @@ WI.NetworkTabContentView = class NetworkTabContentView extends WI.TabContentView
         return representedObject instanceof WI.Resource;
     }
 
+    showRepresentedObject(representedObject, cookie)
+    {
+        console.assert(this._contentBrowser.currentContentView === this._networkTableContentView);
+        this._networkTableContentView.showRepresentedObject(representedObject, cookie);
+    }
+
     get supportsSplitContentBrowser()
     {
         return true;
index c546099..c973314 100644 (file)
@@ -256,6 +256,21 @@ WI.NetworkTableContentView = class NetworkTableContentView extends WI.ContentVie
         }
     }
 
+    showRepresentedObject(representedObject, cookie)
+    {
+        console.assert(representedObject instanceof WI.Resource);
+
+        let rowIndex = this._rowIndexForResource(representedObject);
+        if (rowIndex === -1) {
+            this._selectedResource = null;
+            this._table.clearSelectedRow();
+            this._hideResourceDetailView();
+            return;
+        }
+   
+        this._table.selectRow(rowIndex);
+    }
+
     // NetworkResourceDetailView delegate
 
     networkResourceDetailViewClose(resourceDetailView)
index 9d1c176..2e95fea 100644 (file)
@@ -129,6 +129,12 @@ WI.TabBrowser = class TabBrowser extends WI.View
             if (options.ignoreNetworkTab && tabContentView instanceof WI.NetworkTabContentView)
                 continue;
 
+            if (options.ignoreResourcesTab && tabContentView instanceof WI.ResourcesTabContentView)
+                continue;
+
+            if (options.ignoreDebuggerTab && tabContentView instanceof WI.DebuggerTabContentView)
+                continue;
+
             if (tabContentView.canShowRepresentedObject(representedObject))
                 return tabContentView;
         }