OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 25 matching lines...) Expand all Loading... |
36 WebInspector.PresentationConsoleMessageHelper = function(workspace) | 36 WebInspector.PresentationConsoleMessageHelper = function(workspace) |
37 { | 37 { |
38 /** | 38 /** |
39 * @type {!Object.<string, !Array.<!WebInspector.ConsoleMessage>>} | 39 * @type {!Object.<string, !Array.<!WebInspector.ConsoleMessage>>} |
40 */ | 40 */ |
41 this._pendingConsoleMessages = {}; | 41 this._pendingConsoleMessages = {}; |
42 this._presentationConsoleMessages = []; | 42 this._presentationConsoleMessages = []; |
43 this._workspace = workspace; | 43 this._workspace = workspace; |
44 | 44 |
45 WebInspector.targetManager.observeTargets(this); | 45 WebInspector.targetManager.observeTargets(this); |
| 46 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo
del.Events.ConsoleCleared, this._consoleCleared, this); |
| 47 WebInspector.multitargetConsoleModel.addEventListener(WebInspector.ConsoleMo
del.Events.MessageAdded, this._onConsoleMessageAdded, this); |
| 48 WebInspector.multitargetConsoleModel.messages().forEach(this._consoleMessage
Added, this); |
46 } | 49 } |
47 | 50 |
48 WebInspector.PresentationConsoleMessageHelper.prototype = { | 51 WebInspector.PresentationConsoleMessageHelper.prototype = { |
49 /** | 52 /** |
50 * @param {!WebInspector.Target} target | 53 * @param {!WebInspector.Target} target |
51 */ | 54 */ |
52 targetAdded: function(target) | 55 targetAdded: function(target) |
53 { | 56 { |
54 target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.Me
ssageAdded, this._consoleMessageAdded, this); | |
55 target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.Co
nsoleCleared, this._consoleCleared, this); | |
56 | |
57 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.
ParsedScriptSource, this._parsedScriptSource, this); | 57 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.
ParsedScriptSource, this._parsedScriptSource, this); |
58 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.
FailedToParseScriptSource, this._parsedScriptSource, this); | 58 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.
FailedToParseScriptSource, this._parsedScriptSource, this); |
59 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.
GlobalObjectCleared, this._debuggerReset, this); | 59 target.debuggerModel.addEventListener(WebInspector.DebuggerModel.Events.
GlobalObjectCleared, this._debuggerReset, this); |
60 }, | 60 }, |
61 | 61 |
62 /** | 62 /** |
63 * @param {!WebInspector.Target} target | 63 * @param {!WebInspector.Target} target |
64 */ | 64 */ |
65 targetRemoved: function(target) | 65 targetRemoved: function(target) |
66 { | 66 { |
67 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events
.MessageAdded, this._consoleMessageAdded, this); | |
68 target.consoleModel.removeEventListener(WebInspector.ConsoleModel.Events
.ConsoleCleared, this._consoleCleared, this); | |
69 | |
70 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even
ts.ParsedScriptSource, this._parsedScriptSource, this); | 67 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even
ts.ParsedScriptSource, this._parsedScriptSource, this); |
71 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even
ts.FailedToParseScriptSource, this._parsedScriptSource, this); | 68 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even
ts.FailedToParseScriptSource, this._parsedScriptSource, this); |
72 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even
ts.GlobalObjectCleared, this._debuggerReset, this); | 69 target.debuggerModel.removeEventListener(WebInspector.DebuggerModel.Even
ts.GlobalObjectCleared, this._debuggerReset, this); |
73 }, | 70 }, |
74 | 71 |
75 /** | 72 /** |
76 * @param {!WebInspector.Event} event | 73 * @param {!WebInspector.Event} event |
77 */ | 74 */ |
78 _consoleMessageAdded: function(event) | 75 _onConsoleMessageAdded: function(event) |
79 { | 76 { |
80 var message = /** @type {!WebInspector.ConsoleMessage} */ (event.data); | 77 var message = /** @type {!WebInspector.ConsoleMessage} */ (event.data); |
| 78 this._consoleMessageAdded(message) |
| 79 }, |
| 80 |
| 81 /** |
| 82 * @param {!WebInspector.ConsoleMessage} message |
| 83 */ |
| 84 _consoleMessageAdded: function(message) |
| 85 { |
81 if (!message.url || !message.isErrorOrWarning()) | 86 if (!message.url || !message.isErrorOrWarning()) |
82 return; | 87 return; |
83 | 88 |
84 var rawLocation = this._rawLocation(message); | 89 var rawLocation = this._rawLocation(message); |
85 if (rawLocation) | 90 if (rawLocation) |
86 this._addConsoleMessageToScript(message, rawLocation); | 91 this._addConsoleMessageToScript(message, rawLocation); |
87 else | 92 else |
88 this._addPendingConsoleMessage(message); | 93 this._addPendingConsoleMessage(message); |
89 }, | 94 }, |
90 | 95 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 get lineNumber() | 197 get lineNumber() |
193 { | 198 { |
194 return this._uiLocation.lineNumber; | 199 return this._uiLocation.lineNumber; |
195 }, | 200 }, |
196 | 201 |
197 dispose: function() | 202 dispose: function() |
198 { | 203 { |
199 this._liveLocation.dispose(); | 204 this._liveLocation.dispose(); |
200 } | 205 } |
201 } | 206 } |
OLD | NEW |