Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Joseph Pecoraro | 3 * Copyright (C) 2009 Joseph Pecoraro |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 this._viewport.setStickToBottom(true); | 114 this._viewport.setStickToBottom(true); |
| 115 this._viewport.contentElement().classList.add('console-group', 'console-grou p-messages'); | 115 this._viewport.contentElement().classList.add('console-group', 'console-grou p-messages'); |
| 116 this._contentsElement.appendChild(this._viewport.element); | 116 this._contentsElement.appendChild(this._viewport.element); |
| 117 this._messagesElement = this._viewport.element; | 117 this._messagesElement = this._viewport.element; |
| 118 this._messagesElement.id = 'console-messages'; | 118 this._messagesElement.id = 'console-messages'; |
| 119 this._messagesElement.classList.add('monospace'); | 119 this._messagesElement.classList.add('monospace'); |
| 120 this._messagesElement.addEventListener('click', this._messagesClicked.bind(t his), true); | 120 this._messagesElement.addEventListener('click', this._messagesClicked.bind(t his), true); |
| 121 | 121 |
| 122 this._viewportThrottler = new Common.Throttler(50); | 122 this._viewportThrottler = new Common.Throttler(50); |
| 123 | 123 |
| 124 this._filterStatusMessageElement = createElementWithClass('div', 'console-me ssage'); | 124 this._filterStatusMessageElement = createElementWithClass('div', 'console-me ssage-wrapper'); |
| 125 this._messagesElement.insertBefore(this._filterStatusMessageElement, this._m essagesElement.firstChild); | 125 this._messagesElement.insertBefore(this._filterStatusMessageElement, this._m essagesElement.firstChild); |
| 126 this._filterStatusTextElement = this._filterStatusMessageElement.createChild ('span', 'console-info'); | 126 this._filterStatusTextElement = this._filterStatusMessageElement.createChild ('span', 'console-info'); |
| 127 this._filterStatusMessageElement.createTextChild(' '); | 127 this._filterStatusMessageElement.createTextChild(' '); |
| 128 | 128 |
| 129 this._topGroup = Console.ConsoleGroup.createTopGroup(); | 129 this._topGroup = Console.ConsoleGroup.createTopGroup(); |
| 130 this._currentGroup = this._topGroup; | 130 this._currentGroup = this._topGroup; |
| 131 | 131 |
| 132 this._promptElement = this._messagesElement.createChild('div', 'source-code' ); | 132 this._promptElement = this._messagesElement.createChild('div', 'source-code' ); |
| 133 var promptIcon = UI.Icon.create('smallicon-text-prompt', 'console-prompt-ico n'); | 133 var promptIcon = UI.Icon.create('smallicon-text-prompt', 'console-prompt-ico n'); |
| 134 this._promptElement.appendChild(promptIcon); | 134 this._promptElement.appendChild(promptIcon); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 156 this._prompt.show(this._promptElement); | 156 this._prompt.show(this._promptElement); |
| 157 this._prompt.element.addEventListener('keydown', this._promptKeyDown.bind(th is), true); | 157 this._prompt.element.addEventListener('keydown', this._promptKeyDown.bind(th is), true); |
| 158 | 158 |
| 159 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto ryAutocompleteChanged, this); | 159 this._consoleHistoryAutocompleteSetting.addChangeListener(this._consoleHisto ryAutocompleteChanged, this); |
| 160 | 160 |
| 161 var historyData = this._consoleHistorySetting.get(); | 161 var historyData = this._consoleHistorySetting.get(); |
| 162 this._prompt.history().setHistoryData(historyData); | 162 this._prompt.history().setHistoryData(historyData); |
| 163 this._consoleHistoryAutocompleteChanged(); | 163 this._consoleHistoryAutocompleteChanged(); |
| 164 | 164 |
| 165 this._updateFilterStatus(); | 165 this._updateFilterStatus(); |
| 166 this._timestampsSetting.addChangeListener(this._consoleTimestampsSettingChan ged, this); | 166 this._timestampsSetting.addChangeListener(this._updateMessageList, this); |
| 167 | 167 |
| 168 this._registerWithMessageSink(); | 168 this._registerWithMessageSink(); |
| 169 SDK.targetManager.observeTargets(this); | 169 SDK.targetManager.observeTargets(this); |
| 170 | 170 |
| 171 this._initConsoleMessages(); | 171 this._initConsoleMessages(); |
| 172 | 172 |
| 173 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChanged, this); | 173 UI.context.addFlavorChangeListener(SDK.ExecutionContext, this._executionCont extChanged, this); |
| 174 | 174 |
| 175 this._messagesElement.addEventListener('mousedown', this._updateStickToBotto mOnMouseDown.bind(this), false); | 175 this._messagesElement.addEventListener('mousedown', this._updateStickToBotto mOnMouseDown.bind(this), false); |
| 176 this._messagesElement.addEventListener('mouseup', this._updateStickToBottomO nMouseUp.bind(this), false); | 176 this._messagesElement.addEventListener('mouseup', this._updateStickToBottomO nMouseUp.bind(this), false); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 326 level = SDK.ConsoleMessage.MessageLevel.Warning; | 326 level = SDK.ConsoleMessage.MessageLevel.Warning; |
| 327 break; | 327 break; |
| 328 } | 328 } |
| 329 | 329 |
| 330 var consoleMessage = new SDK.ConsoleMessage( | 330 var consoleMessage = new SDK.ConsoleMessage( |
| 331 null, SDK.ConsoleMessage.MessageSource.Other, level, message.text, undef ined, undefined, undefined, undefined, | 331 null, SDK.ConsoleMessage.MessageSource.Other, level, message.text, undef ined, undefined, undefined, undefined, |
| 332 undefined, undefined, undefined, message.timestamp); | 332 undefined, undefined, undefined, message.timestamp); |
| 333 this._addConsoleMessage(consoleMessage); | 333 this._addConsoleMessage(consoleMessage); |
| 334 } | 334 } |
| 335 | 335 |
| 336 _consoleTimestampsSettingChanged() { | |
| 337 this._updateMessageList(); | |
| 338 this._consoleMessages.forEach(viewMessage => viewMessage.updateTimestamp()); | |
| 339 } | |
| 340 | |
| 341 _executionContextChanged() { | 336 _executionContextChanged() { |
| 342 this._prompt.clearAutocomplete(); | 337 this._prompt.clearAutocomplete(); |
| 343 if (this._filter._showTargetMessagesCheckbox.checked()) | 338 if (this._filter._showTargetMessagesCheckbox.checked()) |
| 344 this._updateMessageList(); | 339 this._updateMessageList(); |
| 345 } | 340 } |
| 346 | 341 |
| 347 /** | 342 /** |
| 348 * @override | 343 * @override |
| 349 */ | 344 */ |
| 350 willHide() { | 345 willHide() { |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 552 | 547 |
| 553 /** | 548 /** |
| 554 * @param {!SDK.ConsoleMessage} message | 549 * @param {!SDK.ConsoleMessage} message |
| 555 * @return {!Console.ConsoleViewMessage} | 550 * @return {!Console.ConsoleViewMessage} |
| 556 */ | 551 */ |
| 557 _createViewMessage(message) { | 552 _createViewMessage(message) { |
| 558 var nestingLevel = this._currentGroup.nestingLevel(); | 553 var nestingLevel = this._currentGroup.nestingLevel(); |
| 559 switch (message.type) { | 554 switch (message.type) { |
| 560 case SDK.ConsoleMessage.MessageType.Command: | 555 case SDK.ConsoleMessage.MessageType.Command: |
| 561 return new Console.ConsoleCommand(message, this._linkifier, nestingLevel ); | 556 return new Console.ConsoleCommand(message, this._linkifier, nestingLevel ); |
| 562 case SDK.ConsoleMessage.MessageType.Result: | |
| 563 return new Console.ConsoleCommandResult(message, this._linkifier, nestin gLevel); | |
| 564 case SDK.ConsoleMessage.MessageType.StartGroupCollapsed: | 557 case SDK.ConsoleMessage.MessageType.StartGroupCollapsed: |
| 565 case SDK.ConsoleMessage.MessageType.StartGroup: | 558 case SDK.ConsoleMessage.MessageType.StartGroup: |
| 566 return new Console.ConsoleGroupViewMessage(message, this._linkifier, nes tingLevel); | 559 return new Console.ConsoleGroupViewMessage(message, this._linkifier, nes tingLevel); |
| 567 default: | 560 default: |
| 568 return new Console.ConsoleViewMessage(message, this._linkifier, nestingL evel); | 561 return new Console.ConsoleViewMessage(message, this._linkifier, nestingL evel); |
| 569 } | 562 } |
| 570 } | 563 } |
| 571 | 564 |
| 572 _consoleCleared() { | 565 _consoleCleared() { |
| 573 this._currentMatchRangeIndex = -1; | 566 this._currentMatchRangeIndex = -1; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 707 for (var i = 0; i < this._visibleViewMessages.length; ++i) { | 700 for (var i = 0; i < this._visibleViewMessages.length; ++i) { |
| 708 this._visibleViewMessages[i].resetCloseGroupDecorationCount(); | 701 this._visibleViewMessages[i].resetCloseGroupDecorationCount(); |
| 709 this._visibleViewMessages[i].resetIncrementRepeatCount(); | 702 this._visibleViewMessages[i].resetIncrementRepeatCount(); |
| 710 } | 703 } |
| 711 this._visibleViewMessages = []; | 704 this._visibleViewMessages = []; |
| 712 for (var i = 0; i < this._consoleMessages.length; ++i) | 705 for (var i = 0; i < this._consoleMessages.length; ++i) |
| 713 this._appendMessageToEnd(this._consoleMessages[i]); | 706 this._appendMessageToEnd(this._consoleMessages[i]); |
| 714 this._updateFilterStatus(); | 707 this._updateFilterStatus(); |
| 715 this._searchableView.updateSearchMatchesCount(this._regexMatchRanges.length) ; | 708 this._searchableView.updateSearchMatchesCount(this._regexMatchRanges.length) ; |
| 716 this._viewport.invalidate(); | 709 this._viewport.invalidate(); |
| 710 this._visibleViewMessages.forEach(message => message.updateMessageElement()) ; | |
|
pfeldman
2017/02/22 00:10:45
This still does not make much sense to me! Why do
| |
| 717 } | 711 } |
| 718 | 712 |
| 719 /** | 713 /** |
| 720 * @param {!Common.Event} event | 714 * @param {!Common.Event} event |
| 721 */ | 715 */ |
| 722 _monitoringXHREnabledSettingChanged(event) { | 716 _monitoringXHREnabledSettingChanged(event) { |
| 723 var enabled = /** @type {boolean} */ (event.data); | 717 var enabled = /** @type {boolean} */ (event.data); |
| 724 SDK.targetManager.targets().forEach(function(target) { | 718 SDK.targetManager.targets().forEach(function(target) { |
| 725 target.networkAgent().setMonitoringXHREnabled(enabled); | 719 target.networkAgent().setMonitoringXHREnabled(enabled); |
| 726 }); | 720 }); |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 super(message, linkifier, nestingLevel); | 1184 super(message, linkifier, nestingLevel); |
| 1191 } | 1185 } |
| 1192 | 1186 |
| 1193 /** | 1187 /** |
| 1194 * @override | 1188 * @override |
| 1195 * @return {!Element} | 1189 * @return {!Element} |
| 1196 */ | 1190 */ |
| 1197 contentElement() { | 1191 contentElement() { |
| 1198 if (!this._contentElement) { | 1192 if (!this._contentElement) { |
| 1199 this._contentElement = createElementWithClass('div', 'console-user-command '); | 1193 this._contentElement = createElementWithClass('div', 'console-user-command '); |
| 1200 var icon = UI.Icon.create('smallicon-user-command', 'command-result-icon') ; | |
| 1201 this._contentElement.appendChild(icon); | |
| 1202 | |
| 1203 this._contentElement.message = this; | 1194 this._contentElement.message = this; |
| 1204 | 1195 |
| 1205 this._formattedCommand = createElementWithClass('span', 'source-code'); | 1196 this._formattedCommand = createElementWithClass('span', 'source-code'); |
| 1206 this._formattedCommand.textContent = this.text.replaceControlCharacters(); | 1197 this._formattedCommand.textContent = this.text.replaceControlCharacters(); |
| 1207 this._contentElement.appendChild(this._formattedCommand); | 1198 this._contentElement.appendChild(this._formattedCommand); |
| 1208 | 1199 |
| 1209 if (this._formattedCommand.textContent.length < Console.ConsoleCommand.Max LengthToIgnoreHighlighter) { | 1200 if (this._formattedCommand.textContent.length < Console.ConsoleCommand.Max LengthToIgnoreHighlighter) { |
| 1210 var javascriptSyntaxHighlighter = new UI.SyntaxHighlighter('text/javascr ipt', true); | 1201 var javascriptSyntaxHighlighter = new UI.SyntaxHighlighter('text/javascr ipt', true); |
| 1211 javascriptSyntaxHighlighter.syntaxHighlightNode(this._formattedCommand). then(this._updateSearch.bind(this)); | 1202 javascriptSyntaxHighlighter.syntaxHighlightNode(this._formattedCommand). then(this._updateSearch.bind(this)); |
| 1212 } else { | 1203 } else { |
| 1213 this._updateSearch(); | 1204 this._updateSearch(); |
| 1214 } | 1205 } |
| 1215 | |
| 1216 this.updateTimestamp(); | |
| 1217 } | 1206 } |
| 1218 return this._contentElement; | 1207 return this._contentElement; |
| 1219 } | 1208 } |
| 1220 | 1209 |
| 1221 _updateSearch() { | 1210 _updateSearch() { |
| 1222 this.setSearchRegex(this.searchRegex()); | 1211 this.setSearchRegex(this.searchRegex()); |
| 1223 } | 1212 } |
| 1224 }; | 1213 }; |
| 1225 | 1214 |
| 1226 /** | 1215 /** |
| 1227 * The maximum length before strings are considered too long for syntax highligh ting. | 1216 * The maximum length before strings are considered too long for syntax highligh ting. |
| 1228 * @const | 1217 * @const |
| 1229 * @type {number} | 1218 * @type {number} |
| 1230 */ | 1219 */ |
| 1231 Console.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000; | 1220 Console.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000; |
| 1232 | 1221 |
| 1233 /** | 1222 /** |
| 1234 * @unrestricted | 1223 * @unrestricted |
| 1235 */ | 1224 */ |
| 1236 Console.ConsoleCommandResult = class extends Console.ConsoleViewMessage { | |
| 1237 /** | |
| 1238 * @param {!SDK.ConsoleMessage} message | |
| 1239 * @param {!Components.Linkifier} linkifier | |
| 1240 * @param {number} nestingLevel | |
| 1241 */ | |
| 1242 constructor(message, linkifier, nestingLevel) { | |
| 1243 super(message, linkifier, nestingLevel); | |
| 1244 } | |
| 1245 | |
| 1246 /** | |
| 1247 * @override | |
| 1248 * @return {!Element} | |
| 1249 */ | |
| 1250 contentElement() { | |
| 1251 var element = super.contentElement(); | |
| 1252 if (!element.classList.contains('console-user-command-result')) { | |
| 1253 element.classList.add('console-user-command-result'); | |
| 1254 if (this.consoleMessage().level === SDK.ConsoleMessage.MessageLevel.Info) { | |
| 1255 var icon = UI.Icon.create('smallicon-command-result', 'command-result-ic on'); | |
| 1256 element.insertBefore(icon, element.firstChild); | |
| 1257 } | |
| 1258 } | |
| 1259 return element; | |
| 1260 } | |
| 1261 }; | |
| 1262 | |
| 1263 /** | |
| 1264 * @unrestricted | |
| 1265 */ | |
| 1266 Console.ConsoleGroup = class { | 1225 Console.ConsoleGroup = class { |
| 1267 /** | 1226 /** |
| 1268 * @param {?Console.ConsoleGroup} parentGroup | 1227 * @param {?Console.ConsoleGroup} parentGroup |
| 1269 * @param {?Console.ConsoleViewMessage} groupMessage | 1228 * @param {?Console.ConsoleViewMessage} groupMessage |
| 1270 */ | 1229 */ |
| 1271 constructor(parentGroup, groupMessage) { | 1230 constructor(parentGroup, groupMessage) { |
| 1272 this._parentGroup = parentGroup; | 1231 this._parentGroup = parentGroup; |
| 1273 this._nestingLevel = parentGroup ? parentGroup.nestingLevel() + 1 : 0; | 1232 this._nestingLevel = parentGroup ? parentGroup.nestingLevel() + 1 : 0; |
| 1274 this._messagesHidden = | 1233 this._messagesHidden = |
| 1275 groupMessage && groupMessage.collapsed() || this._parentGroup && this._p arentGroup.messagesHidden(); | 1234 groupMessage && groupMessage.collapsed() || this._parentGroup && this._p arentGroup.messagesHidden(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1329 return true; | 1288 return true; |
| 1330 } | 1289 } |
| 1331 return false; | 1290 return false; |
| 1332 } | 1291 } |
| 1333 }; | 1292 }; |
| 1334 | 1293 |
| 1335 /** | 1294 /** |
| 1336 * @typedef {{messageIndex: number, matchIndex: number}} | 1295 * @typedef {{messageIndex: number, matchIndex: number}} |
| 1337 */ | 1296 */ |
| 1338 Console.ConsoleView.RegexMatchRange; | 1297 Console.ConsoleView.RegexMatchRange; |
| OLD | NEW |