Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/ObjectPropertiesSection.js

Issue 2139043002: DevTools: show alternate title onexpand of object in console (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reuse dump() in tests Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 25 matching lines...) Expand all
36 */ 36 */
37 WebInspector.ObjectPropertiesSection = function(object, title, linkifier, emptyP laceholder, ignoreHasOwnProperty, extraProperties) 37 WebInspector.ObjectPropertiesSection = function(object, title, linkifier, emptyP laceholder, ignoreHasOwnProperty, extraProperties)
38 { 38 {
39 this._object = object; 39 this._object = object;
40 this._editable = true; 40 this._editable = true;
41 TreeOutlineInShadow.call(this); 41 TreeOutlineInShadow.call(this);
42 this.hideOverflow(); 42 this.hideOverflow();
43 this.setFocusable(false); 43 this.setFocusable(false);
44 this._objectTreeElement = new WebInspector.ObjectPropertiesSection.RootEleme nt(object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraProperties); 44 this._objectTreeElement = new WebInspector.ObjectPropertiesSection.RootEleme nt(object, linkifier, emptyPlaceholder, ignoreHasOwnProperty, extraProperties);
45 this.appendChild(this._objectTreeElement); 45 this.appendChild(this._objectTreeElement);
46 if (typeof title === "string" || !title) 46 if (typeof title === "string" || !title) {
47 this.element.createChild("span").textContent = title || ""; 47 this.titleElement = this.element.createChild("span");
48 else 48 this.titleElement.textContent = title || "";
49 } else {
50 this.titleElement = title;
49 this.element.appendChild(title); 51 this.element.appendChild(title);
52 }
53
54 if (object.description && WebInspector.ObjectPropertiesSection._needsAlterna teTitle(object)) {
55 this.expandedTitleElement = createElement("span");
56 this.expandedTitleElement.createTextChild(object.description);
57
58 var note = this.expandedTitleElement.createChild("span", "object-state-n ote");
59 note.classList.add("info-note");
60 note.title = WebInspector.UIString("Value below was evaluated just now." );
61 }
50 62
51 this.element._section = this; 63 this.element._section = this;
52 this.registerRequiredCSS("components/objectValue.css"); 64 this.registerRequiredCSS("components/objectValue.css");
53 this.registerRequiredCSS("components/objectPropertiesSection.css"); 65 this.registerRequiredCSS("components/objectPropertiesSection.css");
54 this.rootElement().childrenListElement.classList.add("source-code", "object- properties-section"); 66 this.rootElement().childrenListElement.classList.add("source-code", "object- properties-section");
55 } 67 }
56 68
57 /** @const */ 69 /** @const */
58 WebInspector.ObjectPropertiesSection._arrayLoadThreshold = 100; 70 WebInspector.ObjectPropertiesSection._arrayLoadThreshold = 100;
59 71
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 var contentElement = createElement("content"); 178 var contentElement = createElement("content");
167 TreeElement.call(this, contentElement); 179 TreeElement.call(this, contentElement);
168 this.setExpandable(true); 180 this.setExpandable(true);
169 this.selectable = false; 181 this.selectable = false;
170 this.toggleOnClick = true; 182 this.toggleOnClick = true;
171 this.listItemElement.classList.add("object-properties-section-root-element") ; 183 this.listItemElement.classList.add("object-properties-section-root-element") ;
172 this._linkifier = linkifier; 184 this._linkifier = linkifier;
173 } 185 }
174 186
175 WebInspector.ObjectPropertiesSection.RootElement.prototype = { 187 WebInspector.ObjectPropertiesSection.RootElement.prototype = {
176 188 /**
189 * @override
190 */
177 onexpand: function() 191 onexpand: function()
178 { 192 {
179 if (this.treeOutline) 193 if (this.treeOutline) {
180 this.treeOutline.element.classList.add("expanded"); 194 this.treeOutline.element.classList.add("expanded");
181 }, 195 this._showExpandedTitleElement(true);
182 196 }
183 oncollapse: function()
184 {
185 if (this.treeOutline)
186 this.treeOutline.element.classList.remove("expanded");
187 }, 197 },
188 198
189 /** 199 /**
200 * @override
201 */
202 oncollapse: function()
203 {
204 if (this.treeOutline) {
205 this.treeOutline.element.classList.remove("expanded");
206 this._showExpandedTitleElement(false);
207 }
208 },
209
210 /**
211 * @param {boolean} value
212 */
213 _showExpandedTitleElement: function(value)
214 {
215 if (!this.treeOutline.expandedTitleElement)
216 return;
217 if (value)
218 this.treeOutline.element.replaceChild(this.treeOutline.expandedTitle Element, this.treeOutline.titleElement);
219 else
220 this.treeOutline.element.replaceChild(this.treeOutline.titleElement, this.treeOutline.expandedTitleElement);
221 },
222
223 /**
190 * @override 224 * @override
191 * @param {!Event} e 225 * @param {!Event} e
192 * @return {boolean} 226 * @return {boolean}
193 */ 227 */
194 ondblclick: function(e) 228 ondblclick: function(e)
195 { 229 {
196 return true; 230 return true;
197 }, 231 },
198 232
199 onpopulate: function() 233 onpopulate: function()
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 var targetValue = this.property.name !== "__proto__" ? propertyValue : t his.property.parentObject; 310 var targetValue = this.property.name !== "__proto__" ? propertyValue : t his.property.parentObject;
277 WebInspector.ObjectPropertyTreeElement._populate(this, propertyValue, sk ipProto, this._linkifier, undefined, undefined, undefined, targetValue); 311 WebInspector.ObjectPropertyTreeElement._populate(this, propertyValue, sk ipProto, this._linkifier, undefined, undefined, undefined, targetValue);
278 }, 312 },
279 313
280 /** 314 /**
281 * @override 315 * @override
282 * @return {boolean} 316 * @return {boolean}
283 */ 317 */
284 ondblclick: function(event) 318 ondblclick: function(event)
285 { 319 {
286 var editableElement = this.valueElement; 320 var inEditableElement = event.target.isSelfOrDescendant(this.valueElemen t) || (this.expandedValueElement && event.target.isSelfOrDescendant(this.expande dValueElement));
287 if (!this.property.value.customPreview() && (this.property.writable || t his.property.setter) && event.target.isSelfOrDescendant(editableElement)) 321 if (!this.property.value.customPreview() && inEditableElement && (this.p roperty.writable || this.property.setter))
288 this._startEditing(); 322 this._startEditing();
289 return false; 323 return false;
290 }, 324 },
291 325
292 /** 326 /**
293 * @override 327 * @override
294 */ 328 */
295 onattach: function() 329 onattach: function()
296 { 330 {
297 this.update(); 331 this.update();
298 this._updateExpandable(); 332 this._updateExpandable();
299 }, 333 },
300 334
335 /**
336 * @override
337 */
338 onexpand: function()
339 {
340 this._showExpandedValueElement(true);
341 },
342
343 /**
344 * @override
345 */
346 oncollapse: function()
347 {
348 this._showExpandedValueElement(false);
349 },
350
351 /**
352 * @param {boolean} value
353 */
354 _showExpandedValueElement: function(value)
355 {
356 if (!this.expandedValueElement)
357 return;
358 if (value)
359 this.listItemElement.replaceChild(this.expandedValueElement, this.va lueElement);
360 else
361 this.listItemElement.replaceChild(this.valueElement, this.expandedVa lueElement);
362 },
363
364 /**
365 * @param {!WebInspector.RemoteObject} value
366 * @return {?Element}
367 */
368 _createExpandedValueElement: function(value)
369 {
370 if (!WebInspector.ObjectPropertiesSection._needsAlternateTitle(value))
371 return null;
372
373 var valueElement = createElementWithClass("span", "value");
374 valueElement.setTextContentTruncatedIfNeeded(value.description || "");
375 valueElement.classList.add("object-value-" + (value.subtype || value.typ e));
376 valueElement.title = value.description || "";
377 return valueElement;
378 },
379
301 update: function() 380 update: function()
302 { 381 {
303 this.nameElement = WebInspector.ObjectPropertiesSection.createNameElemen t(this.property.name); 382 this.nameElement = WebInspector.ObjectPropertiesSection.createNameElemen t(this.property.name);
304 if (!this.property.enumerable) 383 if (!this.property.enumerable)
305 this.nameElement.classList.add("object-properties-section-dimmed"); 384 this.nameElement.classList.add("object-properties-section-dimmed");
306 if (this.property.isAccessorProperty()) 385 if (this.property.isAccessorProperty())
307 this.nameElement.classList.add("properties-accessor-property-name"); 386 this.nameElement.classList.add("properties-accessor-property-name");
308 if (this.property.synthetic) 387 if (this.property.synthetic)
309 this.nameElement.classList.add("synthetic-property"); 388 this.nameElement.classList.add("synthetic-property");
310 389
311 this._updatePropertyPath(); 390 this._updatePropertyPath();
312 this.nameElement.addEventListener("contextmenu", this._contextMenuFired. bind(this, this.property), false); 391 this.nameElement.addEventListener("contextmenu", this._contextMenuFired. bind(this, this.property), false);
313 392
314 var separatorElement = createElementWithClass("span", "object-properties -section-separator"); 393 var separatorElement = createElementWithClass("span", "object-properties -section-separator");
315 separatorElement.textContent = ": "; 394 separatorElement.textContent = ": ";
316 395
317 if (this.property.value) { 396 if (this.property.value) {
318 this.valueElement = WebInspector.ObjectPropertiesSection.createValue ElementWithCustomSupport(this.property.value, this.property.wasThrown, this.list ItemElement, this._linkifier); 397 this.valueElement = WebInspector.ObjectPropertiesSection.createValue ElementWithCustomSupport(this.property.value, this.property.wasThrown, this.list ItemElement, this._linkifier);
319 this.valueElement.addEventListener("contextmenu", this._contextMenuF ired.bind(this, this.property), false); 398 this.valueElement.addEventListener("contextmenu", this._contextMenuF ired.bind(this, this.property), false);
320 } else if (this.property.getter) { 399 } else if (this.property.getter) {
321 this.valueElement = WebInspector.ObjectPropertyTreeElement.createRem oteObjectAccessorPropertySpan(this.property.parentObject, [this.property.name], this._onInvokeGetterClick.bind(this)); 400 this.valueElement = WebInspector.ObjectPropertyTreeElement.createRem oteObjectAccessorPropertySpan(this.property.parentObject, [this.property.name], this._onInvokeGetterClick.bind(this));
322 } else { 401 } else {
323 this.valueElement = createElementWithClass("span", "object-value-und efined"); 402 this.valueElement = createElementWithClass("span", "object-value-und efined");
324 this.valueElement.textContent = WebInspector.UIString("<unreadable>" ); 403 this.valueElement.textContent = WebInspector.UIString("<unreadable>" );
325 this.valueElement.title = WebInspector.UIString("No property getter" ); 404 this.valueElement.title = WebInspector.UIString("No property getter" );
326 } 405 }
327 406
407 var valueText = this.valueElement.textContent;
408 if (this.property.value && valueText && !this.property.wasThrown)
409 this.expandedValueElement = this._createExpandedValueElement(this.pr operty.value);
410
328 this.listItemElement.removeChildren(); 411 this.listItemElement.removeChildren();
329 this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement); 412 this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement);
330 }, 413 },
331 414
332 _updatePropertyPath: function() 415 _updatePropertyPath: function()
333 { 416 {
334 if (this.nameElement.title) 417 if (this.nameElement.title)
335 return; 418 return;
336 419
337 var useDotNotation = /^(_|\$|[A-Z])(_|\$|[A-Z]|\d)*$/i; 420 var useDotNotation = /^(_|\$|[A-Z])(_|\$|[A-Z]|\d)*$/i;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 452
370 this._editableDiv = this.listItemElement.createChild("span"); 453 this._editableDiv = this.listItemElement.createChild("span");
371 454
372 var text = this.property.value.description; 455 var text = this.property.value.description;
373 if (this.property.value.type === "string" && typeof text === "string") 456 if (this.property.value.type === "string" && typeof text === "string")
374 text = "\"" + text + "\""; 457 text = "\"" + text + "\"";
375 458
376 this._editableDiv.setTextContentTruncatedIfNeeded(text, WebInspector.UIS tring("<string is too large to edit>")); 459 this._editableDiv.setTextContentTruncatedIfNeeded(text, WebInspector.UIS tring("<string is too large to edit>"));
377 var originalContent = this._editableDiv.textContent; 460 var originalContent = this._editableDiv.textContent;
378 461
379 this.valueElement.classList.add("hidden");
380
381 // Lie about our children to prevent expanding on double click and to co llapse subproperties. 462 // Lie about our children to prevent expanding on double click and to co llapse subproperties.
382 this.setExpandable(false); 463 this.setExpandable(false);
383 this.listItemElement.classList.add("editing-sub-part"); 464 this.listItemElement.classList.add("editing-sub-part");
465 this.valueElement.classList.add("hidden");
384 466
385 this._prompt = new WebInspector.ObjectPropertyPrompt(); 467 this._prompt = new WebInspector.ObjectPropertyPrompt();
386 468
387 var proxyElement = this._prompt.attachAndStartEditing(this._editableDiv, this._editingCommitted.bind(this, originalContent)); 469 var proxyElement = this._prompt.attachAndStartEditing(this._editableDiv, this._editingCommitted.bind(this, originalContent));
388 this.listItemElement.getComponentSelection().setBaseAndExtent(this._edit ableDiv, 0, this._editableDiv, 1); 470 this.listItemElement.getComponentSelection().setBaseAndExtent(this._edit ableDiv, 0, this._editableDiv, 1);
389 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this, originalContent), false); 471 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this, originalContent), false);
390 }, 472 },
391 473
392 _editingEnded: function() 474 _editingEnded: function()
393 { 475 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return; 543 return;
462 } 544 }
463 545
464 if (!expression) { 546 if (!expression) {
465 // The property was deleted, so remove this tree element. 547 // The property was deleted, so remove this tree element.
466 this.parent.removeChild(this); 548 this.parent.removeChild(this);
467 } else { 549 } else {
468 // Call updateSiblings since their value might be based on the v alue that just changed. 550 // Call updateSiblings since their value might be based on the v alue that just changed.
469 var parent = this.parent; 551 var parent = this.parent;
470 parent.invalidateChildren(); 552 parent.invalidateChildren();
471 parent.expand(); 553 parent.onpopulate();
472 } 554 }
473 } 555 }
474 }, 556 },
475 557
476 /** 558 /**
477 * @param {?WebInspector.RemoteObject} result 559 * @param {?WebInspector.RemoteObject} result
478 * @param {boolean=} wasThrown 560 * @param {boolean=} wasThrown
479 */ 561 */
480 _onInvokeGetterClick: function(result, wasThrown) 562 _onInvokeGetterClick: function(result, wasThrown)
481 { 563 {
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 function mouseClick(event) 1169 function mouseClick(event)
1088 { 1170 {
1089 WebInspector.Revealer.reveal(value); 1171 WebInspector.Revealer.reveal(value);
1090 event.consume(true); 1172 event.consume(true);
1091 } 1173 }
1092 1174
1093 return valueElement; 1175 return valueElement;
1094 } 1176 }
1095 1177
1096 /** 1178 /**
1179 * @param {!WebInspector.RemoteObject} object
1180 * @return {boolean}
1181 */
1182 WebInspector.ObjectPropertiesSection._needsAlternateTitle = function(object)
1183 {
1184 return object && object.hasChildren && !object.customPreview() && object.sub type !== "node" && object.type !== "function" && (object.type !== "object" || ob ject.preview);
1185 }
1186
1187 /**
1097 * @param {!WebInspector.RemoteObject} func 1188 * @param {!WebInspector.RemoteObject} func
1098 * @param {!Element} element 1189 * @param {!Element} element
1099 * @param {boolean} linkify 1190 * @param {boolean} linkify
1100 * @param {boolean=} includePreview 1191 * @param {boolean=} includePreview
1101 */ 1192 */
1102 WebInspector.ObjectPropertiesSection.formatObjectAsFunction = function(func, ele ment, linkify, includePreview) 1193 WebInspector.ObjectPropertiesSection.formatObjectAsFunction = function(func, ele ment, linkify, includePreview)
1103 { 1194 {
1104 func.debuggerModel().functionDetailsPromise(func).then(didGetDetails); 1195 func.debuggerModel().functionDetailsPromise(func).then(didGetDetails);
1105 1196
1106 /** 1197 /**
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 1351
1261 result = currentName + (result ? "." + result : ""); 1352 result = currentName + (result ? "." + result : "");
1262 current = current.parent; 1353 current = current.parent;
1263 } 1354 }
1264 var treeOutlineId = treeElement.treeOutline[WebInspector.ObjectPropertie sSectionExpandController._treeOutlineId]; 1355 var treeOutlineId = treeElement.treeOutline[WebInspector.ObjectPropertie sSectionExpandController._treeOutlineId];
1265 result = treeOutlineId + (result ? ":" + result : ""); 1356 result = treeOutlineId + (result ? ":" + result : "");
1266 treeElement[WebInspector.ObjectPropertiesSectionExpandController._cached PathSymbol] = result; 1357 treeElement[WebInspector.ObjectPropertiesSectionExpandController._cached PathSymbol] = result;
1267 return result; 1358 return result;
1268 } 1359 }
1269 } 1360 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698