| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.PresentationConsoleMessageHelper = class { | 34 Bindings.PresentationConsoleMessageHelper = class { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.Workspace} workspace | 36 * @param {!Workspace.Workspace} workspace |
| 37 */ | 37 */ |
| 38 constructor(workspace) { | 38 constructor(workspace) { |
| 39 this._workspace = workspace; | 39 this._workspace = workspace; |
| 40 | 40 |
| 41 /** @type {!Object.<string, !Array.<!WebInspector.ConsoleMessage>>} */ | 41 /** @type {!Object.<string, !Array.<!SDK.ConsoleMessage>>} */ |
| 42 this._pendingConsoleMessages = {}; | 42 this._pendingConsoleMessages = {}; |
| 43 | 43 |
| 44 /** @type {!Array.<!WebInspector.PresentationConsoleMessage>} */ | 44 /** @type {!Array.<!Bindings.PresentationConsoleMessage>} */ |
| 45 this._presentationConsoleMessages = []; | 45 this._presentationConsoleMessages = []; |
| 46 | 46 |
| 47 WebInspector.multitargetConsoleModel.addEventListener( | 47 SDK.multitargetConsoleModel.addEventListener( |
| 48 WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, t
his); | 48 SDK.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this); |
| 49 WebInspector.multitargetConsoleModel.addEventListener( | 49 SDK.multitargetConsoleModel.addEventListener( |
| 50 WebInspector.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdd
ed, this); | 50 SDK.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdded, this)
; |
| 51 WebInspector.multitargetConsoleModel.messages().forEach(this._consoleMessage
Added, this); | 51 SDK.multitargetConsoleModel.messages().forEach(this._consoleMessageAdded, th
is); |
| 52 WebInspector.targetManager.addModelListener( | 52 SDK.targetManager.addModelListener( |
| 53 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.ParsedScri
ptSource, this._parsedScriptSource, | 53 SDK.DebuggerModel, SDK.DebuggerModel.Events.ParsedScriptSource, this._pa
rsedScriptSource, |
| 54 this); | 54 this); |
| 55 WebInspector.targetManager.addModelListener( | 55 SDK.targetManager.addModelListener( |
| 56 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.FailedToPa
rseScriptSource, | 56 SDK.DebuggerModel, SDK.DebuggerModel.Events.FailedToParseScriptSource, |
| 57 this._parsedScriptSource, this); | 57 this._parsedScriptSource, this); |
| 58 WebInspector.targetManager.addModelListener( | 58 SDK.targetManager.addModelListener( |
| 59 WebInspector.DebuggerModel, WebInspector.DebuggerModel.Events.GlobalObje
ctCleared, this._debuggerReset, this); | 59 SDK.DebuggerModel, SDK.DebuggerModel.Events.GlobalObjectCleared, this._d
ebuggerReset, this); |
| 60 | 60 |
| 61 this._locationPool = new WebInspector.LiveLocationPool(); | 61 this._locationPool = new Bindings.LiveLocationPool(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * @param {!WebInspector.Event} event | 65 * @param {!Common.Event} event |
| 66 */ | 66 */ |
| 67 _onConsoleMessageAdded(event) { | 67 _onConsoleMessageAdded(event) { |
| 68 var message = /** @type {!WebInspector.ConsoleMessage} */ (event.data); | 68 var message = /** @type {!SDK.ConsoleMessage} */ (event.data); |
| 69 this._consoleMessageAdded(message); | 69 this._consoleMessageAdded(message); |
| 70 } | 70 } |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * @param {!WebInspector.ConsoleMessage} message | 73 * @param {!SDK.ConsoleMessage} message |
| 74 */ | 74 */ |
| 75 _consoleMessageAdded(message) { | 75 _consoleMessageAdded(message) { |
| 76 if (!message.isErrorOrWarning()) | 76 if (!message.isErrorOrWarning()) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 var rawLocation = this._rawLocation(message); | 79 var rawLocation = this._rawLocation(message); |
| 80 if (rawLocation) | 80 if (rawLocation) |
| 81 this._addConsoleMessageToScript(message, rawLocation); | 81 this._addConsoleMessageToScript(message, rawLocation); |
| 82 else | 82 else |
| 83 this._addPendingConsoleMessage(message); | 83 this._addPendingConsoleMessage(message); |
| 84 } | 84 } |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * @param {!WebInspector.ConsoleMessage} message | 87 * @param {!SDK.ConsoleMessage} message |
| 88 * @return {?WebInspector.DebuggerModel.Location} | 88 * @return {?SDK.DebuggerModel.Location} |
| 89 */ | 89 */ |
| 90 _rawLocation(message) { | 90 _rawLocation(message) { |
| 91 var debuggerModel = WebInspector.DebuggerModel.fromTarget(message.target()); | 91 var debuggerModel = SDK.DebuggerModel.fromTarget(message.target()); |
| 92 if (!debuggerModel) | 92 if (!debuggerModel) |
| 93 return null; | 93 return null; |
| 94 if (message.scriptId) | 94 if (message.scriptId) |
| 95 return debuggerModel.createRawLocationByScriptId(message.scriptId, message
.line, message.column); | 95 return debuggerModel.createRawLocationByScriptId(message.scriptId, message
.line, message.column); |
| 96 var callFrame = message.stackTrace && message.stackTrace.callFrames ? messag
e.stackTrace.callFrames[0] : null; | 96 var callFrame = message.stackTrace && message.stackTrace.callFrames ? messag
e.stackTrace.callFrames[0] : null; |
| 97 if (callFrame) | 97 if (callFrame) |
| 98 return debuggerModel.createRawLocationByScriptId( | 98 return debuggerModel.createRawLocationByScriptId( |
| 99 callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber); | 99 callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber); |
| 100 if (message.url) | 100 if (message.url) |
| 101 return debuggerModel.createRawLocationByURL(message.url, message.line, mes
sage.column); | 101 return debuggerModel.createRawLocationByURL(message.url, message.line, mes
sage.column); |
| 102 return null; | 102 return null; |
| 103 } | 103 } |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * @param {!WebInspector.ConsoleMessage} message | 106 * @param {!SDK.ConsoleMessage} message |
| 107 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 107 * @param {!SDK.DebuggerModel.Location} rawLocation |
| 108 */ | 108 */ |
| 109 _addConsoleMessageToScript(message, rawLocation) { | 109 _addConsoleMessageToScript(message, rawLocation) { |
| 110 this._presentationConsoleMessages.push( | 110 this._presentationConsoleMessages.push( |
| 111 new WebInspector.PresentationConsoleMessage(message, rawLocation, this._
locationPool)); | 111 new Bindings.PresentationConsoleMessage(message, rawLocation, this._loca
tionPool)); |
| 112 } | 112 } |
| 113 | 113 |
| 114 /** | 114 /** |
| 115 * @param {!WebInspector.ConsoleMessage} message | 115 * @param {!SDK.ConsoleMessage} message |
| 116 */ | 116 */ |
| 117 _addPendingConsoleMessage(message) { | 117 _addPendingConsoleMessage(message) { |
| 118 if (!message.url) | 118 if (!message.url) |
| 119 return; | 119 return; |
| 120 if (!this._pendingConsoleMessages[message.url]) | 120 if (!this._pendingConsoleMessages[message.url]) |
| 121 this._pendingConsoleMessages[message.url] = []; | 121 this._pendingConsoleMessages[message.url] = []; |
| 122 this._pendingConsoleMessages[message.url].push(message); | 122 this._pendingConsoleMessages[message.url].push(message); |
| 123 } | 123 } |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * @param {!WebInspector.Event} event | 126 * @param {!Common.Event} event |
| 127 */ | 127 */ |
| 128 _parsedScriptSource(event) { | 128 _parsedScriptSource(event) { |
| 129 var script = /** @type {!WebInspector.Script} */ (event.data); | 129 var script = /** @type {!SDK.Script} */ (event.data); |
| 130 | 130 |
| 131 var messages = this._pendingConsoleMessages[script.sourceURL]; | 131 var messages = this._pendingConsoleMessages[script.sourceURL]; |
| 132 if (!messages) | 132 if (!messages) |
| 133 return; | 133 return; |
| 134 | 134 |
| 135 var pendingMessages = []; | 135 var pendingMessages = []; |
| 136 for (var i = 0; i < messages.length; i++) { | 136 for (var i = 0; i < messages.length; i++) { |
| 137 var message = messages[i]; | 137 var message = messages[i]; |
| 138 var rawLocation = this._rawLocation(message); | 138 var rawLocation = this._rawLocation(message); |
| 139 if (!rawLocation) | 139 if (!rawLocation) |
| (...skipping 19 matching lines...) Expand all Loading... |
| 159 } | 159 } |
| 160 | 160 |
| 161 _debuggerReset() { | 161 _debuggerReset() { |
| 162 this._consoleCleared(); | 162 this._consoleCleared(); |
| 163 } | 163 } |
| 164 }; | 164 }; |
| 165 | 165 |
| 166 /** | 166 /** |
| 167 * @unrestricted | 167 * @unrestricted |
| 168 */ | 168 */ |
| 169 WebInspector.PresentationConsoleMessage = class { | 169 Bindings.PresentationConsoleMessage = class { |
| 170 /** | 170 /** |
| 171 * @param {!WebInspector.ConsoleMessage} message | 171 * @param {!SDK.ConsoleMessage} message |
| 172 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 172 * @param {!SDK.DebuggerModel.Location} rawLocation |
| 173 * @param {!WebInspector.LiveLocationPool} locationPool | 173 * @param {!Bindings.LiveLocationPool} locationPool |
| 174 */ | 174 */ |
| 175 constructor(message, rawLocation, locationPool) { | 175 constructor(message, rawLocation, locationPool) { |
| 176 this._text = message.messageText; | 176 this._text = message.messageText; |
| 177 this._level = message.level === WebInspector.ConsoleMessage.MessageLevel.Err
or ? | 177 this._level = message.level === SDK.ConsoleMessage.MessageLevel.Error ? |
| 178 WebInspector.UISourceCode.Message.Level.Error : | 178 Workspace.UISourceCode.Message.Level.Error : |
| 179 WebInspector.UISourceCode.Message.Level.Warning; | 179 Workspace.UISourceCode.Message.Level.Warning; |
| 180 WebInspector.debuggerWorkspaceBinding.createLiveLocation( | 180 Bindings.debuggerWorkspaceBinding.createLiveLocation( |
| 181 rawLocation, this._updateLocation.bind(this), locationPool); | 181 rawLocation, this._updateLocation.bind(this), locationPool); |
| 182 } | 182 } |
| 183 | 183 |
| 184 /** | 184 /** |
| 185 * @param {!WebInspector.LiveLocation} liveLocation | 185 * @param {!Bindings.LiveLocation} liveLocation |
| 186 */ | 186 */ |
| 187 _updateLocation(liveLocation) { | 187 _updateLocation(liveLocation) { |
| 188 if (this._uiMessage) | 188 if (this._uiMessage) |
| 189 this._uiMessage.remove(); | 189 this._uiMessage.remove(); |
| 190 var uiLocation = liveLocation.uiLocation(); | 190 var uiLocation = liveLocation.uiLocation(); |
| 191 if (!uiLocation) | 191 if (!uiLocation) |
| 192 return; | 192 return; |
| 193 this._uiMessage = | 193 this._uiMessage = |
| 194 uiLocation.uiSourceCode.addLineMessage(this._level, this._text, uiLocati
on.lineNumber, uiLocation.columnNumber); | 194 uiLocation.uiSourceCode.addLineMessage(this._level, this._text, uiLocati
on.lineNumber, uiLocation.columnNumber); |
| 195 } | 195 } |
| 196 | 196 |
| 197 dispose() { | 197 dispose() { |
| 198 if (this._uiMessage) | 198 if (this._uiMessage) |
| 199 this._uiMessage.remove(); | 199 this._uiMessage.remove(); |
| 200 } | 200 } |
| 201 }; | 201 }; |
| 202 | 202 |
| 203 /** @type {!WebInspector.PresentationConsoleMessageHelper} */ | 203 /** @type {!Bindings.PresentationConsoleMessageHelper} */ |
| 204 WebInspector.presentationConsoleMessageHelper; | 204 Bindings.presentationConsoleMessageHelper; |
| OLD | NEW |