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

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

Issue 23717011: DevTools: Use scriptId for resolving stack frames in console messages (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed tests Created 7 years, 3 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 | « Source/core/inspector/ScriptCallFrame.cpp ('k') | Source/devtools/protocol.json » ('j') | 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 this._anchorElement = WebInspector.linkifyURLAsNode(this.url , this.url, "console-message-url", isExternal); 156 this._anchorElement = WebInspector.linkifyURLAsNode(this.url , this.url, "console-message-url", isExternal);
157 } 157 }
158 this._messageElement = this._format([this._messageText]); 158 this._messageElement = this._format([this._messageText]);
159 } 159 }
160 } else { 160 } else {
161 var args = this._parameters || [this._messageText]; 161 var args = this._parameters || [this._messageText];
162 this._messageElement = this._format(args); 162 this._messageElement = this._format(args);
163 } 163 }
164 164
165 if (this.source !== WebInspector.ConsoleMessage.MessageSource.Network || this._request) { 165 if (this.source !== WebInspector.ConsoleMessage.MessageSource.Network || this._request) {
166 if (this._stackTrace && this._stackTrace.length && this._stackTrace[ 0].url) { 166 if (this._stackTrace && this._stackTrace.length && this._stackTrace[ 0].scriptId) {
167 this._anchorElement = this._linkifyCallFrame(this._stackTrace[0] ); 167 this._anchorElement = this._linkifyCallFrame(this._stackTrace[0] );
168 } else if (this.url && this.url !== "undefined") { 168 } else if (this.url && this.url !== "undefined") {
169 this._anchorElement = this._linkifyLocation(this.url, this.line, this.column); 169 this._anchorElement = this._linkifyLocation(this.url, this.line, this.column);
170 } 170 }
171 } 171 }
172 172
173 this._formattedMessage.appendChild(this._messageElement); 173 this._formattedMessage.appendChild(this._messageElement);
174 if (this._anchorElement) { 174 if (this._anchorElement) {
175 this._formattedMessage.appendChild(document.createTextNode(" ")); 175 this._formattedMessage.appendChild(document.createTextNode(" "));
176 this._formattedMessage.appendChild(this._anchorElement); 176 this._formattedMessage.appendChild(this._anchorElement);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 columnNumber = columnNumber ? columnNumber - 1 : 0; 238 columnNumber = columnNumber ? columnNumber - 1 : 0;
239 return this._linkifier.linkifyLocation(url, lineNumber, columnNumber, "c onsole-message-url"); 239 return this._linkifier.linkifyLocation(url, lineNumber, columnNumber, "c onsole-message-url");
240 }, 240 },
241 241
242 /** 242 /**
243 * @param {!ConsoleAgent.CallFrame} callFrame 243 * @param {!ConsoleAgent.CallFrame} callFrame
244 * @return {Element} 244 * @return {Element}
245 */ 245 */
246 _linkifyCallFrame: function(callFrame) 246 _linkifyCallFrame: function(callFrame)
247 { 247 {
248 return this._linkifyLocation(callFrame.url, callFrame.lineNumber, callFr ame.columnNumber); 248 // FIXME(62725): stack trace line/column numbers are one-based.
249 var lineNumber = callFrame.lineNumber ? callFrame.lineNumber - 1 : 0;
250 var columnNumber = callFrame.columnNumber ? callFrame.columnNumber - 1 : 0;
251 var rawLocation = new WebInspector.DebuggerModel.Location(callFrame.scri ptId, lineNumber, columnNumber);
252 return this._linkifier.linkifyRawLocation(rawLocation, "console-message- url");
249 }, 253 },
250 254
251 /** 255 /**
252 * @return {boolean} 256 * @return {boolean}
253 */ 257 */
254 isErrorOrWarning: function() 258 isErrorOrWarning: function()
255 { 259 {
256 return (this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || this.level === WebInspector.ConsoleMessage.MessageLevel.Error); 260 return (this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || this.level === WebInspector.ConsoleMessage.MessageLevel.Error);
257 }, 261 },
258 262
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 for (var i = 0; i < this._stackTrace.length; i++) { 791 for (var i = 0; i < this._stackTrace.length; i++) {
788 var frame = this._stackTrace[i]; 792 var frame = this._stackTrace[i];
789 793
790 var content = document.createElement("div"); 794 var content = document.createElement("div");
791 var messageTextElement = document.createElement("span"); 795 var messageTextElement = document.createElement("span");
792 messageTextElement.className = "console-message-text source-code"; 796 messageTextElement.className = "console-message-text source-code";
793 var functionName = frame.functionName || WebInspector.UIString("(ano nymous function)"); 797 var functionName = frame.functionName || WebInspector.UIString("(ano nymous function)");
794 messageTextElement.appendChild(document.createTextNode(functionName) ); 798 messageTextElement.appendChild(document.createTextNode(functionName) );
795 content.appendChild(messageTextElement); 799 content.appendChild(messageTextElement);
796 800
797 if (frame.url) { 801 if (frame.scriptId) {
798 content.appendChild(document.createTextNode(" ")); 802 content.appendChild(document.createTextNode(" "));
799 var urlElement = this._linkifyCallFrame(frame); 803 var urlElement = this._linkifyCallFrame(frame);
800 content.appendChild(urlElement); 804 content.appendChild(urlElement);
801 } 805 }
802 806
803 var treeElement = new TreeElement(content); 807 var treeElement = new TreeElement(content);
804 parentTreeElement.appendChild(treeElement); 808 parentTreeElement.appendChild(treeElement);
805 } 809 }
806 }, 810 },
807 811
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 /** 962 /**
959 * @return {WebInspector.ConsoleMessage} 963 * @return {WebInspector.ConsoleMessage}
960 */ 964 */
961 clone: function() 965 clone: function()
962 { 966 {
963 return WebInspector.ConsoleMessage.create(this.source, this.level, this. _messageText, this.type, this.url, this.line, this.column, this.repeatCount, thi s._parameters, this._stackTrace, this._request ? this._request.requestId : undef ined, this._isOutdated); 967 return WebInspector.ConsoleMessage.create(this.source, this.level, this. _messageText, this.type, this.url, this.line, this.column, this.repeatCount, thi s._parameters, this._stackTrace, this._request ? this._request.requestId : undef ined, this._isOutdated);
964 }, 968 },
965 969
966 __proto__: WebInspector.ConsoleMessage.prototype 970 __proto__: WebInspector.ConsoleMessage.prototype
967 } 971 }
OLDNEW
« no previous file with comments | « Source/core/inspector/ScriptCallFrame.cpp ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698