Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
| index c4c5aea90db9c7cb8a8bd3cb1c525277f428f532..c2f06c19b61acb488c78125399b3174cd538344d 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/console/ConsoleViewMessage.js |
| @@ -48,8 +48,14 @@ Console.ConsoleViewMessage = class { |
| this._dataGrid = null; |
| this._previewFormatter = new Components.RemoteObjectPreviewFormatter(); |
| this._searchRegex = null; |
| - /** @type {?UI.Icon} */ |
| - this._messageLevelIcon = null; |
| + /** @type {?Element} */ |
| + this._timestampElement = null; |
| + /** @type {?Element} */ |
| + this._levelIcon = null; |
| + /** @type {?Element} */ |
| + this._nestingLevelMarkersSlot = null; |
| + /** @type {?Element} */ |
| + this._repeatCountElement = null; |
| } |
| /** |
| @@ -73,6 +79,9 @@ Console.ConsoleViewMessage = class { |
| wasShown() { |
| if (this._dataGrid) |
| this._dataGrid.updateWidths(); |
| + this._rebuildTimestamp(); |
|
pfeldman
2017/02/07 01:11:35
Why would we rebuild these slots over and over as
luoe
2017/02/07 17:33:05
As discussed offline, it should not be too expensi
|
| + this._rebuildLevelIcon(); |
| + this._rebuildRepeatCountElement(); |
| this._isVisible = true; |
| } |
| @@ -826,22 +835,18 @@ Console.ConsoleViewMessage = class { |
| return text.toLowerCase().includes(filter.toLowerCase()); |
| } |
| - updateTimestamp() { |
| - if (!this._contentElement) |
| - return; |
| - |
| + _rebuildTimestamp() { |
|
pfeldman
2017/02/07 01:11:35
I don't see how timestamp becomes visible upon tog
luoe
2017/02/07 17:33:05
Done.
|
| var format = Common.moduleSetting('consoleTimestampFormat').get(); |
| - if (format !== Console.ConsoleViewMessage.TimestampFormat.None) { |
| + var show = format !== Console.ConsoleViewMessage.TimestampFormat.None; |
| + if (show) { |
| var timestampText = formatTimestamp(this._message.timestamp, format); |
| - if (!this._timestampElement) |
| - this._timestampElement = createElementWithClass('span', 'console-timestamp'); |
| this._timestampElement.textContent = timestampText + ' '; |
| this._timestampElement.title = timestampText; |
| - this._contentElement.insertBefore(this._timestampElement, this._contentElement.firstChild); |
| - } else if (this._timestampElement) { |
| - this._timestampElement.remove(); |
| - delete this._timestampElement; |
| + } else { |
| + this._timestampElement.textContent = ''; |
| + this._timestampElement.title = ''; |
| } |
| + this._timestampElement.hidden = !show; |
|
pfeldman
2017/02/07 01:11:35
.classList.toggle('hidden', !show)
luoe
2017/02/07 17:33:05
Done.
|
| /** |
| * @param {number} timestamp |
| @@ -906,12 +911,12 @@ Console.ConsoleViewMessage = class { |
| return this._contentElement; |
| var contentElement = createElementWithClass('div', 'console-message'); |
| - if (this._messageLevelIcon) |
| - contentElement.appendChild(this._messageLevelIcon); |
| this._contentElement = contentElement; |
| if (this._message.type === SDK.ConsoleMessage.MessageType.StartGroup || |
| this._message.type === SDK.ConsoleMessage.MessageType.StartGroupCollapsed) |
| contentElement.classList.add('console-group-title'); |
| + else if (this._message.type === SDK.ConsoleMessage.MessageType.Result) |
| + contentElement.classList.add('console-user-command-result'); |
| var formattedMessage; |
| var consoleMessage = this._message; |
| @@ -929,7 +934,6 @@ Console.ConsoleViewMessage = class { |
| formattedMessage = this._buildMessage(consoleMessage); |
| contentElement.appendChild(formattedMessage); |
| - this.updateTimestamp(); |
| return this._contentElement; |
| } |
| @@ -951,28 +955,20 @@ Console.ConsoleViewMessage = class { |
| this._element.className = 'console-message-wrapper'; |
| this._element.removeChildren(); |
| - |
| - this._nestingLevelMarkers = []; |
| - for (var i = 0; i < this._nestingLevel; ++i) |
| - this._nestingLevelMarkers.push(this._element.createChild('div', 'nesting-level-marker')); |
| - this._updateCloseGroupDecorations(); |
| this._element.message = this; |
| switch (this._message.level) { |
| case SDK.ConsoleMessage.MessageLevel.Verbose: |
| this._element.classList.add('console-verbose-level'); |
| - this._updateMessageLevelIcon(''); |
| break; |
| case SDK.ConsoleMessage.MessageLevel.Info: |
| this._element.classList.add('console-info-level'); |
| break; |
| case SDK.ConsoleMessage.MessageLevel.Warning: |
| this._element.classList.add('console-warning-level'); |
| - this._updateMessageLevelIcon('smallicon-warning'); |
| break; |
| case SDK.ConsoleMessage.MessageLevel.Error: |
| this._element.classList.add('console-error-level'); |
| - this._updateMessageLevelIcon('smallicon-error'); |
| break; |
| } |
| @@ -988,23 +984,30 @@ Console.ConsoleViewMessage = class { |
| } |
| } |
| + this._timestampElement = this._element.createChild('span', 'message-timestamp'); |
| + this._levelIcon = UI.Icon.create('', 'message-level-icon'); |
| + this._element.appendChild(this._levelIcon); |
| + this._nestingLevelMarkersSlot = this._element.createChild('span', 'message-nesting-level-markers-slot'); |
| + this._repeatCountElement = this._element.createChild('label', 'message-repeat-count', 'dt-small-bubble'); |
| this._element.appendChild(this.contentElement()); |
| - if (this._repeatCount > 1) |
| - this._showRepeatCountElement(); |
| + |
| + this._nestingLevelMarkers = []; |
| + for (var i = 0; i < this._nestingLevel; ++i) |
| + this._nestingLevelMarkers.push(this._nestingLevelMarkersSlot.createChild('div', 'message-nesting-level-marker')); |
| + this._updateCloseGroupDecorations(); |
| } |
| - /** |
| - * @param {string} iconType |
| - */ |
| - _updateMessageLevelIcon(iconType) { |
| - if (!iconType && !this._messageLevelIcon) |
| - return; |
| - if (iconType && !this._messageLevelIcon) { |
| - this._messageLevelIcon = UI.Icon.create('', 'message-level-icon'); |
| - if (this._contentElement) |
| - this._contentElement.insertBefore(this._messageLevelIcon, this._contentElement.firstChild); |
| - } |
| - this._messageLevelIcon.setIconType(iconType); |
| + _rebuildLevelIcon() { |
| + var iconType = ''; |
| + if (this._message.level === SDK.ConsoleMessage.MessageLevel.Warning) |
| + iconType = 'smallicon-warning'; |
| + else if (this._message.level === SDK.ConsoleMessage.MessageLevel.Error) |
| + iconType = 'smallicon-error'; |
| + else if (this._message.type === SDK.ConsoleMessage.MessageType.Command) |
| + iconType = 'smallicon-user-command'; |
| + else if (this._message.type === SDK.ConsoleMessage.MessageType.Result) |
| + iconType = 'smallicon-command-result'; |
| + this._levelIcon.setIconType(iconType); |
| } |
| /** |
| @@ -1016,26 +1019,20 @@ Console.ConsoleViewMessage = class { |
| resetIncrementRepeatCount() { |
| this._repeatCount = 1; |
| - if (!this._repeatCountElement) |
| - return; |
| - |
| - this._repeatCountElement.remove(); |
| - if (this._contentElement) |
| - this._contentElement.classList.remove('repeated-message'); |
| - delete this._repeatCountElement; |
| + this._rebuildRepeatCountElement(); |
| } |
| incrementRepeatCount() { |
| this._repeatCount++; |
| - this._showRepeatCountElement(); |
| + this._rebuildRepeatCountElement(); |
| } |
| - _showRepeatCountElement() { |
| - if (!this._contentElement) |
| + _rebuildRepeatCountElement() { |
| + // Repeat counter may be updated before a message is rendered. |
| + if (!this._repeatCountElement) |
| return; |
| - |
| - if (!this._repeatCountElement) { |
| - this._repeatCountElement = createElementWithClass('label', 'console-message-repeat-count', 'dt-small-bubble'); |
| + var show = this._repeatCount > 1; |
| + if (show) { |
| switch (this._message.level) { |
| case SDK.ConsoleMessage.MessageLevel.Warning: |
| this._repeatCountElement.type = 'warning'; |
| @@ -1049,10 +1046,13 @@ Console.ConsoleViewMessage = class { |
| default: |
| this._repeatCountElement.type = 'info'; |
| } |
| - this._element.insertBefore(this._repeatCountElement, this._contentElement); |
| - this._contentElement.classList.add('repeated-message'); |
| + this._repeatCountElement.textContent = this._repeatCount; |
| + } else { |
| + this._repeatCountElement.textContent = ''; |
| } |
| - this._repeatCountElement.textContent = this._repeatCount; |
| + this._repeatCountElement.hidden = !show; |
| + if (this._element) |
| + this._element.classList.toggle('repeated-message', show); |
| } |
| get text() { |