 Chromium Code Reviews
 Chromium Code Reviews Issue 2702913002:
  DevTools: update repeat count only when element is requested
    
  
    Issue 2702913002:
  DevTools: update repeat count only when element is requested 
  | 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 if (this._message.level === SDK.ConsoleMessage.MessageLevel.Warning) | 115 if (this._message.level === SDK.ConsoleMessage.MessageLevel.Warning) | 
| 116 iconType = 'smallicon-warning'; | 116 iconType = 'smallicon-warning'; | 
| 117 else if (this._message.level === SDK.ConsoleMessage.MessageLevel.Error) | 117 else if (this._message.level === SDK.ConsoleMessage.MessageLevel.Error) | 
| 118 iconType = 'smallicon-error'; | 118 iconType = 'smallicon-error'; | 
| 119 else if (this._message.type === SDK.ConsoleMessage.MessageType.Command) | 119 else if (this._message.type === SDK.ConsoleMessage.MessageType.Command) | 
| 120 iconType = 'smallicon-user-command'; | 120 iconType = 'smallicon-user-command'; | 
| 121 else if (this._message.type === SDK.ConsoleMessage.MessageType.Result) | 121 else if (this._message.type === SDK.ConsoleMessage.MessageType.Result) | 
| 122 iconType = 'smallicon-command-result'; | 122 iconType = 'smallicon-command-result'; | 
| 123 this._decorationWrapper.appendChild(UI.Icon.create(iconType, 'message-level- icon')); | 123 this._decorationWrapper.appendChild(UI.Icon.create(iconType, 'message-level- icon')); | 
| 124 | 124 | 
| 125 // Timestamps may affect repeat counter. | |
| 126 this._updateRepeatCountElement(); | |
| 
pfeldman
2017/02/21 19:21:12
I'd rather do it the other way around and create i
 
luoe
2017/02/23 01:09:34
I tried placing message.updateMessageElement() ins
 | |
| 127 | |
| 128 /** | 125 /** | 
| 129 * @param {number} timestamp | 126 * @param {number} timestamp | 
| 130 * @param {boolean} full | 127 * @param {boolean} full | 
| 131 * @return {string} | 128 * @return {string} | 
| 132 */ | 129 */ | 
| 133 function formatTimestamp(timestamp, full) { | 130 function formatTimestamp(timestamp, full) { | 
| 134 var date = new Date(timestamp); | 131 var date = new Date(timestamp); | 
| 135 var yymmdd = date.getFullYear() + '-' + leadZero(date.getMonth() + 1, 2) + '-' + leadZero(date.getDate(), 2); | 132 var yymmdd = date.getFullYear() + '-' + leadZero(date.getMonth() + 1, 2) + '-' + leadZero(date.getDate(), 2); | 
| 136 var hhmmssfff = leadZero(date.getHours(), 2) + ':' + leadZero(date.getMinu tes(), 2) + ':' + | 133 var hhmmssfff = leadZero(date.getHours(), 2) + ':' + leadZero(date.getMinu tes(), 2) + ':' + | 
| 137 leadZero(date.getSeconds(), 2) + '.' + leadZero(date.getMilliseconds() , 3); | 134 leadZero(date.getSeconds(), 2) + '.' + leadZero(date.getMilliseconds() , 3); | 
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 948 formattedMessage = this._buildMessage(consoleMessage); | 945 formattedMessage = this._buildMessage(consoleMessage); | 
| 949 contentElement.appendChild(formattedMessage); | 946 contentElement.appendChild(formattedMessage); | 
| 950 | 947 | 
| 951 return this._contentElement; | 948 return this._contentElement; | 
| 952 } | 949 } | 
| 953 | 950 | 
| 954 /** | 951 /** | 
| 955 * @return {!Element} | 952 * @return {!Element} | 
| 956 */ | 953 */ | 
| 957 toMessageElement() { | 954 toMessageElement() { | 
| 958 if (this._element) | 955 if (!this._element) { | 
| 959 return this._element; | 956 this._element = createElement('div'); | 
| 957 this.updateMessageElement(); | |
| 958 } | |
| 960 | 959 | 
| 961 this._element = createElement('div'); | 960 // Update repeat count. | 
| 962 this.updateMessageElement(); | 961 var show = this._repeatCount > 1; | 
| 962 this._repeatCountElement.textContent = show ? this._repeatCount : ''; | |
| 963 this._repeatCountElement.classList.toggle('hidden', !show); | |
| 964 this._element.classList.toggle('repeated-message', show); | |
| 965 | |
| 963 return this._element; | 966 return this._element; | 
| 964 } | 967 } | 
| 965 | 968 | 
| 966 updateMessageElement() { | 969 updateMessageElement() { | 
| 967 if (!this._element) | 970 if (!this._element) | 
| 968 return; | 971 return; | 
| 969 | 972 | 
| 970 this._element.className = 'console-message-wrapper'; | 973 this._element.className = 'console-message-wrapper'; | 
| 971 this._element.removeChildren(); | 974 this._element.removeChildren(); | 
| 972 this._element.message = this; | 975 this._element.message = this; | 
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1022 | 1025 | 
| 1023 /** | 1026 /** | 
| 1024 * @return {number} | 1027 * @return {number} | 
| 1025 */ | 1028 */ | 
| 1026 repeatCount() { | 1029 repeatCount() { | 
| 1027 return this._repeatCount || 1; | 1030 return this._repeatCount || 1; | 
| 1028 } | 1031 } | 
| 1029 | 1032 | 
| 1030 resetIncrementRepeatCount() { | 1033 resetIncrementRepeatCount() { | 
| 1031 this._repeatCount = 1; | 1034 this._repeatCount = 1; | 
| 1032 this._updateRepeatCountElement(); | |
| 1033 } | 1035 } | 
| 1034 | 1036 | 
| 1035 incrementRepeatCount() { | 1037 incrementRepeatCount() { | 
| 1036 this._repeatCount++; | 1038 this._repeatCount++; | 
| 1037 this._updateRepeatCountElement(); | |
| 1038 } | |
| 1039 | |
| 1040 _updateRepeatCountElement() { | |
| 1041 if (!this._repeatCountElement) | |
| 1042 return; | |
| 1043 var show = this._repeatCount > 1; | |
| 1044 this._repeatCountElement.textContent = show ? this._repeatCount : ''; | |
| 1045 this._repeatCountElement.classList.toggle('hidden', !show); | |
| 1046 if (this._element) | |
| 1047 this._element.classList.toggle('repeated-message', show); | |
| 1048 } | 1039 } | 
| 1049 | 1040 | 
| 1050 get text() { | 1041 get text() { | 
| 1051 return this._message.messageText; | 1042 return this._message.messageText; | 
| 1052 } | 1043 } | 
| 1053 | 1044 | 
| 1054 /** | 1045 /** | 
| 1055 * @return {string} | 1046 * @return {string} | 
| 1056 */ | 1047 */ | 
| 1057 toExportString() { | 1048 toExportString() { | 
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1239 toMessageElement() { | 1230 toMessageElement() { | 
| 1240 if (!this._element) { | 1231 if (!this._element) { | 
| 1241 super.toMessageElement(); | 1232 super.toMessageElement(); | 
| 1242 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); | 1233 this._expandGroupIcon = UI.Icon.create('', 'expand-group-icon'); | 
| 1243 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); | 1234 this._contentElement.insertBefore(this._expandGroupIcon, this._contentElem ent.firstChild); | 
| 1244 this.setCollapsed(this._collapsed); | 1235 this.setCollapsed(this._collapsed); | 
| 1245 } | 1236 } | 
| 1246 return this._element; | 1237 return this._element; | 
| 1247 } | 1238 } | 
| 1248 }; | 1239 }; | 
| OLD | NEW |