Web Inspector: Sources: clicking on a breakpoint changes the path components to not...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Oct 2019 20:41:32 +0000 (20:41 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Oct 2019 20:41:32 +0000 (20:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196450
<rdar://problem/49488100>

Reviewed by Matt Baker.

When selecting any tree element that isn't in the resources tree outline, attempt to find
the corresponding tree element in the resources tree outline and silently select that as
well so that the hierarchical path component shows the right breadcrumb trail.

If the tree element is for a `WI.Script` which has a corresponding `WI.Resource`, use the
`WI.Resource` instead.

* UserInterface/Views/SourcesNavigationSidebarPanel.js:
(WI.SourcesNavigationSidebarPanel.prototype._handleTreeSelectionDidChange):

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/SourcesNavigationSidebarPanel.js

index e004277..d592a32 100644 (file)
@@ -1,3 +1,21 @@
+2019-10-01  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Sources: clicking on a breakpoint changes the path components to not match the script's path
+        https://bugs.webkit.org/show_bug.cgi?id=196450
+        <rdar://problem/49488100>
+
+        Reviewed by Matt Baker.
+
+        When selecting any tree element that isn't in the resources tree outline, attempt to find
+        the corresponding tree element in the resources tree outline and silently select that as
+        well so that the hierarchical path component shows the right breadcrumb trail.
+
+        If the tree element is for a `WI.Script` which has a corresponding `WI.Resource`, use the
+        `WI.Resource` instead.
+
+        * UserInterface/Views/SourcesNavigationSidebarPanel.js:
+        (WI.SourcesNavigationSidebarPanel.prototype._handleTreeSelectionDidChange):
+
 2019-09-30  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: JS Formatter: unexpected newlines added inside template string expression
index fd22bed..702508d 100644 (file)
@@ -1681,12 +1681,32 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
             return;
         }
 
+        // Silently select the corresponding tree element in the resources tree outline to update
+        // the hierarchical path components to show the right ancestor(s).
+        let selectTreeElementInResourcesTreeOutline = (sourceCode) => {
+            let resourceTreeElement = this._resourcesTreeOutline.findTreeElement(sourceCode);
+            if (!resourceTreeElement)
+                return;
+
+            const omitFocus = true;
+            const selectedByUser = false;
+            const suppressNotification = true;
+            resourceTreeElement.select(omitFocus, selectedByUser, suppressNotification);
+        };
+
         if (treeElement instanceof WI.FolderTreeElement
             || treeElement instanceof WI.OriginTreeElement
             || treeElement instanceof WI.ResourceTreeElement
             || treeElement instanceof WI.ScriptTreeElement
             || treeElement instanceof WI.CSSStyleSheetTreeElement) {
             let representedObject = treeElement.representedObject;
+
+            if (representedObject instanceof WI.Script && representedObject.resource)
+                representedObject = representedObject.resource;
+
+            if (treeElement.treeOutline !== this._resourcesTreeOutline)
+                selectTreeElementInResourcesTreeOutline(representedObject);
+
             if (representedObject instanceof WI.Collection || representedObject instanceof WI.SourceCode || representedObject instanceof WI.Frame)
                 WI.showRepresentedObject(representedObject);
             return;
@@ -1711,18 +1731,13 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
             if (WI.debuggerManager.isBreakpointSpecial(breakpoint))
                 return;
 
-            if (treeElement.treeOutline === this._pauseReasonTreeOutline) {
-                WI.showSourceCodeLocation(breakpoint.sourceCodeLocation);
-                return;
-            }
+            let sourceCode = breakpoint.sourceCodeLocation.displaySourceCode;
+            if (sourceCode instanceof WI.Script && sourceCode.resource)
+                sourceCode = sourceCode.resource;
+            selectTreeElementInResourcesTreeOutline(sourceCode);
 
-            if (treeElement.parent.representedObject) {
-                console.assert(treeElement.parent.representedObject instanceof WI.SourceCode);
-                if (treeElement.parent.representedObject instanceof WI.SourceCode) {
-                    WI.showSourceCodeLocation(breakpoint.sourceCodeLocation);
-                    return;
-                }
-            }
+            WI.showSourceCodeLocation(breakpoint.sourceCodeLocation);
+            return;
         }
 
         console.error("Unknown tree element", treeElement);