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 149 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 /** | |
222 * @param {!WebInspector.ContextMenu} contextMenu | |
223 */ | |
224 populateContextMenu: function(contextMenu) | |
225 { | |
226 }, | |
227 | |
228 updateSiblings: function() | 220 updateSiblings: function() |
229 { | 221 { |
230 if (this.parent.root) | 222 if (this.parent.root) |
231 this.treeOutline.section.update(); | 223 this.treeOutline.section.update(); |
232 else | 224 else |
233 this.parent.invalidateChildren(); | 225 this.parent.invalidateChildren(); |
234 }, | 226 }, |
235 | 227 |
236 /** | 228 /** |
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 | 229 * @param {!Event=} event |
257 */ | 230 */ |
258 startEditing: function(event) | 231 startEditing: function(event) |
259 { | 232 { |
260 var elementAndValueToEdit = this.elementAndValueToEdit(); | 233 var valueToEdit = (typeof this.valueElement._originalTextContent === "st
ring") ? this.valueElement._originalTextContent : undefined; |
261 var elementToEdit = elementAndValueToEdit.element; | |
262 var valueToEdit = elementAndValueToEdit.value; | |
263 | 234 |
264 if (WebInspector.isBeingEdited(elementToEdit) || !this.treeOutline.secti
on.editable || this._readOnly) | 235 if (WebInspector.isBeingEdited(this.valueElement) || !this.treeOutline.s
ection.editable || this._readOnly) |
265 return; | 236 return; |
266 | 237 |
267 // Edit original source. | 238 // Edit original source. |
268 if (typeof valueToEdit !== "undefined") | 239 if (typeof valueToEdit !== "undefined") |
269 elementToEdit.setTextContentTruncatedIfNeeded(valueToEdit, WebInspec
tor.UIString("<string is too large to edit>")); | 240 this.valueElement.setTextContentTruncatedIfNeeded(valueToEdit, WebIn
spector.UIString("<string is too large to edit>")); |
270 | 241 |
271 var context = { expanded: this.expanded, elementToEdit: elementToEdit, p
reviousContent: elementToEdit.textContent }; | 242 var context = { expanded: this.expanded, previousContent: this.valueElem
ent.textContent }; |
272 | 243 |
273 // Lie about our children to prevent expanding on double click and to co
llapse subproperties. | 244 // Lie about our children to prevent expanding on double click and to co
llapse subproperties. |
274 this.hasChildren = false; | 245 this.hasChildren = false; |
275 | 246 |
276 this.listItemElement.classList.add("editing-sub-part"); | 247 this.listItemElement.classList.add("editing-sub-part"); |
277 | 248 |
278 this._prompt = new WebInspector.ObjectPropertyPrompt(this.renderPromptAs
Block()); | 249 this._prompt = new WebInspector.ObjectPropertyPrompt(); |
279 | 250 |
280 /** | 251 /** |
281 * @this {WebInspector.ObjectPropertyTreeElement} | 252 * @this {WebInspector.ObjectPropertyTreeElement} |
282 */ | 253 */ |
283 function blurListener() | 254 function blurListener() |
284 { | 255 { |
285 this.editingCommitted(null, elementToEdit.textContent, context.previ
ousContent, context); | 256 this.editingCommitted(null, this.valueElement.textContent, context.p
reviousContent, context); |
286 } | 257 } |
287 | 258 |
288 var proxyElement = this._prompt.attachAndStartEditing(elementToEdit, blu
rListener.bind(this)); | 259 var proxyElement = this._prompt.attachAndStartEditing(this.valueElement,
blurListener.bind(this)); |
289 this.listItemElement.getComponentSelection().setBaseAndExtent(elementToE
dit, 0, elementToEdit, 1); | 260 this.listItemElement.getComponentSelection().setBaseAndExtent(this.value
Element, 0, this.valueElement, 1); |
290 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this,
context), false); | 261 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this,
context), false); |
291 }, | 262 }, |
292 | 263 |
293 /** | 264 /** |
294 * @return {boolean} | 265 * @return {boolean} |
295 */ | 266 */ |
296 isEditing: function() | 267 isEditing: function() |
297 { | 268 { |
298 return !!this._prompt; | 269 return !!this._prompt; |
299 }, | 270 }, |
(...skipping 23 matching lines...) Expand all Loading... |
323 } | 294 } |
324 | 295 |
325 this.editingEnded(context); | 296 this.editingEnded(context); |
326 this.applyExpression(userInput); | 297 this.applyExpression(userInput); |
327 }, | 298 }, |
328 | 299 |
329 _promptKeyDown: function(context, event) | 300 _promptKeyDown: function(context, event) |
330 { | 301 { |
331 if (isEnterKey(event)) { | 302 if (isEnterKey(event)) { |
332 event.consume(true); | 303 event.consume(true); |
333 this.editingCommitted(null, context.elementToEdit.textContent, conte
xt.previousContent, context); | 304 this.editingCommitted(null, this.valueElement.textContent, context.p
reviousContent, context); |
334 return; | 305 return; |
335 } | 306 } |
336 if (event.keyIdentifier === "U+001B") { // Esc | 307 if (event.keyIdentifier === "U+001B") { // Esc |
337 event.consume(); | 308 event.consume(); |
338 this.editingCancelled(null, context); | 309 this.editingCancelled(null, context); |
339 return; | 310 return; |
340 } | 311 } |
341 }, | 312 }, |
342 | 313 |
343 /** | 314 /** |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 { | 999 { |
1029 this.listItemElement.classList.add("name"); | 1000 this.listItemElement.classList.add("name"); |
1030 }, | 1001 }, |
1031 | 1002 |
1032 __proto__: TreeElement.prototype | 1003 __proto__: TreeElement.prototype |
1033 } | 1004 } |
1034 | 1005 |
1035 /** | 1006 /** |
1036 * @constructor | 1007 * @constructor |
1037 * @extends {WebInspector.TextPrompt} | 1008 * @extends {WebInspector.TextPrompt} |
1038 * @param {boolean=} renderAsBlock | |
1039 */ | 1009 */ |
1040 WebInspector.ObjectPropertyPrompt = function(renderAsBlock) | 1010 WebInspector.ObjectPropertyPrompt = function() |
1041 { | 1011 { |
1042 WebInspector.TextPrompt.call(this, WebInspector.ExecutionContextSelector.com
pletionsForTextPromptInCurrentContext); | 1012 WebInspector.TextPrompt.call(this, WebInspector.ExecutionContextSelector.com
pletionsForTextPromptInCurrentContext); |
1043 this.setSuggestBoxEnabled(true); | 1013 this.setSuggestBoxEnabled(true); |
1044 if (renderAsBlock) | |
1045 this.renderAsBlock(); | |
1046 } | 1014 } |
1047 | 1015 |
1048 WebInspector.ObjectPropertyPrompt.prototype = { | 1016 WebInspector.ObjectPropertyPrompt.prototype = { |
1049 __proto__: WebInspector.TextPrompt.prototype | 1017 __proto__: WebInspector.TextPrompt.prototype |
1050 } | 1018 } |
1051 | 1019 |
1052 /** | 1020 /** |
1053 * @param {?string} name | 1021 * @param {?string} name |
1054 * @return {!Element} | 1022 * @return {!Element} |
1055 */ | 1023 */ |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 value.highlightAsDOMNode(); | 1097 value.highlightAsDOMNode(); |
1130 } | 1098 } |
1131 | 1099 |
1132 function mouseLeave() | 1100 function mouseLeave() |
1133 { | 1101 { |
1134 value.hideDOMNodeHighlight(); | 1102 value.hideDOMNodeHighlight(); |
1135 } | 1103 } |
1136 | 1104 |
1137 return valueElement; | 1105 return valueElement; |
1138 } | 1106 } |
OLD | NEW |