| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 WebInspector.DebuggerPresentationUtils = {} | 5 WebInspector.DebuggerPresentationUtils = {} |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * @param {?WebInspector.DebuggerModel} debuggerModel | 8 * @param {?WebInspector.DebuggerModel} debuggerModel |
| 9 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace | 9 * @param {!RuntimeAgent.StackTrace=} stackTrace |
| 10 * @param {!ConsoleAgent.AsyncStackTrace=} asyncStackTrace | |
| 11 * @param {boolean=} showBlackboxed | 10 * @param {boolean=} showBlackboxed |
| 12 * @return {?ConsoleAgent.CallFrame} | 11 * @return {?RuntimeAgent.CallFrame} |
| 13 */ | 12 */ |
| 14 WebInspector.DebuggerPresentationUtils.callFrameAnchorFromStackTrace = function(
debuggerModel, stackTrace, asyncStackTrace, showBlackboxed) | 13 WebInspector.DebuggerPresentationUtils.callFrameAnchorFromStackTrace = function(
debuggerModel, stackTrace, showBlackboxed) |
| 15 { | 14 { |
| 16 /** | 15 /** |
| 17 * @param {?Array.<!ConsoleAgent.CallFrame>=} stackTrace | 16 * @param {!Array.<!RuntimeAgent.CallFrame>} callFrames |
| 18 * @return {?ConsoleAgent.CallFrame} | 17 * @return {?RuntimeAgent.CallFrame} |
| 19 */ | 18 */ |
| 20 function innerCallFrameAnchorFromStackTrace(stackTrace) | 19 function innerCallFrameAnchorFromStackTrace(callFrames) |
| 21 { | 20 { |
| 22 if (!stackTrace || !stackTrace.length) | 21 if (!callFrames.length) |
| 23 return null; | 22 return null; |
| 24 if (showBlackboxed) | 23 if (showBlackboxed) |
| 25 return stackTrace[0]; | 24 return callFrames[0]; |
| 26 for (var i = 0; i < stackTrace.length; ++i) { | 25 for (var i = 0; i < callFrames.length; ++i) { |
| 27 var script = debuggerModel && debuggerModel.scriptForId(stackTrace[i
].scriptId); | 26 var script = debuggerModel && debuggerModel.scriptForId(callFrames[i
].scriptId); |
| 28 var blackboxed = script ? | 27 var blackboxed = script ? |
| 29 WebInspector.BlackboxSupport.isBlackboxed(script.sourceURL, scri
pt.isContentScript()) : | 28 WebInspector.BlackboxSupport.isBlackboxed(script.sourceURL, scri
pt.isContentScript()) : |
| 30 WebInspector.BlackboxSupport.isBlackboxedURL(stackTrace[i].url); | 29 WebInspector.BlackboxSupport.isBlackboxedURL(callFrames[i].url); |
| 31 if (!blackboxed) | 30 if (!blackboxed) |
| 32 return stackTrace[i]; | 31 return callFrames[i]; |
| 33 } | 32 } |
| 34 return null; | 33 return null; |
| 35 } | 34 } |
| 36 | 35 |
| 37 var callFrame = innerCallFrameAnchorFromStackTrace(stackTrace); | 36 var asyncStackTrace = stackTrace; |
| 38 if (callFrame) | |
| 39 return callFrame; | |
| 40 | |
| 41 while (asyncStackTrace) { | 37 while (asyncStackTrace) { |
| 42 callFrame = innerCallFrameAnchorFromStackTrace(asyncStackTrace.callFrame
s); | 38 var callFrame = innerCallFrameAnchorFromStackTrace(asyncStackTrace.callF
rames); |
| 43 if (callFrame) | 39 if (callFrame) |
| 44 return callFrame; | 40 return callFrame; |
| 45 asyncStackTrace = asyncStackTrace.asyncStackTrace; | 41 asyncStackTrace = asyncStackTrace.parent; |
| 46 } | 42 } |
| 47 | 43 return stackTrace && stackTrace.callFrames.length ? stackTrace.callFrames[0]
: null; |
| 48 return stackTrace ? stackTrace[0] : null; | |
| 49 } | 44 } |
| OLD | NEW |