OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 WebInspector.ScopeChainSidebarPane = function() | 26 WebInspector.ScopeChainSidebarPane = function() |
27 { | 27 { |
28 WebInspector.SidebarPane.call(this, WebInspector.UIString("Scope Variables")
); | 28 WebInspector.SidebarPane.call(this, WebInspector.UIString("Scope Variables")
); |
| 29 this._expandedProperties = []; |
29 } | 30 } |
30 | 31 |
31 WebInspector.ScopeChainSidebarPane.prototype = { | 32 WebInspector.ScopeChainSidebarPane.prototype = { |
32 update: function(callFrame) | 33 update: function(callFrame) |
33 { | 34 { |
34 this.bodyElement.removeChildren(); | 35 this.bodyElement.removeChildren(); |
35 | 36 |
36 this.sections = []; | 37 this.sections = []; |
37 this.callFrame = callFrame; | 38 this.callFrame = callFrame; |
38 | 39 |
39 if (!callFrame) { | 40 if (!callFrame) { |
40 var infoElement = document.createElement("div"); | 41 var infoElement = document.createElement("div"); |
41 infoElement.className = "info"; | 42 infoElement.className = "info"; |
42 infoElement.textContent = WebInspector.UIString("Not Paused"); | 43 infoElement.textContent = WebInspector.UIString("Not Paused"); |
43 this.bodyElement.appendChild(infoElement); | 44 this.bodyElement.appendChild(infoElement); |
44 return; | 45 return; |
45 } | 46 } |
46 | 47 |
47 if (!callFrame._expandedProperties) { | |
48 // FIXME: fix this when https://bugs.webkit.org/show_bug.cgi?id=1941
0 is fixed. | |
49 // The callFrame is a JSInspectedObjectWrapper, so we are not allowe
d to assign | |
50 // an object created in the Inspector's context to that object. So c
reate an | |
51 // Object from the inspectedWindow. | |
52 var inspectedWindow = InspectorController.inspectedWindow(); | |
53 callFrame._expandedProperties = new inspectedWindow.Object; | |
54 } | |
55 | |
56 var foundLocalScope = false; | 48 var foundLocalScope = false; |
57 var scopeChain = callFrame.scopeChain; | 49 var scopeChain = callFrame.scopeChain; |
58 for (var i = 0; i < scopeChain.length; ++i) { | 50 for (var i = 0; i < scopeChain.length; ++i) { |
59 var scopeObject = scopeChain[i]; | 51 var scopeObjectProxy = scopeChain[i]; |
60 var title = null; | 52 var title = null; |
61 var subtitle = Object.describe(scopeObject, true); | 53 var subtitle = scopeObjectProxy.description; |
62 var emptyPlaceholder = null; | 54 var emptyPlaceholder = null; |
63 var localScope = false; | |
64 var extraProperties = null; | 55 var extraProperties = null; |
65 | 56 |
66 if (Object.prototype.toString.call(scopeObject) === "[object JSActiv
ation]") { | 57 if (scopeObjectProxy.isLocal) { |
67 if (!foundLocalScope) { | 58 if (scopeObjectProxy.thisObject) { |
68 extraProperties = { "this": callFrame.thisObject }; | 59 extraProperties = [ new WebInspector.ObjectPropertyProxy("th
is", scopeObjectProxy.thisObject) ]; |
69 title = WebInspector.UIString("Local"); | 60 title = WebInspector.UIString("Local"); |
70 } else | 61 } else |
71 title = WebInspector.UIString("Closure"); | 62 title = WebInspector.UIString("Closure"); |
72 emptyPlaceholder = WebInspector.UIString("No Variables"); | 63 emptyPlaceholder = WebInspector.UIString("No Variables"); |
73 subtitle = null; | 64 subtitle = null; |
74 foundLocalScope = true; | 65 foundLocalScope = true; |
75 localScope = true; | |
76 } else if (i === (scopeChain.length - 1)) | 66 } else if (i === (scopeChain.length - 1)) |
77 title = WebInspector.UIString("Global"); | 67 title = WebInspector.UIString("Global"); |
78 else if (foundLocalScope && scopeObject instanceof InspectorControll
er.inspectedWindow().Element) | 68 else if (scopeObjectProxy.isElement) |
79 title = WebInspector.UIString("Event Target"); | 69 title = WebInspector.UIString("Event Target"); |
80 else if (foundLocalScope && scopeObject instanceof InspectorControll
er.inspectedWindow().Document) | 70 else if (scopeObjectProxy.isDocument) |
81 title = WebInspector.UIString("Event Document"); | 71 title = WebInspector.UIString("Event Document"); |
82 else if (!foundLocalScope && !localScope) | 72 else if (scopeObjectProxy.isWithBlock) |
83 title = WebInspector.UIString("With Block"); | 73 title = WebInspector.UIString("With Block"); |
84 | 74 |
85 if (!title || title === subtitle) | 75 if (!title || title === subtitle) |
86 subtitle = null; | 76 subtitle = null; |
87 | 77 |
88 var section = new WebInspector.ObjectPropertiesSection(scopeObject,
title, subtitle, emptyPlaceholder, true, extraProperties, WebInspector.ScopeVari
ableTreeElement); | 78 var section = new WebInspector.ObjectPropertiesSection(scopeObjectPr
oxy, title, subtitle, emptyPlaceholder, true, extraProperties, WebInspector.Scop
eVariableTreeElement); |
89 section.editInSelectedCallFrameWhenPaused = true; | 79 section.editInSelectedCallFrameWhenPaused = true; |
90 section.pane = this; | 80 section.pane = this; |
91 | 81 |
92 if (!foundLocalScope || localScope) | 82 if (!foundLocalScope || scopeObjectProxy.isLocal) |
93 section.expanded = true; | 83 section.expanded = true; |
94 | 84 |
95 this.sections.push(section); | 85 this.sections.push(section); |
96 this.bodyElement.appendChild(section.element); | 86 this.bodyElement.appendChild(section.element); |
97 } | 87 } |
98 } | 88 } |
99 } | 89 } |
100 | 90 |
101 WebInspector.ScopeChainSidebarPane.prototype.__proto__ = WebInspector.SidebarPan
e.prototype; | 91 WebInspector.ScopeChainSidebarPane.prototype.__proto__ = WebInspector.SidebarPan
e.prototype; |
102 | 92 |
103 WebInspector.ScopeVariableTreeElement = function(parentObject, propertyName) | 93 WebInspector.ScopeVariableTreeElement = function(property) |
104 { | 94 { |
105 WebInspector.ObjectPropertyTreeElement.call(this, parentObject, propertyName
); | 95 WebInspector.ObjectPropertyTreeElement.call(this, property); |
106 } | 96 } |
107 | 97 |
108 WebInspector.ScopeVariableTreeElement.prototype = { | 98 WebInspector.ScopeVariableTreeElement.prototype = { |
109 onattach: function() | 99 onattach: function() |
110 { | 100 { |
111 WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this); | 101 WebInspector.ObjectPropertyTreeElement.prototype.onattach.call(this); |
112 if (this.hasChildren && this.propertyIdentifier in this.treeOutline.sect
ion.pane.callFrame._expandedProperties) | 102 if (this.hasChildren && this.propertyIdentifier in this.treeOutline.sect
ion.pane._expandedProperties) |
113 this.expand(); | 103 this.expand(); |
114 }, | 104 }, |
115 | 105 |
116 onexpand: function() | 106 onexpand: function() |
117 { | 107 { |
118 this.treeOutline.section.pane.callFrame._expandedProperties[this.propert
yIdentifier] = true; | 108 this.treeOutline.section.pane._expandedProperties[this.propertyIdentifie
r] = true; |
119 }, | 109 }, |
120 | 110 |
121 oncollapse: function() | 111 oncollapse: function() |
122 { | 112 { |
123 delete this.treeOutline.section.pane.callFrame._expandedProperties[this.
propertyIdentifier]; | 113 delete this.treeOutline.section.pane._expandedProperties[this.propertyId
entifier]; |
124 }, | 114 }, |
125 | 115 |
126 get propertyIdentifier() | 116 get propertyIdentifier() |
127 { | 117 { |
128 if ("_propertyIdentifier" in this) | 118 if ("_propertyIdentifier" in this) |
129 return this._propertyIdentifier; | 119 return this._propertyIdentifier; |
130 var section = this.treeOutline.section; | 120 var section = this.treeOutline.section; |
131 this._propertyIdentifier = section.title + ":" + (section.subtitle ? sec
tion.subtitle + ":" : "") + this.propertyPath; | 121 this._propertyIdentifier = section.title + ":" + (section.subtitle ? sec
tion.subtitle + ":" : "") + this.propertyPath; |
132 return this._propertyIdentifier; | 122 return this._propertyIdentifier; |
133 }, | 123 }, |
134 | 124 |
135 get propertyPath() | 125 get propertyPath() |
136 { | 126 { |
137 if ("_propertyPath" in this) | 127 if ("_propertyPath" in this) |
138 return this._propertyPath; | 128 return this._propertyPath; |
139 | 129 |
140 var current = this; | 130 var current = this; |
141 var result; | 131 var result; |
142 | 132 |
143 do { | 133 do { |
144 if (result) | 134 if (result) |
145 result = current.propertyName + "." + result; | 135 result = current.property.name + "." + result; |
146 else | 136 else |
147 result = current.propertyName; | 137 result = current.property.name; |
148 current = current.parent; | 138 current = current.parent; |
149 } while (current && !current.root); | 139 } while (current && !current.root); |
150 | 140 |
151 this._propertyPath = result; | 141 this._propertyPath = result; |
152 return result; | 142 return result; |
153 } | 143 } |
154 } | 144 } |
155 | 145 |
156 WebInspector.ScopeVariableTreeElement.prototype.__proto__ = WebInspector.ObjectP
ropertyTreeElement.prototype; | 146 WebInspector.ScopeVariableTreeElement.prototype.__proto__ = WebInspector.ObjectP
ropertyTreeElement.prototype; |
OLD | NEW |