OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
4 * Copyright (C) 2009 Joseph Pecoraro | 4 * Copyright (C) 2009 Joseph Pecoraro |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 12 matching lines...) Expand all Loading... | |
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 /** | 31 /** |
32 * @constructor | 32 * @constructor |
33 * | 33 * @param {!WebInspector.Target} target |
34 * @param {!WebInspector.ConsoleMessage} consoleMessage | 34 * @param {!WebInspector.ConsoleMessage} consoleMessage |
35 * @param {?WebInspector.Linkifier} linkifier | 35 * @param {?WebInspector.Linkifier} linkifier |
36 */ | 36 */ |
37 WebInspector.ConsoleViewMessage = function(target, consoleMessage, linkifier) | 37 WebInspector.ConsoleViewMessage = function(target, consoleMessage, linkifier) |
38 { | 38 { |
39 this._message = consoleMessage; | 39 this._message = consoleMessage; |
40 this._linkifier = linkifier; | 40 this._linkifier = linkifier; |
41 this._target = target; | 41 this._target = target; |
42 | 42 |
43 /** @type {!Array.<!WebInspector.DataGrid>} */ | 43 /** @type {!Array.<!WebInspector.DataGrid>} */ |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 } | 153 } |
154 this._messageElement = this._format([consoleMessage.messageT ext]); | 154 this._messageElement = this._format([consoleMessage.messageT ext]); |
155 } | 155 } |
156 } else { | 156 } else { |
157 var args = consoleMessage.parameters || [consoleMessage.messageT ext]; | 157 var args = consoleMessage.parameters || [consoleMessage.messageT ext]; |
158 this._messageElement = this._format(args); | 158 this._messageElement = this._format(args); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 if (consoleMessage.source !== WebInspector.ConsoleMessage.MessageSource. Network || consoleMessage.request) { | 162 if (consoleMessage.source !== WebInspector.ConsoleMessage.MessageSource. Network || consoleMessage.request) { |
163 if (consoleMessage.stackTrace && consoleMessage.stackTrace.length && consoleMessage.stackTrace[0].scriptId) { | 163 var callFrame = this._callFrameAnchorFromStackTrace(consoleMessage.s tackTrace); |
164 this._anchorElement = this._linkifyCallFrame(consoleMessage.stac kTrace[0]); | 164 if (callFrame) |
165 } else if (consoleMessage.url && consoleMessage.url !== "undefined") { | 165 this._anchorElement = this._linkifyCallFrame(callFrame); |
166 else if (consoleMessage.url && consoleMessage.url !== "undefined") | |
166 this._anchorElement = this._linkifyLocation(consoleMessage.url, consoleMessage.line, consoleMessage.column); | 167 this._anchorElement = this._linkifyLocation(consoleMessage.url, consoleMessage.line, consoleMessage.column); |
167 } | |
168 } | 168 } |
169 | 169 |
170 this._formattedMessage.appendChild(this._messageElement); | 170 this._formattedMessage.appendChild(this._messageElement); |
171 if (this._anchorElement) { | 171 if (this._anchorElement) { |
172 this._formattedMessage.appendChild(document.createTextNode(" ")); | 172 this._formattedMessage.appendChild(document.createTextNode(" ")); |
173 this._formattedMessage.appendChild(this._anchorElement); | 173 this._formattedMessage.appendChild(this._anchorElement); |
174 } | 174 } |
175 | 175 |
176 var dumpStackTrace = !!consoleMessage.stackTrace && consoleMessage.stack Trace.length && (consoleMessage.source === WebInspector.ConsoleMessage.MessageSo urce.Network || consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve l.Error || consoleMessage.type === WebInspector.ConsoleMessage.MessageType.Trace ); | 176 var dumpStackTrace = !!consoleMessage.stackTrace && consoleMessage.stack Trace.length && (consoleMessage.source === WebInspector.ConsoleMessage.MessageSo urce.Network || consoleMessage.level === WebInspector.ConsoleMessage.MessageLeve l.Error || consoleMessage.type === WebInspector.ConsoleMessage.MessageType.Trace ); |
177 if (dumpStackTrace) { | 177 if (dumpStackTrace) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
240 if (!this._linkifier) | 240 if (!this._linkifier) |
241 return null; | 241 return null; |
242 // FIXME(62725): stack trace line/column numbers are one-based. | 242 // FIXME(62725): stack trace line/column numbers are one-based. |
243 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0; | 243 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0; |
244 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0; | 244 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0; |
245 var rawLocation = new WebInspector.DebuggerModel.Location(callFrame.scri ptId, lineNumber, columnNumber); | 245 var rawLocation = new WebInspector.DebuggerModel.Location(callFrame.scri ptId, lineNumber, columnNumber); |
246 return this._linkifier.linkifyRawLocation(rawLocation, "console-message- url"); | 246 return this._linkifier.linkifyRawLocation(rawLocation, "console-message- url"); |
247 }, | 247 }, |
248 | 248 |
249 /** | 249 /** |
250 * @param {?Array.<!ConsoleAgent.CallFrame>} stackTrace | |
251 * @return {?ConsoleAgent.CallFrame} | |
252 */ | |
253 _callFrameAnchorFromStackTrace: function(stackTrace) | |
254 { | |
255 if (!stackTrace || !stackTrace.length) | |
256 return null; | |
257 var callFrame = stackTrace[0]; | |
258 if (WebInspector.experimentsSettings.frameworksDebuggingSupport.isEnable d() && WebInspector.settings.skipStackFramesSwitch.get()) { | |
pfeldman
2014/03/26 08:57:25
I'd use early return instead.
aandrey
2014/03/26 09:30:18
Done.
| |
259 var regex; | |
260 try { | |
261 // FIXME: Cache the created RegExp object. | |
aandrey
2014/03/26 08:48:31
this will be addressed after https://codereview.ch
| |
262 regex = new RegExp(WebInspector.settings.skipStackFramesPattern. get()); | |
263 } catch (e) { | |
264 } | |
265 if (regex) { | |
pfeldman
2014/03/26 08:57:25
ditto
aandrey
2014/03/26 09:30:18
Done.
| |
266 for (var i = 0; i < stackTrace.length; ++i) { | |
267 var script = this._target.debuggerModel.scriptForId(stackTra ce[i].scriptId); | |
268 if (!script || !regex.test(script.sourceURL)) { | |
269 callFrame = stackTrace[i]; | |
270 break; | |
271 } | |
272 } | |
273 } | |
274 } | |
275 return callFrame.scriptId ? callFrame : null; | |
276 }, | |
277 | |
278 /** | |
250 * @return {boolean} | 279 * @return {boolean} |
251 */ | 280 */ |
252 isErrorOrWarning: function() | 281 isErrorOrWarning: function() |
253 { | 282 { |
254 return (this._message.level === WebInspector.ConsoleMessage.MessageLevel .Warning || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Err or); | 283 return (this._message.level === WebInspector.ConsoleMessage.MessageLevel .Warning || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Err or); |
255 }, | 284 }, |
256 | 285 |
257 _format: function(parameters) | 286 _format: function(parameters) |
258 { | 287 { |
259 // This node is used like a Builder. Values are continually appended ont o it. | 288 // This node is used like a Builder. Values are continually appended ont o it. |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1018 } | 1047 } |
1019 | 1048 |
1020 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line; | 1049 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line; |
1021 }, | 1050 }, |
1022 | 1051 |
1023 get text() | 1052 get text() |
1024 { | 1053 { |
1025 return this._message.messageText; | 1054 return this._message.messageText; |
1026 } | 1055 } |
1027 } | 1056 } |
OLD | NEW |