Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 */ | 29 */ |
| 30 WebInspector.CallStackSidebarPane = function() | 30 WebInspector.CallStackSidebarPane = function() |
| 31 { | 31 { |
| 32 WebInspector.SimpleView.call(this, WebInspector.UIString("Call Stack")); | 32 WebInspector.SimpleView.call(this, WebInspector.UIString("Call Stack")); |
| 33 this.element.addEventListener("keydown", this._keyDown.bind(this), true); | 33 this.element.addEventListener("keydown", this._keyDown.bind(this), true); |
| 34 this.element.tabIndex = 0; | 34 this.element.tabIndex = 0; |
| 35 this.callFrameList = new WebInspector.UIList(); | 35 this.callFrameList = new WebInspector.UIList(); |
| 36 this.callFrameList.show(this.element); | 36 this.callFrameList.show(this.element); |
| 37 this._linkifier = new WebInspector.Linkifier(); | 37 this._linkifier = new WebInspector.Linkifier(); |
| 38 WebInspector.moduleSetting("enableAsyncStackTraces").addChangeListener(this. _asyncStackTracesStateChanged, this); | 38 WebInspector.moduleSetting("enableAsyncStackTraces").addChangeListener(this. _asyncStackTracesStateChanged, this); |
| 39 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this. _blackboxingStateChanged, this); | 39 WebInspector.moduleSetting("skipStackFramesPattern").addChangeListener(this. _update, this); |
| 40 /** @type {!Array<!WebInspector.CallStackSidebarPane.CallFrame>} */ | 40 /** @type {!Array<!WebInspector.CallStackSidebarPane.CallFrame>} */ |
| 41 this.callFrames = []; | 41 this.callFrames = []; |
| 42 this._locationPool = new WebInspector.LiveLocationPool(); | 42 this._locationPool = new WebInspector.LiveLocationPool(); |
| 43 } | 43 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerPaused, this._update, this); |
| 44 | 44 WebInspector.targetManager.addModelListener(WebInspector.DebuggerModel, WebI nspector.DebuggerModel.Events.DebuggerResumed, this._update, this); |
| 45 /** @enum {string} */ | 45 WebInspector.context.addFlavorChangeListener(WebInspector.Target, this._upda te, this); |
| 46 WebInspector.CallStackSidebarPane.Events = { | 46 WebInspector.context.addFlavorChangeListener(WebInspector.DebuggerModel.Call Frame, this._updateCallFrame, this); |
| 47 CallFrameSelected: "CallFrameSelected", | |
| 48 } | 47 } |
| 49 | 48 |
| 50 WebInspector.CallStackSidebarPane.prototype = { | 49 WebInspector.CallStackSidebarPane.prototype = { |
| 51 /** | 50 _update: function() |
| 52 * @param {?WebInspector.DebuggerPausedDetails} details | |
| 53 */ | |
| 54 update: function(details) | |
| 55 { | 51 { |
| 52 var target = WebInspector.context.flavor(WebInspector.Target); | |
| 53 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | |
| 54 var details = debuggerModel.debuggerPausedDetails(); | |
|
dgozman
2016/08/11 01:42:16
debuggerModel could be null
| |
| 55 | |
| 56 this.callFrameList.detach(); | 56 this.callFrameList.detach(); |
| 57 this.callFrameList.clear(); | 57 this.callFrameList.clear(); |
| 58 this._linkifier.reset(); | 58 this._linkifier.reset(); |
| 59 this.element.removeChildren(); | 59 this.element.removeChildren(); |
| 60 this._locationPool.disposeAll(); | 60 this._locationPool.disposeAll(); |
| 61 | 61 |
| 62 if (!details) { | 62 if (!details) { |
| 63 var infoElement = this.element.createChild("div", "callstack-info"); | 63 var infoElement = this.element.createChild("div", "callstack-info"); |
| 64 infoElement.textContent = WebInspector.UIString("Not Paused"); | 64 infoElement.textContent = WebInspector.UIString("Not Paused"); |
| 65 return; | 65 return; |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 94 element.textContent = WebInspector.UIString("1 stack frame is hi dden (black-boxed)."); | 94 element.textContent = WebInspector.UIString("1 stack frame is hi dden (black-boxed)."); |
| 95 else | 95 else |
| 96 element.textContent = WebInspector.UIString("%d stack frames are hidden (black-boxed).", this._hiddenCallFrames); | 96 element.textContent = WebInspector.UIString("%d stack frames are hidden (black-boxed).", this._hiddenCallFrames); |
| 97 element.createTextChild(" "); | 97 element.createTextChild(" "); |
| 98 var showAllLink = element.createChild("span", "link"); | 98 var showAllLink = element.createChild("span", "link"); |
| 99 showAllLink.textContent = WebInspector.UIString("Show"); | 99 showAllLink.textContent = WebInspector.UIString("Show"); |
| 100 showAllLink.addEventListener("click", this._revealHiddenCallFrames.b ind(this), false); | 100 showAllLink.addEventListener("click", this._revealHiddenCallFrames.b ind(this), false); |
| 101 this.element.insertBefore(element, this.element.firstChild); | 101 this.element.insertBefore(element, this.element.firstChild); |
| 102 this._hiddenCallFramesMessageElement = element; | 102 this._hiddenCallFramesMessageElement = element; |
| 103 } | 103 } |
| 104 WebInspector.viewManager.revealViewWithWidget(this); | |
| 104 }, | 105 }, |
| 105 | 106 |
| 106 /** | 107 /** |
| 107 * @param {!Array.<!WebInspector.DebuggerModel.CallFrame>} callFrames | 108 * @param {!Array.<!WebInspector.DebuggerModel.CallFrame>} callFrames |
| 108 * @return {!Array<!WebInspector.CallStackSidebarPane.CallFrame>} | 109 * @return {!Array<!WebInspector.CallStackSidebarPane.CallFrame>} |
| 109 */ | 110 */ |
| 110 _callFramesFromDebugger: function(callFrames) | 111 _callFramesFromDebugger: function(callFrames) |
| 111 { | 112 { |
| 112 var callFrameItems = []; | 113 var callFrameItems = []; |
| 113 for (var i = 0, n = callFrames.length; i < n; ++i) { | 114 for (var i = 0, n = callFrames.length; i < n; ++i) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 contextMenu.appendItem(WebInspector.UIString.capitalize("Blackbo x ^script"), manager.blackboxUISourceCode.bind(manager, uiSourceCode)); | 242 contextMenu.appendItem(WebInspector.UIString.capitalize("Blackbo x ^script"), manager.blackboxUISourceCode.bind(manager, uiSourceCode)); |
| 242 } | 243 } |
| 243 if (isContentScript) { | 244 if (isContentScript) { |
| 244 if (isBlackboxed) | 245 if (isBlackboxed) |
| 245 contextMenu.appendItem(WebInspector.UIString.capitalize("Stop bl ackboxing ^all ^content ^scripts"), manager.blackboxContentScripts.bind(manager) ); | 246 contextMenu.appendItem(WebInspector.UIString.capitalize("Stop bl ackboxing ^all ^content ^scripts"), manager.blackboxContentScripts.bind(manager) ); |
| 246 else | 247 else |
| 247 contextMenu.appendItem(WebInspector.UIString.capitalize("Blackbo x ^all ^content ^scripts"), manager.unblackboxContentScripts.bind(manager)); | 248 contextMenu.appendItem(WebInspector.UIString.capitalize("Blackbo x ^all ^content ^scripts"), manager.unblackboxContentScripts.bind(manager)); |
| 248 } | 249 } |
| 249 }, | 250 }, |
| 250 | 251 |
| 251 _blackboxingStateChanged: function() | |
| 252 { | |
| 253 if (!this._debuggerModel) | |
| 254 return; | |
| 255 var details = this._debuggerModel.debuggerPausedDetails(); | |
| 256 if (!details) | |
| 257 return; | |
| 258 this.update(details); | |
| 259 var selectedCallFrame = this._debuggerModel.selectedCallFrame(); | |
| 260 if (selectedCallFrame) | |
| 261 this.setSelectedCallFrame(selectedCallFrame); | |
| 262 }, | |
| 263 | |
| 264 _asyncStackTracesStateChanged: function() | 252 _asyncStackTracesStateChanged: function() |
| 265 { | 253 { |
| 266 var enabled = WebInspector.moduleSetting("enableAsyncStackTraces").get() ; | 254 var enabled = WebInspector.moduleSetting("enableAsyncStackTraces").get() ; |
| 267 if (!enabled && this.callFrames) | 255 if (!enabled && this.callFrames) |
| 268 this._removeAsyncCallFrames(); | 256 this._removeAsyncCallFrames(); |
| 269 }, | 257 }, |
| 270 | 258 |
| 271 _removeAsyncCallFrames: function() | 259 _removeAsyncCallFrames: function() |
| 272 { | 260 { |
| 273 var shouldSelectTopFrame = false; | 261 var shouldSelectTopFrame = false; |
| 274 var lastSyncCallFrameIndex = -1; | 262 var lastSyncCallFrameIndex = -1; |
| 275 for (var i = 0; i < this.callFrames.length; ++i) { | 263 for (var i = 0; i < this.callFrames.length; ++i) { |
| 276 var callFrame = this.callFrames[i]; | 264 var callFrame = this.callFrames[i]; |
| 277 if (callFrame._asyncCallFrame) { | 265 if (callFrame._asyncCallFrame) { |
| 278 if (callFrame.isSelected()) | 266 if (callFrame.isSelected()) |
| 279 shouldSelectTopFrame = true; | 267 shouldSelectTopFrame = true; |
| 280 callFrame._asyncCallFrame.element.remove(); | 268 callFrame._asyncCallFrame.element.remove(); |
| 281 callFrame.element.remove(); | 269 callFrame.element.remove(); |
| 282 } else { | 270 } else { |
| 283 lastSyncCallFrameIndex = i; | 271 lastSyncCallFrameIndex = i; |
| 284 } | 272 } |
| 285 } | 273 } |
| 286 this.callFrames.length = lastSyncCallFrameIndex + 1; | 274 this.callFrames.length = lastSyncCallFrameIndex + 1; |
| 287 if (shouldSelectTopFrame) | 275 if (shouldSelectTopFrame) |
| 288 this._selectNextVisibleCallFrame(0); | 276 this._selectNextVisibleCallFrame(0); |
| 289 }, | 277 }, |
| 290 | 278 |
| 291 /** | 279 _updateCallFrame: function() |
| 292 * @param {!WebInspector.DebuggerModel.CallFrame} x | |
| 293 */ | |
| 294 setSelectedCallFrame: function(x) | |
| 295 { | 280 { |
| 281 var x = WebInspector.context.flavor(WebInspector.DebuggerModel.CallFrame ); | |
|
dgozman
2016/08/11 01:42:16
x -> selectedCallFrame
| |
| 296 for (var i = 0; i < this.callFrames.length; ++i) { | 282 for (var i = 0; i < this.callFrames.length; ++i) { |
| 297 var callFrame = this.callFrames[i]; | 283 var callFrame = this.callFrames[i]; |
| 298 callFrame.setSelected(callFrame._debuggerCallFrame === x); | 284 callFrame.setSelected(callFrame._debuggerCallFrame === x); |
| 299 if (callFrame.isSelected() && callFrame.isHidden()) | 285 if (callFrame.isSelected() && callFrame.isHidden()) |
| 300 this._revealHiddenCallFrames(); | 286 this._revealHiddenCallFrames(); |
| 301 } | 287 } |
| 302 }, | 288 }, |
| 303 | 289 |
| 304 /** | 290 /** |
| 305 * @return {boolean} | 291 * @return {boolean} |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 368 }, | 354 }, |
| 369 | 355 |
| 370 /** | 356 /** |
| 371 * @param {!WebInspector.CallStackSidebarPane.CallFrame} callFrameItem | 357 * @param {!WebInspector.CallStackSidebarPane.CallFrame} callFrameItem |
| 372 */ | 358 */ |
| 373 _callFrameSelected: function(callFrameItem) | 359 _callFrameSelected: function(callFrameItem) |
| 374 { | 360 { |
| 375 callFrameItem.element.scrollIntoViewIfNeeded(); | 361 callFrameItem.element.scrollIntoViewIfNeeded(); |
| 376 var callFrame = callFrameItem._debuggerCallFrame; | 362 var callFrame = callFrameItem._debuggerCallFrame; |
| 377 if (callFrame) | 363 if (callFrame) |
| 378 this.dispatchEventToListeners(WebInspector.CallStackSidebarPane.Even ts.CallFrameSelected, callFrame); | 364 callFrame.debuggerModel.setSelectedCallFrame(callFrame); |
| 379 }, | 365 }, |
| 380 | 366 |
| 381 _copyStackTrace: function() | 367 _copyStackTrace: function() |
| 382 { | 368 { |
| 383 var text = ""; | 369 var text = ""; |
| 384 var lastCallFrame = null; | 370 var lastCallFrame = null; |
| 385 for (var i = 0; i < this.callFrames.length; ++i) { | 371 for (var i = 0; i < this.callFrames.length; ++i) { |
| 386 var callFrame = this.callFrames[i]; | 372 var callFrame = this.callFrames[i]; |
| 387 if (callFrame.isHidden()) | 373 if (callFrame.isHidden()) |
| 388 continue; | 374 continue; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 465 var uiLocation = liveLocation.uiLocation(); | 451 var uiLocation = liveLocation.uiLocation(); |
| 466 if (!uiLocation) | 452 if (!uiLocation) |
| 467 return; | 453 return; |
| 468 var text = uiLocation.linkText(); | 454 var text = uiLocation.linkText(); |
| 469 this.setSubtitle(text.trimMiddle(30)); | 455 this.setSubtitle(text.trimMiddle(30)); |
| 470 this.subtitleElement.title = text; | 456 this.subtitleElement.title = text; |
| 471 }, | 457 }, |
| 472 | 458 |
| 473 __proto__: WebInspector.UIList.Item.prototype | 459 __proto__: WebInspector.UIList.Item.prototype |
| 474 } | 460 } |
| OLD | NEW |