Web Inspector: Selecting a DOM Search Result in Search Tab unexpectedly changes Tabs
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Nov 2017 18:56:38 +0000 (18:56 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Nov 2017 18:56:38 +0000 (18:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179223
<rdar://problem/33949556>

Reviewed by Devin Rousso.

* Localizations/en.lproj/localizedStrings.js:
New string.

* UserInterface/Views/SearchResultTreeElement.js:
(WI.SearchResultTreeElement.prototype.populateContextMenu):
Add a context menu for search results to jump to a different tab.
These behaviors match the double click behavior for search results.

* UserInterface/Views/SearchTabContentView.js:
(WI.SearchTabContentView.prototype.canShowRepresentedObject):
Always support showing a DOM Tree. Clients should be using
ignoreSearchTab if they don't want to jump here.

* UserInterface/Views/DOMTreeDataGridNode.js:
(WI.DOMTreeDataGridNode.prototype._goToArrowWasClicked):
* UserInterface/Views/LayerTreeDataGridNode.js:
(WI.LayerTreeDataGridNode.prototype._goToArrowWasClicked):
Use ignoreSearchTab just in case when showing a DOM Tree.

* UserInterface/Views/ContentBrowser.js:
(WI.ContentBrowser.prototype.shown):
When showing, update our UI to reflect the values of the current content view, which
for a while may have been owned by another ContentBrowser.

(WI.ContentBrowser.prototype._contentViewSelectionPathComponentDidChange):
(WI.ContentBrowser.prototype._contentViewSupplementalRepresentedObjectsDidChange):
(WI.ContentBrowser.prototype._contentViewNavigationItemsDidChange):
We can avoid work in a few places where we might not be the owning ContentBrowser
of a ContentView that is changing.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224499 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/ContentBrowser.js
Source/WebInspectorUI/UserInterface/Views/DOMTreeDataGridNode.js
Source/WebInspectorUI/UserInterface/Views/LayerTreeDataGridNode.js
Source/WebInspectorUI/UserInterface/Views/SearchResultTreeElement.js
Source/WebInspectorUI/UserInterface/Views/SearchTabContentView.js

index a1831a0..0966bb1 100644 (file)
@@ -1,3 +1,41 @@
+2017-11-06  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Selecting a DOM Search Result in Search Tab unexpectedly changes Tabs
+        https://bugs.webkit.org/show_bug.cgi?id=179223
+        <rdar://problem/33949556>
+
+        Reviewed by Devin Rousso.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        New string.
+
+        * UserInterface/Views/SearchResultTreeElement.js:
+        (WI.SearchResultTreeElement.prototype.populateContextMenu):
+        Add a context menu for search results to jump to a different tab.
+        These behaviors match the double click behavior for search results.
+
+        * UserInterface/Views/SearchTabContentView.js:
+        (WI.SearchTabContentView.prototype.canShowRepresentedObject):
+        Always support showing a DOM Tree. Clients should be using
+        ignoreSearchTab if they don't want to jump here.
+
+        * UserInterface/Views/DOMTreeDataGridNode.js:
+        (WI.DOMTreeDataGridNode.prototype._goToArrowWasClicked):
+        * UserInterface/Views/LayerTreeDataGridNode.js:
+        (WI.LayerTreeDataGridNode.prototype._goToArrowWasClicked):
+        Use ignoreSearchTab just in case when showing a DOM Tree.
+
+        * UserInterface/Views/ContentBrowser.js:
+        (WI.ContentBrowser.prototype.shown):
+        When showing, update our UI to reflect the values of the current content view, which
+        for a while may have been owned by another ContentBrowser.
+
+        (WI.ContentBrowser.prototype._contentViewSelectionPathComponentDidChange):
+        (WI.ContentBrowser.prototype._contentViewSupplementalRepresentedObjectsDidChange):
+        (WI.ContentBrowser.prototype._contentViewNavigationItemsDidChange):
+        We can avoid work in a few places where we might not be the owning ContentBrowser
+        of a ContentView that is changing.
+
 2017-11-05  Nikita Vasilyev  <nvasilyev@apple.com>
 
         REGRESSION (r221338): Web Inspector: NavigationBar incorrectly calculates minimumWidth
index f5d997e..2cabc37 100644 (file)
@@ -778,6 +778,7 @@ localizedStrings["Return type for function: %s"] = "Return type for function: %s
 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 Original Resource"] = "Reveal in Original Resource";
 localizedStrings["Reveal in Resources Tab"] = "Reveal in Resources Tab";
 localizedStrings["Right"] = "Right";
index 61d6a23..8b88277 100644 (file)
@@ -1782,7 +1782,7 @@ WI._domNodeWasInspected = function(event)
     InspectorFrontendHost.bringToFront();
 
     this.showElementsTab();
-    this.showMainFrameDOMTree(event.data.node);
+    this.showMainFrameDOMTree(event.data.node, {ignoreSearchTab: true});
 };
 
 WI._inspectModeStateChanged = function(event)
index cc4ab97..ee4a56b 100644 (file)
@@ -231,6 +231,9 @@ WI.ContentBrowser = class ContentBrowser extends WI.View
 
     shown()
     {
+        this._updateContentViewSelectionPathNavigationItem(this.currentContentView);
+        this.updateHierarchicalPathForCurrentContentView()
+
         this._contentViewContainer.shown();
     }
 
@@ -487,6 +490,10 @@ WI.ContentBrowser = class ContentBrowser extends WI.View
         if (event.target !== this.currentContentView)
             return;
 
+        // If the ContentView is a tombstone within our ContentViewContainer, do nothing. Let the owning ContentBrowser react.
+        if (event.target.parentContainer !== this._contentViewContainer)
+            return;
+
         this._updateContentViewSelectionPathNavigationItem(event.target);
         this._updateBackForwardButtons();
 
@@ -502,6 +509,10 @@ WI.ContentBrowser = class ContentBrowser extends WI.View
         if (event.target !== this.currentContentView)
             return;
 
+        // If the ContentView is a tombstone within our ContentViewContainer, do nothing. Let the owning ContentBrowser react.
+        if (event.target.parentContainer !== this._contentViewContainer)
+            return;
+
         this.soon._dispatchCurrentRepresentedObjectsDidChangeEvent();
     }
 
@@ -528,6 +539,10 @@ WI.ContentBrowser = class ContentBrowser extends WI.View
         if (event.target !== this.currentContentView)
             return;
 
+        // If the ContentView is a tombstone within our ContentViewContainer, do nothing. Let the owning ContentBrowser react.
+        if (event.target.parentContainer !== this._contentViewContainer)
+            return;
+
         const forceUpdate = true;
         this._updateContentViewNavigationItems(forceUpdate);
         this._navigationBar.needsLayout();
index c0dbbab..635dbda 100644 (file)
@@ -64,6 +64,6 @@ WI.DOMTreeDataGridNode = class DOMTreeDataGridNode extends WI.DataGridNode
 
     _goToArrowWasClicked()
     {
-        WI.showMainFrameDOMTree(this._domNode);
+        WI.showMainFrameDOMTree(this._domNode, {ignoreSearchTab: true});
     }
 };
index 81e1f21..08af99a 100644 (file)
@@ -160,6 +160,6 @@ WI.LayerTreeDataGridNode = class LayerTreeDataGridNode extends WI.DataGridNode
     _goToArrowWasClicked()
     {
         var domNode = WI.domTreeManager.nodeForId(this._layer.nodeId);
-        WI.showMainFrameDOMTree(domNode);
+        WI.showMainFrameDOMTree(domNode, {ignoreSearchTab: true});
     }
 };
index 841b26f..414145a 100644 (file)
@@ -89,4 +89,26 @@ WI.SearchResultTreeElement = class SearchResultTreeElement extends WI.GeneralTre
     {
         return this.representedObject.sourceCodeTextRange.synthesizedTextValue + ":" + this.representedObject.title;
     }
+
+    // Protected
+
+    populateContextMenu(contextMenu, event)
+    {
+        if (this.representedObject instanceof WI.DOMSearchMatchObject) {
+            contextMenu.appendItem(WI.UIString("Reveal in Elements Tab"), () => {
+                WI.showMainFrameDOMTree(this.representedObject.domNode, {
+                    ignoreSearchTab: true,
+                });
+            });
+        } else if (this.representedObject instanceof WI.SourceCodeSearchMatchObject) {
+            contextMenu.appendItem(WI.UIString("Reveal in Resources Tab"), () => {
+                WI.showOriginalOrFormattedSourceCodeTextRange(this.representedObject.sourceCodeTextRange, {
+                    ignoreNetworkTab: true,
+                    ignoreSearchTab: true,
+                });
+            });
+        }
+
+        super.populateContextMenu(contextMenu, event);
+    }
 };
index 4d046e8..2fd32f0 100644 (file)
@@ -70,7 +70,10 @@ WI.SearchTabContentView = class SearchTabContentView extends WI.ContentBrowserTa
 
     canShowRepresentedObject(representedObject)
     {
-        if (!(representedObject instanceof WI.Resource) && !(representedObject instanceof WI.Script) && !(representedObject instanceof WI.DOMTree))
+        if (representedObject instanceof WI.DOMTree)
+            return true;
+
+        if (!(representedObject instanceof WI.Resource) && !(representedObject instanceof WI.Script))
             return false;
 
         return !!this.navigationSidebarPanel.contentTreeOutline.getCachedTreeElement(representedObject);