2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2011 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
29 * @extends {WebInspector.SidebarPane}
31 WebInspector.ScopeChainSidebarPane = function()
33 WebInspector.SidebarPane.call(this, WebInspector.UIString("Scope Variables"));
35 this._expandedSections = {};
36 this._expandedProperties = [];
39 WebInspector.ScopeChainSidebarPane.prototype = {
41 * @param {?WebInspector.DebuggerModel.CallFrame} callFrame
43 update: function(callFrame)
45 this.bodyElement.removeChildren();
48 var infoElement = createElement("div");
49 infoElement.className = "info";
50 infoElement.textContent = WebInspector.UIString("Not Paused");
51 this.bodyElement.appendChild(infoElement);
55 for (var i = 0; i < this._sections.length; ++i) {
56 var section = this._sections[i];
60 this._expandedSections[section.title] = true;
62 delete this._expandedSections[section.title];
67 var foundLocalScope = false;
68 var scopeChain = callFrame.scopeChain;
69 for (var i = 0; i < scopeChain.length; ++i) {
70 var scope = scopeChain[i];
72 var subtitle = scope.object.description;
73 var emptyPlaceholder = null;
74 var extraProperties = [];
78 case DebuggerAgent.ScopeType.Local:
79 foundLocalScope = true;
80 title = WebInspector.UIString("Local");
81 emptyPlaceholder = WebInspector.UIString("No Variables");
83 var thisObject = callFrame.thisObject();
85 extraProperties.push(new WebInspector.RemoteObjectProperty("this", thisObject));
87 var details = callFrame.target().debuggerModel.debuggerPausedDetails();
88 if (!callFrame.isAsync()) {
89 var exception = details.exception();
91 extraProperties.push(new WebInspector.RemoteObjectProperty("<exception>", exception));
93 var returnValue = callFrame.returnValue();
95 extraProperties.push(new WebInspector.RemoteObjectProperty("<return>", returnValue));
97 declarativeScope = true;
99 case DebuggerAgent.ScopeType.Closure:
100 title = WebInspector.UIString("Closure");
101 emptyPlaceholder = WebInspector.UIString("No Variables");
102 subtitle = undefined;
103 declarativeScope = true;
105 case DebuggerAgent.ScopeType.Catch:
106 title = WebInspector.UIString("Catch");
107 subtitle = undefined;
108 declarativeScope = true;
110 case DebuggerAgent.ScopeType.With:
111 title = WebInspector.UIString("With Block");
112 declarativeScope = false;
114 case DebuggerAgent.ScopeType.Global:
115 title = WebInspector.UIString("Global");
116 declarativeScope = false;
120 if (!title || title === subtitle)
121 subtitle = undefined;
123 var runtimeModel = callFrame.target().runtimeModel;
124 if (declarativeScope)
125 var scopeObject = runtimeModel.createScopeRemoteObject(scope.object, new WebInspector.ScopeRef(i, callFrame.id, undefined));
127 var scopeObject = runtimeModel.createRemoteObject(scope.object);
129 var section = new WebInspector.ObjectPropertiesSection(scopeObject, title, subtitle, emptyPlaceholder, true, extraProperties, WebInspector.ScopeVariableTreeElement);
130 section.editInSelectedCallFrameWhenPaused = true;
133 if (scope.type === DebuggerAgent.ScopeType.Global)
134 section.expanded = false;
135 else if (!foundLocalScope || scope.type === DebuggerAgent.ScopeType.Local || title in this._expandedSections)
136 section.expanded = true;
138 this._sections.push(section);
139 this.bodyElement.appendChild(section.element);
143 __proto__: WebInspector.SidebarPane.prototype
148 * @extends {WebInspector.ObjectPropertyTreeElement}
149 * @param {!WebInspector.RemoteObjectProperty} property
151 WebInspector.ScopeVariableTreeElement = function(property)
153 WebInspector.ObjectPropertyTreeElement.call(this, property);
156 WebInspector.ScopeVariableTreeElement.prototype = {
159 WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this);
160 if (this.hasChildren && this.propertyIdentifier in this.treeOutline.section.pane._expandedProperties)
166 this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier] = true;
169 oncollapse: function()
171 delete this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier];
174 get propertyIdentifier()
176 if ("_propertyIdentifier" in this)
177 return this._propertyIdentifier;
178 var section = this.treeOutline.section;
179 this._propertyIdentifier = section.title + ":" + (section.subtitle ? section.subtitle + ":" : "") + this.propertyPath();
180 return this._propertyIdentifier;
183 __proto__: WebInspector.ObjectPropertyTreeElement.prototype