OLD | NEW |
---|---|
1 /* | 1 /* |
pfeldman
2015/02/18 20:51:00
Looks like you can simply land changes in this fil
sergeyv
2015/02/19 10:53:46
Unfortunately, It will break watch expressions
| |
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 |
11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
160 console.assert(propertyValue); | 160 console.assert(propertyValue); |
161 WebInspector.ObjectPropertyTreeElement.populate(this, propertyValue); | 161 WebInspector.ObjectPropertyTreeElement.populate(this, propertyValue); |
162 }, | 162 }, |
163 | 163 |
164 /** | 164 /** |
165 * @override | 165 * @override |
166 * @return {boolean} | 166 * @return {boolean} |
167 */ | 167 */ |
168 ondblclick: function(event) | 168 ondblclick: function(event) |
169 { | 169 { |
170 var editableElement = this.elementAndValueToEdit().element; | 170 var editableElement = this.valueElement; |
171 if ((this.property.writable || this.property.setter) && event.target.isS elfOrDescendant(editableElement)) | 171 if ((this.property.writable || this.property.setter) && event.target.isS elfOrDescendant(editableElement)) |
172 this.startEditing(event); | 172 this.startEditing(event); |
173 return false; | 173 return false; |
174 }, | 174 }, |
175 | 175 |
176 /** | 176 /** |
177 * @override | 177 * @override |
178 */ | 178 */ |
179 onattach: function() | 179 onattach: function() |
180 { | 180 { |
(...skipping 25 matching lines...) Expand all Loading... | |
206 var separatorElement = createElementWithClass("span", "separator"); | 206 var separatorElement = createElementWithClass("span", "separator"); |
207 separatorElement.textContent = ": "; | 207 separatorElement.textContent = ": "; |
208 | 208 |
209 this.listItemElement.removeChildren(); | 209 this.listItemElement.removeChildren(); |
210 this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement); | 210 this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement); |
211 }, | 211 }, |
212 | 212 |
213 _contextMenuFired: function(value, event) | 213 _contextMenuFired: function(value, event) |
214 { | 214 { |
215 var contextMenu = new WebInspector.ContextMenu(event); | 215 var contextMenu = new WebInspector.ContextMenu(event); |
216 this.populateContextMenu(contextMenu); | |
217 contextMenu.appendApplicableItems(value); | 216 contextMenu.appendApplicableItems(value); |
218 contextMenu.show(); | 217 contextMenu.show(); |
219 }, | 218 }, |
220 | 219 |
221 /** | 220 /** |
222 * @param {!WebInspector.ContextMenu} contextMenu | 221 * @param {!WebInspector.ContextMenu} contextMenu |
223 */ | 222 */ |
224 populateContextMenu: function(contextMenu) | 223 populateContextMenu: function(contextMenu) |
pfeldman
2015/02/18 20:51:00
Remove this?
sergeyv
2015/02/19 10:53:46
Done.
| |
225 { | 224 { |
226 }, | 225 }, |
227 | 226 |
228 updateSiblings: function() | 227 updateSiblings: function() |
229 { | 228 { |
230 if (this.parent.root) | 229 if (this.parent.root) |
231 this.treeOutline.section.update(); | 230 this.treeOutline.section.update(); |
232 else | 231 else |
233 this.parent.shouldRefreshChildren = true; | 232 this.parent.shouldRefreshChildren = true; |
234 }, | 233 }, |
235 | 234 |
236 /** | 235 /** |
237 * @return {boolean} | |
238 */ | |
239 renderPromptAsBlock: function() | |
240 { | |
241 return false; | |
242 }, | |
243 | |
244 /** | |
245 * @return {{element: !Element, value: (string|undefined)}} | |
246 */ | |
247 elementAndValueToEdit: function() | |
248 { | |
249 return { | |
250 element: this.valueElement, | |
251 value: (typeof this.valueElement._originalTextContent === "string") ? this.valueElement._originalTextContent : undefined | |
252 }; | |
253 }, | |
254 | |
255 /** | |
256 * @param {!Event=} event | 236 * @param {!Event=} event |
257 */ | 237 */ |
258 startEditing: function(event) | 238 startEditing: function(event) |
259 { | 239 { |
260 var elementAndValueToEdit = this.elementAndValueToEdit(); | 240 var valueToEdit = (typeof this.valueElement._originalTextContent === "st ring") ? this.valueElement._originalTextContent : undefined; |
261 var elementToEdit = elementAndValueToEdit.element; | |
262 var valueToEdit = elementAndValueToEdit.value; | |
263 | 241 |
264 if (WebInspector.isBeingEdited(elementToEdit) || !this.treeOutline.secti on.editable || this._readOnly) | 242 if (WebInspector.isBeingEdited(this.valueElement) || !this.treeOutline.s ection.editable || this._readOnly) |
265 return; | 243 return; |
266 | 244 |
267 // Edit original source. | 245 // Edit original source. |
268 if (typeof valueToEdit !== "undefined") | 246 if (typeof valueToEdit !== "undefined") |
269 elementToEdit.setTextContentTruncatedIfNeeded(valueToEdit, WebInspec tor.UIString("<string is too large to edit>")); | 247 this.valueElement.setTextContentTruncatedIfNeeded(valueToEdit, WebIn spector.UIString("<string is too large to edit>")); |
270 | 248 |
271 var context = { expanded: this.expanded, elementToEdit: elementToEdit, p reviousContent: elementToEdit.textContent }; | 249 var context = { expanded: this.expanded, previousContent: this.valueElem ent.textContent }; |
272 | 250 |
273 // Lie about our children to prevent expanding on double click and to co llapse subproperties. | 251 // Lie about our children to prevent expanding on double click and to co llapse subproperties. |
274 this.hasChildren = false; | 252 this.hasChildren = false; |
275 | 253 |
276 this.listItemElement.classList.add("editing-sub-part"); | 254 this.listItemElement.classList.add("editing-sub-part"); |
277 | 255 |
278 this._prompt = new WebInspector.ObjectPropertyPrompt(this.renderPromptAs Block()); | 256 this._prompt = new WebInspector.ObjectPropertyPrompt(); |
279 | 257 |
280 /** | 258 /** |
281 * @this {WebInspector.ObjectPropertyTreeElement} | 259 * @this {WebInspector.ObjectPropertyTreeElement} |
282 */ | 260 */ |
283 function blurListener() | 261 function blurListener() |
284 { | 262 { |
285 this.editingCommitted(null, elementToEdit.textContent, context.previ ousContent, context); | 263 this.editingCommitted(null, this.valueElement.textContent, context.p reviousContent, context); |
286 } | 264 } |
287 | 265 |
288 var proxyElement = this._prompt.attachAndStartEditing(elementToEdit, blu rListener.bind(this)); | 266 var proxyElement = this._prompt.attachAndStartEditing(this.valueElement, blurListener.bind(this)); |
289 this.listItemElement.getComponentSelection().setBaseAndExtent(elementToE dit, 0, elementToEdit, 1); | 267 this.listItemElement.getComponentSelection().setBaseAndExtent(this.value Element, 0, this.valueElement, 1); |
290 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this, context), false); | 268 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this, context), false); |
291 }, | 269 }, |
292 | 270 |
293 /** | 271 /** |
294 * @return {boolean} | 272 * @return {boolean} |
295 */ | 273 */ |
296 isEditing: function() | 274 isEditing: function() |
297 { | 275 { |
298 return !!this._prompt; | 276 return !!this._prompt; |
299 }, | 277 }, |
(...skipping 23 matching lines...) Expand all Loading... | |
323 } | 301 } |
324 | 302 |
325 this.editingEnded(context); | 303 this.editingEnded(context); |
326 this.applyExpression(userInput); | 304 this.applyExpression(userInput); |
327 }, | 305 }, |
328 | 306 |
329 _promptKeyDown: function(context, event) | 307 _promptKeyDown: function(context, event) |
330 { | 308 { |
331 if (isEnterKey(event)) { | 309 if (isEnterKey(event)) { |
332 event.consume(true); | 310 event.consume(true); |
333 this.editingCommitted(null, context.elementToEdit.textContent, conte xt.previousContent, context); | 311 this.editingCommitted(null, this.valueElement.textContent, context.p reviousContent, context); |
334 return; | 312 return; |
335 } | 313 } |
336 if (event.keyIdentifier === "U+001B") { // Esc | 314 if (event.keyIdentifier === "U+001B") { // Esc |
337 event.consume(); | 315 event.consume(); |
338 this.editingCancelled(null, context); | 316 this.editingCancelled(null, context); |
339 return; | 317 return; |
340 } | 318 } |
341 }, | 319 }, |
342 | 320 |
343 /** | 321 /** |
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1037 { | 1015 { |
1038 this.listItemElement.classList.add("name"); | 1016 this.listItemElement.classList.add("name"); |
1039 }, | 1017 }, |
1040 | 1018 |
1041 __proto__: TreeElement.prototype | 1019 __proto__: TreeElement.prototype |
1042 } | 1020 } |
1043 | 1021 |
1044 /** | 1022 /** |
1045 * @constructor | 1023 * @constructor |
1046 * @extends {WebInspector.TextPrompt} | 1024 * @extends {WebInspector.TextPrompt} |
1047 * @param {boolean=} renderAsBlock | |
1048 */ | 1025 */ |
1049 WebInspector.ObjectPropertyPrompt = function(renderAsBlock) | 1026 WebInspector.ObjectPropertyPrompt = function() |
1050 { | 1027 { |
1051 WebInspector.TextPrompt.call(this, WebInspector.ExecutionContextSelector.com pletionsForTextPromptInCurrentContext); | 1028 WebInspector.TextPrompt.call(this, WebInspector.ExecutionContextSelector.com pletionsForTextPromptInCurrentContext); |
1052 this.setSuggestBoxEnabled(true); | 1029 this.setSuggestBoxEnabled(true); |
1053 if (renderAsBlock) | |
1054 this.renderAsBlock(); | |
1055 } | 1030 } |
1056 | 1031 |
1057 WebInspector.ObjectPropertyPrompt.prototype = { | 1032 WebInspector.ObjectPropertyPrompt.prototype = { |
1058 __proto__: WebInspector.TextPrompt.prototype | 1033 __proto__: WebInspector.TextPrompt.prototype |
1059 } | 1034 } |
1060 | 1035 |
1061 /** | 1036 /** |
1062 * @param {?string} name | 1037 * @param {?string} name |
1063 * @return {!Element} | 1038 * @return {!Element} |
1064 */ | 1039 */ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1138 value.highlightAsDOMNode(); | 1113 value.highlightAsDOMNode(); |
1139 } | 1114 } |
1140 | 1115 |
1141 function mouseLeave() | 1116 function mouseLeave() |
1142 { | 1117 { |
1143 value.hideDOMNodeHighlight(); | 1118 value.hideDOMNodeHighlight(); |
1144 } | 1119 } |
1145 | 1120 |
1146 return valueElement; | 1121 return valueElement; |
1147 } | 1122 } |
OLD | NEW |