| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * @param {!SDK.RemoteObject} object | 72 * @param {!SDK.RemoteObject} object |
| 73 * @param {!Components.Linkifier=} linkifier | 73 * @param {!Components.Linkifier=} linkifier |
| 74 * @param {boolean=} skipProto | 74 * @param {boolean=} skipProto |
| 75 * @return {!Element} | 75 * @return {!Element} |
| 76 */ | 76 */ |
| 77 static defaultObjectPresentation(object, linkifier, skipProto) { | 77 static defaultObjectPresentation(object, linkifier, skipProto) { |
| 78 var componentRoot = createElementWithClass('span', 'source-code'); | 78 var componentRoot = createElementWithClass('span', 'source-code'); |
| 79 var shadowRoot = UI.createShadowRootWithCoreStyles(componentRoot, 'component
s/objectValue.css'); | 79 var shadowRoot = UI.createShadowRootWithCoreStyles(componentRoot, 'component
s/objectValue.css'); |
| 80 shadowRoot.appendChild(Components.ObjectPropertiesSection.createValueElement
(object, false)); | 80 shadowRoot.appendChild( |
| 81 Components.ObjectPropertiesSection.createValueElement(object, false /* w
asThrown */, true /* showPreview */)); |
| 81 if (!object.hasChildren) | 82 if (!object.hasChildren) |
| 82 return componentRoot; | 83 return componentRoot; |
| 83 | 84 |
| 84 var objectPropertiesSection = new Components.ObjectPropertiesSection(object,
componentRoot, linkifier); | 85 var objectPropertiesSection = new Components.ObjectPropertiesSection(object,
componentRoot, linkifier); |
| 85 objectPropertiesSection.editable = false; | 86 objectPropertiesSection.editable = false; |
| 86 if (skipProto) | 87 if (skipProto) |
| 87 objectPropertiesSection.skipProto(); | 88 objectPropertiesSection.skipProto(); |
| 88 | 89 |
| 89 return objectPropertiesSection.element; | 90 return objectPropertiesSection.element; |
| 90 } | 91 } |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 if (includePreview) | 212 if (includePreview) |
| 212 valueElement.createTextChild(body.trim().trimEnd(maxFunctionBodyLength))
; | 213 valueElement.createTextChild(body.trim().trimEnd(maxFunctionBodyLength))
; |
| 213 else | 214 else |
| 214 valueElement.createTextChild(abbreviation.replace(/\n/g, ' ')); | 215 valueElement.createTextChild(abbreviation.replace(/\n/g, ' ')); |
| 215 } | 216 } |
| 216 } | 217 } |
| 217 | 218 |
| 218 /** | 219 /** |
| 219 * @param {!SDK.RemoteObject} value | 220 * @param {!SDK.RemoteObject} value |
| 220 * @param {boolean} wasThrown | 221 * @param {boolean} wasThrown |
| 222 * @param {boolean} showPreview |
| 221 * @param {!Element=} parentElement | 223 * @param {!Element=} parentElement |
| 222 * @param {!Components.Linkifier=} linkifier | 224 * @param {!Components.Linkifier=} linkifier |
| 223 * @return {!Element} | 225 * @return {!Element} |
| 224 */ | 226 */ |
| 225 static createValueElementWithCustomSupport(value, wasThrown, parentElement, li
nkifier) { | 227 static createValueElementWithCustomSupport(value, wasThrown, showPreview, pare
ntElement, linkifier) { |
| 226 if (value.customPreview()) { | 228 if (value.customPreview()) { |
| 227 var result = (new Components.CustomPreviewComponent(value)).element; | 229 var result = (new Components.CustomPreviewComponent(value)).element; |
| 228 result.classList.add('object-properties-section-custom-section'); | 230 result.classList.add('object-properties-section-custom-section'); |
| 229 return result; | 231 return result; |
| 230 } | 232 } |
| 231 return Components.ObjectPropertiesSection.createValueElement(value, wasThrow
n, parentElement, linkifier); | 233 return Components.ObjectPropertiesSection.createValueElement( |
| 234 value, wasThrown, showPreview, parentElement, linkifier); |
| 232 } | 235 } |
| 233 | 236 |
| 234 /** | 237 /** |
| 235 * @param {!SDK.RemoteObject} value | 238 * @param {!SDK.RemoteObject} value |
| 236 * @param {boolean} wasThrown | 239 * @param {boolean} wasThrown |
| 240 * @param {boolean} showPreview |
| 237 * @param {!Element=} parentElement | 241 * @param {!Element=} parentElement |
| 238 * @param {!Components.Linkifier=} linkifier | 242 * @param {!Components.Linkifier=} linkifier |
| 239 * @return {!Element} | 243 * @return {!Element} |
| 240 */ | 244 */ |
| 241 static createValueElement(value, wasThrown, parentElement, linkifier) { | 245 static createValueElement(value, wasThrown, showPreview, parentElement, linkif
ier) { |
| 242 var valueElement; | 246 var valueElement; |
| 243 var type = value.type; | 247 var type = value.type; |
| 244 var subtype = value.subtype; | 248 var subtype = value.subtype; |
| 245 var description = value.description; | 249 var description = value.description; |
| 246 if (type === 'object' && subtype === 'internal#location') { | 250 if (type === 'object' && subtype === 'internal#location') { |
| 247 var rawLocation = value.debuggerModel().createRawLocationByScriptId( | 251 var rawLocation = value.debuggerModel().createRawLocationByScriptId( |
| 248 value.value.scriptId, value.value.lineNumber, value.value.columnNumber
); | 252 value.value.scriptId, value.value.lineNumber, value.value.columnNumber
); |
| 249 if (rawLocation && linkifier) | 253 if (rawLocation && linkifier) |
| 250 return linkifier.linkifyRawLocation(rawLocation, ''); | 254 return linkifier.linkifyRawLocation(rawLocation, ''); |
| 251 valueElement = createUnknownInternalLocationElement(); | 255 valueElement = createUnknownInternalLocationElement(); |
| 252 } else if (type === 'string' && typeof description === 'string') { | 256 } else if (type === 'string' && typeof description === 'string') { |
| 253 valueElement = createStringElement(); | 257 valueElement = createStringElement(); |
| 254 } else if (type === 'function') { | 258 } else if (type === 'function') { |
| 255 valueElement = Components.ObjectPropertiesSection.valueElementForFunctionD
escription(description); | 259 valueElement = Components.ObjectPropertiesSection.valueElementForFunctionD
escription(description); |
| 256 } else if (type === 'object' && subtype === 'node' && description) { | 260 } else if (type === 'object' && subtype === 'node' && description) { |
| 257 valueElement = createNodeElement(); | 261 valueElement = createNodeElement(); |
| 258 } else if (type === 'number' && description && description.indexOf('e') !==
-1) { | 262 } else if (type === 'number' && description && description.indexOf('e') !==
-1) { |
| 259 valueElement = createNumberWithExponentElement(); | 263 valueElement = createNumberWithExponentElement(); |
| 260 if (parentElement) // FIXME: do it in the caller. | 264 if (parentElement) // FIXME: do it in the caller. |
| 261 parentElement.classList.add('hbox'); | 265 parentElement.classList.add('hbox'); |
| 262 } else { | 266 } else { |
| 263 valueElement = createElementWithClass('span', 'object-value-' + (subtype |
| type)); | 267 valueElement = createElementWithClass('span', 'object-value-' + (subtype |
| type)); |
| 264 valueElement.setTextContentTruncatedIfNeeded(description); | |
| 265 valueElement.title = description || ''; | 268 valueElement.title = description || ''; |
| 269 if (Runtime.experiments.isEnabled('objectPreviews') && value.preview && sh
owPreview) { |
| 270 var previewFormatter = new Components.RemoteObjectPreviewFormatter(); |
| 271 previewFormatter.appendObjectPreview(valueElement, value.preview, false
/* isEntry */); |
| 272 } else { |
| 273 valueElement.setTextContentTruncatedIfNeeded(description); |
| 274 } |
| 266 } | 275 } |
| 267 | 276 |
| 268 if (wasThrown) { | 277 if (wasThrown) { |
| 269 var wrapperElement = createElementWithClass('span', 'error value'); | 278 var wrapperElement = createElementWithClass('span', 'error value'); |
| 270 wrapperElement.createTextChild('[' + Common.UIString('Exception') + ': '); | 279 wrapperElement.createTextChild('[' + Common.UIString('Exception') + ': '); |
| 271 wrapperElement.appendChild(valueElement); | 280 wrapperElement.appendChild(valueElement); |
| 272 wrapperElement.createTextChild(']'); | 281 wrapperElement.createTextChild(']'); |
| 273 return wrapperElement; | 282 return wrapperElement; |
| 274 } | 283 } |
| 275 valueElement.classList.add('value'); | 284 valueElement.classList.add('value'); |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 return; | 548 return; |
| 540 | 549 |
| 541 extraProperties = extraProperties || []; | 550 extraProperties = extraProperties || []; |
| 542 for (var i = 0; i < extraProperties.length; ++i) | 551 for (var i = 0; i < extraProperties.length; ++i) |
| 543 properties.push(extraProperties[i]); | 552 properties.push(extraProperties[i]); |
| 544 | 553 |
| 545 Components.ObjectPropertyTreeElement.populateWithProperties( | 554 Components.ObjectPropertyTreeElement.populateWithProperties( |
| 546 treeElement, properties, internalProperties, skipProto, targetValue ||
value, linkifier, emptyPlaceholder); | 555 treeElement, properties, internalProperties, skipProto, targetValue ||
value, linkifier, emptyPlaceholder); |
| 547 } | 556 } |
| 548 | 557 |
| 558 var generatePreview = Runtime.experiments.isEnabled('objectPreviews'); |
| 549 if (flattenProtoChain) | 559 if (flattenProtoChain) |
| 550 value.getAllProperties(false, callback); | 560 value.getAllProperties(false, generatePreview, callback); |
| 551 else | 561 else |
| 552 SDK.RemoteObject.loadFromObjectPerProto(value, callback); | 562 SDK.RemoteObject.loadFromObjectPerProto(value, generatePreview, callback); |
| 553 } | 563 } |
| 554 | 564 |
| 555 /** | 565 /** |
| 556 * @param {!UI.TreeElement} treeNode | 566 * @param {!UI.TreeElement} treeNode |
| 557 * @param {!Array.<!SDK.RemoteObjectProperty>} properties | 567 * @param {!Array.<!SDK.RemoteObjectProperty>} properties |
| 558 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties | 568 * @param {?Array.<!SDK.RemoteObjectProperty>} internalProperties |
| 559 * @param {boolean} skipProto | 569 * @param {boolean} skipProto |
| 560 * @param {?SDK.RemoteObject} value | 570 * @param {?SDK.RemoteObject} value |
| 561 * @param {!Components.Linkifier=} linkifier | 571 * @param {!Components.Linkifier=} linkifier |
| 562 * @param {?string=} emptyPlaceholder | 572 * @param {?string=} emptyPlaceholder |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 if (this.property.synthetic) | 784 if (this.property.synthetic) |
| 775 this.nameElement.classList.add('synthetic-property'); | 785 this.nameElement.classList.add('synthetic-property'); |
| 776 | 786 |
| 777 this._updatePropertyPath(); | 787 this._updatePropertyPath(); |
| 778 this.nameElement.addEventListener('contextmenu', this._contextMenuFired.bind
(this, this.property), false); | 788 this.nameElement.addEventListener('contextmenu', this._contextMenuFired.bind
(this, this.property), false); |
| 779 | 789 |
| 780 var separatorElement = createElementWithClass('span', 'object-properties-sec
tion-separator'); | 790 var separatorElement = createElementWithClass('span', 'object-properties-sec
tion-separator'); |
| 781 separatorElement.textContent = ': '; | 791 separatorElement.textContent = ': '; |
| 782 | 792 |
| 783 if (this.property.value) { | 793 if (this.property.value) { |
| 794 var showPreview = this.property.name !== '__proto__'; |
| 784 this.valueElement = Components.ObjectPropertiesSection.createValueElementW
ithCustomSupport( | 795 this.valueElement = Components.ObjectPropertiesSection.createValueElementW
ithCustomSupport( |
| 785 this.property.value, this.property.wasThrown, this.listItemElement, th
is._linkifier); | 796 this.property.value, this.property.wasThrown, showPreview, this.listIt
emElement, this._linkifier); |
| 786 this.valueElement.addEventListener('contextmenu', this._contextMenuFired.b
ind(this, this.property), false); | 797 this.valueElement.addEventListener('contextmenu', this._contextMenuFired.b
ind(this, this.property), false); |
| 787 } else if (this.property.getter) { | 798 } else if (this.property.getter) { |
| 788 this.valueElement = Components.ObjectPropertyTreeElement.createRemoteObjec
tAccessorPropertySpan( | 799 this.valueElement = Components.ObjectPropertyTreeElement.createRemoteObjec
tAccessorPropertySpan( |
| 789 this.property.parentObject, [this.property.name], this._onInvokeGetter
Click.bind(this)); | 800 this.property.parentObject, [this.property.name], this._onInvokeGetter
Click.bind(this)); |
| 790 } else { | 801 } else { |
| 791 this.valueElement = createElementWithClass('span', 'object-value-undefined
'); | 802 this.valueElement = createElementWithClass('span', 'object-value-undefined
'); |
| 792 this.valueElement.textContent = Common.UIString('<unreadable>'); | 803 this.valueElement.textContent = Common.UIString('<unreadable>'); |
| 793 this.valueElement.title = Common.UIString('No property getter'); | 804 this.valueElement.title = Common.UIString('No property getter'); |
| 794 } | 805 } |
| 795 | 806 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 } | 1170 } |
| 1160 | 1171 |
| 1161 /** | 1172 /** |
| 1162 * @param {?SDK.RemoteObject} arrayFragment | 1173 * @param {?SDK.RemoteObject} arrayFragment |
| 1163 * @param {boolean=} wasThrown | 1174 * @param {boolean=} wasThrown |
| 1164 * @this {Components.ArrayGroupingTreeElement} | 1175 * @this {Components.ArrayGroupingTreeElement} |
| 1165 */ | 1176 */ |
| 1166 function processArrayFragment(arrayFragment, wasThrown) { | 1177 function processArrayFragment(arrayFragment, wasThrown) { |
| 1167 if (!arrayFragment || wasThrown) | 1178 if (!arrayFragment || wasThrown) |
| 1168 return; | 1179 return; |
| 1169 arrayFragment.getAllProperties(false, processProperties.bind(this)); | 1180 arrayFragment.getAllProperties( |
| 1181 false, Runtime.experiments.isEnabled('objectPreviews'), processPropert
ies.bind(this)); |
| 1170 } | 1182 } |
| 1171 | 1183 |
| 1172 /** @this {Components.ArrayGroupingTreeElement} */ | 1184 /** @this {Components.ArrayGroupingTreeElement} */ |
| 1173 function processProperties(properties, internalProperties) { | 1185 function processProperties(properties, internalProperties) { |
| 1174 if (!properties) | 1186 if (!properties) |
| 1175 return; | 1187 return; |
| 1176 | 1188 |
| 1177 properties.sort(Components.ObjectPropertiesSection.CompareProperties); | 1189 properties.sort(Components.ObjectPropertiesSection.CompareProperties); |
| 1178 for (var i = 0; i < properties.length; ++i) { | 1190 for (var i = 0; i < properties.length; ++i) { |
| 1179 properties[i].parentObject = this._object; | 1191 properties[i].parentObject = this._object; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 } | 1229 } |
| 1218 | 1230 |
| 1219 /** | 1231 /** |
| 1220 * @param {?SDK.RemoteObject} arrayFragment | 1232 * @param {?SDK.RemoteObject} arrayFragment |
| 1221 * @param {boolean=} wasThrown | 1233 * @param {boolean=} wasThrown |
| 1222 * @this {Components.ArrayGroupingTreeElement} | 1234 * @this {Components.ArrayGroupingTreeElement} |
| 1223 */ | 1235 */ |
| 1224 function processObjectFragment(arrayFragment, wasThrown) { | 1236 function processObjectFragment(arrayFragment, wasThrown) { |
| 1225 if (!arrayFragment || wasThrown) | 1237 if (!arrayFragment || wasThrown) |
| 1226 return; | 1238 return; |
| 1227 arrayFragment.getOwnProperties(processProperties.bind(this)); | 1239 arrayFragment.getOwnProperties(Runtime.experiments.isEnabled('objectPrevie
ws'), processProperties.bind(this)); |
| 1228 } | 1240 } |
| 1229 | 1241 |
| 1230 /** | 1242 /** |
| 1231 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 1243 * @param {?Array.<!SDK.RemoteObjectProperty>} properties |
| 1232 * @param {?Array.<!SDK.RemoteObjectProperty>=} internalProperties | 1244 * @param {?Array.<!SDK.RemoteObjectProperty>=} internalProperties |
| 1233 * @this {Components.ArrayGroupingTreeElement} | 1245 * @this {Components.ArrayGroupingTreeElement} |
| 1234 */ | 1246 */ |
| 1235 function processProperties(properties, internalProperties) { | 1247 function processProperties(properties, internalProperties) { |
| 1236 if (!properties) | 1248 if (!properties) |
| 1237 return; | 1249 return; |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 } | 1377 } |
| 1366 var treeOutlineId = treeElement.treeOutline[Components.ObjectPropertiesSecti
onExpandController._treeOutlineId]; | 1378 var treeOutlineId = treeElement.treeOutline[Components.ObjectPropertiesSecti
onExpandController._treeOutlineId]; |
| 1367 result = treeOutlineId + (result ? ':' + result : ''); | 1379 result = treeOutlineId + (result ? ':' + result : ''); |
| 1368 treeElement[Components.ObjectPropertiesSectionExpandController._cachedPathSy
mbol] = result; | 1380 treeElement[Components.ObjectPropertiesSectionExpandController._cachedPathSy
mbol] = result; |
| 1369 return result; | 1381 return result; |
| 1370 } | 1382 } |
| 1371 }; | 1383 }; |
| 1372 | 1384 |
| 1373 Components.ObjectPropertiesSectionExpandController._cachedPathSymbol = Symbol('c
achedPath'); | 1385 Components.ObjectPropertiesSectionExpandController._cachedPathSymbol = Symbol('c
achedPath'); |
| 1374 Components.ObjectPropertiesSectionExpandController._treeOutlineId = Symbol('tree
OutlineId'); | 1386 Components.ObjectPropertiesSectionExpandController._treeOutlineId = Symbol('tree
OutlineId'); |
| OLD | NEW |