Chromium Code Reviews| 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Components.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 'releaseNote': | |
| 470 element = this._formatReleaseNote(output); | |
| 471 break; | |
| 469 case 'array': | 472 case 'array': |
| 470 case 'typedarray': | 473 case 'typedarray': |
| 471 element = this._formatParameterAsObject(output, includePreview); | 474 element = this._formatParameterAsObject(output, includePreview); |
| 472 break; | 475 break; |
| 473 case 'error': | 476 case 'error': |
| 474 element = this._formatParameterAsError(output); | 477 element = this._formatParameterAsError(output); |
| 475 break; | 478 break; |
| 476 case 'function': | 479 case 'function': |
| 477 case 'generator': | 480 case 'generator': |
| 478 element = this._formatParameterAsFunction(output, includePreview); | 481 element = this._formatParameterAsFunction(output, includePreview); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 516 _formatParameterAsValue(obj) { | 519 _formatParameterAsValue(obj) { |
| 517 var result = createElement('span'); | 520 var result = createElement('span'); |
| 518 result.createTextChild(obj.description || ''); | 521 result.createTextChild(obj.description || ''); |
| 519 if (obj.objectId) | 522 if (obj.objectId) |
| 520 result.addEventListener('contextmenu', this._contextMenuEventFired.bind(th is, obj), false); | 523 result.addEventListener('contextmenu', this._contextMenuEventFired.bind(th is, obj), false); |
| 521 return result; | 524 return result; |
| 522 } | 525 } |
| 523 | 526 |
| 524 /** | 527 /** |
| 525 * @param {!SDK.RemoteObject} obj | 528 * @param {!SDK.RemoteObject} obj |
| 529 * @return {!Element} | |
| 530 */ | |
| 531 _formatReleaseNote(obj) { | |
|
luoe
2017/02/11 00:30:54
Let's move this into the release note module.
chenwilliam
2017/02/15 00:57:08
Done.
| |
| 532 var description = /** @type {string} */ (obj.description); | |
| 533 var releaseNote = /** @type {!Help.ReleaseNote} */ (JSON.parse(description)) ; | |
| 534 var container = createElement('div'); | |
|
luoe
2017/02/11 00:30:54
Some of this logic already exists through our DOME
chenwilliam
2017/02/15 00:57:08
Done.
| |
| 535 container.className = 'release-note-container'; | |
| 536 insertText(container); | |
| 537 insertImage(container); | |
| 538 | |
| 539 var seenTimeout; | |
| 540 var seenObserver = new IntersectionObserver(() => { | |
| 541 seenTimeout = setTimeout(() => { | |
| 542 Console.ConsoleView.instance().sawReleaseNote(releaseNote.version); | |
| 543 seenObserver.unobserve(container); | |
| 544 notSeenObserver.unobserve(container); | |
| 545 }, releaseNote.timeout); | |
| 546 }, {threshold: 0.75}); | |
| 547 var notSeenObserver = new IntersectionObserver(() => { | |
| 548 clearTimeout(seenTimeout); | |
| 549 }, {threshold: 0.6}); | |
| 550 | |
| 551 seenObserver.observe(container); | |
| 552 notSeenObserver.observe(container); | |
|
luoe
2017/02/11 00:30:54
Is there any guarantee that the order in which Int
chenwilliam
2017/02/15 00:57:08
Removed.
| |
| 553 return container; | |
| 554 | |
| 555 /** | |
| 556 * @param {!Element} parentElement | |
| 557 * @param {string} text | |
| 558 * @param {string} className | |
| 559 */ | |
| 560 function createTextChild(parentElement, text, className) { | |
| 561 var element = createElementWithClass('div', className); | |
| 562 element.textContent = text; | |
| 563 parentElement.appendChild(element); | |
| 564 } | |
| 565 | |
| 566 /** | |
| 567 * @param {!Element} container | |
| 568 */ | |
| 569 function insertImage(container) { | |
| 570 var imageLink = UI.createExternalLink(releaseNote.link, ' ', 'release-note -image-container', undefined, true); | |
| 571 container.appendChild(imageLink); | |
| 572 var image = imageLink.createChild('img'); | |
| 573 image.src = releaseNote.image.src; | |
| 574 image.className = 'release-note-image'; | |
| 575 image.addEventListener('mouseover', e => { | |
| 576 container.className = container.className + ' image-hover'; | |
| 577 }); | |
| 578 image.addEventListener('mouseout', e => { | |
| 579 container.className = container.className.replace('image-hover', ''); | |
| 580 }); | |
|
luoe
2017/02/11 00:30:54
css `:hover`?
chenwilliam
2017/02/15 00:57:08
I'm trying to create a selector for the featured l
| |
| 581 } | |
| 582 | |
| 583 /** | |
| 584 * @param {!Element} container | |
| 585 */ | |
| 586 function insertText(container) { | |
| 587 var textContainer = container.createChild('div'); | |
| 588 textContainer.className = 'release-note-text-container'; | |
| 589 | |
| 590 createTextChild(textContainer, `New in DevTools v${releaseNote.version}`, 'release-note-header'); | |
| 591 var highlightContainer = createElementWithClass('ul', 'release-note-highli ght-container'); | |
| 592 for (var highlight of releaseNote.highlights) { | |
| 593 var highlightElement = highlightContainer.createChild('li'); | |
|
luoe
2017/02/11 00:30:54
Can we simplify the DOM and do without highlightEl
chenwilliam
2017/02/15 00:57:08
Tried doing without it but it makes styling the bu
| |
| 594 var highlightLink = UI.createExternalLink( | |
| 595 highlight.link, highlight.text, 'release-note-highlight release-note -link', undefined, true); | |
|
luoe
2017/02/11 00:30:54
`release-note-highlight` seems to have to rules?
chenwilliam
2017/02/15 00:57:08
Done.
| |
| 596 if (highlight.featured) | |
| 597 highlightLink.className += ' release-note-featured-link'; | |
| 598 highlightElement.appendChild(highlightLink); | |
| 599 } | |
| 600 textContainer.appendChild(highlightContainer); | |
| 601 | |
| 602 var viewMoreButton = | |
| 603 UI.createExternalLink(releaseNote.link, 'And more...', 'dth-button is- primary', undefined, true); | |
|
luoe
2017/02/11 00:30:54
Common.UIString() for 'And more...' and 'Hide'
chenwilliam
2017/02/15 00:57:08
Done.
| |
| 604 textContainer.appendChild(viewMoreButton); | |
| 605 | |
| 606 var closeButton = container.createChild('button'); | |
| 607 closeButton.className = 'dth-button is-secondary close-release-note-messag e'; | |
| 608 closeButton.textContent = 'Hide'; | |
| 609 closeButton.addEventListener( | |
| 610 'click', () => Console.ConsoleView.instance().removeReleaseNote(releas eNote.version), false); | |
| 611 textContainer.appendChild(closeButton); | |
| 612 } | |
| 613 } | |
| 614 | |
| 615 /** | |
| 616 * @param {!SDK.RemoteObject} obj | |
| 526 * @param {boolean=} includePreview | 617 * @param {boolean=} includePreview |
| 527 * @return {!Element} | 618 * @return {!Element} |
| 528 */ | 619 */ |
| 529 _formatParameterAsObject(obj, includePreview) { | 620 _formatParameterAsObject(obj, includePreview) { |
| 530 var titleElement = createElement('span'); | 621 var titleElement = createElement('span'); |
| 531 if (includePreview && obj.preview) { | 622 if (includePreview && obj.preview) { |
| 532 titleElement.classList.add('console-object-preview'); | 623 titleElement.classList.add('console-object-preview'); |
| 533 this._previewFormatter.appendObjectPreview(titleElement, obj.preview, fals e /* isEntry */); | 624 this._previewFormatter.appendObjectPreview(titleElement, obj.preview, fals e /* isEntry */); |
| 534 } else if (obj.type === 'function') { | 625 } else if (obj.type === 'function') { |
| 535 Components.ObjectPropertiesSection.formatObjectAsFunction(obj, titleElemen t, false); | 626 Components.ObjectPropertiesSection.formatObjectAsFunction(obj, titleElemen t, false); |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 this._element.classList.add('console-info-level'); | 1058 this._element.classList.add('console-info-level'); |
| 968 break; | 1059 break; |
| 969 case SDK.ConsoleMessage.MessageLevel.Warning: | 1060 case SDK.ConsoleMessage.MessageLevel.Warning: |
| 970 this._element.classList.add('console-warning-level'); | 1061 this._element.classList.add('console-warning-level'); |
| 971 this._updateMessageLevelIcon('smallicon-warning'); | 1062 this._updateMessageLevelIcon('smallicon-warning'); |
| 972 break; | 1063 break; |
| 973 case SDK.ConsoleMessage.MessageLevel.Error: | 1064 case SDK.ConsoleMessage.MessageLevel.Error: |
| 974 this._element.classList.add('console-error-level'); | 1065 this._element.classList.add('console-error-level'); |
| 975 this._updateMessageLevelIcon('smallicon-error'); | 1066 this._updateMessageLevelIcon('smallicon-error'); |
| 976 break; | 1067 break; |
| 1068 case SDK.ConsoleMessage.MessageLevel.Note: | |
| 1069 this._element.classList.add('console-note-level'); | |
| 1070 break; | |
| 977 } | 1071 } |
| 978 | 1072 |
| 979 // Render verbose and info deprecations, interventions and violations with w arning background. | 1073 // Render verbose and info deprecations, interventions and violations with w arning background. |
| 980 if (this._message.level === SDK.ConsoleMessage.MessageLevel.Verbose || | 1074 if (this._message.level === SDK.ConsoleMessage.MessageLevel.Verbose || |
| 981 this._message.level === SDK.ConsoleMessage.MessageLevel.Info) { | 1075 this._message.level === SDK.ConsoleMessage.MessageLevel.Info) { |
| 982 switch (this._message.source) { | 1076 switch (this._message.source) { |
| 983 case SDK.ConsoleMessage.MessageSource.Violation: | 1077 case SDK.ConsoleMessage.MessageSource.Violation: |
| 984 case SDK.ConsoleMessage.MessageSource.Deprecation: | 1078 case SDK.ConsoleMessage.MessageSource.Deprecation: |
| 985 case SDK.ConsoleMessage.MessageSource.Intervention: | 1079 case SDK.ConsoleMessage.MessageSource.Intervention: |
| 986 this._element.classList.add('console-warning-level'); | 1080 this._element.classList.add('console-warning-level'); |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1247 toMessageElement() { | 1341 toMessageElement() { |
| 1248 if (!this._element) { | 1342 if (!this._element) { |
| 1249 super.toMessageElement(); | 1343 super.toMessageElement(); |
| 1250 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); | 1344 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); |
| 1251 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); | 1345 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); |
| 1252 this.setCollapsed(this._collapsed); | 1346 this.setCollapsed(this._collapsed); |
| 1253 } | 1347 } |
| 1254 return this._element; | 1348 return this._element; |
| 1255 } | 1349 } |
| 1256 }; | 1350 }; |
| OLD | NEW |