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

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

Issue 2712513002: DevTools: extract ObjectUI module from Components (Closed)
Patch Set: fix build.gn Created 3 years, 10 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 28 matching lines...) Expand all
39 */ 39 */
40 constructor(consoleMessage, linkifier, nestingLevel) { 40 constructor(consoleMessage, linkifier, nestingLevel) {
41 this._message = consoleMessage; 41 this._message = consoleMessage;
42 this._linkifier = linkifier; 42 this._linkifier = linkifier;
43 this._repeatCount = 1; 43 this._repeatCount = 1;
44 this._closeGroupDecorationCount = 0; 44 this._closeGroupDecorationCount = 0;
45 this._nestingLevel = nestingLevel; 45 this._nestingLevel = nestingLevel;
46 46
47 /** @type {?DataGrid.DataGrid} */ 47 /** @type {?DataGrid.DataGrid} */
48 this._dataGrid = null; 48 this._dataGrid = null;
49 this._previewFormatter = new Components.RemoteObjectPreviewFormatter(); 49 this._previewFormatter = new ObjectUI.RemoteObjectPreviewFormatter();
50 this._searchRegex = null; 50 this._searchRegex = null;
51 /** @type {?UI.Icon} */ 51 /** @type {?UI.Icon} */
52 this._messageLevelIcon = null; 52 this._messageLevelIcon = null;
53 } 53 }
54 54
55 /** 55 /**
56 * @return {?SDK.Target} 56 * @return {?SDK.Target}
57 */ 57 */
58 _target() { 58 _target() {
59 return this.consoleMessage().target(); 59 return this.consoleMessage().target();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 consoleMessage() { 114 consoleMessage() {
115 return this._message; 115 return this._message;
116 } 116 }
117 117
118 /** 118 /**
119 * @param {!SDK.ConsoleMessage} consoleMessage 119 * @param {!SDK.ConsoleMessage} consoleMessage
120 * @return {!Element} 120 * @return {!Element}
121 */ 121 */
122 _buildTableMessage(consoleMessage) { 122 _buildTableMessage(consoleMessage) {
123 var formattedMessage = createElement('span'); 123 var formattedMessage = createElement('span');
124 UI.appendStyle(formattedMessage, 'components/objectValue.css'); 124 UI.appendStyle(formattedMessage, 'object_ui/objectValue.css');
125 formattedMessage.className = 'source-code'; 125 formattedMessage.className = 'source-code';
126 var anchorElement = this._buildMessageAnchor(consoleMessage); 126 var anchorElement = this._buildMessageAnchor(consoleMessage);
127 if (anchorElement) 127 if (anchorElement)
128 formattedMessage.appendChild(anchorElement); 128 formattedMessage.appendChild(anchorElement);
129 129
130 var table = consoleMessage.parameters && consoleMessage.parameters.length ? consoleMessage.parameters[0] : null; 130 var table = consoleMessage.parameters && consoleMessage.parameters.length ? consoleMessage.parameters[0] : null;
131 if (table) 131 if (table)
132 table = this._parameterToRemoteObject(table, this._target()); 132 table = this._parameterToRemoteObject(table, this._target());
133 if (!table || !table.preview) 133 if (!table || !table.preview)
134 return formattedMessage; 134 return formattedMessage;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 else if (consoleMessage.source === SDK.ConsoleMessage.MessageSource.Interv ention) 252 else if (consoleMessage.source === SDK.ConsoleMessage.MessageSource.Interv ention)
253 messageText = Common.UIString('[Intervention] %s', messageText); 253 messageText = Common.UIString('[Intervention] %s', messageText);
254 if (consoleMessage.source === SDK.ConsoleMessage.MessageSource.Deprecation ) 254 if (consoleMessage.source === SDK.ConsoleMessage.MessageSource.Deprecation )
255 messageText = Common.UIString('[Deprecation] %s', messageText); 255 messageText = Common.UIString('[Deprecation] %s', messageText);
256 var args = consoleMessage.parameters || [messageText]; 256 var args = consoleMessage.parameters || [messageText];
257 messageElement = this._format(args); 257 messageElement = this._format(args);
258 } 258 }
259 messageElement.classList.add('console-message-text'); 259 messageElement.classList.add('console-message-text');
260 260
261 var formattedMessage = createElement('span'); 261 var formattedMessage = createElement('span');
262 UI.appendStyle(formattedMessage, 'components/objectValue.css'); 262 UI.appendStyle(formattedMessage, 'object_ui/objectValue.css');
263 formattedMessage.className = 'source-code'; 263 formattedMessage.className = 'source-code';
264 264
265 var anchorElement = this._buildMessageAnchor(consoleMessage); 265 var anchorElement = this._buildMessageAnchor(consoleMessage);
266 if (anchorElement) 266 if (anchorElement)
267 formattedMessage.appendChild(anchorElement); 267 formattedMessage.appendChild(anchorElement);
268 formattedMessage.appendChild(messageElement); 268 formattedMessage.appendChild(messageElement);
269 return formattedMessage; 269 return formattedMessage;
270 270
271 /** 271 /**
272 * @param {string} title 272 * @param {string} title
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 454 }
455 455
456 /** 456 /**
457 * @param {!SDK.RemoteObject} output 457 * @param {!SDK.RemoteObject} output
458 * @param {boolean=} forceObjectFormat 458 * @param {boolean=} forceObjectFormat
459 * @param {boolean=} includePreview 459 * @param {boolean=} includePreview
460 * @return {!Element} 460 * @return {!Element}
461 */ 461 */
462 _formatParameter(output, forceObjectFormat, includePreview) { 462 _formatParameter(output, forceObjectFormat, includePreview) {
463 if (output.customPreview()) 463 if (output.customPreview())
464 return (new Components.CustomPreviewComponent(output)).element; 464 return (new ObjectUI.CustomPreviewComponent(output)).element;
465 465
466 var type = forceObjectFormat ? 'object' : (output.subtype || output.type); 466 var type = forceObjectFormat ? 'object' : (output.subtype || output.type);
467 var element; 467 var element;
468 switch (type) { 468 switch (type) {
469 case 'array': 469 case 'array':
470 case 'typedarray': 470 case 'typedarray':
471 element = this._formatParameterAsObject(output, includePreview); 471 element = this._formatParameterAsObject(output, includePreview);
472 break; 472 break;
473 case 'error': 473 case 'error':
474 element = this._formatParameterAsError(output); 474 element = this._formatParameterAsError(output);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 * @param {!SDK.RemoteObject} obj 525 * @param {!SDK.RemoteObject} obj
526 * @param {boolean=} includePreview 526 * @param {boolean=} includePreview
527 * @return {!Element} 527 * @return {!Element}
528 */ 528 */
529 _formatParameterAsObject(obj, includePreview) { 529 _formatParameterAsObject(obj, includePreview) {
530 var titleElement = createElement('span'); 530 var titleElement = createElement('span');
531 if (includePreview && obj.preview) { 531 if (includePreview && obj.preview) {
532 titleElement.classList.add('console-object-preview'); 532 titleElement.classList.add('console-object-preview');
533 this._previewFormatter.appendObjectPreview(titleElement, obj.preview, fals e /* isEntry */); 533 this._previewFormatter.appendObjectPreview(titleElement, obj.preview, fals e /* isEntry */);
534 } else if (obj.type === 'function') { 534 } else if (obj.type === 'function') {
535 Components.ObjectPropertiesSection.formatObjectAsFunction(obj, titleElemen t, false); 535 ObjectUI.ObjectPropertiesSection.formatObjectAsFunction(obj, titleElement, false);
536 titleElement.classList.add('object-value-function'); 536 titleElement.classList.add('object-value-function');
537 } else { 537 } else {
538 titleElement.createTextChild(obj.description || ''); 538 titleElement.createTextChild(obj.description || '');
539 } 539 }
540 540
541 var note = titleElement.createChild('span', 'object-state-note'); 541 var note = titleElement.createChild('span', 'object-state-note');
542 note.classList.add('info-note'); 542 note.classList.add('info-note');
543 note.title = Common.UIString('Value below was evaluated just now.'); 543 note.title = Common.UIString('Value below was evaluated just now.');
544 544
545 var section = new Components.ObjectPropertiesSection(obj, titleElement, this ._linkifier); 545 var section = new ObjectUI.ObjectPropertiesSection(obj, titleElement, this._ linkifier);
546 section.element.classList.add('console-view-object-properties-section'); 546 section.element.classList.add('console-view-object-properties-section');
547 section.enableContextMenu(); 547 section.enableContextMenu();
548 return section.element; 548 return section.element;
549 } 549 }
550 550
551 /** 551 /**
552 * @param {!SDK.RemoteObject} func 552 * @param {!SDK.RemoteObject} func
553 * @param {boolean=} includePreview 553 * @param {boolean=} includePreview
554 * @return {!Element} 554 * @return {!Element}
555 */ 555 */
556 _formatParameterAsFunction(func, includePreview) { 556 _formatParameterAsFunction(func, includePreview) {
557 var result = createElement('span'); 557 var result = createElement('span');
558 SDK.RemoteFunction.objectAsFunction(func).targetFunction().then(formatTarget Function.bind(this)); 558 SDK.RemoteFunction.objectAsFunction(func).targetFunction().then(formatTarget Function.bind(this));
559 return result; 559 return result;
560 560
561 /** 561 /**
562 * @param {!SDK.RemoteObject} targetFunction 562 * @param {!SDK.RemoteObject} targetFunction
563 * @this {Console.ConsoleViewMessage} 563 * @this {Console.ConsoleViewMessage}
564 */ 564 */
565 function formatTargetFunction(targetFunction) { 565 function formatTargetFunction(targetFunction) {
566 var functionElement = createElement('span'); 566 var functionElement = createElement('span');
567 Components.ObjectPropertiesSection.formatObjectAsFunction(targetFunction, functionElement, true, includePreview); 567 ObjectUI.ObjectPropertiesSection.formatObjectAsFunction(targetFunction, fu nctionElement, true, includePreview);
568 result.appendChild(functionElement); 568 result.appendChild(functionElement);
569 if (targetFunction !== func) { 569 if (targetFunction !== func) {
570 var note = result.createChild('span', 'object-info-state-note'); 570 var note = result.createChild('span', 'object-info-state-note');
571 note.title = Common.UIString('Function was resolved from bound function. '); 571 note.title = Common.UIString('Function was resolved from bound function. ');
572 } 572 }
573 result.addEventListener('contextmenu', this._contextMenuEventFired.bind(th is, targetFunction), false); 573 result.addEventListener('contextmenu', this._contextMenuEventFired.bind(th is, targetFunction), false);
574 } 574 }
575 } 575 }
576 576
577 /** 577 /**
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 return this._previewFormatter.renderPropertyPreview(output.type, output.subt ype, output.description); 660 return this._previewFormatter.renderPropertyPreview(output.type, output.subt ype, output.description);
661 } 661 }
662 662
663 /** 663 /**
664 * @param {?SDK.RemoteObject} object 664 * @param {?SDK.RemoteObject} object
665 * @param {!Array.<string>} propertyPath 665 * @param {!Array.<string>} propertyPath
666 * @param {boolean} isArrayEntry 666 * @param {boolean} isArrayEntry
667 * @return {!Element} 667 * @return {!Element}
668 */ 668 */
669 _formatAsAccessorProperty(object, propertyPath, isArrayEntry) { 669 _formatAsAccessorProperty(object, propertyPath, isArrayEntry) {
670 var rootElement = Components.ObjectPropertyTreeElement.createRemoteObjectAcc essorPropertySpan( 670 var rootElement = ObjectUI.ObjectPropertyTreeElement.createRemoteObjectAcces sorPropertySpan(
671 object, propertyPath, onInvokeGetterClick.bind(this)); 671 object, propertyPath, onInvokeGetterClick.bind(this));
672 672
673 /** 673 /**
674 * @param {?SDK.RemoteObject} result 674 * @param {?SDK.RemoteObject} result
675 * @param {boolean=} wasThrown 675 * @param {boolean=} wasThrown
676 * @this {Console.ConsoleViewMessage} 676 * @this {Console.ConsoleViewMessage}
677 */ 677 */
678 function onInvokeGetterClick(result, wasThrown) { 678 function onInvokeGetterClick(result, wasThrown) {
679 if (!result) 679 if (!result)
680 return; 680 return;
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 toMessageElement() { 1247 toMessageElement() {
1248 if (!this._element) { 1248 if (!this._element) {
1249 super.toMessageElement(); 1249 super.toMessageElement();
1250 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); 1250 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon');
1251 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); 1251 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild);
1252 this.setCollapsed(this._collapsed); 1252 this.setCollapsed(this._collapsed);
1253 } 1253 }
1254 return this._element; 1254 return this._element;
1255 } 1255 }
1256 }; 1256 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698