Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: Source/devtools/front_end/ConsoleViewMessage.js

Issue 211493002: DevTools: Show user code location for wrapped console.log() calls. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/inspector/console/resources/framework.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 this._repeatCount = 1; 42 this._repeatCount = 1;
43 43
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 154 }
155 this._messageElement = this._format([consoleMessage.messageT ext]); 155 this._messageElement = this._format([consoleMessage.messageT ext]);
156 } 156 }
157 } else { 157 } else {
158 var args = consoleMessage.parameters || [consoleMessage.messageT ext]; 158 var args = consoleMessage.parameters || [consoleMessage.messageT ext];
159 this._messageElement = this._format(args); 159 this._messageElement = this._format(args);
160 } 160 }
161 } 161 }
162 162
163 if (consoleMessage.source !== WebInspector.ConsoleMessage.MessageSource. Network || consoleMessage.request) { 163 if (consoleMessage.source !== WebInspector.ConsoleMessage.MessageSource. Network || consoleMessage.request) {
164 if (consoleMessage.stackTrace && consoleMessage.stackTrace.length && consoleMessage.stackTrace[0].scriptId) { 164 var callFrame = this._callFrameAnchorFromStackTrace(consoleMessage.s tackTrace);
165 this._anchorElement = this._linkifyCallFrame(consoleMessage.stac kTrace[0]); 165 if (callFrame)
166 } else if (consoleMessage.url && consoleMessage.url !== "undefined") { 166 this._anchorElement = this._linkifyCallFrame(callFrame);
167 else if (consoleMessage.url && consoleMessage.url !== "undefined")
167 this._anchorElement = this._linkifyLocation(consoleMessage.url, consoleMessage.line, consoleMessage.column); 168 this._anchorElement = this._linkifyLocation(consoleMessage.url, consoleMessage.line, consoleMessage.column);
168 }
169 } 169 }
170 170
171 this._formattedMessage.appendChild(this._messageElement); 171 this._formattedMessage.appendChild(this._messageElement);
172 if (this._anchorElement) { 172 if (this._anchorElement) {
173 this._formattedMessage.appendChild(document.createTextNode(" ")); 173 this._formattedMessage.appendChild(document.createTextNode(" "));
174 this._formattedMessage.appendChild(this._anchorElement); 174 this._formattedMessage.appendChild(this._anchorElement);
175 } 175 }
176 176
177 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 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 );
178 if (dumpStackTrace) { 178 if (dumpStackTrace) {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 if (!this._linkifier) 241 if (!this._linkifier)
242 return null; 242 return null;
243 // FIXME(62725): stack trace line/column numbers are one-based. 243 // FIXME(62725): stack trace line/column numbers are one-based.
244 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0; 244 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0;
245 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0; 245 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0;
246 var rawLocation = new WebInspector.DebuggerModel.Location(callFrame.scri ptId, lineNumber, columnNumber); 246 var rawLocation = new WebInspector.DebuggerModel.Location(callFrame.scri ptId, lineNumber, columnNumber);
247 return this._linkifier.linkifyRawLocation(rawLocation, "console-message- url"); 247 return this._linkifier.linkifyRawLocation(rawLocation, "console-message- url");
248 }, 248 },
249 249
250 /** 250 /**
251 * @param {?Array.<!ConsoleAgent.CallFrame>} stackTrace
252 * @return {?ConsoleAgent.CallFrame}
253 */
254 _callFrameAnchorFromStackTrace: function(stackTrace)
255 {
256 if (!stackTrace || !stackTrace.length)
257 return null;
258 var callFrame = stackTrace[0].scriptId ? stackTrace[0] : null;
259 if (!WebInspector.experimentsSettings.frameworksDebuggingSupport.isEnabl ed())
260 return callFrame;
261 if (!WebInspector.settings.skipStackFramesSwitch.get())
262 return callFrame;
263 var regex = WebInspector.settings.skipStackFramesPattern.asRegExp();
264 if (!regex)
265 return callFrame;
266 for (var i = 0; i < stackTrace.length; ++i) {
267 var script = this._target.debuggerModel.scriptForId(stackTrace[i].sc riptId);
268 if (!script || !regex.test(script.sourceURL))
269 return stackTrace[i].scriptId ? stackTrace[i] : null;
270 }
271 return callFrame;
272 },
273
274 /**
251 * @return {boolean} 275 * @return {boolean}
252 */ 276 */
253 isErrorOrWarning: function() 277 isErrorOrWarning: function()
254 { 278 {
255 return (this._message.level === WebInspector.ConsoleMessage.MessageLevel .Warning || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Err or); 279 return (this._message.level === WebInspector.ConsoleMessage.MessageLevel .Warning || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Err or);
256 }, 280 },
257 281
258 _format: function(parameters) 282 _format: function(parameters)
259 { 283 {
260 // This node is used like a Builder. Values are continually appended ont o it. 284 // This node is used like a Builder. Values are continually appended ont o it.
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
1026 } 1050 }
1027 1051
1028 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line; 1052 return sourceString + " " + typeString + " " + levelString + ": " + this .formattedMessage().textContent + "\n" + this._message.url + " line " + this._me ssage.line;
1029 }, 1053 },
1030 1054
1031 get text() 1055 get text()
1032 { 1056 {
1033 return this._message.messageText; 1057 return this._message.messageText;
1034 } 1058 }
1035 } 1059 }
OLDNEW
« no previous file with comments | « LayoutTests/inspector/console/resources/framework.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698