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

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: Remove complex value editing from 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)) {
lushnikov 2016/08/03 22:34:49 Let's not make it static without a need - it's eas
luoe 2016/08/05 01:12:47 Unfortunately, I don't think we can easily make th
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
lushnikov 2016/08/03 22:34:48 stray line
luoe 2016/08/05 01:12:47 Done.
189 /**
190 * @override
191 */
177 onexpand: function() 192 onexpand: function()
178 { 193 {
179 if (this.treeOutline) 194 if (this.treeOutline) {
180 this.treeOutline.element.classList.add("expanded"); 195 this.treeOutline.element.classList.add("expanded");
181 }, 196 this._toggleExpandedTitleElement();
182 197 }
183 oncollapse: function()
184 {
185 if (this.treeOutline)
186 this.treeOutline.element.classList.remove("expanded");
187 }, 198 },
188 199
189 /** 200 /**
201 * @override
202 */
203 oncollapse: function()
204 {
205 if (this.treeOutline) {
206 this.treeOutline.element.classList.remove("expanded");
207 this._toggleExpandedTitleElement();
208 }
209 },
210
211 _toggleExpandedTitleElement: function()
lushnikov 2016/08/03 22:34:48 let's make it straightforward: /** * @param {bo
luoe 2016/08/05 01:12:47 Done.
212 {
213 if (!this.treeOutline.expandedTitleElement)
214 return;
215 if (this.expanded)
216 this.treeOutline.element.replaceChild(this.treeOutline.expandedTitle Element, this.treeOutline.titleElement);
217 else
218 this.treeOutline.element.replaceChild(this.treeOutline.titleElement, this.treeOutline.expandedTitleElement);
219 },
220
221 /**
190 * @override 222 * @override
191 * @param {!Event} e 223 * @param {!Event} e
192 * @return {boolean} 224 * @return {boolean}
193 */ 225 */
194 ondblclick: function(e) 226 ondblclick: function(e)
195 { 227 {
196 return true; 228 return true;
197 }, 229 },
198 230
199 onpopulate: function() 231 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; 308 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); 309 WebInspector.ObjectPropertyTreeElement._populate(this, propertyValue, sk ipProto, this._linkifier, undefined, undefined, undefined, targetValue);
278 }, 310 },
279 311
280 /** 312 /**
281 * @override 313 * @override
282 * @return {boolean} 314 * @return {boolean}
283 */ 315 */
284 ondblclick: function(event) 316 ondblclick: function(event)
285 { 317 {
286 var editableElement = this.valueElement; 318 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)) 319 if (!this.property.value.customPreview() && inEditableElement && (this.p roperty.writable || this.property.setter))
288 this._startEditing(); 320 this._startEditing();
289 return false; 321 return false;
290 }, 322 },
291 323
292 /** 324 /**
293 * @override 325 * @override
294 */ 326 */
295 onattach: function() 327 onattach: function()
296 { 328 {
297 this.update(); 329 this.update();
298 this._updateExpandable(); 330 this._updateExpandable();
299 }, 331 },
300 332
333 /**
334 * @override
335 */
336 onexpand: function()
337 {
338 this._toggleExpandedValueElement();
339 },
340
341 /**
342 * @override
343 */
344 oncollapse: function()
345 {
346 this._toggleExpandedValueElement();
347 },
348
349 _toggleExpandedValueElement: function()
lushnikov 2016/08/03 22:34:49 Like with title: _setExpandedValueElement: functi
luoe 2016/08/05 01:12:47 Done.
350 {
351 if (!this.expandedValueElement)
352 return;
353 if (this.expanded)
354 this.listItemElement.replaceChild(this.expandedValueElement, this.va lueElement);
355 else
356 this.listItemElement.replaceChild(this.valueElement, this.expandedVa lueElement);
357 },
358
301 update: function() 359 update: function()
302 { 360 {
303 this.nameElement = WebInspector.ObjectPropertiesSection.createNameElemen t(this.property.name); 361 this.nameElement = WebInspector.ObjectPropertiesSection.createNameElemen t(this.property.name);
304 if (!this.property.enumerable) 362 if (!this.property.enumerable)
305 this.nameElement.classList.add("object-properties-section-dimmed"); 363 this.nameElement.classList.add("object-properties-section-dimmed");
306 if (this.property.isAccessorProperty()) 364 if (this.property.isAccessorProperty())
307 this.nameElement.classList.add("properties-accessor-property-name"); 365 this.nameElement.classList.add("properties-accessor-property-name");
308 if (this.property.synthetic) 366 if (this.property.synthetic)
309 this.nameElement.classList.add("synthetic-property"); 367 this.nameElement.classList.add("synthetic-property");
310 368
311 this._updatePropertyPath(); 369 this._updatePropertyPath();
312 this.nameElement.addEventListener("contextmenu", this._contextMenuFired. bind(this, this.property), false); 370 this.nameElement.addEventListener("contextmenu", this._contextMenuFired. bind(this, this.property), false);
313 371
314 var separatorElement = createElementWithClass("span", "object-properties -section-separator"); 372 var separatorElement = createElementWithClass("span", "object-properties -section-separator");
315 separatorElement.textContent = ": "; 373 separatorElement.textContent = ": ";
316 374
317 if (this.property.value) { 375 if (this.property.value) {
318 this.valueElement = WebInspector.ObjectPropertiesSection.createValue ElementWithCustomSupport(this.property.value, this.property.wasThrown, this.list ItemElement, this._linkifier); 376 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); 377 this.valueElement.addEventListener("contextmenu", this._contextMenuF ired.bind(this, this.property), false);
320 } else if (this.property.getter) { 378 } else if (this.property.getter) {
321 this.valueElement = WebInspector.ObjectPropertyTreeElement.createRem oteObjectAccessorPropertySpan(this.property.parentObject, [this.property.name], this._onInvokeGetterClick.bind(this)); 379 this.valueElement = WebInspector.ObjectPropertyTreeElement.createRem oteObjectAccessorPropertySpan(this.property.parentObject, [this.property.name], this._onInvokeGetterClick.bind(this));
322 } else { 380 } else {
323 this.valueElement = createElementWithClass("span", "object-value-und efined"); 381 this.valueElement = createElementWithClass("span", "object-value-und efined");
324 this.valueElement.textContent = WebInspector.UIString("<unreadable>" ); 382 this.valueElement.textContent = WebInspector.UIString("<unreadable>" );
325 this.valueElement.title = WebInspector.UIString("No property getter" ); 383 this.valueElement.title = WebInspector.UIString("No property getter" );
326 } 384 }
327 385
386 var valueText = this.valueElement.textContent;
387 if (this.property.value && valueText && !this.property.wasThrown)
388 this.expandedValueElement = WebInspector.ObjectPropertiesSection._cr eateExpandedValueElement(this.property.value);
lushnikov 2016/08/03 22:34:48 this._createExpandedValueElement(this.property.val
luoe 2016/08/05 01:12:47 Done.
389
328 this.listItemElement.removeChildren(); 390 this.listItemElement.removeChildren();
329 this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement); 391 this.listItemElement.appendChildren(this.nameElement, separatorElement, this.valueElement);
330 }, 392 },
331 393
332 _updatePropertyPath: function() 394 _updatePropertyPath: function()
333 { 395 {
334 if (this.nameElement.title) 396 if (this.nameElement.title)
335 return; 397 return;
336 398
337 var useDotNotation = /^(_|\$|[A-Z])(_|\$|[A-Z]|\d)*$/i; 399 var useDotNotation = /^(_|\$|[A-Z])(_|\$|[A-Z]|\d)*$/i;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 431
370 this._editableDiv = this.listItemElement.createChild("span"); 432 this._editableDiv = this.listItemElement.createChild("span");
371 433
372 var text = this.property.value.description; 434 var text = this.property.value.description;
373 if (this.property.value.type === "string" && typeof text === "string") 435 if (this.property.value.type === "string" && typeof text === "string")
374 text = "\"" + text + "\""; 436 text = "\"" + text + "\"";
375 437
376 this._editableDiv.setTextContentTruncatedIfNeeded(text, WebInspector.UIS tring("<string is too large to edit>")); 438 this._editableDiv.setTextContentTruncatedIfNeeded(text, WebInspector.UIS tring("<string is too large to edit>"));
377 var originalContent = this._editableDiv.textContent; 439 var originalContent = this._editableDiv.textContent;
378 440
379 this.valueElement.classList.add("hidden");
380
381 // Lie about our children to prevent expanding on double click and to co llapse subproperties. 441 // Lie about our children to prevent expanding on double click and to co llapse subproperties.
382 this.setExpandable(false); 442 this.setExpandable(false);
383 this.listItemElement.classList.add("editing-sub-part"); 443 this.listItemElement.classList.add("editing-sub-part");
444 this.valueElement.classList.add("hidden");
384 445
385 this._prompt = new WebInspector.ObjectPropertyPrompt(); 446 this._prompt = new WebInspector.ObjectPropertyPrompt();
386 447
387 var proxyElement = this._prompt.attachAndStartEditing(this._editableDiv, this._editingCommitted.bind(this, originalContent)); 448 var proxyElement = this._prompt.attachAndStartEditing(this._editableDiv, this._editingCommitted.bind(this, originalContent));
388 this.listItemElement.getComponentSelection().setBaseAndExtent(this._edit ableDiv, 0, this._editableDiv, 1); 449 this.listItemElement.getComponentSelection().setBaseAndExtent(this._edit ableDiv, 0, this._editableDiv, 1);
389 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this, originalContent), false); 450 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this, originalContent), false);
390 }, 451 },
391 452
392 _editingEnded: function() 453 _editingEnded: function()
393 { 454 {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return; 522 return;
462 } 523 }
463 524
464 if (!expression) { 525 if (!expression) {
465 // The property was deleted, so remove this tree element. 526 // The property was deleted, so remove this tree element.
466 this.parent.removeChild(this); 527 this.parent.removeChild(this);
467 } else { 528 } else {
468 // Call updateSiblings since their value might be based on the v alue that just changed. 529 // Call updateSiblings since their value might be based on the v alue that just changed.
469 var parent = this.parent; 530 var parent = this.parent;
470 parent.invalidateChildren(); 531 parent.invalidateChildren();
471 parent.expand(); 532 parent.onpopulate();
472 } 533 }
473 } 534 }
474 }, 535 },
475 536
476 /** 537 /**
477 * @param {?WebInspector.RemoteObject} result 538 * @param {?WebInspector.RemoteObject} result
478 * @param {boolean=} wasThrown 539 * @param {boolean=} wasThrown
479 */ 540 */
480 _onInvokeGetterClick: function(result, wasThrown) 541 _onInvokeGetterClick: function(result, wasThrown)
481 { 542 {
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 function mouseClick(event) 1148 function mouseClick(event)
1088 { 1149 {
1089 WebInspector.Revealer.reveal(value); 1150 WebInspector.Revealer.reveal(value);
1090 event.consume(true); 1151 event.consume(true);
1091 } 1152 }
1092 1153
1093 return valueElement; 1154 return valueElement;
1094 } 1155 }
1095 1156
1096 /** 1157 /**
1158 * @param {!WebInspector.RemoteObject} object
1159 * @return {boolean}
1160 */
1161 WebInspector.ObjectPropertiesSection._needsAlternateTitle = function(object)
1162 {
1163 return object && object.hasChildren && !object.customPreview() && object.sub type !== "node" && object.type !== "function" && (object.type !== "object" || ob ject.preview);
1164 }
1165
1166 /**
1167 * @param {!WebInspector.RemoteObject} value
1168 * @return {?Element}
1169 */
1170 WebInspector.ObjectPropertiesSection._createExpandedValueElement = function(valu e)
1171 {
1172 if (!WebInspector.ObjectPropertiesSection._needsAlternateTitle(value))
1173 return null;
1174
1175 var valueElement = createElementWithClass("span", "value");
1176 valueElement.setTextContentTruncatedIfNeeded(value.description || "");
1177 valueElement.classList.add("object-value-" + (value.subtype || value.type));
1178 valueElement.title = value.description || "";
1179 return valueElement;
1180 }
1181
1182 /**
1097 * @param {!WebInspector.RemoteObject} func 1183 * @param {!WebInspector.RemoteObject} func
1098 * @param {!Element} element 1184 * @param {!Element} element
1099 * @param {boolean} linkify 1185 * @param {boolean} linkify
1100 * @param {boolean=} includePreview 1186 * @param {boolean=} includePreview
1101 */ 1187 */
1102 WebInspector.ObjectPropertiesSection.formatObjectAsFunction = function(func, ele ment, linkify, includePreview) 1188 WebInspector.ObjectPropertiesSection.formatObjectAsFunction = function(func, ele ment, linkify, includePreview)
1103 { 1189 {
1104 func.debuggerModel().functionDetailsPromise(func).then(didGetDetails); 1190 func.debuggerModel().functionDetailsPromise(func).then(didGetDetails);
1105 1191
1106 /** 1192 /**
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 1346
1261 result = currentName + (result ? "." + result : ""); 1347 result = currentName + (result ? "." + result : "");
1262 current = current.parent; 1348 current = current.parent;
1263 } 1349 }
1264 var treeOutlineId = treeElement.treeOutline[WebInspector.ObjectPropertie sSectionExpandController._treeOutlineId]; 1350 var treeOutlineId = treeElement.treeOutline[WebInspector.ObjectPropertie sSectionExpandController._treeOutlineId];
1265 result = treeOutlineId + (result ? ":" + result : ""); 1351 result = treeOutlineId + (result ? ":" + result : "");
1266 treeElement[WebInspector.ObjectPropertiesSectionExpandController._cached PathSymbol] = result; 1352 treeElement[WebInspector.ObjectPropertiesSectionExpandController._cached PathSymbol] = result;
1267 return result; 1353 return result;
1268 } 1354 }
1269 } 1355 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698