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

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 580 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));
607 return result;
608 606
609 /** 607 /**
610 * @param {!Element} rendererElement 608 * @param {!Element} rendererElement
611 * @this {Console.ConsoleViewMessage}
612 */ 609 */
613 function appendRenderer(rendererElement) { 610 var appendRenderer = rendererElement => {
614 result.appendChild(rendererElement); 611 result.appendChild(rendererElement);
615 this._formattedParameterAsNodeForTest(); 612 this._formattedParameterAsNodeForTest();
613 };
614
615 var failedToRender = () => {
616 result.appendChild(this._formatParameterAsObject(remoteObject, false));
pfeldman 2017/03/01 02:37:44 don't use arrow function here and above, leave the
chenwilliam 2017/03/02 00:06:55 Done.
617 };
618
619 var domModel = SDK.DOMModel.fromTarget(remoteObject.target());
620 if (!domModel) {
621 failedToRender();
622 return result;
616 } 623 }
624 domModel.pushObjectAsNodeToFrontend(remoteObject, onNodeResolved);
pfeldman 2017/03/01 02:37:44 isNode() helps!
chenwilliam 2017/03/02 00:06:55 Done.
617 625
618 /** 626 /**
619 * @this {Console.ConsoleViewMessage} 627 * @param {?SDK.DOMNode} node
620 */ 628 */
621 function failedToRender() { 629 function onNodeResolved(node) {
622 result.appendChild(this._formatParameterAsObject(object, false)); 630 if (!node) {
631 failedToRender();
632 return result;
633 }
634 Common.Renderer.renderPromise(node).then(appendRenderer, failedToRender);
623 } 635 }
636 return result;
624 } 637 }
625 638
626 _formattedParameterAsNodeForTest() { 639 _formattedParameterAsNodeForTest() {
627 } 640 }
628 641
629 /** 642 /**
630 * @param {!SDK.RemoteObject} output 643 * @param {!SDK.RemoteObject} output
631 * @return {!Element} 644 * @return {!Element}
632 */ 645 */
633 _formatParameterAsString(output) { 646 _formatParameterAsString(output) {
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 toMessageElement() { 1260 toMessageElement() {
1248 if (!this._element) { 1261 if (!this._element) {
1249 super.toMessageElement(); 1262 super.toMessageElement();
1250 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); 1263 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon');
1251 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); 1264 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild);
1252 this.setCollapsed(this._collapsed); 1265 this.setCollapsed(this._collapsed);
1253 } 1266 }
1254 return this._element; 1267 return this._element;
1255 } 1268 }
1256 }; 1269 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698