Web Inspector: Debugger: breakpoints don't populate in inspector2 on first load
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2019 21:50:02 +0000 (21:50 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 1 Apr 2019 21:50:02 +0000 (21:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196063
<rdar://problem/49097787>

Reviewed by Joseph Pecoraro.

In the case that a breakpoint becomes resolved after the resource has finished loaded, there
won't be an already existing `TreeElement` for the breakpoint to replace.

This can realistically only happen if the IndexedDB lookup is super slow, or the resource is
extremely fast (e.g. a `data` url).

* UserInterface/Views/DebuggerSidebarPanel.js:
(WI.DebuggerSidebarPanel.prototype._handleDebuggerObjectDisplayLocationDidChange):
(WI.DebuggerSidebarPanel.prototype._addDebuggerObject): Deleted.

* UserInterface/Views/SourcesNavigationSidebarPanel.js:
(WI.SourcesNavigationSidebarPanel.prototype._addBreakpoint):
(WI.SourcesNavigationSidebarPanel.prototype._addBreakpointsForSourceCode):
(WI.SourcesNavigationSidebarPanel.prototype._handleDebuggerObjectDisplayLocationDidChange):

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

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

index 29deaaf..56c6ef8 100644 (file)
@@ -1,3 +1,26 @@
+2019-04-01  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: Debugger: breakpoints don't populate in inspector2 on first load
+        https://bugs.webkit.org/show_bug.cgi?id=196063
+        <rdar://problem/49097787>
+
+        Reviewed by Joseph Pecoraro.
+
+        In the case that a breakpoint becomes resolved after the resource has finished loaded, there
+        won't be an already existing `TreeElement` for the breakpoint to replace.
+
+        This can realistically only happen if the IndexedDB lookup is super slow, or the resource is
+        extremely fast (e.g. a `data` url).
+
+        * UserInterface/Views/DebuggerSidebarPanel.js:
+        (WI.DebuggerSidebarPanel.prototype._handleDebuggerObjectDisplayLocationDidChange):
+        (WI.DebuggerSidebarPanel.prototype._addDebuggerObject): Deleted.
+
+        * UserInterface/Views/SourcesNavigationSidebarPanel.js:
+        (WI.SourcesNavigationSidebarPanel.prototype._addBreakpoint):
+        (WI.SourcesNavigationSidebarPanel.prototype._addBreakpointsForSourceCode):
+        (WI.SourcesNavigationSidebarPanel.prototype._handleDebuggerObjectDisplayLocationDidChange):
+
 2019-04-01  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: CPU Usage Timeline - Adjust Energy Impact Threshholds
index dfb59de..fc82144 100644 (file)
@@ -822,19 +822,26 @@ WI.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WI.NavigationSideba
         if (event.data.oldDisplaySourceCode === debuggerObject.sourceCodeLocation.displaySourceCode)
             return;
 
-        var debuggerTreeElement = this._breakpointsContentTreeOutline.getCachedTreeElement(debuggerObject);
-        if (!debuggerTreeElement)
-            return;
+        // A known debugger object (breakpoint, issueMessage, etc.) moved between resources. Remove
+        // the old tree element and create a new tree element with the updated file.
 
-        // A known debugger object (breakpoint, issueMessage, etc.) moved between resources, remove the old tree element
-        // and create a new tree element with the updated file.
+        let wasSelected = false;
+        let oldDebuggerTreeElement = this._breakpointsContentTreeOutline.getCachedTreeElement(debuggerObject);
+        if (oldDebuggerTreeElement)
+            wasSelected = oldDebuggerTreeElement.selected;
 
-        var wasSelected = debuggerTreeElement.selected;
+        let newDebuggerTreeElement = null;
+        if (debuggerObject instanceof WI.Breakpoint)
+            newDebuggerTreeElement = this._addBreakpoint(debuggerObject);
+        else if (debuggerObject instanceof WI.IssueMessage)
+            newDebuggerTreeElement = this._addIssue(debuggerObject);
+        if (!newDebuggerTreeElement)
+            return;
 
-        this._removeDebuggerTreeElement(debuggerTreeElement);
-        var newDebuggerTreeElement = this._addDebuggerObject(debuggerObject);
+        if (oldDebuggerTreeElement)
+            this._removeDebuggerTreeElement(oldDebuggerTreeElement);
 
-        if (newDebuggerTreeElement && wasSelected)
+        if (wasSelected)
             newDebuggerTreeElement.revealAndSelect(true, false, true);
     }
 
@@ -1369,17 +1376,6 @@ WI.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WI.NavigationSideba
         this._pauseReasonLinkContainerElement.appendChild(linkElement);
     }
 
-    _addDebuggerObject(debuggerObject)
-    {
-        if (debuggerObject instanceof WI.Breakpoint)
-            return this._addBreakpoint(debuggerObject);
-
-        if (debuggerObject instanceof WI.IssueMessage)
-            return this._addIssue(debuggerObject);
-
-        return null;
-    }
-
     _addIssue(issueMessage)
     {
         let issueTreeElement = this._scriptsContentTreeOutline.findTreeElement(issueMessage);
index 42f091a..568a3cd 100644 (file)
@@ -863,6 +863,9 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
 
     _addBreakpoint(breakpoint)
     {
+        if (this._breakpointsTreeOutline.findTreeElement(breakpoint))
+            return null;
+
         let constructor = WI.BreakpointTreeElement;
         let options = {};
         let parentTreeElement = this._breakpointsTreeOutline;
@@ -875,7 +878,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
             let domNodeTreeElement = this._breakpointsTreeOutline.findTreeElement(domNode);
             if (!domNodeTreeElement) {
                 domNodeTreeElement = new WI.DOMNodeTreeElement(domNode);
-                this._insertDebuggerTreeElement(domNodeTreeElement, parentTreeElement);
+                this._insertDebuggerTreeElement(domNodeTreeElement, this._breakpointsTreeOutline);
             }
             return domNodeTreeElement;
         };
@@ -910,7 +913,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
                     if (!eventTargetTreeElement) {
                         const subtitle = null;
                         eventTargetTreeElement = new WI.GeneralTreeElement(["event-target-window"], WI.unlocalizedString("window"), subtitle, SourcesNavigationSidebarPanel.__windowEventTargetRepresentedObject);
-                        this._insertDebuggerTreeElement(eventTargetTreeElement, parentTreeElement);
+                        this._insertDebuggerTreeElement(eventTargetTreeElement, this._breakpointsTreeOutline);
                     }
                 } else if (breakpoint.eventListener.node)
                     eventTargetTreeElement = getDOMNodeTreeElement(breakpoint.eventListener.node);
@@ -929,9 +932,6 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
             if (!sourceCode)
                 return null;
 
-            if (this._breakpointsTreeOutline.findTreeElement(breakpoint))
-                return null;
-
             parentTreeElement = this._addDebuggerTreeElementForSourceCode(sourceCode);
 
             // Mark disabled breakpoints as resolved if there is source code loaded with that URL.
@@ -1032,7 +1032,7 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
     _addBreakpointsForSourceCode(sourceCode)
     {
         for (let breakpoint of WI.debuggerManager.breakpointsForSourceCode(sourceCode))
-            this._addBreakpoint(breakpoint, sourceCode);
+            this._addBreakpoint(breakpoint);
     }
 
     _addIssuesForSourceCode(sourceCode)
@@ -1761,22 +1761,25 @@ WI.SourcesNavigationSidebarPanel = class SourcesNavigationSidebarPanel extends W
         let newDebuggerTreeElement = null;
         if (debuggerObject instanceof WI.Breakpoint) {
             oldDebuggerTreeElement = this._breakpointsTreeOutline.findTreeElement(debuggerObject);
-            if (oldDebuggerTreeElement) {
-                newDebuggerTreeElement = this._addBreakpoint(debuggerObject);
+            if (oldDebuggerTreeElement)
                 wasSelected = oldDebuggerTreeElement.selected;
-            }
+
+            newDebuggerTreeElement = this._addBreakpoint(debuggerObject);
         } else if (debuggerObject instanceof WI.IssueMessage) {
             oldDebuggerTreeElement = this._resourcesTreeOutline.findTreeElement(debuggerObject);
-            if (oldDebuggerTreeElement) {
-                newDebuggerTreeElement = this._addIssue(debuggerObject);
+            if (oldDebuggerTreeElement)
                 wasSelected = oldDebuggerTreeElement.selected;
-            }
+
+            newDebuggerTreeElement = this._addIssue(debuggerObject);
         }
 
+        if (!newDebuggerTreeElement)
+            return;
+
         if (oldDebuggerTreeElement)
             this._removeDebuggerTreeElement(oldDebuggerTreeElement);
 
-        if (newDebuggerTreeElement && wasSelected)
+        if (wasSelected)
             newDebuggerTreeElement.revealAndSelect(true, false, true);
     }