| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * 1. Redistributions of source code must retain the above copyright | |
| 8 * notice, this list of conditions and the following disclaimer. | |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | |
| 10 * notice, this list of conditions and the following disclaimer in the | |
| 11 * documentation and/or other materials provided with the distribution. | |
| 12 * | |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 24 */ | |
| 25 | |
| 26 WebInspector.CallStackSidebarPane = function() | |
| 27 { | |
| 28 WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack")); | |
| 29 | |
| 30 this._shortcuts = {}; | |
| 31 | |
| 32 var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardSh
ortcut.KeyCodes.Period, | |
| 33 WebInspector.KeyboardSh
ortcut.Modifiers.Ctrl); | |
| 34 this._shortcuts[shortcut] = this._selectNextCallFrameOnStack.bind(this); | |
| 35 | |
| 36 var shortcut = WebInspector.KeyboardShortcut.makeKey(WebInspector.KeyboardSh
ortcut.KeyCodes.Comma, | |
| 37 WebInspector.KeyboardSh
ortcut.Modifiers.Ctrl); | |
| 38 this._shortcuts[shortcut] = this._selectPreviousCallFrameOnStack.bind(this); | |
| 39 } | |
| 40 | |
| 41 WebInspector.CallStackSidebarPane.prototype = { | |
| 42 update: function(callFrames, sourceIDMap) | |
| 43 { | |
| 44 this.bodyElement.removeChildren(); | |
| 45 | |
| 46 this.placards = []; | |
| 47 delete this._selectedCallFrame; | |
| 48 | |
| 49 if (!callFrames) { | |
| 50 var infoElement = document.createElement("div"); | |
| 51 infoElement.className = "info"; | |
| 52 infoElement.textContent = WebInspector.UIString("Not Paused"); | |
| 53 this.bodyElement.appendChild(infoElement); | |
| 54 return; | |
| 55 } | |
| 56 | |
| 57 var title; | |
| 58 var subtitle; | |
| 59 var scriptOrResource; | |
| 60 | |
| 61 for (var i = 0; i < callFrames.length; ++i) { | |
| 62 var callFrame = callFrames[i]; | |
| 63 switch (callFrame.type) { | |
| 64 case "function": | |
| 65 title = callFrame.functionName || WebInspector.UIString("(anonym
ous function)"); | |
| 66 break; | |
| 67 case "program": | |
| 68 title = WebInspector.UIString("(program)"); | |
| 69 break; | |
| 70 } | |
| 71 | |
| 72 scriptOrResource = sourceIDMap[callFrame.sourceID]; | |
| 73 subtitle = WebInspector.displayNameForURL(scriptOrResource.sourceURL
|| scriptOrResource.url); | |
| 74 | |
| 75 if (callFrame.line > 0) { | |
| 76 if (subtitle) | |
| 77 subtitle += ":" + callFrame.line; | |
| 78 else | |
| 79 subtitle = WebInspector.UIString("line %d", callFrame.line); | |
| 80 } | |
| 81 | |
| 82 var placard = new WebInspector.Placard(title, subtitle); | |
| 83 placard.callFrame = callFrame; | |
| 84 | |
| 85 placard.element.addEventListener("click", this._placardSelected.bind
(this), false); | |
| 86 | |
| 87 this.placards.push(placard); | |
| 88 this.bodyElement.appendChild(placard.element); | |
| 89 } | |
| 90 }, | |
| 91 | |
| 92 get selectedCallFrame() | |
| 93 { | |
| 94 return this._selectedCallFrame; | |
| 95 }, | |
| 96 | |
| 97 set selectedCallFrame(x) | |
| 98 { | |
| 99 if (this._selectedCallFrame === x) | |
| 100 return; | |
| 101 | |
| 102 this._selectedCallFrame = x; | |
| 103 | |
| 104 for (var i = 0; i < this.placards.length; ++i) { | |
| 105 var placard = this.placards[i]; | |
| 106 placard.selected = (placard.callFrame === this._selectedCallFrame); | |
| 107 } | |
| 108 | |
| 109 this.dispatchEventToListeners("call frame selected"); | |
| 110 }, | |
| 111 | |
| 112 handleKeyEvent: function(event) | |
| 113 { | |
| 114 var shortcut = WebInspector.KeyboardShortcut.makeKeyFromEvent(event); | |
| 115 var handler = this._shortcuts[shortcut]; | |
| 116 if (handler) { | |
| 117 handler(event); | |
| 118 event.preventDefault(); | |
| 119 event.handled = true; | |
| 120 } | |
| 121 }, | |
| 122 | |
| 123 _selectNextCallFrameOnStack: function() | |
| 124 { | |
| 125 var index = this._selectedCallFrameIndex(); | |
| 126 if (index == -1) | |
| 127 return; | |
| 128 this._selectedPlacardByIndex(index + 1); | |
| 129 }, | |
| 130 | |
| 131 _selectPreviousCallFrameOnStack: function() | |
| 132 { | |
| 133 var index = this._selectedCallFrameIndex(); | |
| 134 if (index == -1) | |
| 135 return; | |
| 136 this._selectedPlacardByIndex(index - 1); | |
| 137 }, | |
| 138 | |
| 139 _selectedPlacardByIndex: function(index) | |
| 140 { | |
| 141 if (index < 0 || index >= this.placards.length) | |
| 142 return; | |
| 143 var placard = this.placards[index]; | |
| 144 this.selectedCallFrame = placard.callFrame | |
| 145 }, | |
| 146 | |
| 147 _selectedCallFrameIndex: function() | |
| 148 { | |
| 149 if (!this._selectedCallFrame) | |
| 150 return -1; | |
| 151 for (var i = 0; i < this.placards.length; ++i) { | |
| 152 var placard = this.placards[i]; | |
| 153 if (placard.callFrame === this._selectedCallFrame) | |
| 154 return i; | |
| 155 } | |
| 156 return -1; | |
| 157 }, | |
| 158 | |
| 159 _placardSelected: function(event) | |
| 160 { | |
| 161 var placardElement = event.target.enclosingNodeOrSelfWithClass("placard"
); | |
| 162 this.selectedCallFrame = placardElement.placard.callFrame; | |
| 163 } | |
| 164 } | |
| 165 | |
| 166 WebInspector.CallStackSidebarPane.prototype.__proto__ = WebInspector.SidebarPane
.prototype; | |
| OLD | NEW |