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) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
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 |
(...skipping 16 matching lines...) Expand all Loading... | |
27 /** | 27 /** |
28 * @constructor | 28 * @constructor |
29 * @extends {WebInspector.Section} | 29 * @extends {WebInspector.Section} |
30 * @param {!WebInspector.RemoteObject} object | 30 * @param {!WebInspector.RemoteObject} object |
31 * @param {?string|!Element=} title | 31 * @param {?string|!Element=} title |
32 * @param {string=} subtitle | 32 * @param {string=} subtitle |
33 * @param {?string=} emptyPlaceholder | 33 * @param {?string=} emptyPlaceholder |
34 * @param {boolean=} ignoreHasOwnProperty | 34 * @param {boolean=} ignoreHasOwnProperty |
35 * @param {!Array.<!WebInspector.RemoteObjectProperty>=} extraProperties | 35 * @param {!Array.<!WebInspector.RemoteObjectProperty>=} extraProperties |
36 * @param {function(new:TreeElement, !WebInspector.RemoteObjectProperty)=} treeE lementConstructor | 36 * @param {function(new:TreeElement, !WebInspector.RemoteObjectProperty)=} treeE lementConstructor |
37 * @param {?WebInspector.SidebarPane=} sidebarPane | |
37 */ | 38 */ |
38 WebInspector.ObjectPropertiesSection = function(object, title, subtitle, emptyPl aceholder, ignoreHasOwnProperty, extraProperties, treeElementConstructor) | 39 WebInspector.ObjectPropertiesSection = function(object, title, subtitle, emptyPl aceholder, ignoreHasOwnProperty, extraProperties, treeElementConstructor, sideba rPane) |
39 { | 40 { |
40 this._emptyPlaceholder = emptyPlaceholder; | 41 this._emptyPlaceholder = emptyPlaceholder; |
41 this.object = object; | 42 this.object = object; |
42 this.ignoreHasOwnProperty = ignoreHasOwnProperty; | 43 this.ignoreHasOwnProperty = ignoreHasOwnProperty; |
43 this.extraProperties = extraProperties; | 44 this.extraProperties = extraProperties; |
44 this.treeElementConstructor = treeElementConstructor || WebInspector.ObjectP ropertyTreeElement; | 45 this.treeElementConstructor = treeElementConstructor || WebInspector.ObjectP ropertyTreeElement; |
45 this.editable = true; | 46 this.editable = true; |
46 this.skipProto = false; | 47 this.skipProto = false; |
48 this.pane = sidebarPane; | |
aandrey
2015/01/20 05:05:01
Should not depend on SidebarPane, should not have
| |
47 | 49 |
48 WebInspector.Section.call(this, title || "", subtitle); | 50 WebInspector.Section.call(this, title || "", subtitle); |
49 } | 51 } |
50 | 52 |
51 /** @const */ | 53 /** @const */ |
52 WebInspector.ObjectPropertiesSection._arrayLoadThreshold = 100; | 54 WebInspector.ObjectPropertiesSection._arrayLoadThreshold = 100; |
53 | 55 |
54 WebInspector.ObjectPropertiesSection.prototype = { | 56 WebInspector.ObjectPropertiesSection.prototype = { |
55 enableContextMenu: function() | 57 enableContextMenu: function() |
56 { | 58 { |
(...skipping 30 matching lines...) Expand all Loading... | |
87 if (!properties) | 89 if (!properties) |
88 return; | 90 return; |
89 this.updateProperties(properties, internalProperties); | 91 this.updateProperties(properties, internalProperties); |
90 } | 92 } |
91 | 93 |
92 WebInspector.RemoteObject.loadFromObject(this.object, !!this.ignoreHasOw nProperty, callback.bind(this)); | 94 WebInspector.RemoteObject.loadFromObject(this.object, !!this.ignoreHasOw nProperty, callback.bind(this)); |
93 }, | 95 }, |
94 | 96 |
95 updateProperties: function(properties, internalProperties, rootTreeElementCo nstructor, rootPropertyComparer) | 97 updateProperties: function(properties, internalProperties, rootTreeElementCo nstructor, rootPropertyComparer) |
96 { | 98 { |
99 // Delete the cached last descriptions of all propertyIdentifiers | |
100 // did were not preset when the debugee was suspended last time | |
101 if (this.pane && this.pane._lastDescriptions && this.pane._propertyIdent ifiers) | |
102 for (var pi in this.pane._lastDescriptions) { | |
103 if (!(pi in this.pane._propertyIdentifiers)) | |
104 // Delete the properties that no longer exist | |
105 delete this.pane._lastDescriptions[pi]; | |
106 } | |
107 | |
108 // start with empty propertyIdentifiers cache | |
109 // this will get populated as the tree elemnts are | |
110 // shown | |
111 if (this.pane) | |
112 this.pane._propertyIdentifiers = {}; | |
aandrey
2015/01/20 05:05:01
this is a no-go
| |
113 | |
97 if (!rootTreeElementConstructor) | 114 if (!rootTreeElementConstructor) |
98 rootTreeElementConstructor = this.treeElementConstructor; | 115 rootTreeElementConstructor = this.treeElementConstructor; |
99 | 116 |
100 if (!rootPropertyComparer) | 117 if (!rootPropertyComparer) |
101 rootPropertyComparer = WebInspector.ObjectPropertiesSection.CompareP roperties; | 118 rootPropertyComparer = WebInspector.ObjectPropertiesSection.CompareP roperties; |
102 | 119 |
103 if (this.extraProperties) { | 120 if (this.extraProperties) { |
104 for (var i = 0; i < this.extraProperties.length; ++i) | 121 for (var i = 0; i < this.extraProperties.length; ++i) |
105 properties.push(this.extraProperties[i]); | 122 properties.push(this.extraProperties[i]); |
106 } | 123 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 if ((this.property.writable || this.property.setter) && event.target.isS elfOrDescendant(editableElement)) | 188 if ((this.property.writable || this.property.setter) && event.target.isS elfOrDescendant(editableElement)) |
172 this.startEditing(event); | 189 this.startEditing(event); |
173 return false; | 190 return false; |
174 }, | 191 }, |
175 | 192 |
176 /** | 193 /** |
177 * @override | 194 * @override |
178 */ | 195 */ |
179 onattach: function() | 196 onattach: function() |
180 { | 197 { |
198 // record the propertyIdentifier | |
199 if (this.treeOutline.section.pane && this.propertyPath() && this.treeOut line.section.pane._propertyIdentifiers) | |
200 this.treeOutline.section.pane._propertyIdentifiers[this.propertyPath ()] = 1; | |
201 | |
181 this.update(); | 202 this.update(); |
182 }, | 203 }, |
183 | 204 |
184 update: function() | 205 update: function() |
185 { | 206 { |
186 this.nameElement = createElementWithClass("span", "name"); | 207 this.nameElement = createElementWithClass("span", "name"); |
187 var name = this.property.name; | 208 var name = this.property.name; |
188 if (/^\s|\s$|^$|\n/.test(name)) | 209 if (/^\s|\s$|^$|\n/.test(name)) |
189 this.nameElement.createTextChildren("\"", name.replace(/\n/g, "\u21B 5"), "\""); | 210 this.nameElement.createTextChildren("\"", name.replace(/\n/g, "\u21B 5"), "\""); |
190 else | 211 else |
191 this.nameElement.textContent = name; | 212 this.nameElement.textContent = name; |
192 if (!this.property.enumerable) | 213 if (!this.property.enumerable) |
193 this.nameElement.classList.add("dimmed"); | 214 this.nameElement.classList.add("dimmed"); |
194 if (this.property.isAccessorProperty()) | 215 if (this.property.isAccessorProperty()) |
195 this.nameElement.classList.add("properties-accessor-property-name"); | 216 this.nameElement.classList.add("properties-accessor-property-name"); |
196 if (this.property.symbol) | 217 if (this.property.symbol) |
197 this.nameElement.addEventListener("contextmenu", this._contextMenuFi red.bind(this, this.property.symbol), false); | 218 this.nameElement.addEventListener("contextmenu", this._contextMenuFi red.bind(this, this.property.symbol), false); |
198 | 219 |
199 var separatorElement = createElementWithClass("span", "separator"); | 220 var separatorElement = createElementWithClass("span", "separator"); |
200 separatorElement.textContent = ": "; | 221 separatorElement.textContent = ": "; |
201 | 222 |
202 if (this.property.value) { | 223 if (this.property.value) { |
203 this.valueElement = createElementWithClass("span", "value"); | 224 this.valueElement = createElementWithClass("span", "value"); |
204 var type = this.property.value.type; | 225 var type = this.property.value.type; |
205 var subtype = this.property.value.subtype; | 226 var subtype = this.property.value.subtype; |
227 | |
228 if (this.treeOutline.section && this.treeOutline.section.pane) { | |
229 // detect if the propertyIdentifier was shown when the debugee w as suspended last time | |
230 var hadProperty = true; | |
231 if (this.propertyPath()) | |
232 // not a first suspension | |
233 if (this.treeOutline.section.pane._lastDescriptions) | |
234 hadProperty = (this.treeOutline.section.pane._lastDescri ptions[this.propertyPath()] != undefined); | |
235 else { | |
236 // first suspension | |
237 this.treeOutline.section.pane._lastDescriptions = {}; | |
238 hadProperty = false; | |
239 } | |
240 | |
241 var oldDescription; | |
242 | |
243 if (this.propertyPath() && this.treeOutline.section.pane._lastDe scriptions) | |
244 // retrieve the description from last suspension | |
245 oldDescription = this.treeOutline.section.pane._lastDescript ions[this.propertyPath()]; | |
246 } | |
247 | |
206 var description = this.property.value.description; | 248 var description = this.property.value.description; |
249 | |
250 if (this.treeOutline.section && this.treeOutline.section.pane) { | |
251 var descriptionToCompare = (type + ":" + | |
252 (subtype? subtype : "") + ":" + /* (this.property.value.obje ctId ? this.property.value.objectId : "") + ":" + */ description); | |
253 // determine if it has it changed only if description is initial ized | |
254 // this handles the case when the variable came into scope but | |
255 // was not initialized | |
256 var descriptionChanged = false; | |
257 if (hadProperty) | |
258 descriptionChanged = (descriptionToCompare != oldDescription ); | |
259 else | |
260 descriptionChanged = true; | |
261 | |
262 if (this.propertyPath() && this.treeOutline.section.pane._lastDe scriptions) | |
263 this.treeOutline.section.pane._lastDescriptions[this.propert yPath()] = descriptionToCompare; | |
264 } | |
265 | |
207 var prefix; | 266 var prefix; |
208 var valueText; | 267 var valueText; |
209 var suffix; | 268 var suffix; |
210 if (this.property.wasThrown) { | 269 if (this.property.wasThrown) { |
211 prefix = "[Exception: "; | 270 prefix = "[Exception: "; |
212 valueText = description; | 271 valueText = description; |
213 suffix = "]"; | 272 suffix = "]"; |
214 } else if (type === "string" && typeof description === "string") { | 273 } else if (type === "string" && typeof description === "string") { |
215 // Render \n as a nice unicode cr symbol. | 274 // Render \n as a nice unicode cr symbol. |
216 prefix = "\""; | 275 prefix = "\""; |
(...skipping 16 matching lines...) Expand all Loading... | |
233 } else { | 292 } else { |
234 var numberParts = valueText.split("e"); | 293 var numberParts = valueText.split("e"); |
235 var mantissa = this.valueElement.createChild("span", "scientific -notation-mantissa"); | 294 var mantissa = this.valueElement.createChild("span", "scientific -notation-mantissa"); |
236 mantissa.textContent = numberParts[0]; | 295 mantissa.textContent = numberParts[0]; |
237 var exponent = this.valueElement.createChild("span", "scientific -notation-exponent"); | 296 var exponent = this.valueElement.createChild("span", "scientific -notation-exponent"); |
238 exponent.textContent = "e" + numberParts[1]; | 297 exponent.textContent = "e" + numberParts[1]; |
239 this.valueElement.classList.add("scientific-notation-number"); | 298 this.valueElement.classList.add("scientific-notation-number"); |
240 this.listItemElement.classList.add("hbox"); | 299 this.listItemElement.classList.add("hbox"); |
241 } | 300 } |
242 | 301 |
302 if (this.treeOutline.section && this.treeOutline.section.pane) { | |
303 if (descriptionChanged) { | |
304 this.valueElement.classList.add("highlighted-search-result") ; | |
305 if (!hadProperty) | |
306 // new - highlight name also | |
307 this.nameElement.classList.add("highlighted-search-resul t"); | |
308 } | |
309 } | |
310 | |
243 if (this.property.wasThrown) | 311 if (this.property.wasThrown) |
244 this.valueElement.classList.add("error"); | 312 this.valueElement.classList.add("error"); |
245 if (subtype || type) | 313 if (subtype || type) |
246 this.valueElement.classList.add("console-formatted-" + (subtype || type)); | 314 this.valueElement.classList.add("console-formatted-" + (subtype || type)); |
247 | 315 |
248 this.valueElement.addEventListener("contextmenu", this._contextMenuF ired.bind(this, this.property.value), false); | 316 this.valueElement.addEventListener("contextmenu", this._contextMenuF ired.bind(this, this.property.value), false); |
249 if (type === "object" && subtype === "node" && description) { | 317 if (type === "object" && subtype === "node" && description) { |
250 WebInspector.DOMPresentationUtils.createSpansForNodeTitle(this.v alueElement, description); | 318 WebInspector.DOMPresentationUtils.createSpansForNodeTitle(this.v alueElement, description); |
251 this.valueElement.addEventListener("mousemove", this._mouseMove. bind(this), false); | 319 this.valueElement.addEventListener("mousemove", this._mouseMove. bind(this), false); |
252 this.valueElement.addEventListener("mouseleave", this._mouseLeav e.bind(this), false); | 320 this.valueElement.addEventListener("mouseleave", this._mouseLeav e.bind(this), false); |
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1097 { | 1165 { |
1098 WebInspector.TextPrompt.call(this, WebInspector.ExecutionContextSelector.com pletionsForTextPromptInCurrentContext); | 1166 WebInspector.TextPrompt.call(this, WebInspector.ExecutionContextSelector.com pletionsForTextPromptInCurrentContext); |
1099 this.setSuggestBoxEnabled(true); | 1167 this.setSuggestBoxEnabled(true); |
1100 if (renderAsBlock) | 1168 if (renderAsBlock) |
1101 this.renderAsBlock(); | 1169 this.renderAsBlock(); |
1102 } | 1170 } |
1103 | 1171 |
1104 WebInspector.ObjectPropertyPrompt.prototype = { | 1172 WebInspector.ObjectPropertyPrompt.prototype = { |
1105 __proto__: WebInspector.TextPrompt.prototype | 1173 __proto__: WebInspector.TextPrompt.prototype |
1106 } | 1174 } |
OLD | NEW |