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

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

Issue 297163014: DevTools: Some printed objects in console are not pinnable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 30 matching lines...) Expand all
41 this._linkifier = linkifier; 41 this._linkifier = linkifier;
42 this._repeatCount = 1; 42 this._repeatCount = 1;
43 this._closeGroupDecorationCount = 0; 43 this._closeGroupDecorationCount = 0;
44 this._nestingLevel = nestingLevel; 44 this._nestingLevel = nestingLevel;
45 45
46 /** @type {!Array.<!WebInspector.DataGrid>} */ 46 /** @type {!Array.<!WebInspector.DataGrid>} */
47 this._dataGrids = []; 47 this._dataGrids = [];
48 /** @type {!Map.<!WebInspector.DataGrid, ?Element>} */ 48 /** @type {!Map.<!WebInspector.DataGrid, ?Element>} */
49 this._dataGridParents = new Map(); 49 this._dataGridParents = new Map();
50 50
51 /** @type {!Object.<string, function(!WebInspector.RemoteObject, !Element, b oolean=)>} */
51 this._customFormatters = { 52 this._customFormatters = {
52 "object": this._formatParameterAsObject, 53 "object": this._formatParameterAsObject,
53 "array": this._formatParameterAsArray, 54 "array": this._formatParameterAsArray,
54 "node": this._formatParameterAsNode, 55 "node": this._formatParameterAsNode,
55 "string": this._formatParameterAsString 56 "string": this._formatParameterAsString
56 }; 57 };
57 } 58 }
58 59
59 WebInspector.ConsoleViewMessage.prototype = { 60 WebInspector.ConsoleViewMessage.prototype = {
60 /** 61 /**
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 formattedResult.appendChild(WebInspector.linkifyStringAsFragment (parameters[i].description)); 359 formattedResult.appendChild(WebInspector.linkifyStringAsFragment (parameters[i].description));
359 else 360 else
360 formattedResult.appendChild(this._formatParameter(parameters[i], false, true)); 361 formattedResult.appendChild(this._formatParameter(parameters[i], false, true));
361 if (i < parameters.length - 1) 362 if (i < parameters.length - 1)
362 formattedResult.appendChild(document.createTextNode(" ")); 363 formattedResult.appendChild(document.createTextNode(" "));
363 } 364 }
364 return formattedResult; 365 return formattedResult;
365 }, 366 },
366 367
367 /** 368 /**
368 * @param {?Object} output 369 * @param {!WebInspector.RemoteObject} output
369 * @param {boolean=} forceObjectFormat 370 * @param {boolean=} forceObjectFormat
370 * @param {boolean=} includePreview 371 * @param {boolean=} includePreview
371 * @return {!Element} 372 * @return {!Element}
372 */ 373 */
373 _formatParameter: function(output, forceObjectFormat, includePreview) 374 _formatParameter: function(output, forceObjectFormat, includePreview)
374 { 375 {
375 var type; 376 var type = forceObjectFormat ? "object" : (output.subtype || output.type );
376 if (forceObjectFormat) 377 var formatter = this._customFormatters[type] || this._formatParameterAsV alue;
377 type = "object";
378 else if (output instanceof WebInspector.RemoteObject)
379 type = output.subtype || output.type;
380 else
381 type = typeof output;
382
383 var formatter = this._customFormatters[type];
384 if (!formatter) {
385 formatter = this._formatParameterAsValue;
386 output = output.description;
387 }
388
389 var span = document.createElement("span"); 378 var span = document.createElement("span");
390 span.className = "console-formatted-" + type + " source-code"; 379 span.className = "console-formatted-" + type + " source-code";
391 formatter.call(this, output, span, includePreview); 380 formatter.call(this, output, span, includePreview);
392 return span; 381 return span;
393 }, 382 },
394 383
395 _formatParameterAsValue: function(val, elem) 384 /**
385 * @param {!WebInspector.RemoteObject} obj
386 * @param {!Element} elem
387 */
388 _formatParameterAsValue: function(obj, elem)
396 { 389 {
397 elem.appendChild(document.createTextNode(val)); 390 elem.appendChild(document.createTextNode(obj.description || ""));
391 if (obj.objectId)
392 elem.addEventListener("contextmenu", this._contextMenuEventFired.bin d(this, obj), false);
398 }, 393 },
399 394
400 /** 395 /**
401 * @param {!WebInspector.RemoteObject} obj 396 * @param {!WebInspector.RemoteObject} obj
402 * @param {!Element} elem 397 * @param {!Element} elem
403 * @param {boolean} includePreview 398 * @param {boolean=} includePreview
404 */ 399 */
405 _formatParameterAsObject: function(obj, elem, includePreview) 400 _formatParameterAsObject: function(obj, elem, includePreview)
406 { 401 {
407 this._formatParameterAsArrayOrObject(obj, obj.description || "", elem, i ncludePreview); 402 this._formatParameterAsArrayOrObject(obj, obj.description || "", elem, i ncludePreview);
408 }, 403 },
409 404
410 /** 405 /**
411 * @param {!WebInspector.RemoteObject} obj 406 * @param {!WebInspector.RemoteObject} obj
412 * @param {string} description 407 * @param {string} description
413 * @param {!Element} elem 408 * @param {!Element} elem
414 * @param {boolean} includePreview 409 * @param {boolean=} includePreview
415 */ 410 */
416 _formatParameterAsArrayOrObject: function(obj, description, elem, includePre view) 411 _formatParameterAsArrayOrObject: function(obj, description, elem, includePre view)
417 { 412 {
418 var titleElement = document.createElement("span"); 413 var titleElement = document.createElement("span");
419 if (description) 414 if (description)
420 titleElement.createTextChild(description); 415 titleElement.createTextChild(description);
421 if (includePreview && obj.preview) { 416 if (includePreview && obj.preview) {
422 titleElement.classList.add("console-object-preview"); 417 titleElement.classList.add("console-object-preview");
423 var lossless = this._appendObjectPreview(obj, description, titleElem ent); 418 var lossless = this._appendObjectPreview(obj, description, titleElem ent);
424 if (lossless) { 419 if (lossless) {
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 518
524 if (type === "string") { 519 if (type === "string") {
525 span.textContent = "\"" + description.replace(/\n/g, "\u21B5") + "\" "; 520 span.textContent = "\"" + description.replace(/\n/g, "\u21B5") + "\" ";
526 return span; 521 return span;
527 } 522 }
528 523
529 span.textContent = description; 524 span.textContent = description;
530 return span; 525 return span;
531 }, 526 },
532 527
528 /**
529 * @param {!WebInspector.RemoteObject} object
530 * @param {!Element} elem
531 */
533 _formatParameterAsNode: function(object, elem) 532 _formatParameterAsNode: function(object, elem)
534 { 533 {
535 /** 534 /**
536 * @param {!WebInspector.DOMNode} node 535 * @param {!WebInspector.DOMNode} node
537 * @this {WebInspector.ConsoleViewMessage} 536 * @this {WebInspector.ConsoleViewMessage}
538 */ 537 */
539 function printNode(node) 538 function printNode(node)
540 { 539 {
541 if (!node) { 540 if (!node) {
542 // Sometimes DOM is loaded after the sync message is being forma tted, so we get no 541 // Sometimes DOM is loaded after the sync message is being forma tted, so we get no
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 } 637 }
639 638
640 columnNames.unshift(WebInspector.UIString("(index)")); 639 columnNames.unshift(WebInspector.UIString("(index)"));
641 var dataGrid = WebInspector.DataGrid.createSortableDataGrid(columnNames, flatValues); 640 var dataGrid = WebInspector.DataGrid.createSortableDataGrid(columnNames, flatValues);
642 dataGrid.renderInline(); 641 dataGrid.renderInline();
643 this._dataGrids.push(dataGrid); 642 this._dataGrids.push(dataGrid);
644 this._dataGridParents.put(dataGrid, dataGridContainer); 643 this._dataGridParents.put(dataGrid, dataGridContainer);
645 return element; 644 return element;
646 }, 645 },
647 646
647 /**
648 * @param {!WebInspector.RemoteObject} output
649 * @param {!Element} elem
650 */
648 _formatParameterAsString: function(output, elem) 651 _formatParameterAsString: function(output, elem)
649 { 652 {
650 var span = document.createElement("span"); 653 var span = document.createElement("span");
651 span.className = "console-formatted-string source-code"; 654 span.className = "console-formatted-string source-code";
652 span.appendChild(WebInspector.linkifyStringAsFragment(output.description )); 655 span.appendChild(WebInspector.linkifyStringAsFragment(output.description || ""));
653 656
654 // Make black quotes. 657 // Make black quotes.
655 elem.classList.remove("console-formatted-string"); 658 elem.classList.remove("console-formatted-string");
656 elem.appendChild(document.createTextNode("\"")); 659 elem.appendChild(document.createTextNode("\""));
657 elem.appendChild(span); 660 elem.appendChild(span);
658 elem.appendChild(document.createTextNode("\"")); 661 elem.appendChild(document.createTextNode("\""));
659 }, 662 },
660 663
661 /** 664 /**
662 * @param {!WebInspector.RemoteObject} array 665 * @param {!WebInspector.RemoteObject} array
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 * @param {string} format 775 * @param {string} format
773 * @param {!Array.<string>} parameters 776 * @param {!Array.<string>} parameters
774 * @param {!Element} formattedResult 777 * @param {!Element} formattedResult
775 */ 778 */
776 _formatWithSubstitutionString: function(format, parameters, formattedResult) 779 _formatWithSubstitutionString: function(format, parameters, formattedResult)
777 { 780 {
778 var formatters = {}; 781 var formatters = {};
779 782
780 /** 783 /**
781 * @param {boolean} force 784 * @param {boolean} force
782 * @param {!Object} obj 785 * @param {!WebInspector.RemoteObject} obj
783 * @return {!Element} 786 * @return {!Element}
784 * @this {WebInspector.ConsoleViewMessage} 787 * @this {WebInspector.ConsoleViewMessage}
785 */ 788 */
786 function parameterFormatter(force, obj) 789 function parameterFormatter(force, obj)
787 { 790 {
788 return this._formatParameter(obj, force, false); 791 return this._formatParameter(obj, force, false);
789 } 792 }
790 793
791 function stringFormatter(obj) 794 function stringFormatter(obj)
792 { 795 {
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1229 { 1232 {
1230 if (!this._wrapperElement) { 1233 if (!this._wrapperElement) {
1231 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this ); 1234 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this );
1232 this._wrapperElement.classList.toggle("collapsed", this._collapsed); 1235 this._wrapperElement.classList.toggle("collapsed", this._collapsed);
1233 } 1236 }
1234 return this._wrapperElement; 1237 return this._wrapperElement;
1235 }, 1238 },
1236 1239
1237 __proto__: WebInspector.ConsoleViewMessage.prototype 1240 __proto__: WebInspector.ConsoleViewMessage.prototype
1238 } 1241 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698