Chromium Code Reviews| Index: Source/devtools/front_end/ConsoleModel.js |
| diff --git a/Source/devtools/front_end/ConsoleModel.js b/Source/devtools/front_end/ConsoleModel.js |
| index 67eb4068a67d69776ff5433bbf93d6559db1ff50..91e7f2f698478d293cd95b734b203c27d25d2860 100644 |
| --- a/Source/devtools/front_end/ConsoleModel.js |
| +++ b/Source/devtools/front_end/ConsoleModel.js |
| @@ -39,7 +39,6 @@ WebInspector.ConsoleModel = function(target) |
| this.messages = []; |
| this.warnings = 0; |
| this.errors = 0; |
| - this._interruptRepeatCount = false; |
| this._target = target; |
| this._consoleAgent = target.consoleAgent(); |
| target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); |
| @@ -94,16 +93,31 @@ WebInspector.ConsoleModel.prototype = { |
| if (isFromBackend && WebInspector.SourceMap.hasSourceMapRequestHeader(msg.request)) |
| return; |
| - msg.index = this.messages.length; |
| - this.messages.push(msg); |
| - this._incrementErrorWarningCount(msg); |
| + var interruptRepeatCount = !isFromBackend || WebInspector.settings.consoleTimestampsEnabled.get(); |
| - if (isFromBackend) |
| - this._previousMessage = msg; |
| - |
| - this._interruptRepeatCount = !isFromBackend; |
| + /** |
| + * @param {?WebInspector.ConsoleMessage} msg |
| + * @return {boolean} |
| + */ |
| + function isGroupMessage(msg) |
| + { |
| + return !!msg && ((msg.type === WebInspector.ConsoleMessage.MessageType.StartGroup) |
| + || (msg.type === WebInspector.ConsoleMessage.MessageType.StartGroupCollapsed) |
| + || (msg.type === WebInspector.ConsoleMessage.MessageType.EndGroup)); |
| + } |
| - this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAdded, msg); |
| + if (!interruptRepeatCount && !isGroupMessage(this._previousMessage) && msg.isEqual(this._previousMessage)) { |
| + this._previousMessage.timestamp = msg.timestamp; |
| + this._previousMessage.repeatCount++; |
|
apavlov
2014/03/21 09:30:46
For things other than loop counters we tend to use
|
| + this._incrementErrorWarningCount(this._previousMessage); |
| + this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.RepeatCountUpdated, this._previousMessage); |
| + } else { |
| + msg.index = this.messages.length; |
| + this.messages.push(msg); |
| + this._incrementErrorWarningCount(msg); |
| + this._previousMessage = msg; |
| + this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAdded, msg); |
| + } |
| }, |
| /** |
| @@ -185,10 +199,10 @@ WebInspector.ConsoleModel.prototype = { |
| { |
| switch (msg.level) { |
| case WebInspector.ConsoleMessage.MessageLevel.Warning: |
| - this.warnings += msg.repeatDelta; |
| + this.warnings++; |
|
apavlov
2014/03/21 09:30:46
ditto
|
| break; |
| case WebInspector.ConsoleMessage.MessageLevel.Error: |
| - this.errors += msg.repeatDelta; |
| + this.errors++; |
|
apavlov
2014/03/21 09:30:46
ditto
|
| break; |
| } |
| }, |
| @@ -210,33 +224,6 @@ WebInspector.ConsoleModel.prototype = { |
| this.warnings = 0; |
| }, |
| - /** |
| - * @param {number} count |
| - */ |
| - _messageRepeatCountUpdated: function(count) |
| - { |
| - var msg = this._previousMessage; |
| - if (!msg) |
| - return; |
| - |
| - var prevRepeatCount = msg.totalRepeatCount; |
| - |
| - if (!this._interruptRepeatCount) { |
| - msg.repeatDelta = count - prevRepeatCount; |
| - msg.repeatCount = msg.repeatCount + msg.repeatDelta; |
| - msg.totalRepeatCount = count; |
| - |
| - this._incrementErrorWarningCount(msg); |
| - this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.RepeatCountUpdated, msg); |
| - } else { |
| - var msgCopy = msg.clone(); |
| - msgCopy.totalRepeatCount = count; |
| - msgCopy.repeatCount = (count - prevRepeatCount) || 1; |
| - msgCopy.repeatDelta = msgCopy.repeatCount; |
| - this.addMessage(msgCopy, true); |
| - } |
| - }, |
| - |
| __proto__: WebInspector.Object.prototype |
| } |
| @@ -269,13 +256,13 @@ WebInspector.ConsoleModel.UIDelegate.prototype = { |
| * @param {?string=} url |
| * @param {number=} line |
| * @param {number=} column |
| - * @param {number=} repeatCount |
| * @param {!NetworkAgent.RequestId=} requestId |
| * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters |
| * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace |
| + * @param {number=} timestamp |
| * @param {boolean=} isOutdated |
| */ |
| -WebInspector.ConsoleMessage = function(source, level, messageText, type, url, line, column, repeatCount, requestId, parameters, stackTrace, isOutdated) |
| +WebInspector.ConsoleMessage = function(source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, isOutdated) |
| { |
| this.source = source; |
| this.level = level; |
| @@ -286,12 +273,10 @@ WebInspector.ConsoleMessage = function(source, level, messageText, type, url, li |
| this.column = column || 0; |
| this.parameters = parameters; |
| this.stackTrace = stackTrace; |
| + this.timestamp = timestamp || Date.now(); |
| this.isOutdated = isOutdated; |
| - repeatCount = repeatCount || 1; |
| - this.repeatCount = repeatCount; |
| - this.repeatDelta = repeatCount; |
| - this.totalRepeatCount = repeatCount; |
| + this.repeatCount = 1; |
| this.request = requestId ? WebInspector.networkLog.requestForId(requestId) : null; |
| } |
| @@ -317,10 +302,10 @@ WebInspector.ConsoleMessage.prototype = { |
| this.url, |
| this.line, |
| this.column, |
| - this.repeatCount, |
| this.request ? this.request.requestId : undefined, |
| this.parameters, |
| this.stackTrace, |
| + this.timestamp, |
| this.isOutdated); |
| }, |
| @@ -333,6 +318,20 @@ WebInspector.ConsoleMessage.prototype = { |
| if (!msg) |
| return false; |
| + if (this.parameters) { |
| + if (!msg.parameters) |
| + return false; |
| + var l = this.parameters; |
|
apavlov
2014/03/21 09:30:46
"l" is a poor variable name, since it's easily "co
|
| + var r = msg.parameters; |
| + if (l.length !== r.length) |
| + return false; |
| + // Never treat objects as equal - their properties might change over time. |
| + for (var i = 0; i < l.length; i++) { |
|
apavlov
2014/03/21 09:30:46
prefix ++ for consistency
|
| + if (WebInspector.RemoteObject.fromPayload(l[i]).type === "object") |
| + return false; |
| + } |
| + } |
| + |
| if (this.stackTrace) { |
| if (!msg.stackTrace) |
| return false; |
| @@ -432,22 +431,14 @@ WebInspector.ConsoleDispatcher.prototype = { |
| payload.url, |
| payload.line, |
| payload.column, |
| - payload.repeatCount, |
| payload.networkRequestId, |
| payload.parameters, |
| payload.stackTrace, |
| + payload.timestamp * 1000, // Convert to ms. |
| this._console._enablingConsole); |
| this._console.addMessage(consoleMessage, true); |
| }, |
| - /** |
| - * @param {number} count |
| - */ |
| - messageRepeatCountUpdated: function(count) |
| - { |
| - this._console._messageRepeatCountUpdated(count); |
| - }, |
| - |
| messagesCleared: function() |
| { |
| if (!WebInspector.settings.preserveConsoleLog.get()) |