| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | |
| 27 /** | 26 /** |
| 28 * @constructor | |
| 29 * @extends {WebInspector.VBox} | |
| 30 * @implements {WebInspector.ContextFlavorListener} | 27 * @implements {WebInspector.ContextFlavorListener} |
| 28 * @unrestricted |
| 31 */ | 29 */ |
| 32 WebInspector.ScopeChainSidebarPane = function() | 30 WebInspector.ScopeChainSidebarPane = class extends WebInspector.VBox { |
| 33 { | 31 constructor() { |
| 34 WebInspector.VBox.call(this); | 32 super(); |
| 35 this._expandController = new WebInspector.ObjectPropertiesSectionExpandContr
oller(); | 33 this._expandController = new WebInspector.ObjectPropertiesSectionExpandContr
oller(); |
| 36 this._linkifier = new WebInspector.Linkifier(); | 34 this._linkifier = new WebInspector.Linkifier(); |
| 37 this._update(); | 35 this._update(); |
| 36 } |
| 37 |
| 38 /** |
| 39 * @override |
| 40 * @param {?Object} object |
| 41 */ |
| 42 flavorChanged(object) { |
| 43 this._update(); |
| 44 } |
| 45 |
| 46 _update() { |
| 47 var callFrame = WebInspector.context.flavor(WebInspector.DebuggerModel.CallF
rame); |
| 48 var details = WebInspector.context.flavor(WebInspector.DebuggerPausedDetails
); |
| 49 this._linkifier.reset(); |
| 50 WebInspector.SourceMapNamesResolver.resolveThisObject(callFrame).then( |
| 51 this._innerUpdate.bind(this, details, callFrame)); |
| 52 } |
| 53 |
| 54 /** |
| 55 * @param {?WebInspector.DebuggerPausedDetails} details |
| 56 * @param {?WebInspector.DebuggerModel.CallFrame} callFrame |
| 57 * @param {?WebInspector.RemoteObject} thisObject |
| 58 */ |
| 59 _innerUpdate(details, callFrame, thisObject) { |
| 60 this.element.removeChildren(); |
| 61 |
| 62 if (!details || !callFrame) { |
| 63 var infoElement = createElement('div'); |
| 64 infoElement.className = 'gray-info-message'; |
| 65 infoElement.textContent = WebInspector.UIString('Not Paused'); |
| 66 this.element.appendChild(infoElement); |
| 67 return; |
| 68 } |
| 69 |
| 70 var foundLocalScope = false; |
| 71 var scopeChain = callFrame.scopeChain(); |
| 72 for (var i = 0; i < scopeChain.length; ++i) { |
| 73 var scope = scopeChain[i]; |
| 74 var title = null; |
| 75 var emptyPlaceholder = null; |
| 76 var extraProperties = []; |
| 77 |
| 78 switch (scope.type()) { |
| 79 case DebuggerAgent.ScopeType.Local: |
| 80 foundLocalScope = true; |
| 81 title = WebInspector.UIString('Local'); |
| 82 emptyPlaceholder = WebInspector.UIString('No Variables'); |
| 83 if (thisObject) |
| 84 extraProperties.push(new WebInspector.RemoteObjectProperty('this', t
hisObject)); |
| 85 if (i === 0) { |
| 86 var exception = details.exception(); |
| 87 if (exception) |
| 88 extraProperties.push(new WebInspector.RemoteObjectProperty( |
| 89 WebInspector.UIString.capitalize('Exception'), exception, unde
fined, undefined, undefined, undefined, |
| 90 undefined, true)); |
| 91 var returnValue = callFrame.returnValue(); |
| 92 if (returnValue) |
| 93 extraProperties.push(new WebInspector.RemoteObjectProperty( |
| 94 WebInspector.UIString.capitalize('Return ^value'), returnValue
, undefined, undefined, undefined, |
| 95 undefined, undefined, true)); |
| 96 } |
| 97 break; |
| 98 case DebuggerAgent.ScopeType.Closure: |
| 99 var scopeName = scope.name(); |
| 100 if (scopeName) |
| 101 title = WebInspector.UIString('Closure (%s)', WebInspector.beautifyF
unctionName(scopeName)); |
| 102 else |
| 103 title = WebInspector.UIString('Closure'); |
| 104 emptyPlaceholder = WebInspector.UIString('No Variables'); |
| 105 break; |
| 106 case DebuggerAgent.ScopeType.Catch: |
| 107 title = WebInspector.UIString('Catch'); |
| 108 break; |
| 109 case DebuggerAgent.ScopeType.Block: |
| 110 title = WebInspector.UIString('Block'); |
| 111 break; |
| 112 case DebuggerAgent.ScopeType.Script: |
| 113 title = WebInspector.UIString('Script'); |
| 114 break; |
| 115 case DebuggerAgent.ScopeType.With: |
| 116 title = WebInspector.UIString('With Block'); |
| 117 break; |
| 118 case DebuggerAgent.ScopeType.Global: |
| 119 title = WebInspector.UIString('Global'); |
| 120 break; |
| 121 } |
| 122 |
| 123 var subtitle = scope.description(); |
| 124 if (!title || title === subtitle) |
| 125 subtitle = undefined; |
| 126 |
| 127 var titleElement = createElementWithClass('div', 'scope-chain-sidebar-pane
-section-header'); |
| 128 titleElement.createChild('div', 'scope-chain-sidebar-pane-section-subtitle
').textContent = subtitle; |
| 129 titleElement.createChild('div', 'scope-chain-sidebar-pane-section-title').
textContent = title; |
| 130 |
| 131 var section = new WebInspector.ObjectPropertiesSection( |
| 132 WebInspector.SourceMapNamesResolver.resolveScopeInObject(scope), title
Element, this._linkifier, |
| 133 emptyPlaceholder, true, extraProperties); |
| 134 this._expandController.watchSection(title + (subtitle ? ':' + subtitle : '
'), section); |
| 135 |
| 136 if (scope.type() === DebuggerAgent.ScopeType.Global) |
| 137 section.objectTreeElement().collapse(); |
| 138 else if (!foundLocalScope || scope.type() === DebuggerAgent.ScopeType.Loca
l) |
| 139 section.objectTreeElement().expand(); |
| 140 |
| 141 section.element.classList.add('scope-chain-sidebar-pane-section'); |
| 142 this.element.appendChild(section.element); |
| 143 } |
| 144 this._sidebarPaneUpdatedForTest(); |
| 145 } |
| 146 |
| 147 _sidebarPaneUpdatedForTest() { |
| 148 } |
| 38 }; | 149 }; |
| 39 | 150 |
| 40 WebInspector.ScopeChainSidebarPane._pathSymbol = Symbol("path"); | 151 WebInspector.ScopeChainSidebarPane._pathSymbol = Symbol('path'); |
| 41 | |
| 42 WebInspector.ScopeChainSidebarPane.prototype = { | |
| 43 /** | |
| 44 * @override | |
| 45 * @param {?Object} object | |
| 46 */ | |
| 47 flavorChanged: function(object) | |
| 48 { | |
| 49 this._update(); | |
| 50 }, | |
| 51 | |
| 52 _update: function() | |
| 53 { | |
| 54 var callFrame = WebInspector.context.flavor(WebInspector.DebuggerModel.C
allFrame); | |
| 55 var details = WebInspector.context.flavor(WebInspector.DebuggerPausedDet
ails); | |
| 56 this._linkifier.reset(); | |
| 57 WebInspector.SourceMapNamesResolver.resolveThisObject(callFrame) | |
| 58 .then(this._innerUpdate.bind(this, details, callFrame)); | |
| 59 }, | |
| 60 | |
| 61 /** | |
| 62 * @param {?WebInspector.DebuggerPausedDetails} details | |
| 63 * @param {?WebInspector.DebuggerModel.CallFrame} callFrame | |
| 64 * @param {?WebInspector.RemoteObject} thisObject | |
| 65 */ | |
| 66 _innerUpdate: function(details, callFrame, thisObject) | |
| 67 { | |
| 68 this.element.removeChildren(); | |
| 69 | |
| 70 if (!details || !callFrame) { | |
| 71 var infoElement = createElement("div"); | |
| 72 infoElement.className = "gray-info-message"; | |
| 73 infoElement.textContent = WebInspector.UIString("Not Paused"); | |
| 74 this.element.appendChild(infoElement); | |
| 75 return; | |
| 76 } | |
| 77 | |
| 78 var foundLocalScope = false; | |
| 79 var scopeChain = callFrame.scopeChain(); | |
| 80 for (var i = 0; i < scopeChain.length; ++i) { | |
| 81 var scope = scopeChain[i]; | |
| 82 var title = null; | |
| 83 var emptyPlaceholder = null; | |
| 84 var extraProperties = []; | |
| 85 | |
| 86 switch (scope.type()) { | |
| 87 case DebuggerAgent.ScopeType.Local: | |
| 88 foundLocalScope = true; | |
| 89 title = WebInspector.UIString("Local"); | |
| 90 emptyPlaceholder = WebInspector.UIString("No Variables"); | |
| 91 if (thisObject) | |
| 92 extraProperties.push(new WebInspector.RemoteObjectProperty("
this", thisObject)); | |
| 93 if (i === 0) { | |
| 94 var exception = details.exception(); | |
| 95 if (exception) | |
| 96 extraProperties.push(new WebInspector.RemoteObjectProper
ty(WebInspector.UIString.capitalize("Exception"), exception, undefined, undefine
d, undefined, undefined, undefined, true)); | |
| 97 var returnValue = callFrame.returnValue(); | |
| 98 if (returnValue) | |
| 99 extraProperties.push(new WebInspector.RemoteObjectProper
ty(WebInspector.UIString.capitalize("Return ^value"), returnValue, undefined, un
defined, undefined, undefined, undefined, true)); | |
| 100 } | |
| 101 break; | |
| 102 case DebuggerAgent.ScopeType.Closure: | |
| 103 var scopeName = scope.name(); | |
| 104 if (scopeName) | |
| 105 title = WebInspector.UIString("Closure (%s)", WebInspector.b
eautifyFunctionName(scopeName)); | |
| 106 else | |
| 107 title = WebInspector.UIString("Closure"); | |
| 108 emptyPlaceholder = WebInspector.UIString("No Variables"); | |
| 109 break; | |
| 110 case DebuggerAgent.ScopeType.Catch: | |
| 111 title = WebInspector.UIString("Catch"); | |
| 112 break; | |
| 113 case DebuggerAgent.ScopeType.Block: | |
| 114 title = WebInspector.UIString("Block"); | |
| 115 break; | |
| 116 case DebuggerAgent.ScopeType.Script: | |
| 117 title = WebInspector.UIString("Script"); | |
| 118 break; | |
| 119 case DebuggerAgent.ScopeType.With: | |
| 120 title = WebInspector.UIString("With Block"); | |
| 121 break; | |
| 122 case DebuggerAgent.ScopeType.Global: | |
| 123 title = WebInspector.UIString("Global"); | |
| 124 break; | |
| 125 } | |
| 126 | |
| 127 var subtitle = scope.description(); | |
| 128 if (!title || title === subtitle) | |
| 129 subtitle = undefined; | |
| 130 | |
| 131 var titleElement = createElementWithClass("div", "scope-chain-sideba
r-pane-section-header"); | |
| 132 titleElement.createChild("div", "scope-chain-sidebar-pane-section-su
btitle").textContent = subtitle; | |
| 133 titleElement.createChild("div", "scope-chain-sidebar-pane-section-ti
tle").textContent = title; | |
| 134 | |
| 135 var section = new WebInspector.ObjectPropertiesSection(WebInspector.
SourceMapNamesResolver.resolveScopeInObject(scope), titleElement, this._linkifie
r, emptyPlaceholder, true, extraProperties); | |
| 136 this._expandController.watchSection(title + (subtitle ? ":" + subtit
le : ""), section); | |
| 137 | |
| 138 if (scope.type() === DebuggerAgent.ScopeType.Global) | |
| 139 section.objectTreeElement().collapse(); | |
| 140 else if (!foundLocalScope || scope.type() === DebuggerAgent.ScopeTyp
e.Local) | |
| 141 section.objectTreeElement().expand(); | |
| 142 | |
| 143 section.element.classList.add("scope-chain-sidebar-pane-section"); | |
| 144 this.element.appendChild(section.element); | |
| 145 } | |
| 146 this._sidebarPaneUpdatedForTest(); | |
| 147 }, | |
| 148 | |
| 149 _sidebarPaneUpdatedForTest: function() { }, | |
| 150 | |
| 151 __proto__: WebInspector.VBox.prototype | |
| 152 }; | |
| OLD | NEW |