Web Inspector: Show async stack traces for workers
authormattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 22:32:33 +0000 (22:32 +0000)
committermattbaker@apple.com <mattbaker@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 1 Dec 2016 22:32:33 +0000 (22:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165235
<rdar://problem/29450172>

Reviewed by Joseph Pecoraro.

* UserInterface/Views/CallFrameTreeElement.css:
(.tree-outline > .children > .item.call-frame.async-boundary):
(.tree-outline:not(.single-thread) > .children > .item.call-frame.async-boundary):
(.tree-outline .item.call-frame.async-boundary::before):
(.tree-outline.single-thread .item.call-frame.async-boundary::before):
(.tree-outline .item.call-frame.async-boundary): Deleted.
Style changes for single/multiple-thread call stacks.
Padding changes to account for Thread tree element.
Make selectors more specific where needed.

* UserInterface/Views/DebuggerSidebarPanel.css:
(.sidebar > .panel.navigation.debugger .tree-outline.single-thread > .item.thread):
(.sidebar > .panel.navigation.debugger .tree-outline.single-thread):
Style changes for single/multiple-thread call stacks.

* UserInterface/Views/DebuggerSidebarPanel.js:
(WebInspector.DebuggerSidebarPanel):
Use a single tree outline for showing a single thread or multiple threads.
For single-threaded, hide Thread tree element and un-indent children.

(WebInspector.DebuggerSidebarPanel.prototype._targetAdded):
(WebInspector.DebuggerSidebarPanel.prototype._targetRemoved):
(WebInspector.DebuggerSidebarPanel.prototype._updateCallStackTreeOutline):
Update tree style and whether Thread tree element is selectable.
(WebInspector.DebuggerSidebarPanel.prototype._debuggerActiveCallFrameDidChange):
Remove support for second tree outline.

(WebInspector.DebuggerSidebarPanel.prototype._updateSingleThreadCallStacks): Deleted.
(WebInspector.DebuggerSidebarPanel.prototype._selectActiveCallFrameTreeElement): Deleted.
(WebInspector.DebuggerSidebarPanel.prototype._showSingleThreadCallStacks): Deleted.
(WebInspector.DebuggerSidebarPanel.prototype._showMultipleThreadCallStacks): Deleted.
No longer needed after unifying tree outlines.

* UserInterface/Views/ThreadTreeElement.js:
(WebInspector.ThreadTreeElement.prototype.refresh):
Append call frames from the async stack trace.

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

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/CallFrameTreeElement.css
Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.css
Source/WebInspectorUI/UserInterface/Views/DebuggerSidebarPanel.js
Source/WebInspectorUI/UserInterface/Views/ThreadTreeElement.js

index 3006775..58289b0 100644 (file)
@@ -1,3 +1,48 @@
+2016-12-01  Matt Baker  <mattbaker@apple.com>
+
+        Web Inspector: Show async stack traces for workers
+        https://bugs.webkit.org/show_bug.cgi?id=165235
+        <rdar://problem/29450172>
+
+        Reviewed by Joseph Pecoraro.
+
+        * UserInterface/Views/CallFrameTreeElement.css:
+        (.tree-outline > .children > .item.call-frame.async-boundary):
+        (.tree-outline:not(.single-thread) > .children > .item.call-frame.async-boundary):
+        (.tree-outline .item.call-frame.async-boundary::before):
+        (.tree-outline.single-thread .item.call-frame.async-boundary::before):
+        (.tree-outline .item.call-frame.async-boundary): Deleted.
+        Style changes for single/multiple-thread call stacks.
+        Padding changes to account for Thread tree element.
+        Make selectors more specific where needed.
+
+        * UserInterface/Views/DebuggerSidebarPanel.css:
+        (.sidebar > .panel.navigation.debugger .tree-outline.single-thread > .item.thread):
+        (.sidebar > .panel.navigation.debugger .tree-outline.single-thread):
+        Style changes for single/multiple-thread call stacks.
+
+        * UserInterface/Views/DebuggerSidebarPanel.js:
+        (WebInspector.DebuggerSidebarPanel):
+        Use a single tree outline for showing a single thread or multiple threads.
+        For single-threaded, hide Thread tree element and un-indent children.
+
+        (WebInspector.DebuggerSidebarPanel.prototype._targetAdded):
+        (WebInspector.DebuggerSidebarPanel.prototype._targetRemoved):
+        (WebInspector.DebuggerSidebarPanel.prototype._updateCallStackTreeOutline):
+        Update tree style and whether Thread tree element is selectable.
+        (WebInspector.DebuggerSidebarPanel.prototype._debuggerActiveCallFrameDidChange):
+        Remove support for second tree outline.
+
+        (WebInspector.DebuggerSidebarPanel.prototype._updateSingleThreadCallStacks): Deleted.
+        (WebInspector.DebuggerSidebarPanel.prototype._selectActiveCallFrameTreeElement): Deleted.
+        (WebInspector.DebuggerSidebarPanel.prototype._showSingleThreadCallStacks): Deleted.
+        (WebInspector.DebuggerSidebarPanel.prototype._showMultipleThreadCallStacks): Deleted.
+        No longer needed after unifying tree outlines.
+
+        * UserInterface/Views/ThreadTreeElement.js:
+        (WebInspector.ThreadTreeElement.prototype.refresh):
+        Append call frames from the async stack trace.
+
 2016-11-30  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: Clicking on link in Web Inspector can cause UIProcess to crash
index 00b15e7..e7fdeef 100644 (file)
 .tree-outline .item.call-frame.async-boundary {
     cursor: default;
     color: var(--text-color-gray-medium);
-    padding-left: 0;
+}
+
+.tree-outline:not(.single-thread) > .children > .item.call-frame.async-boundary {
+    padding-left: 5px;
 }
 
 .tree-outline .item.call-frame.async-boundary .icon {
 }
 
 .tree-outline .item.call-frame.async-boundary::before {
+    width: 30px;
+    margin-left: -5px;
+    margin-right: 1px;
+}
+
+.tree-outline.single-thread .item.call-frame.async-boundary::before {
     width: 20px;
-    margin-right: 2px;
 }
index 95ba6c6..9b8ccf6 100644 (file)
     background-color: hsl(50, 100%, 94%);
 }
 
+.sidebar > .panel.navigation.debugger .tree-outline.single-thread > .item.thread {
+    display: none;
+}
+
+.sidebar > .panel.navigation.debugger .tree-outline.single-thread {
+    margin-left: -10px;
+}
+
 .sidebar > .panel.navigation.debugger .warning-banner > a {
     text-decoration: underline;
     cursor: pointer;
index 71d9f4d..fe8650c 100644 (file)
@@ -177,25 +177,20 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
         this._callStackTreeOutline = this.createContentTreeOutline(dontHideByDefault, suppressFiltering);
         this._callStackTreeOutline.addEventListener(WebInspector.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
 
-        this._singleThreadCallStackTreeOutline = this.createContentTreeOutline(dontHideByDefault, suppressFiltering);
-        this._singleThreadCallStackTreeOutline.addEventListener(WebInspector.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
+        this._mainTargetTreeElement = new WebInspector.ThreadTreeElement(WebInspector.mainTarget);
+        this._callStackTreeOutline.appendChild(this._mainTargetTreeElement);
 
-        let mainTargetTreeElement = new WebInspector.ThreadTreeElement(WebInspector.mainTarget);
-        this._callStackTreeOutline.appendChild(mainTargetTreeElement);
+        this._updateCallStackTreeOutline();
 
-        this._multipleThreadsCallStackRow = new WebInspector.DetailsSectionRow;
-        this._multipleThreadsCallStackRow.element.appendChild(this._callStackTreeOutline.element);
+        this._callStackRow = new WebInspector.DetailsSectionRow;
+        this._callStackRow.element.appendChild(this._callStackTreeOutline.element);
 
-        this._singleThreadCallStackRow = new WebInspector.DetailsSectionRow;
-        this._singleThreadCallStackRow.element.appendChild(this._singleThreadCallStackTreeOutline.element);
-
-        this._callStackGroup = new WebInspector.DetailsSectionGroup([this._singleThreadCallStackRow]);
+        this._callStackGroup = new WebInspector.DetailsSectionGroup([this._callStackRow]);
         this._callStackSection = new WebInspector.DetailsSection("call-stack", WebInspector.UIString("Call Stack"), [this._callStackGroup]);
 
         this._showingSingleThreadCallStack = true;
 
         this._activeCallFrameTreeElement = null;
-        this._singleThreadActiveCallFrameTreeElement = null;
 
         this._pauseReasonTreeOutline = null;
 
@@ -601,99 +596,6 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
         this._removeDebuggerTreeElement(breakpointTreeElement);
     }
 
-    _updateSingleThreadCallStacks()
-    {
-        let targetData = WebInspector.debuggerManager.dataForTarget(WebInspector.mainTarget);
-        let callFrames = targetData.callFrames;
-
-        this._singleThreadCallStackTreeOutline.removeChildren();
-
-        if (!callFrames.length) {
-            this._singleThreadCallStackTreeOutline.appendChild(new WebInspector.IdleTreeElement);
-            return;
-        }
-
-        let activeCallFrame = WebInspector.debuggerManager.activeCallFrame;
-        let activeCallFrameTreeElement = null;
-
-        for (let callFrame of callFrames) {
-            let callFrameTreeElement = new WebInspector.CallFrameTreeElement(callFrame);
-            if (callFrame === activeCallFrame)
-                activeCallFrameTreeElement = callFrameTreeElement;
-            this._singleThreadCallStackTreeOutline.appendChild(callFrameTreeElement);
-        }
-
-        if (activeCallFrameTreeElement) {
-            activeCallFrameTreeElement.isActiveCallFrame = true;
-            if (this._showingSingleThreadCallStack)
-                activeCallFrameTreeElement.select(true, true);
-        }
-
-        if (!targetData.asyncStackTrace)
-            return;
-
-        let currentStackTrace = targetData.asyncStackTrace;
-        while (currentStackTrace) {
-            console.assert(currentStackTrace.callFrames.length, "StackTrace should have non-empty call frames array.");
-            if (!currentStackTrace.callFrames.length)
-                break;
-
-            let boundaryCallFrame;
-            if (currentStackTrace.topCallFrameIsBoundary) {
-                boundaryCallFrame = currentStackTrace.callFrames[0];
-                console.assert(boundaryCallFrame.nativeCode && !boundaryCallFrame.sourceCodeLocation);
-            } else {
-                // Create a generic native CallFrame for the asynchronous boundary.
-                const functionName = WebInspector.UIString("(async)");
-                const nativeCode = true;
-                boundaryCallFrame = new WebInspector.CallFrame(null, null, null, functionName, null, null, nativeCode);
-            }
-
-            const isAsyncBoundaryCallFrame = true;
-            this._singleThreadCallStackTreeOutline.appendChild(new WebInspector.CallFrameTreeElement(boundaryCallFrame, isAsyncBoundaryCallFrame));
-
-            let startIndex = currentStackTrace.topCallFrameIsBoundary ? 1 : 0;
-            for (let i = startIndex; i < currentStackTrace.callFrames.length; ++i)
-                this._singleThreadCallStackTreeOutline.appendChild(new WebInspector.CallFrameTreeElement(currentStackTrace.callFrames[i]));
-
-            currentStackTrace = currentStackTrace.parentStackTrace;
-        }
-    }
-
-    _selectActiveCallFrameTreeElement(treeOutline)
-    {
-        let activeCallFrame = WebInspector.debuggerManager.activeCallFrame;
-        if (activeCallFrame) {
-            let activeCallFrameTreeElement = treeOutline.findTreeElement(activeCallFrame);
-            if (activeCallFrameTreeElement)
-                activeCallFrameTreeElement.select(true, true);
-        }
-    }
-
-    _showSingleThreadCallStacks()
-    {
-        console.assert(!this._showingSingleThreadCallStack);
-        console.assert(WebInspector.targets.size === 1);
-
-        this._showingSingleThreadCallStack = true;
-
-        this._callStackGroup.rows = [this._singleThreadCallStackRow];
-
-        this._selectActiveCallFrameTreeElement(this._singleThreadCallStackTreeOutline);
-    }
-
-    _showMultipleThreadCallStacks()
-    {
-        console.assert(this._showingSingleThreadCallStack);
-        console.assert(WebInspector.targets.size > 1);
-
-        this._showingSingleThreadCallStack = false;
-
-        this._callStackGroup.rows = [this._multipleThreadsCallStackRow];
-
-        this._selectActiveCallFrameTreeElement(this._callStackTreeOutline);
-    }
-
     _findThreadTreeElementForTarget(target)
     {
         for (let child of this._callStackTreeOutline.children) {
@@ -710,8 +612,7 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
         let treeElement = new WebInspector.ThreadTreeElement(target);
         this._callStackTreeOutline.appendChild(treeElement);
 
-        if (this._showingSingleThreadCallStack)
-            this._showMultipleThreadCallStacks();
+        this._updateCallStackTreeOutline();
     }
 
     _targetRemoved(event)
@@ -720,8 +621,14 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
         let treeElement = this._findThreadTreeElementForTarget(target);
         this._callStackTreeOutline.removeChild(treeElement);
 
-        if (WebInspector.targets.size === 1)
-            this._showSingleThreadCallStacks();
+        this._updateCallStackTreeOutline();
+    }
+
+    _updateCallStackTreeOutline()
+    {
+        let singleThreadShowing = WebInspector.targets.size === 1;
+        this._callStackTreeOutline.element.classList.toggle("single-thread", singleThreadShowing);
+        this._mainTargetTreeElement.selectable = !singleThreadShowing;
     }
 
     _handleDebuggerObjectDisplayLocationDidChange(event)
@@ -770,9 +677,6 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
         let target = event.data.target;
         let treeElement = this._findThreadTreeElementForTarget(target);
         treeElement.refresh();
-
-        if (target === WebInspector.mainTarget)
-            this._updateSingleThreadCallStacks();
     }
 
     _debuggerActiveCallFrameDidChange()
@@ -781,10 +685,6 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
             this._activeCallFrameTreeElement.isActiveCallFrame = false;
             this._activeCallFrameTreeElement = null;
         }
-        if (this._singleThreadActiveCallFrameTreeElement) {
-            this._singleThreadActiveCallFrameTreeElement.isActiveCallFrame = false;
-            this._singleThreadActiveCallFrameTreeElement = null;
-        }
 
         if (!WebInspector.debuggerManager.activeCallFrame)
             return;
@@ -792,10 +692,6 @@ WebInspector.DebuggerSidebarPanel = class DebuggerSidebarPanel extends WebInspec
         this._activeCallFrameTreeElement = this._callStackTreeOutline.findTreeElement(WebInspector.debuggerManager.activeCallFrame);
         if (this._activeCallFrameTreeElement)
             this._activeCallFrameTreeElement.isActiveCallFrame = true;
-
-        this._singleThreadActiveCallFrameTreeElement = this._singleThreadCallStackTreeOutline.findTreeElement(WebInspector.debuggerManager.activeCallFrame);
-        if (this._singleThreadActiveCallFrameTreeElement)
-            this._singleThreadActiveCallFrameTreeElement.isActiveCallFrame = true;
     }
 
     _breakpointsBeneathTreeElement(treeElement)
index 7825bf2..58713a9 100644 (file)
@@ -66,6 +66,33 @@ WebInspector.ThreadTreeElement = class ThreadTreeElement extends WebInspector.Ge
             activeCallFrameTreeElement.isActiveCallFrame = true;
         }
 
+        let currentStackTrace = targetData.asyncStackTrace;
+        while (currentStackTrace) {
+            console.assert(currentStackTrace.callFrames.length, "StackTrace should have non-empty call frames array.");
+            if (!currentStackTrace.callFrames.length)
+                break;
+
+            let boundaryCallFrame;
+            if (currentStackTrace.topCallFrameIsBoundary) {
+                boundaryCallFrame = currentStackTrace.callFrames[0];
+                console.assert(boundaryCallFrame.nativeCode && !boundaryCallFrame.sourceCodeLocation);
+            } else {
+                // Create a generic native CallFrame for the asynchronous boundary.
+                const functionName = WebInspector.UIString("(async)");
+                const nativeCode = true;
+                boundaryCallFrame = new WebInspector.CallFrame(null, null, null, functionName, null, null, nativeCode);
+            }
+
+            const isAsyncBoundaryCallFrame = true;
+            this.appendChild(new WebInspector.CallFrameTreeElement(boundaryCallFrame, isAsyncBoundaryCallFrame));
+
+            let startIndex = currentStackTrace.topCallFrameIsBoundary ? 1 : 0;
+            for (let i = startIndex; i < currentStackTrace.callFrames.length; ++i)
+                this.appendChild(new WebInspector.CallFrameTreeElement(currentStackTrace.callFrames[i]));
+
+            currentStackTrace = currentStackTrace.parentStackTrace;
+        }
+
         this.expand();
     }