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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/bindings/PresentationConsoleMessageHelper.js

Issue 2173233002: [DevTools] Better locations for snippets (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
OLDNEW
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 { 60 {
61 var message = /** @type {!WebInspector.ConsoleMessage} */ (event.data); 61 var message = /** @type {!WebInspector.ConsoleMessage} */ (event.data);
62 this._consoleMessageAdded(message); 62 this._consoleMessageAdded(message);
63 }, 63 },
64 64
65 /** 65 /**
66 * @param {!WebInspector.ConsoleMessage} message 66 * @param {!WebInspector.ConsoleMessage} message
67 */ 67 */
68 _consoleMessageAdded: function(message) 68 _consoleMessageAdded: function(message)
69 { 69 {
70 if (!message.url || !message.isErrorOrWarning()) 70 if (!message.isErrorOrWarning())
71 return; 71 return;
72 72
73 var rawLocation = this._rawLocation(message); 73 var rawLocation = this._rawLocation(message);
74 if (rawLocation) 74 if (rawLocation)
75 this._addConsoleMessageToScript(message, rawLocation); 75 this._addConsoleMessageToScript(message, rawLocation);
76 else 76 else
77 this._addPendingConsoleMessage(message); 77 this._addPendingConsoleMessage(message);
78 }, 78 },
79 79
80 /** 80 /**
81 * @param {!WebInspector.ConsoleMessage} message 81 * @param {!WebInspector.ConsoleMessage} message
82 * @return {?WebInspector.DebuggerModel.Location} 82 * @return {?WebInspector.DebuggerModel.Location}
83 */ 83 */
84 _rawLocation: function(message) 84 _rawLocation: function(message)
85 { 85 {
86 var debuggerModel = WebInspector.DebuggerModel.fromTarget(message.target ()); 86 var debuggerModel = WebInspector.DebuggerModel.fromTarget(message.target ());
87 if (!debuggerModel) 87 if (!debuggerModel)
88 return null; 88 return null;
89 if (message.scriptId)
90 return debuggerModel.createRawLocationByScriptId(message.scriptId, m essage.line, message.column);
89 var callFrame = message.stackTrace && message.stackTrace.callFrames ? me ssage.stackTrace.callFrames[0] : null; 91 var callFrame = message.stackTrace && message.stackTrace.callFrames ? me ssage.stackTrace.callFrames[0] : null;
90 var lineNumber = callFrame ? callFrame.lineNumber : message.line;
91 var columnNumber = callFrame ? callFrame.columnNumber : message.column;
92 if (callFrame) 92 if (callFrame)
93 columnNumber = callFrame.columnNumber; 93 return debuggerModel.createRawLocationByScriptId(callFrame.scriptId, callFrame.lineNumber, callFrame.columnNumber);
94 if (message.scriptId) 94 if (message.url)
95 return debuggerModel.createRawLocationByScriptId(message.scriptId, l ineNumber, columnNumber); 95 return debuggerModel.createRawLocationByURL(message.url, message.lin e, message.column);
96 return debuggerModel.createRawLocationByURL(message.url || "", lineNumbe r, columnNumber); 96 return null;
97 }, 97 },
98 98
99 /** 99 /**
100 * @param {!WebInspector.ConsoleMessage} message 100 * @param {!WebInspector.ConsoleMessage} message
101 * @param {!WebInspector.DebuggerModel.Location} rawLocation 101 * @param {!WebInspector.DebuggerModel.Location} rawLocation
102 */ 102 */
103 _addConsoleMessageToScript: function(message, rawLocation) 103 _addConsoleMessageToScript: function(message, rawLocation)
104 { 104 {
105 this._presentationConsoleMessages.push(new WebInspector.PresentationCons oleMessage(message, rawLocation, this._locationPool)); 105 this._presentationConsoleMessages.push(new WebInspector.PresentationCons oleMessage(message, rawLocation, this._locationPool));
106 }, 106 },
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 190
191 dispose: function() 191 dispose: function()
192 { 192 {
193 if (this._uiMessage) 193 if (this._uiMessage)
194 this._uiMessage.remove(); 194 this._uiMessage.remove();
195 } 195 }
196 } 196 }
197 197
198 /** @type {!WebInspector.PresentationConsoleMessageHelper} */ 198 /** @type {!WebInspector.PresentationConsoleMessageHelper} */
199 WebInspector.presentationConsoleMessageHelper; 199 WebInspector.presentationConsoleMessageHelper;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698