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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 var cellProperty = rowPreview.properties[j]; | 146 var cellProperty = rowPreview.properties[j]; |
147 var columnRendered = columnNames.indexOf(cellProperty.name) !== -1; | 147 var columnRendered = columnNames.indexOf(cellProperty.name) !== -1; |
148 if (!columnRendered) { | 148 if (!columnRendered) { |
149 if (columnNames.length === maxColumnsToRender) | 149 if (columnNames.length === maxColumnsToRender) |
150 continue; | 150 continue; |
151 columnRendered = true; | 151 columnRendered = true; |
152 columnNames.push(cellProperty.name); | 152 columnNames.push(cellProperty.name); |
153 } | 153 } |
154 | 154 |
155 if (columnRendered) { | 155 if (columnRendered) { |
156 var cellElement = this._renderPropertyPreviewOrAccessor(table, [rowPro
perty, cellProperty]); | 156 var cellElement = this._previewFormatter.renderPropertyPreviewOrAccess
or([rowProperty, cellProperty], table); |
157 cellElement.classList.add('console-message-nowrap-below'); | 157 cellElement.classList.add('console-message-nowrap-below'); |
158 rowValue[cellProperty.name] = cellElement; | 158 rowValue[cellProperty.name] = cellElement; |
159 } | 159 } |
160 } | 160 } |
161 rows.push([rowProperty.name, rowValue]); | 161 rows.push([rowProperty.name, rowValue]); |
162 } | 162 } |
163 | 163 |
164 var flatValues = []; | 164 var flatValues = []; |
165 for (var i = 0; i < rows.length; ++i) { | 165 for (var i = 0; i < rows.length; ++i) { |
166 var rowName = rows[i][0]; | 166 var rowName = rows[i][0]; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 | 515 |
516 /** | 516 /** |
517 * @param {!SDK.RemoteObject} obj | 517 * @param {!SDK.RemoteObject} obj |
518 * @param {boolean=} includePreview | 518 * @param {boolean=} includePreview |
519 * @return {!Element} | 519 * @return {!Element} |
520 */ | 520 */ |
521 _formatParameterAsObject(obj, includePreview) { | 521 _formatParameterAsObject(obj, includePreview) { |
522 var titleElement = createElement('span'); | 522 var titleElement = createElement('span'); |
523 if (includePreview && obj.preview) { | 523 if (includePreview && obj.preview) { |
524 titleElement.classList.add('console-object-preview'); | 524 titleElement.classList.add('console-object-preview'); |
525 this._previewFormatter.appendObjectPreview(titleElement, obj.preview); | 525 this._previewFormatter.appendObjectPreview(titleElement, obj.preview, obj)
; |
526 } else if (obj.type === 'function') { | 526 } else if (obj.type === 'function') { |
527 Components.ObjectPropertiesSection.formatObjectAsFunction(obj, titleElemen
t, false); | 527 Components.ObjectPropertiesSection.formatObjectAsFunction(obj, titleElemen
t, false); |
528 titleElement.classList.add('object-value-function'); | 528 titleElement.classList.add('object-value-function'); |
529 } else { | 529 } else { |
530 titleElement.createTextChild(obj.description || ''); | 530 titleElement.createTextChild(obj.description || ''); |
531 } | 531 } |
532 | 532 |
533 var section = new Components.ObjectPropertiesSection(obj, titleElement, this
._linkifier); | 533 var section = new Components.ObjectPropertiesSection(obj, titleElement, this
._linkifier); |
534 section.element.classList.add('console-view-object-properties-section'); | 534 section.element.classList.add('console-view-object-properties-section'); |
535 section.enableContextMenu(); | 535 section.enableContextMenu(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 * @param {!SDK.RemoteObject} obj | 567 * @param {!SDK.RemoteObject} obj |
568 * @param {!Event} event | 568 * @param {!Event} event |
569 */ | 569 */ |
570 _contextMenuEventFired(obj, event) { | 570 _contextMenuEventFired(obj, event) { |
571 var contextMenu = new UI.ContextMenu(event); | 571 var contextMenu = new UI.ContextMenu(event); |
572 contextMenu.appendApplicableItems(obj); | 572 contextMenu.appendApplicableItems(obj); |
573 contextMenu.show(); | 573 contextMenu.show(); |
574 } | 574 } |
575 | 575 |
576 /** | 576 /** |
577 * @param {?SDK.RemoteObject} object | |
578 * @param {!Array.<!Protocol.Runtime.PropertyPreview>} propertyPath | |
579 * @return {!Element} | |
580 */ | |
581 _renderPropertyPreviewOrAccessor(object, propertyPath) { | |
582 var property = propertyPath.peekLast(); | |
583 if (property.type === 'accessor') | |
584 return this._formatAsAccessorProperty(object, propertyPath.map(property =>
property.name), false); | |
585 return this._previewFormatter.renderPropertyPreview( | |
586 property.type, /** @type {string} */ (property.subtype), property.value)
; | |
587 } | |
588 | |
589 /** | |
590 * @param {!SDK.RemoteObject} object | 577 * @param {!SDK.RemoteObject} object |
591 * @return {!Element} | 578 * @return {!Element} |
592 */ | 579 */ |
593 _formatParameterAsNode(object) { | 580 _formatParameterAsNode(object) { |
594 var result = createElement('span'); | 581 var result = createElement('span'); |
595 Common.Renderer.renderPromise(object).then(appendRenderer.bind(this), failed
ToRender.bind(this)); | 582 Common.Renderer.renderPromise(object).then(appendRenderer.bind(this), failed
ToRender.bind(this)); |
596 return result; | 583 return result; |
597 | 584 |
598 /** | 585 /** |
599 * @param {!Element} rendererElement | 586 * @param {!Element} rendererElement |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 return; | 626 return; |
640 } | 627 } |
641 | 628 |
642 var titleElement = createElement('span'); | 629 var titleElement = createElement('span'); |
643 var elements = {}; | 630 var elements = {}; |
644 for (var i = 0; i < properties.length; ++i) { | 631 for (var i = 0; i < properties.length; ++i) { |
645 var property = properties[i]; | 632 var property = properties[i]; |
646 var name = property.name; | 633 var name = property.name; |
647 if (isNaN(name)) | 634 if (isNaN(name)) |
648 continue; | 635 continue; |
649 if (property.getter) | 636 var formatter = this._previewFormatter; |
650 elements[name] = this._formatAsAccessorProperty(array, [name], true); | 637 if (property.getter) { |
651 else if (property.value) | 638 elements[name] = formatter.formatAsAccessorProperty([name], array); |
652 elements[name] = this._formatAsArrayEntry(property.value); | 639 } else if (property.value) { |
| 640 var output = property.value; |
| 641 elements[name] = formatter.renderPropertyPreview(output.type, output.s
ubtype, output.description); |
| 642 } |
653 } | 643 } |
654 | 644 |
655 titleElement.createTextChild('['); | 645 titleElement.createTextChild('['); |
656 var lastNonEmptyIndex = -1; | 646 var lastNonEmptyIndex = -1; |
657 | 647 |
658 function appendUndefined(titleElement, index) { | 648 function appendUndefined(titleElement, index) { |
659 if (index - lastNonEmptyIndex <= 1) | 649 if (index - lastNonEmptyIndex <= 1) |
660 return; | 650 return; |
661 var span = titleElement.createChild('span', 'object-value-undefined'); | 651 var span = titleElement.createChild('span', 'object-value-undefined'); |
662 span.textContent = Common.UIString('undefined × %d', index - lastNonEmpt
yIndex - 1); | 652 span.textContent = Common.UIString('undefined × %d', index - lastNonEmpt
yIndex - 1); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 * @return {!Element} | 699 * @return {!Element} |
710 */ | 700 */ |
711 _formatParameterAsError(output) { | 701 _formatParameterAsError(output) { |
712 var result = createElement('span'); | 702 var result = createElement('span'); |
713 var errorSpan = this._tryFormatAsError(output.description || ''); | 703 var errorSpan = this._tryFormatAsError(output.description || ''); |
714 result.appendChild(errorSpan ? errorSpan : Components.linkifyStringAsFragmen
t(output.description || '')); | 704 result.appendChild(errorSpan ? errorSpan : Components.linkifyStringAsFragmen
t(output.description || '')); |
715 return result; | 705 return result; |
716 } | 706 } |
717 | 707 |
718 /** | 708 /** |
719 * @param {!SDK.RemoteObject} output | |
720 * @return {!Element} | |
721 */ | |
722 _formatAsArrayEntry(output) { | |
723 return this._previewFormatter.renderPropertyPreview(output.type, output.subt
ype, output.description); | |
724 } | |
725 | |
726 /** | |
727 * @param {?SDK.RemoteObject} object | |
728 * @param {!Array.<string>} propertyPath | |
729 * @param {boolean} isArrayEntry | |
730 * @return {!Element} | |
731 */ | |
732 _formatAsAccessorProperty(object, propertyPath, isArrayEntry) { | |
733 var rootElement = Components.ObjectPropertyTreeElement.createRemoteObjectAcc
essorPropertySpan( | |
734 object, propertyPath, onInvokeGetterClick.bind(this)); | |
735 | |
736 /** | |
737 * @param {?SDK.RemoteObject} result | |
738 * @param {boolean=} wasThrown | |
739 * @this {Console.ConsoleViewMessage} | |
740 */ | |
741 function onInvokeGetterClick(result, wasThrown) { | |
742 if (!result) | |
743 return; | |
744 rootElement.removeChildren(); | |
745 if (wasThrown) { | |
746 var element = rootElement.createChild('span'); | |
747 element.textContent = Common.UIString('<exception>'); | |
748 element.title = /** @type {string} */ (result.description); | |
749 } else if (isArrayEntry) { | |
750 rootElement.appendChild(this._formatAsArrayEntry(result)); | |
751 } else { | |
752 // Make a PropertyPreview from the RemoteObject similar to the backend l
ogic. | |
753 const maxLength = 100; | |
754 var type = result.type; | |
755 var subtype = result.subtype; | |
756 var description = ''; | |
757 if (type !== 'function' && result.description) { | |
758 if (type === 'string' || subtype === 'regexp') | |
759 description = result.description.trimMiddle(maxLength); | |
760 else | |
761 description = result.description.trimEnd(maxLength); | |
762 } | |
763 rootElement.appendChild(this._previewFormatter.renderPropertyPreview(typ
e, subtype, description)); | |
764 } | |
765 } | |
766 | |
767 return rootElement; | |
768 } | |
769 | |
770 /** | |
771 * @param {string} format | 709 * @param {string} format |
772 * @param {!Array.<!SDK.RemoteObject>} parameters | 710 * @param {!Array.<!SDK.RemoteObject>} parameters |
773 * @param {!Element} formattedResult | 711 * @param {!Element} formattedResult |
774 */ | 712 */ |
775 _formatWithSubstitutionString(format, parameters, formattedResult) { | 713 _formatWithSubstitutionString(format, parameters, formattedResult) { |
776 var formatters = {}; | 714 var formatters = {}; |
777 | 715 |
778 /** | 716 /** |
779 * @param {boolean} force | 717 * @param {boolean} force |
780 * @param {!SDK.RemoteObject} obj | 718 * @param {!SDK.RemoteObject} obj |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 * @return {!Element} | 1172 * @return {!Element} |
1235 */ | 1173 */ |
1236 toMessageElement() { | 1174 toMessageElement() { |
1237 if (!this._element) { | 1175 if (!this._element) { |
1238 super.toMessageElement(); | 1176 super.toMessageElement(); |
1239 this._element.classList.toggle('collapsed', this._collapsed); | 1177 this._element.classList.toggle('collapsed', this._collapsed); |
1240 } | 1178 } |
1241 return this._element; | 1179 return this._element; |
1242 } | 1180 } |
1243 }; | 1181 }; |
OLD | NEW |