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 exception = WebInspector.debuggerModel.debuggerPausedDetails.exception;
80 extraProperties = extraProperties || [];
81 extraProperties.push(new WebInspector.RemoteObjectProperty("<exception>", WebInspector.RemoteObject.fromPayload(exception)));
86 title = WebInspector.UIString("Closure");
87 emptyPlaceholder = WebInspector.UIString("No Variables");
91 title = WebInspector.UIString("Catch");
94 title = WebInspector.UIString("With Block");
97 title = WebInspector.UIString("Global");
101 if (!title || title === subtitle)
104 var section = new WebInspector.ObjectPropertiesSection(WebInspector.RemoteObject.fromPayload(scope.object), title, subtitle, emptyPlaceholder, true, extraProperties, WebInspector.ScopeVariableTreeElement);
105 section.editInSelectedCallFrameWhenPaused = true;
108 if (!foundLocalScope || scope.type === "local" || title in this._expandedSections)
109 section.expanded = true;
111 this._sections.push(section);
112 this.bodyElement.appendChild(section.element);
117 WebInspector.ScopeChainSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;
119 WebInspector.ScopeVariableTreeElement = function(property)
121 WebInspector.ObjectPropertyTreeElement.call(this, property);
124 WebInspector.ScopeVariableTreeElement.prototype = {
127 WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this);
128 if (this.hasChildren && this.propertyIdentifier in this.treeOutline.section.pane._expandedProperties)
134 this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier] = true;
137 oncollapse: function()
139 delete this.treeOutline.section.pane._expandedProperties[this.propertyIdentifier];
142 get propertyIdentifier()
144 if ("_propertyIdentifier" in this)
145 return this._propertyIdentifier;
146 var section = this.treeOutline.section;
147 this._propertyIdentifier = section.title + ":" + (section.subtitle ? section.subtitle + ":" : "") + this.propertyPath;
148 return this._propertyIdentifier;
153 if ("_propertyPath" in this)
154 return this._propertyPath;
161 result = current.property.name + "." + result;
163 result = current.property.name;
164 current = current.parent;
165 } while (current && !current.root);
167 this._propertyPath = result;
172 WebInspector.ScopeVariableTreeElement.prototype.__proto__ = WebInspector.ObjectPropertyTreeElement.prototype;