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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 | 510 |
511 /** | 511 /** |
512 * @param {!Element} parentElement | 512 * @param {!Element} parentElement |
513 * @param {!RuntimeAgent.ObjectPreview} preview | 513 * @param {!RuntimeAgent.ObjectPreview} preview |
514 * @param {?WebInspector.RemoteObject} object | 514 * @param {?WebInspector.RemoteObject} object |
515 * @return {boolean} true iff preview captured all information. | 515 * @return {boolean} true iff preview captured all information. |
516 */ | 516 */ |
517 _appendPropertiesPreview: function(parentElement, preview, object) | 517 _appendPropertiesPreview: function(parentElement, preview, object) |
518 { | 518 { |
519 var isArray = preview.subtype === "array"; | 519 var isArray = preview.subtype === "array"; |
| 520 var arrayLength = WebInspector.RemoteObject.arrayLength(preview); |
| 521 var properties = preview.properties; |
| 522 if (isArray) |
| 523 properties = properties.slice().stableSort(compareIndexesFirst); |
| 524 |
| 525 /** |
| 526 * @param {!RuntimeAgent.PropertyPreview} a |
| 527 * @param {!RuntimeAgent.PropertyPreview} b |
| 528 */ |
| 529 function compareIndexesFirst(a, b) |
| 530 { |
| 531 var index1 = toArrayIndex(a.name); |
| 532 var index2 = toArrayIndex(b.name); |
| 533 if (index1 < 0) |
| 534 return index2 < 0 ? 0 : 1; |
| 535 return index2 < 0 ? -1 : index1 - index2; |
| 536 } |
| 537 |
| 538 /** |
| 539 * @param {string} name |
| 540 * @return {number} |
| 541 */ |
| 542 function toArrayIndex(name) |
| 543 { |
| 544 var index = name >>> 0; |
| 545 if (String(index) === name && index < arrayLength) |
| 546 return index; |
| 547 return -1; |
| 548 } |
| 549 |
520 parentElement.createTextChild(isArray ? "[" : "{"); | 550 parentElement.createTextChild(isArray ? "[" : "{"); |
521 for (var i = 0; i < preview.properties.length; ++i) { | 551 for (var i = 0; i < properties.length; ++i) { |
522 if (i > 0) | 552 if (i > 0) |
523 parentElement.createTextChild(", "); | 553 parentElement.createTextChild(", "); |
524 | 554 |
525 var property = preview.properties[i]; | 555 var property = properties[i]; |
526 var name = property.name; | 556 var name = property.name; |
527 if (!isArray || name != i) { | 557 if (!isArray || name != i || i >= arrayLength) { |
528 if (/^\s|\s$|^$|\n/.test(name)) | 558 if (/^\s|\s$|^$|\n/.test(name)) |
529 parentElement.createChild("span", "name").createTextChildren
("\"", name.replace(/\n/g, "\u21B5"), "\""); | 559 parentElement.createChild("span", "name").createTextChildren
("\"", name.replace(/\n/g, "\u21B5"), "\""); |
530 else | 560 else |
531 parentElement.createChild("span", "name").textContent = name
; | 561 parentElement.createChild("span", "name").textContent = name
; |
532 parentElement.createTextChild(": "); | 562 parentElement.createTextChild(": "); |
533 } | 563 } |
534 | 564 |
535 parentElement.appendChild(this._renderPropertyPreviewOrAccessor(obje
ct, [property])); | 565 parentElement.appendChild(this._renderPropertyPreviewOrAccessor(obje
ct, [property])); |
536 } | 566 } |
537 if (preview.overflow) | 567 if (preview.overflow) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 * @param {!WebInspector.RemoteObject} array | 677 * @param {!WebInspector.RemoteObject} array |
648 * @param {!Element} elem | 678 * @param {!Element} elem |
649 */ | 679 */ |
650 _formatParameterAsArray: function(array, elem) | 680 _formatParameterAsArray: function(array, elem) |
651 { | 681 { |
652 if (this.useArrayPreviewInFormatter(array)) { | 682 if (this.useArrayPreviewInFormatter(array)) { |
653 this._formatParameterAsArrayOrObject(array, elem, true); | 683 this._formatParameterAsArrayOrObject(array, elem, true); |
654 return; | 684 return; |
655 } | 685 } |
656 | 686 |
657 const maxFlatArrayLength = 100; | 687 var maxFlatArrayLength = 100; |
658 if (this._message.isOutdated || array.arrayLength() > maxFlatArrayLength
) | 688 if (this._message.isOutdated || array.arrayLength() > maxFlatArrayLength
) |
659 this._formatParameterAsObject(array, elem, false); | 689 this._formatParameterAsObject(array, elem, false); |
660 else | 690 else |
661 array.getOwnProperties(this._printArray.bind(this, array, elem)); | 691 array.getAllProperties(false, this._printArray.bind(this, array, ele
m)); |
662 }, | 692 }, |
663 | 693 |
664 /** | 694 /** |
665 * @param {!Array.<!WebInspector.RemoteObject>} parameters | 695 * @param {!Array.<!WebInspector.RemoteObject>} parameters |
666 * @return {!Element} | 696 * @return {!Element} |
667 */ | 697 */ |
668 _formatParameterAsTable: function(parameters) | 698 _formatParameterAsTable: function(parameters) |
669 { | 699 { |
670 var element = createElement("span"); | 700 var element = createElement("span"); |
671 var table = parameters[0]; | 701 var table = parameters[0]; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 elem.createTextChild("\""); | 773 elem.createTextChild("\""); |
744 }, | 774 }, |
745 | 775 |
746 /** | 776 /** |
747 * @param {!WebInspector.RemoteObject} array | 777 * @param {!WebInspector.RemoteObject} array |
748 * @param {!Element} elem | 778 * @param {!Element} elem |
749 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties | 779 * @param {?Array.<!WebInspector.RemoteObjectProperty>} properties |
750 */ | 780 */ |
751 _printArray: function(array, elem, properties) | 781 _printArray: function(array, elem, properties) |
752 { | 782 { |
753 if (!properties) | 783 if (!properties) { |
| 784 this._formatParameterAsObject(array, elem, false); |
754 return; | 785 return; |
| 786 } |
755 | 787 |
756 var elements = []; | 788 var elements = []; |
757 for (var i = 0; i < properties.length; ++i) { | 789 for (var i = 0; i < properties.length; ++i) { |
758 var property = properties[i]; | 790 var property = properties[i]; |
759 var name = property.name; | 791 var name = property.name; |
760 if (isNaN(name)) | 792 if (isNaN(name)) |
761 continue; | 793 continue; |
762 if (property.getter) | 794 if (property.getter) |
763 elements[name] = this._formatAsAccessorProperty(array, [name], t
rue); | 795 elements[name] = this._formatAsAccessorProperty(array, [name], t
rue); |
764 else if (property.value) | 796 else if (property.value) |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 { | 1432 { |
1401 if (!this._wrapperElement) { | 1433 if (!this._wrapperElement) { |
1402 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); | 1434 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); |
1403 this._wrapperElement.classList.toggle("collapsed", this._collapsed); | 1435 this._wrapperElement.classList.toggle("collapsed", this._collapsed); |
1404 } | 1436 } |
1405 return this._wrapperElement; | 1437 return this._wrapperElement; |
1406 }, | 1438 }, |
1407 | 1439 |
1408 __proto__: WebInspector.ConsoleViewMessage.prototype | 1440 __proto__: WebInspector.ConsoleViewMessage.prototype |
1409 } | 1441 } |
OLD | NEW |