| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * @constructor | 27 * @constructor |
| 28 * @extends {WebInspector.SidebarPane} | 28 * @extends {WebInspector.SidebarPane} |
| 29 */ | 29 */ |
| 30 WebInspector.CallStackSidebarPane = function() | 30 WebInspector.CallStackSidebarPane = function() |
| 31 { | 31 { |
| 32 WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack")); | 32 WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack")); |
| 33 this.bodyElement.addEventListener("keydown", this._keyDown.bind(this), true)
; | 33 this.bodyElement.addEventListener("keydown", this._keyDown.bind(this), true)
; |
| 34 this.bodyElement.tabIndex = 0; | 34 this.bodyElement.tabIndex = 0; |
| 35 |
| 36 var asyncCheckbox = this.titleElement.appendChild(WebInspector.SettingsTab.c
reateSettingCheckbox(WebInspector.UIString("Async"), WebInspector.settings.enabl
eAsyncStackTraces, true, undefined, WebInspector.UIString("Capture async stack t
races"))); |
| 37 asyncCheckbox.classList.add("scripts-callstack-async"); |
| 38 asyncCheckbox.addEventListener("click", consumeEvent, false); |
| 39 |
| 40 WebInspector.settings.enableAsyncStackTraces.addChangeListener(this._asyncSt
ackTracesStateChanged, this); |
| 35 } | 41 } |
| 36 | 42 |
| 37 WebInspector.CallStackSidebarPane.Events = { | 43 WebInspector.CallStackSidebarPane.Events = { |
| 38 CallFrameRestarted: "CallFrameRestarted", | 44 CallFrameRestarted: "CallFrameRestarted", |
| 39 CallFrameSelected: "CallFrameSelected" | 45 CallFrameSelected: "CallFrameSelected" |
| 40 } | 46 } |
| 41 | 47 |
| 42 WebInspector.CallStackSidebarPane.prototype = { | 48 WebInspector.CallStackSidebarPane.prototype = { |
| 43 /** | 49 /** |
| 44 * @param {?Array.<!WebInspector.DebuggerModel.CallFrame>} callFrames | 50 * @param {?Array.<!WebInspector.DebuggerModel.CallFrame>} callFrames |
| 45 * @param {?WebInspector.DebuggerModel.StackTrace} asyncStackTrace | 51 * @param {?WebInspector.DebuggerModel.StackTrace} asyncStackTrace |
| 46 */ | 52 */ |
| 47 update: function(callFrames, asyncStackTrace) | 53 update: function(callFrames, asyncStackTrace) |
| 48 { | 54 { |
| 49 this.bodyElement.removeChildren(); | 55 this.bodyElement.removeChildren(); |
| 50 delete this._statusMessageElement; | 56 delete this._statusMessageElement; |
| 51 /** @type {!Array.<!WebInspector.CallStackSidebarPane.Placard>} */ | 57 /** @type {!Array.<!WebInspector.CallStackSidebarPane.Placard>} */ |
| 52 this.placards = []; | 58 this.placards = []; |
| 53 | 59 |
| 54 if (!callFrames) { | 60 if (!callFrames) { |
| 55 var infoElement = this.bodyElement.createChild("div", "info"); | 61 var infoElement = this.bodyElement.createChild("div", "info"); |
| 56 infoElement.textContent = WebInspector.UIString("Not Paused"); | 62 infoElement.textContent = WebInspector.UIString("Not Paused"); |
| 57 return; | 63 return; |
| 58 } | 64 } |
| 59 | 65 |
| 60 this._appendSidebarPlacards(callFrames, this.bodyElement); | 66 this._appendSidebarPlacards(callFrames); |
| 61 | 67 |
| 62 while (asyncStackTrace) { | 68 while (asyncStackTrace) { |
| 63 var asyncPlacards = this._appendSidebarPlacards(asyncStackTrace.call
Frames); | 69 var asyncPlacard = new WebInspector.Placard(WebInspector.UIString("[
Async Call]"), ""); |
| 64 var group = new WebInspector.PlacardGroup(WebInspector.UIString("[As
ync Call]"), asyncPlacards); | 70 this.bodyElement.appendChild(asyncPlacard.element); |
| 65 group.element.addEventListener("contextmenu", this._placardContextMe
nu.bind(this, asyncPlacards[0]), true); | 71 this._appendSidebarPlacards(asyncStackTrace.callFrames, asyncPlacard
); |
| 66 this.bodyElement.appendChild(group.element); | |
| 67 asyncStackTrace = asyncStackTrace.asyncStackTrace; | 72 asyncStackTrace = asyncStackTrace.asyncStackTrace; |
| 68 } | 73 } |
| 69 }, | 74 }, |
| 70 | 75 |
| 71 /** | 76 /** |
| 72 * @param {!Array.<!WebInspector.DebuggerModel.CallFrame>} callFrames | 77 * @param {!Array.<!WebInspector.DebuggerModel.CallFrame>} callFrames |
| 73 * @param {!Element=} parentElement | 78 * @param {!WebInspector.Placard=} asyncPlacard |
| 74 * @return {!Array.<!WebInspector.CallStackSidebarPane.Placard>} | |
| 75 */ | 79 */ |
| 76 _appendSidebarPlacards: function(callFrames, parentElement) | 80 _appendSidebarPlacards: function(callFrames, asyncPlacard) |
| 77 { | 81 { |
| 78 var result = []; | |
| 79 for (var i = 0, n = callFrames.length; i < n; ++i) { | 82 for (var i = 0, n = callFrames.length; i < n; ++i) { |
| 80 var placard = new WebInspector.CallStackSidebarPane.Placard(callFram
es[i]); | 83 var placard = new WebInspector.CallStackSidebarPane.Placard(callFram
es[i], asyncPlacard); |
| 81 placard.element.addEventListener("click", this._placardSelected.bind
(this, placard), false); | 84 placard.element.addEventListener("click", this._placardSelected.bind
(this, placard), false); |
| 82 placard.element.addEventListener("contextmenu", this._placardContext
Menu.bind(this, placard), true); | 85 placard.element.addEventListener("contextmenu", this._placardContext
Menu.bind(this, placard), true); |
| 83 result.push(placard); | 86 if (!i && asyncPlacard) { |
| 87 asyncPlacard.element.addEventListener("click", this._placardSele
cted.bind(this, placard), false); |
| 88 asyncPlacard.element.addEventListener("contextmenu", this._placa
rdContextMenu.bind(this, placard), true); |
| 89 } |
| 84 this.placards.push(placard); | 90 this.placards.push(placard); |
| 85 if (parentElement) | 91 this.bodyElement.appendChild(placard.element); |
| 86 parentElement.appendChild(placard.element); | |
| 87 } | 92 } |
| 88 return result; | |
| 89 }, | 93 }, |
| 90 | 94 |
| 91 /** | 95 /** |
| 92 * @param {!WebInspector.CallStackSidebarPane.Placard} placard | 96 * @param {!WebInspector.CallStackSidebarPane.Placard} placard |
| 93 */ | 97 */ |
| 94 _placardContextMenu: function(placard, event) | 98 _placardContextMenu: function(placard, event) |
| 95 { | 99 { |
| 96 var contextMenu = new WebInspector.ContextMenu(event); | 100 var contextMenu = new WebInspector.ContextMenu(event); |
| 97 | 101 |
| 98 if (!placard._callFrame.isAsync() && WebInspector.debuggerModel.canSetSc
riptSource()) | 102 if (!placard._callFrame.isAsync() && WebInspector.debuggerModel.canSetSc
riptSource()) |
| 99 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa
seMenuTitles() ? "Restart frame" : "Restart Frame"), this._restartFrame.bind(thi
s, placard)); | 103 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa
seMenuTitles() ? "Restart frame" : "Restart Frame"), this._restartFrame.bind(thi
s, placard)); |
| 100 | 104 |
| 101 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe
nuTitles() ? "Copy stack trace" : "Copy Stack Trace"), this._copyStackTrace.bind
(this)); | 105 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe
nuTitles() ? "Copy stack trace" : "Copy Stack Trace"), this._copyStackTrace.bind
(this)); |
| 102 contextMenu.appendSeparator(); | |
| 103 | |
| 104 var asyncStacksEnabled = WebInspector.settings.enableAsyncStackTraces.ge
t(); | |
| 105 if (asyncStacksEnabled) | |
| 106 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa
seMenuTitles() ? "Disable async stack traces" : "Disable Async Stack Traces"), t
his._enableAsyncStacks.bind(this, false)); | |
| 107 else | |
| 108 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCa
seMenuTitles() ? "Enable async stack traces" : "Enable Async Stack Traces"), thi
s._enableAsyncStacks.bind(this, true)); | |
| 109 | |
| 110 contextMenu.show(); | 106 contextMenu.show(); |
| 111 }, | 107 }, |
| 112 | 108 |
| 113 /** | 109 /** |
| 114 * @param {!WebInspector.CallStackSidebarPane.Placard} placard | 110 * @param {!WebInspector.CallStackSidebarPane.Placard} placard |
| 115 */ | 111 */ |
| 116 _restartFrame: function(placard) | 112 _restartFrame: function(placard) |
| 117 { | 113 { |
| 118 placard._callFrame.restart(); | 114 placard._callFrame.restart(); |
| 119 this.dispatchEventToListeners(WebInspector.CallStackSidebarPane.Events.C
allFrameRestarted, placard._callFrame); | 115 this.dispatchEventToListeners(WebInspector.CallStackSidebarPane.Events.C
allFrameRestarted, placard._callFrame); |
| 120 }, | 116 }, |
| 121 | 117 |
| 122 /** | 118 _asyncStackTracesStateChanged: function() |
| 123 * @param {boolean} enable | |
| 124 */ | |
| 125 _enableAsyncStacks: function(enable) | |
| 126 { | 119 { |
| 127 WebInspector.settings.enableAsyncStackTraces.set(enable); | 120 var enabled = WebInspector.settings.enableAsyncStackTraces.get(); |
| 121 if (!enabled && this.placards) |
| 122 this._removeAsyncPlacards(); |
| 123 }, |
| 124 |
| 125 _removeAsyncPlacards: function() |
| 126 { |
| 127 var shouldSelectTopFrame = false; |
| 128 var lastSyncPlacardIndex = -1; |
| 129 for (var i = 0; i < this.placards.length; ++i) { |
| 130 var placard = this.placards[i]; |
| 131 if (placard._asyncPlacard) { |
| 132 if (placard.selected) |
| 133 shouldSelectTopFrame = true; |
| 134 placard._asyncPlacard.element.remove(); |
| 135 placard.element.remove(); |
| 136 } else { |
| 137 lastSyncPlacardIndex = i; |
| 138 } |
| 139 } |
| 140 this.placards.length = lastSyncPlacardIndex + 1; |
| 141 if (shouldSelectTopFrame) |
| 142 this._selectPlacardByIndex(0); |
| 128 }, | 143 }, |
| 129 | 144 |
| 130 /** | 145 /** |
| 131 * @param {WebInspector.DebuggerModel.CallFrame} x | 146 * @param {WebInspector.DebuggerModel.CallFrame} x |
| 132 */ | 147 */ |
| 133 setSelectedCallFrame: function(x) | 148 setSelectedCallFrame: function(x) |
| 134 { | 149 { |
| 135 for (var i = 0; i < this.placards.length; ++i) { | 150 for (var i = 0; i < this.placards.length; ++i) { |
| 136 var placard = this.placards[i]; | 151 var placard = this.placards[i]; |
| 137 placard.selected = (placard._callFrame === x); | 152 placard.selected = (placard._callFrame === x); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 */ | 210 */ |
| 196 _placardSelected: function(placard) | 211 _placardSelected: function(placard) |
| 197 { | 212 { |
| 198 this.dispatchEventToListeners(WebInspector.CallStackSidebarPane.Events.C
allFrameSelected, placard._callFrame); | 213 this.dispatchEventToListeners(WebInspector.CallStackSidebarPane.Events.C
allFrameSelected, placard._callFrame); |
| 199 }, | 214 }, |
| 200 | 215 |
| 201 _copyStackTrace: function() | 216 _copyStackTrace: function() |
| 202 { | 217 { |
| 203 var text = ""; | 218 var text = ""; |
| 204 for (var i = 0; i < this.placards.length; ++i) { | 219 for (var i = 0; i < this.placards.length; ++i) { |
| 205 if (i && this.placards[i].group() !== this.placards[i - 1].group()) | 220 if (i && this.placards[i]._asyncPlacard !== this.placards[i - 1]._as
yncPlacard) |
| 206 text += this.placards[i].group().title() + "\n"; | 221 text += this.placards[i]._asyncPlacard.title + "\n"; |
| 207 text += this.placards[i].title + " (" + this.placards[i].subtitle +
")\n"; | 222 text += this.placards[i].title + " (" + this.placards[i].subtitle +
")\n"; |
| 208 } | 223 } |
| 209 InspectorFrontendHost.copyText(text); | 224 InspectorFrontendHost.copyText(text); |
| 210 }, | 225 }, |
| 211 | 226 |
| 212 /** | 227 /** |
| 213 * @param {function(!Array.<!WebInspector.KeyboardShortcut.Descriptor>, func
tion(Event=):boolean)} registerShortcutDelegate | 228 * @param {function(!Array.<!WebInspector.KeyboardShortcut.Descriptor>, func
tion(Event=):boolean)} registerShortcutDelegate |
| 214 */ | 229 */ |
| 215 registerShortcuts: function(registerShortcutDelegate) | 230 registerShortcuts: function(registerShortcutDelegate) |
| 216 { | 231 { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 247 } | 262 } |
| 248 }, | 263 }, |
| 249 | 264 |
| 250 __proto__: WebInspector.SidebarPane.prototype | 265 __proto__: WebInspector.SidebarPane.prototype |
| 251 } | 266 } |
| 252 | 267 |
| 253 /** | 268 /** |
| 254 * @constructor | 269 * @constructor |
| 255 * @extends {WebInspector.Placard} | 270 * @extends {WebInspector.Placard} |
| 256 * @param {!WebInspector.DebuggerModel.CallFrame} callFrame | 271 * @param {!WebInspector.DebuggerModel.CallFrame} callFrame |
| 272 * @param {!WebInspector.Placard=} asyncPlacard |
| 257 */ | 273 */ |
| 258 WebInspector.CallStackSidebarPane.Placard = function(callFrame) | 274 WebInspector.CallStackSidebarPane.Placard = function(callFrame, asyncPlacard) |
| 259 { | 275 { |
| 260 WebInspector.Placard.call(this, callFrame.functionName || WebInspector.UIStr
ing("(anonymous function)"), ""); | 276 WebInspector.Placard.call(this, callFrame.functionName || WebInspector.UIStr
ing("(anonymous function)"), ""); |
| 261 callFrame.createLiveLocation(this._update.bind(this)); | 277 callFrame.createLiveLocation(this._update.bind(this)); |
| 262 this._callFrame = callFrame; | 278 this._callFrame = callFrame; |
| 279 this._asyncPlacard = asyncPlacard; |
| 263 } | 280 } |
| 264 | 281 |
| 265 WebInspector.CallStackSidebarPane.Placard.prototype = { | 282 WebInspector.CallStackSidebarPane.Placard.prototype = { |
| 266 /** | 283 /** |
| 267 * @param {!WebInspector.UILocation} uiLocation | 284 * @param {!WebInspector.UILocation} uiLocation |
| 268 */ | 285 */ |
| 269 _update: function(uiLocation) | 286 _update: function(uiLocation) |
| 270 { | 287 { |
| 271 this.subtitle = uiLocation.linkText().trimMiddle(100); | 288 this.subtitle = uiLocation.linkText().trimMiddle(100); |
| 272 }, | 289 }, |
| 273 | 290 |
| 274 __proto__: WebInspector.Placard.prototype | 291 __proto__: WebInspector.Placard.prototype |
| 275 } | 292 } |
| OLD | NEW |