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.
27 WebInspector.ScopeChainSidebarPane = function()
29 WebInspector.SidebarPane.call(this, WebInspector.UIString("Scope Variables"));
31 this._expandedSections = {};
32 this._expandedProperties = [];
35 WebInspector.ScopeChainSidebarPane.prototype = {
36 update: function(callFrame)
38 this.bodyElement.removeChildren();
41 var infoElement = document.createElement("div");
42 infoElement.className = "info";
43 infoElement.textContent = WebInspector.UIString("Not Paused");
44 this.bodyElement.appendChild(infoElement);
48 for (var i = 0; i < this._sections.length; ++i) {
49 var section = this._sections[i];
53 this._expandedSections[section.title] = true;
55 delete this._expandedSections[section.title];
60 var foundLocalScope = false;
61 var scopeChain = callFrame.scopeChain;
62 for (var i = 0; i < scopeChain.length; ++i) {
63 var scope = scopeChain[i];
65 var subtitle = scope.object.description;
66 var emptyPlaceholder = null;
67 var extraProperties = null;
71 foundLocalScope = true;
72 title = WebInspector.UIString("Local");
73 emptyPlaceholder = WebInspector.UIString("No Variables");
76 extraProperties = [ new WebInspector.RemoteObjectProperty("this", WebInspector.RemoteObject.fromPayload(callFrame.this)) ];
78 var details = WebInspector.debuggerModel.debuggerPausedDetails;
79 var exception = details.reason === WebInspector.ScriptsPanel.BreakReason.Exception ? details.auxData : 0;
81 extraProperties = extraProperties || [];
82 extraProperties.push(new WebInspector.RemoteObjectProperty("<exception>", WebInspector.RemoteObject.fromPayload(exception)));
87 title = WebInspector.UIString("Closure");
88 emptyPlaceholder = WebInspector.UIString("No Variables");
92 title = WebInspector.UIString("Catch");
95 title = WebInspector.UIString("With Block");
98 title = WebInspector.UIString("Global");
102 if (!title || title === subtitle)
105 var section = new WebInspector.ObjectPropertiesSection(WebInspector.RemoteObject.fromPayload(scope.object), title, subtitle, emptyPlaceholder, true, extraProperties, WebInspector.ScopeVariableTreeElement);
106 section.editInSelectedCallFrameWhenPaused = true;
109 if (!foundLocalScope || scope.type === "local" || title in this._expandedSections)
110 section.expanded = true;
112 this._sections.push(section);
113 this.bodyElement.appendChild(section.element);
118 WebInspector.ScopeChainSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
120 WebInspector.ScopeVariableTreeElement = function(property)
122 WebInspector.ObjectPropertyTreeElement.call(this, property);
125 WebInspector.ScopeVariableTreeElement.prototype = {
128 WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this);
129 if (this.hasChildren && this.propertyIdentifier in this.treeOutline.section.pane._expandedProperties)
135 this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier] = true;
138 oncollapse: function()
140 delete this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier];
143 get propertyIdentifier()
145 if ("_propertyIdentifier" in this)
146 return this._propertyIdentifier;
147 var section = this.treeOutline.section;
148 this._propertyIdentifier = section.title + ":" + (section.subtitle ? section.subtitle + ":" : "") + this.propertyPath;
149 return this._propertyIdentifier;
154 if ("_propertyPath" in this)
155 return this._propertyPath;
162 result = current.property.name + "." + result;
164 result = current.property.name;
165 current = current.parent;
166 } while (current && !current.root);
168 this._propertyPath = result;
173 WebInspector.ScopeVariableTreeElement.prototype.__proto__ = WebInspector.ObjectPropertyTreeElement.prototype;