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

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

Issue 2605693003: DevTools: introduce object previews experiment (Closed)
Patch Set: tests Created 3 years, 11 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 else 212 else
213 valueElement.createTextChild(abbreviation.replace(/\n/g, ' ')); 213 valueElement.createTextChild(abbreviation.replace(/\n/g, ' '));
214 } 214 }
215 } 215 }
216 216
217 /** 217 /**
218 * @param {!SDK.RemoteObject} value 218 * @param {!SDK.RemoteObject} value
219 * @param {boolean} wasThrown 219 * @param {boolean} wasThrown
220 * @param {!Element=} parentElement 220 * @param {!Element=} parentElement
221 * @param {!Components.Linkifier=} linkifier 221 * @param {!Components.Linkifier=} linkifier
222 * @param {boolean=} hidePreview
222 * @return {!Element} 223 * @return {!Element}
223 */ 224 */
224 static createValueElementWithCustomSupport(value, wasThrown, parentElement, li nkifier) { 225 static createValueElementWithCustomSupport(value, wasThrown, parentElement, li nkifier, hidePreview) {
225 if (value.customPreview()) { 226 if (value.customPreview()) {
226 var result = (new Components.CustomPreviewComponent(value)).element; 227 var result = (new Components.CustomPreviewComponent(value)).element;
227 result.classList.add('object-properties-section-custom-section'); 228 result.classList.add('object-properties-section-custom-section');
228 return result; 229 return result;
229 } 230 }
230 return Components.ObjectPropertiesSection.createValueElement(value, wasThrow n, parentElement, linkifier); 231 return Components.ObjectPropertiesSection.createValueElement(
232 value, wasThrown, parentElement, linkifier, hidePreview);
231 } 233 }
232 234
233 /** 235 /**
234 * @param {!SDK.RemoteObject} value 236 * @param {!SDK.RemoteObject} value
235 * @param {boolean} wasThrown 237 * @param {boolean} wasThrown
236 * @param {!Element=} parentElement 238 * @param {!Element=} parentElement
237 * @param {!Components.Linkifier=} linkifier 239 * @param {!Components.Linkifier=} linkifier
240 * @param {boolean=} hidePreview
238 * @return {!Element} 241 * @return {!Element}
239 */ 242 */
240 static createValueElement(value, wasThrown, parentElement, linkifier) { 243 static createValueElement(value, wasThrown, parentElement, linkifier, hidePrev iew) {
241 var valueElement; 244 var valueElement;
242 var type = value.type; 245 var type = value.type;
243 var subtype = value.subtype; 246 var subtype = value.subtype;
244 var description = value.description; 247 var description = value.description;
245 if (type === 'object' && subtype === 'internal#location') { 248 if (type === 'object' && subtype === 'internal#location') {
246 var rawLocation = value.debuggerModel().createRawLocationByScriptId( 249 var rawLocation = value.debuggerModel().createRawLocationByScriptId(
247 value.value.scriptId, value.value.lineNumber, value.value.columnNumber ); 250 value.value.scriptId, value.value.lineNumber, value.value.columnNumber );
248 if (rawLocation && linkifier) 251 if (rawLocation && linkifier)
249 return linkifier.linkifyRawLocation(rawLocation, ''); 252 return linkifier.linkifyRawLocation(rawLocation, '');
250 valueElement = createUnknownInternalLocationElement(); 253 valueElement = createUnknownInternalLocationElement();
251 valueElement.title = description; 254 valueElement.title = description;
252 } else if (type === 'string' && typeof description === 'string') { 255 } else if (type === 'string' && typeof description === 'string') {
253 valueElement = createStringElement(); 256 valueElement = createStringElement();
254 valueElement.title = description; 257 valueElement.title = description;
255 } else if (type === 'function') { 258 } else if (type === 'function') {
256 valueElement = Components.ObjectPropertiesSection.valueElementForFunctionD escription(description); 259 valueElement = Components.ObjectPropertiesSection.valueElementForFunctionD escription(description);
257 valueElement.title = description; 260 valueElement.title = description;
258 } else if (type === 'object' && subtype === 'node' && description) { 261 } else if (type === 'object' && subtype === 'node' && description) {
259 valueElement = createNodeElement(); 262 valueElement = createNodeElement();
260 } else if (type === 'number' && description && description.indexOf('e') !== -1) { 263 } else if (type === 'number' && description && description.indexOf('e') !== -1) {
261 valueElement = createNumberWithExponentElement(); 264 valueElement = createNumberWithExponentElement();
262 valueElement.title = description; 265 valueElement.title = description;
263 if (parentElement) // FIXME: do it in the caller. 266 if (parentElement) // FIXME: do it in the caller.
264 parentElement.classList.add('hbox'); 267 parentElement.classList.add('hbox');
265 } else { 268 } else {
266 valueElement = createElementWithClass('span', 'object-value-' + (subtype | | type)); 269 valueElement = createElementWithClass('span', 'object-value-' + (subtype | | type));
267 valueElement.setTextContentTruncatedIfNeeded(description);
268 valueElement.title = description; 270 valueElement.title = description;
271 if (value.preview && !hidePreview) {
dgozman 2017/01/10 22:26:09 You should check experiment here, not at the call
luoe 2017/01/13 01:11:45 Done.
272 var previewFormatter = new Components.RemoteObjectPreviewFormatter();
273 previewFormatter.appendObjectPreview(valueElement, value.preview);
274 } else {
275 valueElement.setTextContentTruncatedIfNeeded(description);
276 }
269 } 277 }
270 278
271 if (wasThrown) { 279 if (wasThrown) {
272 var wrapperElement = createElementWithClass('span', 'error value'); 280 var wrapperElement = createElementWithClass('span', 'error value');
273 wrapperElement.createTextChild('[' + Common.UIString('Exception') + ': '); 281 wrapperElement.createTextChild('[' + Common.UIString('Exception') + ': ');
274 wrapperElement.appendChild(valueElement); 282 wrapperElement.appendChild(valueElement);
275 wrapperElement.createTextChild(']'); 283 wrapperElement.createTextChild(']');
276 return wrapperElement; 284 return wrapperElement;
277 } 285 }
278 valueElement.classList.add('value'); 286 valueElement.classList.add('value');
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 if (this.property.synthetic) 782 if (this.property.synthetic)
775 this.nameElement.classList.add('synthetic-property'); 783 this.nameElement.classList.add('synthetic-property');
776 784
777 this._updatePropertyPath(); 785 this._updatePropertyPath();
778 this.nameElement.addEventListener('contextmenu', this._contextMenuFired.bind (this, this.property), false); 786 this.nameElement.addEventListener('contextmenu', this._contextMenuFired.bind (this, this.property), false);
779 787
780 var separatorElement = createElementWithClass('span', 'object-properties-sec tion-separator'); 788 var separatorElement = createElementWithClass('span', 'object-properties-sec tion-separator');
781 separatorElement.textContent = ': '; 789 separatorElement.textContent = ': ';
782 790
783 if (this.property.value) { 791 if (this.property.value) {
792 var hidePreview = this.property.name === '__proto__' || !Runtime.experimen ts.isEnabled('objectPreviews');
784 this.valueElement = Components.ObjectPropertiesSection.createValueElementW ithCustomSupport( 793 this.valueElement = Components.ObjectPropertiesSection.createValueElementW ithCustomSupport(
785 this.property.value, this.property.wasThrown, this.listItemElement, th is._linkifier); 794 this.property.value, this.property.wasThrown, this.listItemElement, th is._linkifier, hidePreview);
786 this.valueElement.addEventListener('contextmenu', this._contextMenuFired.b ind(this, this.property), false); 795 this.valueElement.addEventListener('contextmenu', this._contextMenuFired.b ind(this, this.property), false);
787 } else if (this.property.getter) { 796 } else if (this.property.getter) {
788 this.valueElement = Components.ObjectPropertyTreeElement.createRemoteObjec tAccessorPropertySpan( 797 this.valueElement = Components.ObjectPropertyTreeElement.createRemoteObjec tAccessorPropertySpan(
789 this.property.parentObject, [this.property.name], this._onInvokeGetter Click.bind(this)); 798 this.property.parentObject, [this.property.name], this._onInvokeGetter Click.bind(this));
790 } else { 799 } else {
791 this.valueElement = createElementWithClass('span', 'object-value-undefined '); 800 this.valueElement = createElementWithClass('span', 'object-value-undefined ');
792 this.valueElement.textContent = Common.UIString('<unreadable>'); 801 this.valueElement.textContent = Common.UIString('<unreadable>');
793 this.valueElement.title = Common.UIString('No property getter'); 802 this.valueElement.title = Common.UIString('No property getter');
794 } 803 }
795 804
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 } 1374 }
1366 var treeOutlineId = treeElement.treeOutline[Components.ObjectPropertiesSecti onExpandController._treeOutlineId]; 1375 var treeOutlineId = treeElement.treeOutline[Components.ObjectPropertiesSecti onExpandController._treeOutlineId];
1367 result = treeOutlineId + (result ? ':' + result : ''); 1376 result = treeOutlineId + (result ? ':' + result : '');
1368 treeElement[Components.ObjectPropertiesSectionExpandController._cachedPathSy mbol] = result; 1377 treeElement[Components.ObjectPropertiesSectionExpandController._cachedPathSy mbol] = result;
1369 return result; 1378 return result;
1370 } 1379 }
1371 }; 1380 };
1372 1381
1373 Components.ObjectPropertiesSectionExpandController._cachedPathSymbol = Symbol('c achedPath'); 1382 Components.ObjectPropertiesSectionExpandController._cachedPathSymbol = Symbol('c achedPath');
1374 Components.ObjectPropertiesSectionExpandController._treeOutlineId = Symbol('tree OutlineId'); 1383 Components.ObjectPropertiesSectionExpandController._treeOutlineId = Symbol('tree OutlineId');
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698