| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 this._registerShortcuts(); | 130 this._registerShortcuts(); |
| 131 | 131 |
| 132 this._messagesElement.addEventListener("contextmenu", this._handleContextMen
uEvent.bind(this), false); | 132 this._messagesElement.addEventListener("contextmenu", this._handleContextMen
uEvent.bind(this), false); |
| 133 WebInspector.moduleSetting("monitoringXHREnabled").addChangeListener(this._m
onitoringXHREnabledSettingChanged, this); | 133 WebInspector.moduleSetting("monitoringXHREnabled").addChangeListener(this._m
onitoringXHREnabledSettingChanged, this); |
| 134 | 134 |
| 135 this._linkifier = new WebInspector.Linkifier(); | 135 this._linkifier = new WebInspector.Linkifier(); |
| 136 | 136 |
| 137 /** @type {!Array.<!WebInspector.ConsoleViewMessage>} */ | 137 /** @type {!Array.<!WebInspector.ConsoleViewMessage>} */ |
| 138 this._consoleMessages = []; | 138 this._consoleMessages = []; |
| 139 this._viewMessageSymbol = Symbol("viewMessage"); | |
| 140 | 139 |
| 141 this._prompt = new WebInspector.TextPromptWithHistory(WebInspector.Execution
ContextSelector.completionsForTextPromptInCurrentContext); | 140 this._prompt = new WebInspector.TextPromptWithHistory(WebInspector.Execution
ContextSelector.completionsForTextPromptInCurrentContext); |
| 142 this._prompt.setSuggestBoxEnabled(true); | 141 this._prompt.setSuggestBoxEnabled(true); |
| 143 this._prompt.setAutocompletionTimeout(0); | 142 this._prompt.setAutocompletionTimeout(0); |
| 144 this._prompt.renderAsBlock(); | 143 this._prompt.renderAsBlock(); |
| 145 var proxyElement = this._prompt.attach(this._promptElement); | 144 var proxyElement = this._prompt.attach(this._promptElement); |
| 146 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this), fal
se); | 145 proxyElement.addEventListener("keydown", this._promptKeyDown.bind(this), fal
se); |
| 147 | 146 |
| 148 this._consoleHistorySetting = WebInspector.settings.createLocalSetting("cons
oleHistory", []); | 147 this._consoleHistorySetting = WebInspector.settings.createLocalSetting("cons
oleHistory", []); |
| 149 var historyData = this._consoleHistorySetting.get(); | 148 var historyData = this._consoleHistorySetting.get(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 if (resourceTreeModel.target() !== WebInspector.targetManager.mainTarget
()) | 199 if (resourceTreeModel.target() !== WebInspector.targetManager.mainTarget
()) |
| 201 return; | 200 return; |
| 202 WebInspector.targetManager.removeModelListener(WebInspector.ResourceTree
Model, WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._on
ResourceTreeModelLoaded, this); | 201 WebInspector.targetManager.removeModelListener(WebInspector.ResourceTree
Model, WebInspector.ResourceTreeModel.EventTypes.CachedResourcesLoaded, this._on
ResourceTreeModelLoaded, this); |
| 203 this._fetchMultitargetMessages(); | 202 this._fetchMultitargetMessages(); |
| 204 }, | 203 }, |
| 205 | 204 |
| 206 _fetchMultitargetMessages: function() | 205 _fetchMultitargetMessages: function() |
| 207 { | 206 { |
| 208 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.ConsoleCleared, this._consoleCleared, this); | 207 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.ConsoleCleared, this._consoleCleared, this); |
| 209 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.MessageAdded, this._onConsoleMessageAdded, this); | 208 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.MessageAdded, this._onConsoleMessageAdded, this); |
| 210 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.MessageUpdated, this._onConsoleMessageUpdated, this); | |
| 211 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.CommandEvaluated, this._commandEvaluated, this); | 209 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.Conso
leModel.Events.CommandEvaluated, this._commandEvaluated, this); |
| 212 WebInspector.multitargetConsoleModel.messages().forEach(this._addConsole
Message, this); | 210 WebInspector.multitargetConsoleModel.messages().forEach(this._addConsole
Message, this); |
| 213 }, | 211 }, |
| 214 | 212 |
| 215 /** | 213 /** |
| 216 * @override | 214 * @override |
| 217 * @return {number} | 215 * @return {number} |
| 218 */ | 216 */ |
| 219 itemCount: function() | 217 itemCount: function() |
| 220 { | 218 { |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 * @return {number} | 553 * @return {number} |
| 556 */ | 554 */ |
| 557 function compareTimestamps(viewMessage1, viewMessage2) | 555 function compareTimestamps(viewMessage1, viewMessage2) |
| 558 { | 556 { |
| 559 return WebInspector.ConsoleMessage.timestampComparator(viewMessage1.
consoleMessage(), viewMessage2.consoleMessage()); | 557 return WebInspector.ConsoleMessage.timestampComparator(viewMessage1.
consoleMessage(), viewMessage2.consoleMessage()); |
| 560 } | 558 } |
| 561 | 559 |
| 562 if (message.type === WebInspector.ConsoleMessage.MessageType.Command ||
message.type === WebInspector.ConsoleMessage.MessageType.Result) | 560 if (message.type === WebInspector.ConsoleMessage.MessageType.Command ||
message.type === WebInspector.ConsoleMessage.MessageType.Result) |
| 563 message.timestamp = this._consoleMessages.length ? this._consoleMess
ages.peekLast().consoleMessage().timestamp : 0; | 561 message.timestamp = this._consoleMessages.length ? this._consoleMess
ages.peekLast().consoleMessage().timestamp : 0; |
| 564 var viewMessage = this._createViewMessage(message); | 562 var viewMessage = this._createViewMessage(message); |
| 565 message[this._viewMessageSymbol] = viewMessage; | |
| 566 var insertAt = insertionIndexForObjectInListSortedByFunction(viewMessage
, this._consoleMessages, compareTimestamps, true); | 563 var insertAt = insertionIndexForObjectInListSortedByFunction(viewMessage
, this._consoleMessages, compareTimestamps, true); |
| 567 var insertedInMiddle = insertAt < this._consoleMessages.length; | 564 var insertedInMiddle = insertAt < this._consoleMessages.length; |
| 568 this._consoleMessages.splice(insertAt, 0, viewMessage); | 565 this._consoleMessages.splice(insertAt, 0, viewMessage); |
| 569 | 566 |
| 570 if (this._urlToMessageCount[message.url]) | 567 if (this._urlToMessageCount[message.url]) |
| 571 ++this._urlToMessageCount[message.url]; | 568 ++this._urlToMessageCount[message.url]; |
| 572 else | 569 else |
| 573 this._urlToMessageCount[message.url] = 1; | 570 this._urlToMessageCount[message.url] = 1; |
| 574 | 571 |
| 575 if (!insertedInMiddle) { | 572 if (!insertedInMiddle) { |
| 576 this._appendMessageToEnd(viewMessage); | 573 this._appendMessageToEnd(viewMessage); |
| 577 this._updateFilterStatus(); | 574 this._updateFilterStatus(); |
| 578 this._searchableView.updateSearchMatchesCount(this._regexMatchRanges
.length); | 575 this._searchableView.updateSearchMatchesCount(this._regexMatchRanges
.length); |
| 579 } else { | 576 } else { |
| 580 this._needsFullUpdate = true; | 577 this._needsFullUpdate = true; |
| 581 } | 578 } |
| 582 | 579 |
| 583 this._scheduleViewportRefresh(); | 580 this._scheduleViewportRefresh(); |
| 584 this._consoleMessageAddedForTest(viewMessage); | 581 this._consoleMessageAddedForTest(viewMessage); |
| 585 }, | 582 }, |
| 586 | 583 |
| 587 /** | 584 /** |
| 588 * @param {!WebInspector.Event} event | |
| 589 */ | |
| 590 _onConsoleMessageUpdated: function(event) | |
| 591 { | |
| 592 var message = /** @type {!WebInspector.ConsoleMessage} */ (event.data); | |
| 593 var viewMessage = message[this._viewMessageSymbol]; | |
| 594 if (viewMessage) { | |
| 595 viewMessage.updateMessageElement(); | |
| 596 this._updateMessageList(); | |
| 597 } | |
| 598 }, | |
| 599 | |
| 600 /** | |
| 601 * @param {!WebInspector.ConsoleViewMessage} viewMessage | 585 * @param {!WebInspector.ConsoleViewMessage} viewMessage |
| 602 */ | 586 */ |
| 603 _consoleMessageAddedForTest: function(viewMessage) { }, | 587 _consoleMessageAddedForTest: function(viewMessage) { }, |
| 604 | 588 |
| 605 /** | 589 /** |
| 606 * @param {!WebInspector.ConsoleViewMessage} viewMessage | 590 * @param {!WebInspector.ConsoleViewMessage} viewMessage |
| 607 */ | 591 */ |
| 608 _appendMessageToEnd: function(viewMessage) | 592 _appendMessageToEnd: function(viewMessage) |
| 609 { | 593 { |
| 610 if (!this._filter.shouldBeVisible(viewMessage)) { | 594 if (!this._filter.shouldBeVisible(viewMessage)) { |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 }; | 1149 }; |
| 1166 | 1150 |
| 1167 WebInspector.ConsoleViewFilter.prototype = { | 1151 WebInspector.ConsoleViewFilter.prototype = { |
| 1168 addFilters: function(filterBar) | 1152 addFilters: function(filterBar) |
| 1169 { | 1153 { |
| 1170 this._textFilterUI = new WebInspector.TextFilterUI(true); | 1154 this._textFilterUI = new WebInspector.TextFilterUI(true); |
| 1171 this._textFilterUI.addEventListener(WebInspector.FilterUI.Events.FilterC
hanged, this._textFilterChanged, this); | 1155 this._textFilterUI.addEventListener(WebInspector.FilterUI.Events.FilterC
hanged, this._textFilterChanged, this); |
| 1172 filterBar.addFilter(this._textFilterUI); | 1156 filterBar.addFilter(this._textFilterUI); |
| 1173 | 1157 |
| 1174 var levels = [ | 1158 var levels = [ |
| 1175 {name: WebInspector.ConsoleMessage.MessageLevel.Error, label: WebIns
pector.UIString("Errors")}, | 1159 {name: "error", label: WebInspector.UIString("Errors")}, |
| 1176 {name: WebInspector.ConsoleMessage.MessageLevel.Warning, label: WebI
nspector.UIString("Warnings")}, | 1160 {name: "warning", label: WebInspector.UIString("Warnings")}, |
| 1177 {name: WebInspector.ConsoleMessage.MessageLevel.Info, label: WebInsp
ector.UIString("Info")}, | 1161 {name: "info", label: WebInspector.UIString("Info")}, |
| 1178 {name: WebInspector.ConsoleMessage.MessageLevel.Log, label: WebInspe
ctor.UIString("Logs")}, | 1162 {name: "log", label: WebInspector.UIString("Logs")}, |
| 1179 {name: WebInspector.ConsoleMessage.MessageLevel.Debug, label: WebIns
pector.UIString("Debug")}, | 1163 {name: "debug", label: WebInspector.UIString("Debug")} |
| 1180 {name: WebInspector.ConsoleMessage.MessageLevel.RevokedError, label:
WebInspector.UIString("Handled")} | |
| 1181 ]; | 1164 ]; |
| 1182 this._levelFilterUI = new WebInspector.NamedBitSetFilterUI(levels, this.
_messageLevelFiltersSetting); | 1165 this._levelFilterUI = new WebInspector.NamedBitSetFilterUI(levels, this.
_messageLevelFiltersSetting); |
| 1183 this._levelFilterUI.addEventListener(WebInspector.FilterUI.Events.Filter
Changed, this._filterChanged, this); | 1166 this._levelFilterUI.addEventListener(WebInspector.FilterUI.Events.Filter
Changed, this._filterChanged, this); |
| 1184 filterBar.addFilter(this._levelFilterUI); | 1167 filterBar.addFilter(this._levelFilterUI); |
| 1185 this._hideNetworkMessagesCheckbox = new WebInspector.CheckboxFilterUI("h
ide-network-messages", WebInspector.UIString("Hide network messages"), true, Web
Inspector.moduleSetting("hideNetworkMessages")); | 1168 this._hideNetworkMessagesCheckbox = new WebInspector.CheckboxFilterUI("h
ide-network-messages", WebInspector.UIString("Hide network messages"), true, Web
Inspector.moduleSetting("hideNetworkMessages")); |
| 1186 this._hideNetworkMessagesCheckbox.addEventListener(WebInspector.FilterUI
.Events.FilterChanged, this._filterChanged.bind(this), this); | 1169 this._hideNetworkMessagesCheckbox.addEventListener(WebInspector.FilterUI
.Events.FilterChanged, this._filterChanged.bind(this), this); |
| 1187 filterBar.addFilter(this._hideNetworkMessagesCheckbox); | 1170 filterBar.addFilter(this._hideNetworkMessagesCheckbox); |
| 1188 }, | 1171 }, |
| 1189 | 1172 |
| 1190 _textFilterChanged: function(event) | 1173 _textFilterChanged: function(event) |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1435 handleAction: function(context, actionId) | 1418 handleAction: function(context, actionId) |
| 1436 { | 1419 { |
| 1437 WebInspector.console.show(); | 1420 WebInspector.console.show(); |
| 1438 } | 1421 } |
| 1439 } | 1422 } |
| 1440 | 1423 |
| 1441 /** | 1424 /** |
| 1442 * @typedef {{messageIndex: number, matchIndex: number}} | 1425 * @typedef {{messageIndex: number, matchIndex: number}} |
| 1443 */ | 1426 */ |
| 1444 WebInspector.ConsoleView.RegexMatchRange; | 1427 WebInspector.ConsoleView.RegexMatchRange; |
| OLD | NEW |