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

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

Issue 298333003: DevTools: Implement console message logging through an extension (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove duplicate logging Created 6 years, 6 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
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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 this._customFormatters = { 51 this._customFormatters = {
52 "object": this._formatParameterAsObject, 52 "object": this._formatParameterAsObject,
53 "array": this._formatParameterAsArray, 53 "array": this._formatParameterAsArray,
54 "node": this._formatParameterAsNode, 54 "node": this._formatParameterAsNode,
55 "string": this._formatParameterAsString 55 "string": this._formatParameterAsString
56 }; 56 };
57 } 57 }
58 58
59 WebInspector.ConsoleViewMessage.prototype = { 59 WebInspector.ConsoleViewMessage.prototype = {
60 /** 60 /**
61 * @return {!WebInspector.Target} 61 * @return {?WebInspector.Target}
62 */ 62 */
63 _target: function() 63 _target: function()
64 { 64 {
65 return this.consoleMessage().target(); 65 return this.consoleMessage().target();
66 }, 66 },
67 67
68 /** 68 /**
69 * @return {!Element} 69 * @return {!Element}
70 */ 70 */
71 element: function() 71 element: function()
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 /** 241 /**
242 * @param {string} url 242 * @param {string} url
243 * @param {number} lineNumber 243 * @param {number} lineNumber
244 * @param {number} columnNumber 244 * @param {number} columnNumber
245 * @return {?Element} 245 * @return {?Element}
246 */ 246 */
247 _linkifyLocation: function(url, lineNumber, columnNumber) 247 _linkifyLocation: function(url, lineNumber, columnNumber)
248 { 248 {
249 console.assert(this._linkifier); 249 console.assert(this._linkifier);
250 if (!this._linkifier) 250 var target = this._target();
251 if (!this._linkifier || !target)
251 return null; 252 return null;
252 // FIXME(62725): stack trace line/column numbers are one-based. 253 // FIXME(62725): stack trace line/column numbers are one-based.
253 lineNumber = lineNumber ? lineNumber - 1 : 0; 254 lineNumber = lineNumber ? lineNumber - 1 : 0;
254 columnNumber = columnNumber ? columnNumber - 1 : 0; 255 columnNumber = columnNumber ? columnNumber - 1 : 0;
255 if (this._message.source === WebInspector.ConsoleMessage.MessageSource.C SS) { 256 if (this._message.source === WebInspector.ConsoleMessage.MessageSource.C SS) {
256 var headerIds = this._target().cssModel.styleSheetIdsForURL(url); 257 var headerIds = target.cssModel.styleSheetIdsForURL(url);
257 var cssLocation = new WebInspector.CSSLocation(this._target(), url, lineNumber, columnNumber); 258 var cssLocation = new WebInspector.CSSLocation(target, url, lineNumb er, columnNumber);
258 return this._linkifier.linkifyCSSLocation(headerIds[0] || null, cssL ocation, "console-message-url"); 259 return this._linkifier.linkifyCSSLocation(headerIds[0] || null, cssL ocation, "console-message-url");
259 } 260 }
260 261
261 return this._linkifier.linkifyLocation(this._target(), url, lineNumber, columnNumber, "console-message-url"); 262 return this._linkifier.linkifyLocation(target, url, lineNumber, columnNu mber, "console-message-url");
262 }, 263 },
263 264
264 /** 265 /**
265 * @param {!ConsoleAgent.CallFrame} callFrame 266 * @param {!ConsoleAgent.CallFrame} callFrame
266 * @return {?Element} 267 * @return {?Element}
267 */ 268 */
268 _linkifyCallFrame: function(callFrame) 269 _linkifyCallFrame: function(callFrame)
269 { 270 {
270 console.assert(this._linkifier); 271 console.assert(this._linkifier);
271 if (!this._linkifier) 272 var target = this._target();
273 if (!this._linkifier || !target)
272 return null; 274 return null;
273 // FIXME(62725): stack trace line/column numbers are one-based. 275 // FIXME(62725): stack trace line/column numbers are one-based.
274 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0; 276 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0;
275 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0; 277 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0;
276 var rawLocation = new WebInspector.DebuggerModel.Location(this._target() , callFrame.scriptId, lineNumber, columnNumber); 278 var rawLocation = new WebInspector.DebuggerModel.Location(target, callFr ame.scriptId, lineNumber, columnNumber);
277 return this._linkifier.linkifyRawLocation(rawLocation, "console-message- url"); 279 return this._linkifier.linkifyRawLocation(rawLocation, "console-message- url");
278 }, 280 },
279 281
280 /** 282 /**
281 * @param {?Array.<!ConsoleAgent.CallFrame>} stackTrace 283 * @param {?Array.<!ConsoleAgent.CallFrame>} stackTrace
282 * @return {?ConsoleAgent.CallFrame} 284 * @return {?ConsoleAgent.CallFrame}
283 */ 285 */
284 _callFrameAnchorFromStackTrace: function(stackTrace) 286 _callFrameAnchorFromStackTrace: function(stackTrace)
285 { 287 {
286 if (!stackTrace || !stackTrace.length) 288 if (!stackTrace || !stackTrace.length)
(...skipping 22 matching lines...) Expand all
309 return (this._message.level === WebInspector.ConsoleMessage.MessageLevel .Warning || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Err or); 311 return (this._message.level === WebInspector.ConsoleMessage.MessageLevel .Warning || this._message.level === WebInspector.ConsoleMessage.MessageLevel.Err or);
310 }, 312 },
311 313
312 _format: function(parameters) 314 _format: function(parameters)
313 { 315 {
314 // This node is used like a Builder. Values are continually appended ont o it. 316 // This node is used like a Builder. Values are continually appended ont o it.
315 var formattedResult = document.createElement("span"); 317 var formattedResult = document.createElement("span");
316 if (!parameters.length) 318 if (!parameters.length)
317 return formattedResult; 319 return formattedResult;
318 320
321 var target = this._target();
322
319 // Formatting code below assumes that parameters are all wrappers wherea s frontend console 323 // Formatting code below assumes that parameters are all wrappers wherea s frontend console
320 // API allows passing arbitrary values as messages (strings, numbers, et c.). Wrap them here. 324 // API allows passing arbitrary values as messages (strings, numbers, et c.). Wrap them here.
321 for (var i = 0; i < parameters.length; ++i) { 325 for (var i = 0; i < parameters.length; ++i) {
322 // FIXME: Only pass runtime wrappers here. 326 // FIXME: Only pass runtime wrappers here.
323 if (parameters[i] instanceof WebInspector.RemoteObject) 327 if (parameters[i] instanceof WebInspector.RemoteObject)
324 continue; 328 continue;
325 329
330 if (!target) {
331 parameters[i] = WebInspector.RemoteObject.fromLocalObject(parame ters[i]);
332 continue;
333 }
334
326 if (typeof parameters[i] === "object") 335 if (typeof parameters[i] === "object")
327 parameters[i] = this._target().runtimeModel.createRemoteObject(p arameters[i]); 336 parameters[i] = target.runtimeModel.createRemoteObject(parameter s[i]);
328 else 337 else
329 parameters[i] = this._target().runtimeModel.createRemoteObjectFr omPrimitiveValue(parameters[i]); 338 parameters[i] = target.runtimeModel.createRemoteObjectFromPrimit iveValue(parameters[i]);
330 } 339 }
331 340
332 // There can be string log and string eval result. We distinguish betwee n them based on message type. 341 // There can be string log and string eval result. We distinguish betwee n them based on message type.
333 var shouldFormatMessage = WebInspector.RemoteObject.type(parameters[0]) === "string" && this._message.type !== WebInspector.ConsoleMessage.MessageType.R esult; 342 var shouldFormatMessage = WebInspector.RemoteObject.type(parameters[0]) === "string" && this._message.type !== WebInspector.ConsoleMessage.MessageType.R esult;
334 343
335 // Multiple parameters with the first being a format string. Save unused substitutions. 344 // Multiple parameters with the first being a format string. Save unused substitutions.
336 if (shouldFormatMessage) { 345 if (shouldFormatMessage) {
337 // Multiple parameters with the first being a format string. Save un used substitutions. 346 // Multiple parameters with the first being a format string. Save un used substitutions.
338 var result = this._formatWithSubstitutionString(parameters[0].descri ption, parameters.slice(1), formattedResult); 347 var result = this._formatWithSubstitutionString(parameters[0].descri ption, parameters.slice(1), formattedResult);
339 parameters = result.unusedSubstitutions; 348 parameters = result.unusedSubstitutions;
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 { 1233 {
1225 if (!this._wrapperElement) { 1234 if (!this._wrapperElement) {
1226 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this ); 1235 WebInspector.ConsoleViewMessage.prototype.toMessageElement.call(this );
1227 this._wrapperElement.classList.toggle("collapsed", this._collapsed); 1236 this._wrapperElement.classList.toggle("collapsed", this._collapsed);
1228 } 1237 }
1229 return this._wrapperElement; 1238 return this._wrapperElement;
1230 }, 1239 },
1231 1240
1232 __proto__: WebInspector.ConsoleViewMessage.prototype 1241 __proto__: WebInspector.ConsoleViewMessage.prototype
1233 } 1242 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/console/ConsoleView.js ('k') | Source/devtools/front_end/elements/MetricsSidebarPane.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698