| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * | 9 * |
| 10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 } | 615 } |
| 616 | 616 |
| 617 /** | 617 /** |
| 618 * @param {!SDK.RemoteObject} array | 618 * @param {!SDK.RemoteObject} array |
| 619 * @return {!Element} | 619 * @return {!Element} |
| 620 */ | 620 */ |
| 621 _formatParameterAsArray(array) { | 621 _formatParameterAsArray(array) { |
| 622 var usePrintedArrayFormat = this._message.type !== SDK.ConsoleMessage.Messag
eType.DirXML && | 622 var usePrintedArrayFormat = this._message.type !== SDK.ConsoleMessage.Messag
eType.DirXML && |
| 623 this._message.type !== SDK.ConsoleMessage.MessageType.Result; | 623 this._message.type !== SDK.ConsoleMessage.MessageType.Result; |
| 624 var isLongArray = array.arrayLength() > 100; | 624 var isLongArray = array.arrayLength() > 100; |
| 625 if (usePrintedArrayFormat || isLongArray) | 625 if (usePrintedArrayFormat || isLongArray || !array.preview) |
| 626 return this._formatParameterAsObject(array, usePrintedArrayFormat || !isLo
ngArray); | 626 return this._formatParameterAsObject(array, usePrintedArrayFormat || !isLo
ngArray); |
| 627 var result = createElement('span'); | 627 var titleElement = createElementWithClass('span', 'console-object-preview'); |
| 628 array.getAllProperties(false, printArrayResult.bind(this)); | 628 this._previewFormatter.appendObjectPreview(titleElement, array.preview); |
| 629 return result; | 629 var section = new Components.ObjectPropertiesSection(array, titleElement, th
is._linkifier); |
| 630 | 630 section.element.classList.add('console-view-object-properties-section'); |
| 631 /** | 631 section.enableContextMenu(); |
| 632 * @param {?Array.<!SDK.RemoteObjectProperty>} properties | 632 return section.element; |
| 633 * @this {!Console.ConsoleViewMessage} | |
| 634 */ | |
| 635 function printArrayResult(properties) { | |
| 636 if (!properties) { | |
| 637 result.appendChild(this._formatParameterAsObject(array, false)); | |
| 638 return; | |
| 639 } | |
| 640 | |
| 641 var titleElement = createElementWithClass('span', 'console-object-preview'
); | |
| 642 if (array.subtype === 'typedarray') | |
| 643 titleElement.createTextChild(array.description + ' '); | |
| 644 var elements = {}; | |
| 645 for (var i = 0; i < properties.length; ++i) { | |
| 646 var property = properties[i]; | |
| 647 var name = property.name; | |
| 648 if (isNaN(name)) | |
| 649 continue; | |
| 650 if (property.getter) | |
| 651 elements[name] = this._formatAsAccessorProperty(array, [name], true); | |
| 652 else if (property.value) | |
| 653 elements[name] = this._formatAsArrayEntry(property.value); | |
| 654 } | |
| 655 | |
| 656 titleElement.createTextChild('['); | |
| 657 var lastNonEmptyIndex = -1; | |
| 658 | |
| 659 function appendUndefined(titleElement, index) { | |
| 660 if (index - lastNonEmptyIndex <= 1) | |
| 661 return; | |
| 662 var span = titleElement.createChild('span', 'object-value-undefined'); | |
| 663 span.textContent = Common.UIString('undefined × %d', index - lastNonEmpt
yIndex - 1); | |
| 664 } | |
| 665 | |
| 666 var length = array.arrayLength(); | |
| 667 for (var i = 0; i < length; ++i) { | |
| 668 var element = elements[i]; | |
| 669 if (!element) | |
| 670 continue; | |
| 671 | |
| 672 if (i - lastNonEmptyIndex > 1) { | |
| 673 appendUndefined(titleElement, i); | |
| 674 titleElement.createTextChild(', '); | |
| 675 } | |
| 676 | |
| 677 titleElement.appendChild(element); | |
| 678 lastNonEmptyIndex = i; | |
| 679 if (i < length - 1) | |
| 680 titleElement.createTextChild(', '); | |
| 681 } | |
| 682 appendUndefined(titleElement, length); | |
| 683 | |
| 684 titleElement.createTextChild(']'); | |
| 685 | |
| 686 var section = new Components.ObjectPropertiesSection(array, titleElement,
this._linkifier); | |
| 687 section.element.classList.add('console-view-object-properties-section'); | |
| 688 section.enableContextMenu(); | |
| 689 result.appendChild(section.element); | |
| 690 } | |
| 691 } | 633 } |
| 692 | 634 |
| 693 /** | 635 /** |
| 694 * @param {!SDK.RemoteObject} output | 636 * @param {!SDK.RemoteObject} output |
| 695 * @return {!Element} | 637 * @return {!Element} |
| 696 */ | 638 */ |
| 697 _formatParameterAsString(output) { | 639 _formatParameterAsString(output) { |
| 698 var span = createElement('span'); | 640 var span = createElement('span'); |
| 699 span.appendChild(Components.linkifyStringAsFragment(output.description || ''
)); | 641 span.appendChild(Components.linkifyStringAsFragment(output.description || ''
)); |
| 700 | 642 |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 toMessageElement() { | 1204 toMessageElement() { |
| 1263 if (!this._element) { | 1205 if (!this._element) { |
| 1264 super.toMessageElement(); | 1206 super.toMessageElement(); |
| 1265 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); | 1207 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); |
| 1266 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem
ent.firstChild); | 1208 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem
ent.firstChild); |
| 1267 this.setCollapsed(this._collapsed); | 1209 this.setCollapsed(this._collapsed); |
| 1268 } | 1210 } |
| 1269 return this._element; | 1211 return this._element; |
| 1270 } | 1212 } |
| 1271 }; | 1213 }; |
| OLD | NEW |