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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 return; | 470 return; |
| 471 } | 471 } |
| 472 | 472 |
| 473 if (this._tryToCollapseMessages(viewMessage, this._visibleViewMessages.peekL ast())) | 473 if (this._tryToCollapseMessages(viewMessage, this._visibleViewMessages.peekL ast())) |
| 474 return; | 474 return; |
| 475 | 475 |
| 476 var lastMessage = this._visibleViewMessages.peekLast(); | 476 var lastMessage = this._visibleViewMessages.peekLast(); |
| 477 if (viewMessage.consoleMessage().type === ConsoleModel.ConsoleMessage.Messag eType.EndGroup) { | 477 if (viewMessage.consoleMessage().type === ConsoleModel.ConsoleMessage.Messag eType.EndGroup) { |
| 478 if (lastMessage && !this._currentGroup.messagesHidden()) | 478 if (lastMessage && !this._currentGroup.messagesHidden()) |
| 479 lastMessage.incrementCloseGroupDecorationCount(); | 479 lastMessage.incrementCloseGroupDecorationCount(); |
| 480 this._currentGroup = this._currentGroup.parentGroup(); | 480 this._currentGroup = this._currentGroup.parentGroup() || this._currentGrou p; |
| 481 return; | 481 return; |
| 482 } | 482 } |
| 483 if (!this._currentGroup.messagesHidden()) { | 483 if (!this._currentGroup.messagesHidden()) { |
| 484 var originatingMessage = viewMessage.consoleMessage().originatingMessage() ; | 484 var originatingMessage = viewMessage.consoleMessage().originatingMessage() ; |
| 485 if (lastMessage && originatingMessage && lastMessage.consoleMessage() === originatingMessage) | 485 if (lastMessage && originatingMessage && lastMessage.consoleMessage() === originatingMessage) |
| 486 lastMessage.toMessageElement().classList.add('console-adjacent-user-comm and-result'); | 486 lastMessage.toMessageElement().classList.add('console-adjacent-user-comm and-result'); |
| 487 | 487 |
| 488 this._visibleViewMessages.push(viewMessage); | 488 this._visibleViewMessages.push(viewMessage); |
| 489 this._searchMessage(this._visibleViewMessages.length - 1); | 489 this._searchMessage(this._visibleViewMessages.length - 1); |
| 490 } | 490 } |
| 491 | 491 |
| 492 if (viewMessage.consoleMessage().isGroupStartMessage()) | 492 if (viewMessage.consoleMessage().isGroupStartMessage()) { |
| 493 this._currentGroup = new Console.ConsoleGroup(this._currentGroup, viewMess age); | 493 this._currentGroup = new Console.ConsoleGroup( |
| 494 /** @type {!Console.ConsoleGroupOptions} */ ({parentGroup: this._curre ntGroup, groupMessage: viewMessage})); | |
| 495 } | |
| 494 | 496 |
| 495 this._messageAppendedForTests(); | 497 this._messageAppendedForTests(); |
| 496 } | 498 } |
| 497 | 499 |
| 498 _messageAppendedForTests() { | 500 _messageAppendedForTests() { |
| 499 // This method is sniffed in tests. | 501 // This method is sniffed in tests. |
| 500 } | 502 } |
| 501 | 503 |
| 502 /** | 504 /** |
| 503 * @param {!ConsoleModel.ConsoleMessage} message | 505 * @param {!ConsoleModel.ConsoleMessage} message |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 971 this._promptTextChangedForTest(); | 973 this._promptTextChangedForTest(); |
| 972 } | 974 } |
| 973 | 975 |
| 974 _promptTextChangedForTest() { | 976 _promptTextChangedForTest() { |
| 975 // This method is sniffed in tests. | 977 // This method is sniffed in tests. |
| 976 } | 978 } |
| 977 }; | 979 }; |
| 978 | 980 |
| 979 Console.ConsoleView.persistedHistorySize = 300; | 981 Console.ConsoleView.persistedHistorySize = 300; |
| 980 | 982 |
| 981 /** | |
| 982 * @unrestricted | |
| 983 */ | |
| 984 Console.ConsoleViewFilter = class { | 983 Console.ConsoleViewFilter = class { |
| 985 /** | 984 /** |
| 986 * @param {function()} filterChangedCallback | 985 * @param {function()} filterChangedCallback |
| 987 */ | 986 */ |
| 988 constructor(filterChangedCallback) { | 987 constructor(filterChangedCallback) { |
| 989 this._filterChanged = filterChangedCallback; | 988 this._filterChanged = filterChangedCallback; |
| 990 | 989 |
| 991 this._messageURLFiltersSetting = Common.settings.createSetting('messageURLFi lters', {}); | 990 this._messageURLFiltersSetting = Common.settings.createSetting('messageURLFi lters', {}); |
| 992 this._messageLevelFiltersSetting = Console.ConsoleViewFilter.levelFilterSett ing(); | 991 this._messageLevelFiltersSetting = Console.ConsoleViewFilter.levelFilterSett ing(); |
| 993 | 992 |
| 994 this._hideNetworkMessagesSetting = Common.moduleSetting('hideNetworkMessages '); | 993 this._hideNetworkMessagesSetting = Common.moduleSetting('hideNetworkMessages '); |
| 995 this._filterByExecutionContextSetting = Common.moduleSetting('selectedContex tFilterEnabled'); | 994 this._filterByExecutionContextSetting = Common.moduleSetting('selectedContex tFilterEnabled'); |
| 996 this._filterByConsoleAPISetting = Common.moduleSetting('consoleAPIFilterEnab led'); | 995 this._filterByConsoleAPISetting = Common.moduleSetting('consoleAPIFilterEnab led'); |
| 997 | 996 |
| 998 this._messageURLFiltersSetting.addChangeListener(this._filterChanged); | 997 this._messageURLFiltersSetting.addChangeListener(this._filterChanged); |
| 999 this._messageLevelFiltersSetting.addChangeListener(this._filterChanged); | 998 this._messageLevelFiltersSetting.addChangeListener(this._filterChanged); |
| 1000 this._hideNetworkMessagesSetting.addChangeListener(this._filterChanged); | 999 this._hideNetworkMessagesSetting.addChangeListener(this._filterChanged); |
| 1001 this._filterByExecutionContextSetting.addChangeListener(this._filterChanged) ; | 1000 this._filterByExecutionContextSetting.addChangeListener(this._filterChanged) ; |
| 1002 this._filterByConsoleAPISetting.addChangeListener(this._filterChanged); | 1001 this._filterByConsoleAPISetting.addChangeListener(this._filterChanged); |
| 1003 | 1002 |
| 1004 this._textFilterUI = new UI.ToolbarInput(Common.UIString('Filter'), 0.2, 1, true); | 1003 this._textFilterUI = new UI.ToolbarInput(Common.UIString('Filter'), 0.2, 1, true); |
| 1005 this._textFilterUI.addEventListener(UI.ToolbarInput.Event.TextChanged, this. _textFilterChanged, this); | 1004 this._textFilterUI.addEventListener(UI.ToolbarInput.Event.TextChanged, this. _textFilterChanged, this); |
| 1005 this._filterText = this._textFilterUI.value(); | |
| 1006 /** @type {?RegExp} */ | |
| 1007 this._filterRegex = null; | |
| 1006 | 1008 |
| 1007 this._levelLabels = {}; | 1009 this._levelLabels = {}; |
| 1008 this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Verbose] = Common .UIString('Verbose'); | 1010 this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Verbose] = Common .UIString('Verbose'); |
| 1009 this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Info] = Common.UI String('Info'); | 1011 this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Info] = Common.UI String('Info'); |
| 1010 this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Warning] = Common .UIString('Warnings'); | 1012 this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Warning] = Common .UIString('Warnings'); |
| 1011 this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Error] = Common.U IString('Errors'); | 1013 this._levelLabels[ConsoleModel.ConsoleMessage.MessageLevel.Error] = Common.U IString('Errors'); |
| 1012 | 1014 |
| 1013 this._levelMenuButton = new UI.ToolbarText(''); | 1015 this._levelMenuButton = new UI.ToolbarText(''); |
| 1014 this._levelMenuButtonArrow = new UI.ToolbarItem(UI.Icon.create('smallicon-tr iangle-down')); | 1016 this._levelMenuButtonArrow = new UI.ToolbarItem(UI.Icon.create('smallicon-tr iangle-down')); |
| 1015 this._levelMenuButton.element.addEventListener('click', this._showLevelConte xtMenu.bind(this)); | 1017 this._levelMenuButton.element.addEventListener('click', this._showLevelConte xtMenu.bind(this)); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1240 } | 1242 } |
| 1241 }; | 1243 }; |
| 1242 | 1244 |
| 1243 /** | 1245 /** |
| 1244 * The maximum length before strings are considered too long for syntax highligh ting. | 1246 * The maximum length before strings are considered too long for syntax highligh ting. |
| 1245 * @const | 1247 * @const |
| 1246 * @type {number} | 1248 * @type {number} |
| 1247 */ | 1249 */ |
| 1248 Console.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000; | 1250 Console.ConsoleCommand.MaxLengthToIgnoreHighlighter = 10000; |
| 1249 | 1251 |
| 1250 /** | |
| 1251 * @unrestricted | |
| 1252 */ | |
| 1253 Console.ConsoleCommandResult = class extends Console.ConsoleViewMessage { | 1252 Console.ConsoleCommandResult = class extends Console.ConsoleViewMessage { |
| 1254 /** | 1253 /** |
| 1255 * @param {!ConsoleModel.ConsoleMessage} message | 1254 * @param {!ConsoleModel.ConsoleMessage} message |
| 1256 * @param {!Components.Linkifier} linkifier | 1255 * @param {!Components.Linkifier} linkifier |
| 1257 * @param {!ProductRegistry.BadgePool} badgePool | 1256 * @param {!ProductRegistry.BadgePool} badgePool |
| 1258 * @param {number} nestingLevel | 1257 * @param {number} nestingLevel |
| 1259 */ | 1258 */ |
| 1260 constructor(message, linkifier, badgePool, nestingLevel) { | 1259 constructor(message, linkifier, badgePool, nestingLevel) { |
| 1261 super(message, linkifier, badgePool, nestingLevel); | 1260 super(message, linkifier, badgePool, nestingLevel); |
| 1262 } | 1261 } |
| 1263 | 1262 |
| 1264 /** | 1263 /** |
| 1265 * @override | 1264 * @override |
| 1266 * @return {!Element} | 1265 * @return {!Element} |
| 1267 */ | 1266 */ |
| 1268 contentElement() { | 1267 contentElement() { |
| 1269 var element = super.contentElement(); | 1268 var element = super.contentElement(); |
| 1270 if (!element.classList.contains('console-user-command-result')) { | 1269 if (!element.classList.contains('console-user-command-result')) { |
| 1271 element.classList.add('console-user-command-result'); | 1270 element.classList.add('console-user-command-result'); |
| 1272 if (this.consoleMessage().level === ConsoleModel.ConsoleMessage.MessageLev el.Info) { | 1271 if (this.consoleMessage().level === ConsoleModel.ConsoleMessage.MessageLev el.Info) { |
| 1273 var icon = UI.Icon.create('smallicon-command-result', 'command-result-ic on'); | 1272 var icon = UI.Icon.create('smallicon-command-result', 'command-result-ic on'); |
| 1274 element.insertBefore(icon, element.firstChild); | 1273 element.insertBefore(icon, element.firstChild); |
| 1275 } | 1274 } |
| 1276 } | 1275 } |
| 1277 return element; | 1276 return element; |
| 1278 } | 1277 } |
| 1279 }; | 1278 }; |
| 1280 | 1279 |
| 1281 /** | |
| 1282 * @unrestricted | |
| 1283 */ | |
| 1284 Console.ConsoleGroup = class { | 1280 Console.ConsoleGroup = class { |
| 1285 /** | 1281 /** |
| 1286 * @param {?Console.ConsoleGroup} parentGroup | 1282 * @param {?Console.ConsoleGroupOptions} options |
| 1287 * @param {?Console.ConsoleViewMessage} groupMessage | |
| 1288 */ | 1283 */ |
| 1289 constructor(parentGroup, groupMessage) { | 1284 constructor(options) { |
|
lushnikov
2017/07/17 22:47:38
let's not have options object - just pass paramete
luoe
2017/07/17 23:38:21
Done.
| |
| 1290 this._parentGroup = parentGroup; | 1285 if (options) { |
| 1291 this._nestingLevel = parentGroup ? parentGroup.nestingLevel() + 1 : 0; | 1286 this._parentGroup = options.parentGroup; |
| 1292 this._messagesHidden = | 1287 this._nestingLevel = this._parentGroup.nestingLevel() + 1; |
| 1293 groupMessage && groupMessage.collapsed() || this._parentGroup && this._p arentGroup.messagesHidden(); | 1288 this._messagesHidden = options.groupMessage.collapsed() || this._parentGro up.messagesHidden(); |
| 1289 } else { | |
| 1290 this._parentGroup = null; | |
| 1291 this._nestingLevel = 0; | |
| 1292 this._messagesHidden = false; | |
| 1293 } | |
| 1294 } | 1294 } |
| 1295 | 1295 |
| 1296 /** | 1296 /** |
| 1297 * @return {!Console.ConsoleGroup} | 1297 * @return {!Console.ConsoleGroup} |
| 1298 */ | 1298 */ |
| 1299 static createTopGroup() { | 1299 static createTopGroup() { |
| 1300 return new Console.ConsoleGroup(null, null); | 1300 return new Console.ConsoleGroup(null); |
| 1301 } | 1301 } |
| 1302 | 1302 |
| 1303 /** | 1303 /** |
| 1304 * @return {boolean} | 1304 * @return {boolean} |
| 1305 */ | 1305 */ |
| 1306 messagesHidden() { | 1306 messagesHidden() { |
| 1307 return this._messagesHidden; | 1307 return this._messagesHidden; |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 /** | 1310 /** |
| 1311 * @return {number} | 1311 * @return {number} |
| 1312 */ | 1312 */ |
| 1313 nestingLevel() { | 1313 nestingLevel() { |
| 1314 return this._nestingLevel; | 1314 return this._nestingLevel; |
| 1315 } | 1315 } |
| 1316 | 1316 |
| 1317 /** | 1317 /** |
| 1318 * @return {?Console.ConsoleGroup} | 1318 * @return {?Console.ConsoleGroup} |
| 1319 */ | 1319 */ |
| 1320 parentGroup() { | 1320 parentGroup() { |
| 1321 return this._parentGroup || this; | 1321 return this._parentGroup; |
| 1322 } | 1322 } |
| 1323 }; | 1323 }; |
| 1324 | 1324 |
| 1325 /** | |
| 1326 * @typedef {!{parentGroup: !Console.ConsoleGroup, groupMessage: !Console.Consol eViewMessage}} | |
| 1327 */ | |
| 1328 Console.ConsoleGroupOptions; | |
| 1325 | 1329 |
| 1326 /** | 1330 /** |
| 1327 * @implements {UI.ActionDelegate} | 1331 * @implements {UI.ActionDelegate} |
| 1328 * @unrestricted | |
| 1329 */ | 1332 */ |
| 1330 Console.ConsoleView.ActionDelegate = class { | 1333 Console.ConsoleView.ActionDelegate = class { |
| 1331 /** | 1334 /** |
| 1332 * @override | 1335 * @override |
| 1333 * @param {!UI.Context} context | 1336 * @param {!UI.Context} context |
| 1334 * @param {string} actionId | 1337 * @param {string} actionId |
| 1335 * @return {boolean} | 1338 * @return {boolean} |
| 1336 */ | 1339 */ |
| 1337 handleAction(context, actionId) { | 1340 handleAction(context, actionId) { |
| 1338 switch (actionId) { | 1341 switch (actionId) { |
| 1339 case 'console.show': | 1342 case 'console.show': |
| 1340 Common.console.show(); | 1343 Common.console.show(); |
| 1341 return true; | 1344 return true; |
| 1342 case 'console.clear': | 1345 case 'console.clear': |
| 1343 Console.ConsoleView.clearConsole(); | 1346 Console.ConsoleView.clearConsole(); |
| 1344 return true; | 1347 return true; |
| 1345 case 'console.clear.history': | 1348 case 'console.clear.history': |
| 1346 Console.ConsoleView.instance()._clearHistory(); | 1349 Console.ConsoleView.instance()._clearHistory(); |
| 1347 return true; | 1350 return true; |
| 1348 } | 1351 } |
| 1349 return false; | 1352 return false; |
| 1350 } | 1353 } |
| 1351 }; | 1354 }; |
| 1352 | 1355 |
| 1353 /** | 1356 /** |
| 1354 * @typedef {{messageIndex: number, matchIndex: number}} | 1357 * @typedef {{messageIndex: number, matchIndex: number}} |
| 1355 */ | 1358 */ |
| 1356 Console.ConsoleView.RegexMatchRange; | 1359 Console.ConsoleView.RegexMatchRange; |
| OLD | NEW |