OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 /** @type {!Object.<string, function(!WebInspector.RemoteObject, !Element, b
oolean=)>} */ |
52 this._customFormatters = { | 52 this._customFormatters = { |
53 "object": this._formatParameterAsObject, | 53 "object": this._formatParameterAsObject, |
54 "array": this._formatParameterAsArray, | 54 "array": this._formatParameterAsArray, |
55 "node": this._formatParameterAsNode, | 55 "node": this._formatParameterAsNode, |
| 56 "map": this._formatParameterAsObject, |
| 57 "set": this._formatParameterAsObject, |
56 "string": this._formatParameterAsString | 58 "string": this._formatParameterAsString |
57 }; | 59 }; |
58 } | 60 } |
59 | 61 |
60 WebInspector.ConsoleViewMessage.prototype = { | 62 WebInspector.ConsoleViewMessage.prototype = { |
61 /** | 63 /** |
62 * @return {?WebInspector.Target} | 64 * @return {?WebInspector.Target} |
63 */ | 65 */ |
64 _target: function() | 66 _target: function() |
65 { | 67 { |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 elem.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this, obj), false); | 425 elem.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this, obj), false); |
424 }, | 426 }, |
425 | 427 |
426 /** | 428 /** |
427 * @param {!WebInspector.RemoteObject} obj | 429 * @param {!WebInspector.RemoteObject} obj |
428 * @param {!Element} elem | 430 * @param {!Element} elem |
429 * @param {boolean=} includePreview | 431 * @param {boolean=} includePreview |
430 */ | 432 */ |
431 _formatParameterAsObject: function(obj, elem, includePreview) | 433 _formatParameterAsObject: function(obj, elem, includePreview) |
432 { | 434 { |
433 this._formatParameterAsArrayOrObject(obj, obj.description || "", elem, i
ncludePreview); | 435 this._formatParameterAsArrayOrObject(obj, elem, includePreview); |
434 }, | 436 }, |
435 | 437 |
436 /** | 438 /** |
437 * @param {!WebInspector.RemoteObject} obj | 439 * @param {!WebInspector.RemoteObject} obj |
438 * @param {string} description | |
439 * @param {!Element} elem | 440 * @param {!Element} elem |
440 * @param {boolean=} includePreview | 441 * @param {boolean=} includePreview |
441 */ | 442 */ |
442 _formatParameterAsArrayOrObject: function(obj, description, elem, includePre
view) | 443 _formatParameterAsArrayOrObject: function(obj, elem, includePreview) |
443 { | 444 { |
444 var titleElement = document.createElement("span"); | 445 var titleElement = document.createElement("span"); |
445 if (description) | |
446 titleElement.createTextChild(description); | |
447 if (includePreview && obj.preview) { | 446 if (includePreview && obj.preview) { |
448 titleElement.classList.add("console-object-preview"); | 447 titleElement.classList.add("console-object-preview"); |
449 var lossless = this._appendObjectPreview(obj, description, titleElem
ent); | 448 var lossless = this._appendObjectPreview(titleElement, obj.preview,
obj); |
450 if (lossless) { | 449 if (lossless) { |
451 elem.appendChild(titleElement); | 450 elem.appendChild(titleElement); |
452 titleElement.addEventListener("contextmenu", this._contextMenuEv
entFired.bind(this, obj), false); | 451 titleElement.addEventListener("contextmenu", this._contextMenuEv
entFired.bind(this, obj), false); |
453 return; | 452 return; |
454 } | 453 } |
| 454 } else { |
| 455 titleElement.createTextChild(obj.description || ""); |
455 } | 456 } |
456 var section = new WebInspector.ObjectPropertiesSection(obj, titleElement
); | 457 var section = new WebInspector.ObjectPropertiesSection(obj, titleElement
); |
457 section.enableContextMenu(); | 458 section.enableContextMenu(); |
458 elem.appendChild(section.element); | 459 elem.appendChild(section.element); |
459 | 460 |
460 var note = section.titleElement.createChild("span", "object-info-state-n
ote"); | 461 var note = section.titleElement.createChild("span", "object-info-state-n
ote"); |
461 note.title = WebInspector.UIString("Object state below is captured upon
first expansion"); | 462 note.title = WebInspector.UIString("Object state below is captured upon
first expansion"); |
462 }, | 463 }, |
463 | 464 |
464 /** | 465 /** |
465 * @param {!WebInspector.RemoteObject} obj | 466 * @param {!WebInspector.RemoteObject} obj |
466 * @param {!Event} event | 467 * @param {!Event} event |
467 */ | 468 */ |
468 _contextMenuEventFired: function(obj, event) | 469 _contextMenuEventFired: function(obj, event) |
469 { | 470 { |
470 var contextMenu = new WebInspector.ContextMenu(event); | 471 var contextMenu = new WebInspector.ContextMenu(event); |
471 contextMenu.appendApplicableItems(obj); | 472 contextMenu.appendApplicableItems(obj); |
472 contextMenu.show(); | 473 contextMenu.show(); |
473 }, | 474 }, |
474 | 475 |
475 /** | 476 /** |
476 * @param {!WebInspector.RemoteObject} obj | 477 * @param {!Element} parentElement |
477 * @param {string} description | 478 * @param {!RuntimeAgent.ObjectPreview} preview |
478 * @param {!Element} titleElement | 479 * @param {?WebInspector.RemoteObject} object |
479 * @return {boolean} true iff preview captured all information. | 480 * @return {boolean} true iff preview captured all information. |
480 */ | 481 */ |
481 _appendObjectPreview: function(obj, description, titleElement) | 482 _appendObjectPreview: function(parentElement, preview, object) |
482 { | 483 { |
483 var preview = obj.preview; | 484 var description = preview.description; |
484 var isArray = obj.subtype === "array"; | 485 if (preview.type !== "object" || preview.subtype === "null") { |
| 486 parentElement.appendChild(this._renderPropertyPreview(preview.type,
preview.subtype, description)); |
| 487 return true; |
| 488 } |
| 489 if (description && preview.subtype !== "array") |
| 490 parentElement.createTextChildren(description, " "); |
| 491 if (preview.entries) |
| 492 return this._appendEntriesPreview(parentElement, preview); |
| 493 return this._appendPropertiesPreview(parentElement, preview, object); |
| 494 }, |
485 | 495 |
486 if (description) | 496 /** |
487 titleElement.createTextChild(" "); | 497 * @param {!Element} parentElement |
488 titleElement.createTextChild(isArray ? "[" : "{"); | 498 * @param {!RuntimeAgent.ObjectPreview} preview |
| 499 * @param {?WebInspector.RemoteObject} object |
| 500 * @return {boolean} true iff preview captured all information. |
| 501 */ |
| 502 _appendPropertiesPreview: function(parentElement, preview, object) |
| 503 { |
| 504 var isArray = preview.subtype === "array"; |
| 505 parentElement.createTextChild(isArray ? "[" : "{"); |
489 for (var i = 0; i < preview.properties.length; ++i) { | 506 for (var i = 0; i < preview.properties.length; ++i) { |
490 if (i > 0) | 507 if (i > 0) |
491 titleElement.createTextChild(", "); | 508 parentElement.createTextChild(", "); |
492 | 509 |
493 var property = preview.properties[i]; | 510 var property = preview.properties[i]; |
494 var name = property.name; | 511 var name = property.name; |
495 if (!isArray || name != i) { | 512 if (!isArray || name != i) { |
496 if (/^\s|\s$|^$|\n/.test(name)) | 513 if (/^\s|\s$|^$|\n/.test(name)) |
497 titleElement.createChild("span", "name").createTextChildren(
"\"", name.replace(/\n/g, "\u21B5"), "\""); | 514 parentElement.createChild("span", "name").createTextChildren
("\"", name.replace(/\n/g, "\u21B5"), "\""); |
498 else | 515 else |
499 titleElement.createChild("span", "name").textContent = name; | 516 parentElement.createChild("span", "name").textContent = name
; |
500 titleElement.createTextChild(": "); | 517 parentElement.createTextChild(": "); |
501 } | 518 } |
502 | 519 |
503 titleElement.appendChild(this._renderPropertyPreviewOrAccessor(obj,
[property])); | 520 parentElement.appendChild(this._renderPropertyPreviewOrAccessor(obje
ct, [property])); |
504 } | 521 } |
505 if (preview.overflow) | 522 if (preview.overflow) |
506 titleElement.createChild("span").textContent = "\u2026"; | 523 parentElement.createChild("span").textContent = "\u2026"; |
507 titleElement.createTextChild(isArray ? "]" : "}"); | 524 parentElement.createTextChild(isArray ? "]" : "}"); |
508 return preview.lossless; | 525 return preview.lossless; |
509 }, | 526 }, |
510 | 527 |
511 /** | 528 /** |
512 * @param {!WebInspector.RemoteObject} object | 529 * @param {!Element} parentElement |
| 530 * @param {!RuntimeAgent.ObjectPreview} preview |
| 531 * @return {boolean} true iff preview captured all information. |
| 532 */ |
| 533 _appendEntriesPreview: function(parentElement, preview) |
| 534 { |
| 535 var lossless = preview.lossless && !preview.properties.length; |
| 536 parentElement.createTextChild("{"); |
| 537 for (var i = 0; i < preview.entries.length; ++i) { |
| 538 if (i > 0) |
| 539 parentElement.createTextChild(", "); |
| 540 |
| 541 var entry = preview.entries[i]; |
| 542 if (entry.key) { |
| 543 this._appendObjectPreview(parentElement, entry.key, null); |
| 544 parentElement.createTextChild(" => "); |
| 545 } |
| 546 this._appendObjectPreview(parentElement, entry.value, null); |
| 547 } |
| 548 if (preview.overflow) |
| 549 parentElement.createChild("span").textContent = "\u2026"; |
| 550 parentElement.createTextChild("}"); |
| 551 return lossless; |
| 552 }, |
| 553 |
| 554 /** |
| 555 * @param {?WebInspector.RemoteObject} object |
513 * @param {!Array.<!RuntimeAgent.PropertyPreview>} propertyPath | 556 * @param {!Array.<!RuntimeAgent.PropertyPreview>} propertyPath |
514 * @return {!Element} | 557 * @return {!Element} |
515 */ | 558 */ |
516 _renderPropertyPreviewOrAccessor: function(object, propertyPath) | 559 _renderPropertyPreviewOrAccessor: function(object, propertyPath) |
517 { | 560 { |
518 var property = propertyPath.peekLast(); | 561 var property = propertyPath.peekLast(); |
519 if (property.type === "accessor") | 562 if (property.type === "accessor") |
520 return this._formatAsAccessorProperty(object, propertyPath.select("n
ame"), false); | 563 return this._formatAsAccessorProperty(object, propertyPath.select("n
ame"), false); |
521 return this._renderPropertyPreview(property.type, /** @type {string} */
(property.subtype), property.value); | 564 return this._renderPropertyPreview(property.type, /** @type {string} */
(property.subtype), property.value); |
522 }, | 565 }, |
523 | 566 |
524 /** | 567 /** |
525 * @param {string} type | 568 * @param {string} type |
526 * @param {string=} subtype | 569 * @param {string=} subtype |
527 * @param {string=} description | 570 * @param {string=} description |
528 * @return {!Element} | 571 * @return {!Element} |
529 */ | 572 */ |
530 _renderPropertyPreview: function(type, subtype, description) | 573 _renderPropertyPreview: function(type, subtype, description) |
531 { | 574 { |
532 var span = document.createElementWithClass("span", "console-formatted-"
+ (subtype || type)); | 575 var span = document.createElementWithClass("span", "console-formatted-"
+ (subtype || type)); |
| 576 description = description || ""; |
533 | 577 |
534 if (type === "function") { | 578 if (type === "function") { |
535 span.textContent = "function"; | 579 span.textContent = "function"; |
536 return span; | 580 return span; |
537 } | 581 } |
538 | 582 |
539 if (type === "object" && subtype === "regexp") { | |
540 span.textContent = description; | |
541 return span; | |
542 } | |
543 | |
544 if (type === "object" && subtype === "node" && description) { | 583 if (type === "object" && subtype === "node" && description) { |
545 span.classList.add("console-formatted-preview-node"); | 584 span.classList.add("console-formatted-preview-node"); |
546 WebInspector.DOMPresentationUtils.createSpansForNodeTitle(span, desc
ription); | 585 WebInspector.DOMPresentationUtils.createSpansForNodeTitle(span, desc
ription); |
547 return span; | 586 return span; |
548 } | 587 } |
549 | 588 |
550 if (type === "string") { | 589 if (type === "string") { |
551 span.createTextChildren("\"", description.replace(/\n/g, "\u21B5"),
"\""); | 590 span.createTextChildren("\"", description.replace(/\n/g, "\u21B5"),
"\""); |
552 return span; | 591 return span; |
553 } | 592 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 return this._message.type !== WebInspector.ConsoleMessage.MessageType.Di
rXML && !!array.preview; | 631 return this._message.type !== WebInspector.ConsoleMessage.MessageType.Di
rXML && !!array.preview; |
593 }, | 632 }, |
594 | 633 |
595 /** | 634 /** |
596 * @param {!WebInspector.RemoteObject} array | 635 * @param {!WebInspector.RemoteObject} array |
597 * @param {!Element} elem | 636 * @param {!Element} elem |
598 */ | 637 */ |
599 _formatParameterAsArray: function(array, elem) | 638 _formatParameterAsArray: function(array, elem) |
600 { | 639 { |
601 if (this.useArrayPreviewInFormatter(array)) { | 640 if (this.useArrayPreviewInFormatter(array)) { |
602 this._formatParameterAsArrayOrObject(array, "", elem, true); | 641 this._formatParameterAsArrayOrObject(array, elem, true); |
603 return; | 642 return; |
604 } | 643 } |
605 | 644 |
606 const maxFlatArrayLength = 100; | 645 const maxFlatArrayLength = 100; |
607 if (this._message.isOutdated || array.arrayLength() > maxFlatArrayLength
) | 646 if (this._message.isOutdated || array.arrayLength() > maxFlatArrayLength
) |
608 this._formatParameterAsObject(array, elem, false); | 647 this._formatParameterAsObject(array, elem, false); |
609 else | 648 else |
610 array.getOwnProperties(this._printArray.bind(this, array, elem)); | 649 array.getOwnProperties(this._printArray.bind(this, array, elem)); |
611 }, | 650 }, |
612 | 651 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 * @param {!WebInspector.RemoteObject} output | 790 * @param {!WebInspector.RemoteObject} output |
752 * @return {!Element} | 791 * @return {!Element} |
753 */ | 792 */ |
754 _formatAsArrayEntry: function(output) | 793 _formatAsArrayEntry: function(output) |
755 { | 794 { |
756 // Prevent infinite expansion of cross-referencing arrays. | 795 // Prevent infinite expansion of cross-referencing arrays. |
757 return this._formatParameter(output, output.subtype === "array", false); | 796 return this._formatParameter(output, output.subtype === "array", false); |
758 }, | 797 }, |
759 | 798 |
760 /** | 799 /** |
761 * @param {!WebInspector.RemoteObject} object | 800 * @param {?WebInspector.RemoteObject} object |
762 * @param {!Array.<string>} propertyPath | 801 * @param {!Array.<string>} propertyPath |
763 * @param {boolean} isArrayEntry | 802 * @param {boolean} isArrayEntry |
764 * @return {!Element} | 803 * @return {!Element} |
765 */ | 804 */ |
766 _formatAsAccessorProperty: function(object, propertyPath, isArrayEntry) | 805 _formatAsAccessorProperty: function(object, propertyPath, isArrayEntry) |
767 { | 806 { |
768 var rootElement = WebInspector.ObjectPropertyTreeElement.createRemoteObj
ectAccessorPropertySpan(object, propertyPath, onInvokeGetterClick.bind(this)); | 807 var rootElement = WebInspector.ObjectPropertyTreeElement.createRemoteObj
ectAccessorPropertySpan(object, propertyPath, onInvokeGetterClick.bind(this)); |
769 | 808 |
770 /** | 809 /** |
771 * @param {?WebInspector.RemoteObject} result | 810 * @param {?WebInspector.RemoteObject} result |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 { | 1320 { |
1282 if (!this._wrapperElement) { | 1321 if (!this._wrapperElement) { |
1283 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); | 1322 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); |
1284 this._wrapperElement.classList.toggle("collapsed", this._collapsed); | 1323 this._wrapperElement.classList.toggle("collapsed", this._collapsed); |
1285 } | 1324 } |
1286 return this._wrapperElement; | 1325 return this._wrapperElement; |
1287 }, | 1326 }, |
1288 | 1327 |
1289 __proto__: WebInspector.ConsoleViewMessage.prototype | 1328 __proto__: WebInspector.ConsoleViewMessage.prototype |
1290 } | 1329 } |
OLD | NEW |