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