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

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 return result; 607 var domModel = SDK.DOMModel.fromTarget(remoteObject.runtimeModel().target()) ;
608 domModel.pushObjectAsNodeToFrontend(remoteObject).then(onNodeResolved.bind(t his));
dgozman 2017/03/21 23:00:49 if (!domModel) return result;
chenwilliam 2017/03/22 00:30:38 Done.
608 609
609 /** 610 /**
610 * @param {!Element} rendererElement 611 * @param {?SDK.DOMNode} node
611 * @this {Console.ConsoleViewMessage} 612 * @this {Console.ConsoleViewMessage}
612 */ 613 */
613 function appendRenderer(rendererElement) { 614 function onNodeResolved(node) {
dgozman 2017/03/21 23:00:49 Make it an arrow function?
chenwilliam 2017/03/22 00:30:38 Done.
614 result.appendChild(rendererElement); 615 if (!node) {
615 this._formattedParameterAsNodeForTest(); 616 result.appendChild(this._formatParameterAsObject(remoteObject, false));
dgozman 2017/03/21 23:00:49 Just return here.
chenwilliam 2017/03/22 00:30:38 Done.
617 return result;
618 }
619 Common.Renderer.renderPromise(node).then(rendererElement => {
620 result.appendChild(rendererElement);
621 this._formattedParameterAsNodeForTest();
622 });
616 } 623 }
617 624 return result;
618 /**
619 * @this {Console.ConsoleViewMessage}
620 */
621 function failedToRender() {
622 result.appendChild(this._formatParameterAsObject(object, false));
623 }
624 } 625 }
625 626
626 _formattedParameterAsNodeForTest() { 627 _formattedParameterAsNodeForTest() {
627 } 628 }
628 629
629 /** 630 /**
630 * @param {!SDK.RemoteObject} output 631 * @param {!SDK.RemoteObject} output
631 * @return {!Element} 632 * @return {!Element}
632 */ 633 */
633 _formatParameterAsString(output) { 634 _formatParameterAsString(output) {
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 toMessageElement() { 1248 toMessageElement() {
1248 if (!this._element) { 1249 if (!this._element) {
1249 super.toMessageElement(); 1250 super.toMessageElement();
1250 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); 1251 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon');
1251 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); 1252 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild);
1252 this.setCollapsed(this._collapsed); 1253 this.setCollapsed(this._collapsed);
1253 } 1254 }
1254 return this._element; 1255 return this._element;
1255 } 1256 }
1256 }; 1257 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698