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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js

Issue 2728543002: DevTools: refactor Common.Renderer for DOM nodes (Closed)
Patch Set: fixup Created 3 years, 9 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) 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 break; 479 break;
480 case 'iterator': 480 case 'iterator':
481 case 'map': 481 case 'map':
482 case 'object': 482 case 'object':
483 case 'promise': 483 case 'promise':
484 case 'proxy': 484 case 'proxy':
485 case 'set': 485 case 'set':
486 element = this._formatParameterAsObject(output, includePreview); 486 element = this._formatParameterAsObject(output, includePreview);
487 break; 487 break;
488 case 'node': 488 case 'node':
489 element = this._formatParameterAsNode(output); 489 element = output.isNode() ? this._formatParameterAsNode(output) : this._ formatParameterAsObject(output, false);
490 break; 490 break;
491 case 'string': 491 case 'string':
492 element = this._formatParameterAsString(output); 492 element = this._formatParameterAsString(output);
493 break; 493 break;
494 case 'boolean': 494 case 'boolean':
495 case 'date': 495 case 'date':
496 case 'null': 496 case 'null':
497 case 'number': 497 case 'number':
498 case 'regexp': 498 case 'regexp':
499 case 'symbol': 499 case 'symbol':
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 */ 591 */
592 _renderPropertyPreviewOrAccessor(object, propertyPath) { 592 _renderPropertyPreviewOrAccessor(object, propertyPath) {
593 var property = propertyPath.peekLast(); 593 var property = propertyPath.peekLast();
594 if (property.type === 'accessor') 594 if (property.type === 'accessor')
595 return this._formatAsAccessorProperty(object, propertyPath.map(property => property.name), false); 595 return this._formatAsAccessorProperty(object, propertyPath.map(property => property.name), false);
596 return this._previewFormatter.renderPropertyPreview( 596 return this._previewFormatter.renderPropertyPreview(
597 property.type, /** @type {string} */ (property.subtype), property.value) ; 597 property.type, /** @type {string} */ (property.subtype), property.value) ;
598 } 598 }
599 599
600 /** 600 /**
601 * @param {!SDK.RemoteObject} object 601 * @param {!SDK.RemoteObject} remoteObject
602 * @return {!Element} 602 * @return {!Element}
603 */ 603 */
604 _formatParameterAsNode(object) { 604 _formatParameterAsNode(remoteObject) {
605 var result = createElement('span'); 605 var result = createElement('span');
606 Common.Renderer.renderPromise(object).then(appendRenderer.bind(this), failed ToRender.bind(this)); 606
607 var domModel = SDK.DOMModel.fromTarget(remoteObject.runtimeModel().target()) ;
608 if (!domModel)
609 return result;
610 domModel.pushObjectAsNodeToFrontend(remoteObject).then(node => {
611 if (!node) {
612 result.appendChild(this._formatParameterAsObject(remoteObject, false));
613 return;
614 }
615 Common.Renderer.renderPromise(node).then(rendererElement => {
616 result.appendChild(rendererElement);
617 this._formattedParameterAsNodeForTest();
618 });
619 });
620
607 return result; 621 return result;
608
609 /**
610 * @param {!Element} rendererElement
611 * @this {Console.ConsoleViewMessage}
612 */
613 function appendRenderer(rendererElement) {
614 result.appendChild(rendererElement);
615 this._formattedParameterAsNodeForTest();
616 }
617
618 /**
619 * @this {Console.ConsoleViewMessage}
620 */
621 function failedToRender() {
622 result.appendChild(this._formatParameterAsObject(object, false));
623 }
624 } 622 }
625 623
626 _formattedParameterAsNodeForTest() { 624 _formattedParameterAsNodeForTest() {
627 } 625 }
628 626
629 /** 627 /**
630 * @param {!SDK.RemoteObject} output 628 * @param {!SDK.RemoteObject} output
631 * @return {!Element} 629 * @return {!Element}
632 */ 630 */
633 _formatParameterAsString(output) { 631 _formatParameterAsString(output) {
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 toMessageElement() { 1245 toMessageElement() {
1248 if (!this._element) { 1246 if (!this._element) {
1249 super.toMessageElement(); 1247 super.toMessageElement();
1250 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); 1248 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon');
1251 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); 1249 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild);
1252 this.setCollapsed(this._collapsed); 1250 this.setCollapsed(this._collapsed);
1253 } 1251 }
1254 return this._element; 1252 return this._element;
1255 } 1253 }
1256 }; 1254 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698