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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 elem.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this, obj), false); | 397 elem.addEventListener("contextmenu", this._contextMenuEventFired.bin
d(this, obj), false); |
396 }, | 398 }, |
397 | 399 |
398 /** | 400 /** |
399 * @param {!WebInspector.RemoteObject} obj | 401 * @param {!WebInspector.RemoteObject} obj |
400 * @param {!Element} elem | 402 * @param {!Element} elem |
401 * @param {boolean=} includePreview | 403 * @param {boolean=} includePreview |
402 */ | 404 */ |
403 _formatParameterAsObject: function(obj, elem, includePreview) | 405 _formatParameterAsObject: function(obj, elem, includePreview) |
404 { | 406 { |
405 this._formatParameterAsArrayOrObject(obj, obj.description || "", elem, i
ncludePreview); | 407 this._formatParameterAsArrayOrObject(obj, elem, includePreview); |
406 }, | 408 }, |
407 | 409 |
408 /** | 410 /** |
409 * @param {!WebInspector.RemoteObject} obj | 411 * @param {!WebInspector.RemoteObject} obj |
410 * @param {string} description | |
411 * @param {!Element} elem | 412 * @param {!Element} elem |
412 * @param {boolean=} includePreview | 413 * @param {boolean=} includePreview |
413 */ | 414 */ |
414 _formatParameterAsArrayOrObject: function(obj, description, elem, includePre
view) | 415 _formatParameterAsArrayOrObject: function(obj, elem, includePreview) |
415 { | 416 { |
416 var titleElement = document.createElement("span"); | 417 var titleElement = document.createElement("span"); |
417 if (description) | |
418 titleElement.createTextChild(description); | |
419 if (includePreview && obj.preview) { | 418 if (includePreview && obj.preview) { |
420 titleElement.classList.add("console-object-preview"); | 419 titleElement.classList.add("console-object-preview"); |
421 var lossless = this._appendObjectPreview(obj, description, titleElem
ent); | 420 var lossless = this._appendObjectPreview(titleElement, obj.preview,
obj); |
422 if (lossless) { | 421 if (lossless) { |
423 elem.appendChild(titleElement); | 422 elem.appendChild(titleElement); |
424 titleElement.addEventListener("contextmenu", this._contextMenuEv
entFired.bind(this, obj), false); | 423 titleElement.addEventListener("contextmenu", this._contextMenuEv
entFired.bind(this, obj), false); |
425 return; | 424 return; |
426 } | 425 } |
| 426 } else { |
| 427 titleElement.createTextChild(obj.description || ""); |
427 } | 428 } |
428 var section = new WebInspector.ObjectPropertiesSection(obj, titleElement
); | 429 var section = new WebInspector.ObjectPropertiesSection(obj, titleElement
); |
429 section.enableContextMenu(); | 430 section.enableContextMenu(); |
430 elem.appendChild(section.element); | 431 elem.appendChild(section.element); |
431 | 432 |
432 var note = section.titleElement.createChild("span", "object-info-state-n
ote"); | 433 var note = section.titleElement.createChild("span", "object-info-state-n
ote"); |
433 note.title = WebInspector.UIString("Object state below is captured upon
first expansion"); | 434 note.title = WebInspector.UIString("Object state below is captured upon
first expansion"); |
434 }, | 435 }, |
435 | 436 |
436 /** | 437 /** |
437 * @param {!WebInspector.RemoteObject} obj | 438 * @param {!WebInspector.RemoteObject} obj |
438 * @param {!Event} event | 439 * @param {!Event} event |
439 */ | 440 */ |
440 _contextMenuEventFired: function(obj, event) | 441 _contextMenuEventFired: function(obj, event) |
441 { | 442 { |
442 var contextMenu = new WebInspector.ContextMenu(event); | 443 var contextMenu = new WebInspector.ContextMenu(event); |
443 contextMenu.appendApplicableItems(obj); | 444 contextMenu.appendApplicableItems(obj); |
444 contextMenu.show(); | 445 contextMenu.show(); |
445 }, | 446 }, |
446 | 447 |
447 /** | 448 /** |
448 * @param {!WebInspector.RemoteObject} obj | 449 * @param {!Element} parentElement |
449 * @param {string} description | 450 * @param {!RuntimeAgent.ObjectPreview} preview |
450 * @param {!Element} titleElement | 451 * @param {?WebInspector.RemoteObject} object |
451 * @return {boolean} true iff preview captured all information. | 452 * @return {boolean} true iff preview captured all information. |
452 */ | 453 */ |
453 _appendObjectPreview: function(obj, description, titleElement) | 454 _appendObjectPreview: function(parentElement, preview, object) |
454 { | 455 { |
455 var preview = obj.preview; | 456 var description = preview.description; |
456 var isArray = obj.subtype === "array"; | 457 if (preview.type !== "object" || preview.subtype === "null") { |
| 458 parentElement.appendChild(this._renderPropertyPreview(preview.type,
preview.subtype, description)); |
| 459 return true; |
| 460 } |
| 461 if (description && preview.subtype !== "array") |
| 462 parentElement.createTextChildren(description, " "); |
| 463 if (preview.entries) |
| 464 return this._appendEntriesPreview(parentElement, preview); |
| 465 return this._appendPropertiesPreview(parentElement, preview, object); |
| 466 }, |
457 | 467 |
458 if (description) | 468 /** |
459 titleElement.createTextChild(" "); | 469 * @param {!Element} parentElement |
460 titleElement.createTextChild(isArray ? "[" : "{"); | 470 * @param {!RuntimeAgent.ObjectPreview} preview |
| 471 * @param {?WebInspector.RemoteObject} object |
| 472 * @return {boolean} true iff preview captured all information. |
| 473 */ |
| 474 _appendPropertiesPreview: function(parentElement, preview, object) |
| 475 { |
| 476 var isArray = preview.subtype === "array"; |
| 477 parentElement.createTextChild(isArray ? "[" : "{"); |
461 for (var i = 0; i < preview.properties.length; ++i) { | 478 for (var i = 0; i < preview.properties.length; ++i) { |
462 if (i > 0) | 479 if (i > 0) |
463 titleElement.createTextChild(", "); | 480 parentElement.createTextChild(", "); |
464 | 481 |
465 var property = preview.properties[i]; | 482 var property = preview.properties[i]; |
466 var name = property.name; | 483 var name = property.name; |
467 if (!isArray || name != i) { | 484 if (!isArray || name != i) { |
468 if (/^\s|\s$|^$|\n/.test(name)) | 485 if (/^\s|\s$|^$|\n/.test(name)) |
469 titleElement.createChild("span", "name").createTextChildren(
"\"", name.replace(/\n/g, "\u21B5"), "\""); | 486 parentElement.createChild("span", "name").createTextChildren
("\"", name.replace(/\n/g, "\u21B5"), "\""); |
470 else | 487 else |
471 titleElement.createChild("span", "name").textContent = name; | 488 parentElement.createChild("span", "name").textContent = name
; |
472 titleElement.createTextChild(": "); | 489 parentElement.createTextChild(": "); |
473 } | 490 } |
474 | 491 |
475 titleElement.appendChild(this._renderPropertyPreviewOrAccessor(obj,
[property])); | 492 parentElement.appendChild(this._renderPropertyPreviewOrAccessor(obje
ct, [property])); |
476 } | 493 } |
477 if (preview.overflow) | 494 if (preview.overflow) |
478 titleElement.createChild("span").textContent = "\u2026"; | 495 parentElement.createChild("span").textContent = "\u2026"; |
479 titleElement.createTextChild(isArray ? "]" : "}"); | 496 parentElement.createTextChild(isArray ? "]" : "}"); |
480 return preview.lossless; | 497 return preview.lossless; |
481 }, | 498 }, |
482 | 499 |
483 /** | 500 /** |
484 * @param {!WebInspector.RemoteObject} object | 501 * @param {!Element} parentElement |
| 502 * @param {!RuntimeAgent.ObjectPreview} preview |
| 503 * @return {boolean} true iff preview captured all information. |
| 504 */ |
| 505 _appendEntriesPreview: function(parentElement, preview) |
| 506 { |
| 507 var lossless = preview.lossless && !preview.properties.length; |
| 508 parentElement.createTextChild("{"); |
| 509 for (var i = 0; i < preview.entries.length; ++i) { |
| 510 if (i > 0) |
| 511 parentElement.createTextChild(", "); |
| 512 |
| 513 var entry = preview.entries[i]; |
| 514 if (entry.key) { |
| 515 this._appendObjectPreview(parentElement, entry.key, null); |
| 516 parentElement.createTextChild(" => "); |
| 517 } |
| 518 this._appendObjectPreview(parentElement, entry.value, null); |
| 519 } |
| 520 if (preview.overflow) |
| 521 parentElement.createChild("span").textContent = "\u2026"; |
| 522 parentElement.createTextChild("}"); |
| 523 return lossless; |
| 524 }, |
| 525 |
| 526 /** |
| 527 * @param {?WebInspector.RemoteObject} object |
485 * @param {!Array.<!RuntimeAgent.PropertyPreview>} propertyPath | 528 * @param {!Array.<!RuntimeAgent.PropertyPreview>} propertyPath |
486 * @return {!Element} | 529 * @return {!Element} |
487 */ | 530 */ |
488 _renderPropertyPreviewOrAccessor: function(object, propertyPath) | 531 _renderPropertyPreviewOrAccessor: function(object, propertyPath) |
489 { | 532 { |
490 var property = propertyPath.peekLast(); | 533 var property = propertyPath.peekLast(); |
491 if (property.type === "accessor") | 534 if (property.type === "accessor") |
492 return this._formatAsAccessorProperty(object, propertyPath.select("n
ame"), false); | 535 return this._formatAsAccessorProperty(object, propertyPath.select("n
ame"), false); |
493 return this._renderPropertyPreview(property.type, /** @type {string} */
(property.subtype), property.value); | 536 return this._renderPropertyPreview(property.type, /** @type {string} */
(property.subtype), property.value); |
494 }, | 537 }, |
495 | 538 |
496 /** | 539 /** |
497 * @param {string} type | 540 * @param {string} type |
498 * @param {string=} subtype | 541 * @param {string=} subtype |
499 * @param {string=} description | 542 * @param {string=} description |
500 * @return {!Element} | 543 * @return {!Element} |
501 */ | 544 */ |
502 _renderPropertyPreview: function(type, subtype, description) | 545 _renderPropertyPreview: function(type, subtype, description) |
503 { | 546 { |
504 var span = document.createElementWithClass("span", "console-formatted-"
+ (subtype || type)); | 547 var span = document.createElementWithClass("span", "console-formatted-"
+ (subtype || type)); |
| 548 description = description || ""; |
505 | 549 |
506 if (type === "function") { | 550 if (type === "function") { |
507 span.textContent = "function"; | 551 span.textContent = "function"; |
508 return span; | 552 return span; |
509 } | 553 } |
510 | 554 |
511 if (type === "object" && subtype === "regexp") { | |
512 span.textContent = description; | |
513 return span; | |
514 } | |
515 | |
516 if (type === "object" && subtype === "node" && description) { | 555 if (type === "object" && subtype === "node" && description) { |
517 span.classList.add("console-formatted-preview-node"); | 556 span.classList.add("console-formatted-preview-node"); |
518 WebInspector.DOMPresentationUtils.createSpansForNodeTitle(span, desc
ription); | 557 WebInspector.DOMPresentationUtils.createSpansForNodeTitle(span, desc
ription); |
519 return span; | 558 return span; |
520 } | 559 } |
521 | 560 |
522 if (type === "string") { | 561 if (type === "string") { |
523 span.createTextChildren("\"", description.replace(/\n/g, "\u21B5"),
"\""); | 562 span.createTextChildren("\"", description.replace(/\n/g, "\u21B5"),
"\""); |
524 return span; | 563 return span; |
525 } | 564 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 return this._message.type !== WebInspector.ConsoleMessage.MessageType.Di
rXML && !!array.preview; | 603 return this._message.type !== WebInspector.ConsoleMessage.MessageType.Di
rXML && !!array.preview; |
565 }, | 604 }, |
566 | 605 |
567 /** | 606 /** |
568 * @param {!WebInspector.RemoteObject} array | 607 * @param {!WebInspector.RemoteObject} array |
569 * @param {!Element} elem | 608 * @param {!Element} elem |
570 */ | 609 */ |
571 _formatParameterAsArray: function(array, elem) | 610 _formatParameterAsArray: function(array, elem) |
572 { | 611 { |
573 if (this.useArrayPreviewInFormatter(array)) { | 612 if (this.useArrayPreviewInFormatter(array)) { |
574 this._formatParameterAsArrayOrObject(array, "", elem, true); | 613 this._formatParameterAsArrayOrObject(array, elem, true); |
575 return; | 614 return; |
576 } | 615 } |
577 | 616 |
578 const maxFlatArrayLength = 100; | 617 const maxFlatArrayLength = 100; |
579 if (this._message.isOutdated || array.arrayLength() > maxFlatArrayLength
) | 618 if (this._message.isOutdated || array.arrayLength() > maxFlatArrayLength
) |
580 this._formatParameterAsObject(array, elem, false); | 619 this._formatParameterAsObject(array, elem, false); |
581 else | 620 else |
582 array.getOwnProperties(this._printArray.bind(this, array, elem)); | 621 array.getOwnProperties(this._printArray.bind(this, array, elem)); |
583 }, | 622 }, |
584 | 623 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 * @param {!WebInspector.RemoteObject} output | 762 * @param {!WebInspector.RemoteObject} output |
724 * @return {!Element} | 763 * @return {!Element} |
725 */ | 764 */ |
726 _formatAsArrayEntry: function(output) | 765 _formatAsArrayEntry: function(output) |
727 { | 766 { |
728 // Prevent infinite expansion of cross-referencing arrays. | 767 // Prevent infinite expansion of cross-referencing arrays. |
729 return this._formatParameter(output, output.subtype === "array", false); | 768 return this._formatParameter(output, output.subtype === "array", false); |
730 }, | 769 }, |
731 | 770 |
732 /** | 771 /** |
733 * @param {!WebInspector.RemoteObject} object | 772 * @param {?WebInspector.RemoteObject} object |
734 * @param {!Array.<string>} propertyPath | 773 * @param {!Array.<string>} propertyPath |
735 * @param {boolean} isArrayEntry | 774 * @param {boolean} isArrayEntry |
736 * @return {!Element} | 775 * @return {!Element} |
737 */ | 776 */ |
738 _formatAsAccessorProperty: function(object, propertyPath, isArrayEntry) | 777 _formatAsAccessorProperty: function(object, propertyPath, isArrayEntry) |
739 { | 778 { |
740 var rootElement = WebInspector.ObjectPropertyTreeElement.createRemoteObj
ectAccessorPropertySpan(object, propertyPath, onInvokeGetterClick.bind(this)); | 779 var rootElement = WebInspector.ObjectPropertyTreeElement.createRemoteObj
ectAccessorPropertySpan(object, propertyPath, onInvokeGetterClick.bind(this)); |
741 | 780 |
742 /** | 781 /** |
743 * @param {?WebInspector.RemoteObject} result | 782 * @param {?WebInspector.RemoteObject} result |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 { | 1292 { |
1254 if (!this._wrapperElement) { | 1293 if (!this._wrapperElement) { |
1255 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); | 1294 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this
); |
1256 this._wrapperElement.classList.toggle("collapsed", this._collapsed); | 1295 this._wrapperElement.classList.toggle("collapsed", this._collapsed); |
1257 } | 1296 } |
1258 return this._wrapperElement; | 1297 return this._wrapperElement; |
1259 }, | 1298 }, |
1260 | 1299 |
1261 __proto__: WebInspector.ConsoleViewMessage.prototype | 1300 __proto__: WebInspector.ConsoleViewMessage.prototype |
1262 } | 1301 } |
OLD | NEW |