OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 RefPtrWillBeRawPtr<ScriptAsyncCallStack> result = nullptr; | 1168 RefPtrWillBeRawPtr<ScriptAsyncCallStack> result = nullptr; |
1169 for (AsyncCallStackTracker::AsyncCallStackVector::const_reverse_iterator it = callStacks.rbegin(); it != callStacks.rend(); ++it) { | 1169 for (AsyncCallStackTracker::AsyncCallStackVector::const_reverse_iterator it = callStacks.rbegin(); it != callStacks.rend(); ++it) { |
1170 RefPtrWillBeRawPtr<JavaScriptCallFrame> callFrame = ScriptDebugServer::t oJavaScriptCallFrame((*it)->callFrames()); | 1170 RefPtrWillBeRawPtr<JavaScriptCallFrame> callFrame = ScriptDebugServer::t oJavaScriptCallFrame((*it)->callFrames()); |
1171 if (!callFrame) | 1171 if (!callFrame) |
1172 break; | 1172 break; |
1173 result = ScriptAsyncCallStack::create((*it)->description(), toScriptCall Stack(callFrame.get()), result.release()); | 1173 result = ScriptAsyncCallStack::create((*it)->description(), toScriptCall Stack(callFrame.get()), result.release()); |
1174 } | 1174 } |
1175 return result.release(); | 1175 return result.release(); |
1176 } | 1176 } |
1177 | 1177 |
1178 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script) | 1178 String InspectorDebuggerAgent::sourceMapURLForScript(const Script& script, Compi leResult compileResult) |
1179 { | 1179 { |
1180 bool deprecated; | 1180 bool hasSyntaxError = compileResult != CompileSuccess; |
1181 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source, Co ntentSearchUtils::JavaScriptMagicComment, &deprecated); | 1181 if (hasSyntaxError) { |
1182 if (!sourceMapURL.isEmpty()) { | 1182 bool deprecated; |
1183 // FIXME: add deprecated console message here. | 1183 String sourceMapURL = ContentSearchUtils::findSourceMapURL(script.source , ContentSearchUtils::JavaScriptMagicComment, &deprecated); |
1184 return sourceMapURL; | 1184 if (!sourceMapURL.isEmpty()) |
1185 return sourceMapURL; | |
1185 } | 1186 } |
1186 | 1187 |
1188 if (!script.sourceMappingURL.isEmpty()) | |
1189 return script.sourceMappingURL; | |
1190 | |
1187 if (script.url.isEmpty()) | 1191 if (script.url.isEmpty()) |
1188 return String(); | 1192 return String(); |
1189 | 1193 |
1190 InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgent(); | 1194 InspectorPageAgent* pageAgent = m_instrumentingAgents->inspectorPageAgent(); |
1191 if (!pageAgent) | 1195 if (!pageAgent) |
1192 return String(); | 1196 return String(); |
1193 return pageAgent->resourceSourceMapURL(script.url); | 1197 return pageAgent->resourceSourceMapURL(script.url); |
1194 } | 1198 } |
1195 | 1199 |
1196 // JavaScriptDebugListener functions | 1200 // ScriptDebugListener functions |
1197 | 1201 |
1198 void InspectorDebuggerAgent::didParseSource(const String& scriptId, const Script & script, CompileResult compileResult) | 1202 void InspectorDebuggerAgent::didParseSource(const String& scriptId, Script& scri pt, CompileResult compileResult) |
1199 { | 1203 { |
1200 // Don't send script content to the front end until it's really needed. | |
1201 const bool* isContentScript = script.isContentScript ? &script.isContentScri pt : 0; | 1204 const bool* isContentScript = script.isContentScript ? &script.isContentScri pt : 0; |
1202 String sourceMapURL = sourceMapURLForScript(script); | 1205 |
1206 bool hasSyntaxError = compileResult != CompileSuccess; | |
1207 if (!script.startLine && !script.startColumn) { | |
1208 if (hasSyntaxError) { | |
1209 bool deprecated; | |
1210 script.sourceURL = ContentSearchUtils::findSourceURL(script.source, ContentSearchUtils::JavaScriptMagicComment, &deprecated); | |
1211 } | |
1212 } else { | |
1213 script.sourceURL = String(); | |
yurys
2014/07/17 14:05:40
I don't like that we modify Script here. Let's mov
| |
1214 } | |
1215 | |
1216 bool hasSourceURL = !script.sourceURL.isEmpty(); | |
1217 String scriptURL = hasSourceURL ? script.sourceURL : script.url; | |
1218 | |
1219 String sourceMapURL = sourceMapURLForScript(script, compileResult); | |
1203 String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL; | 1220 String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL; |
1204 String sourceURL; | 1221 |
1205 if (!script.startLine && !script.startColumn) { | |
1206 bool deprecated; | |
1207 sourceURL = ContentSearchUtils::findSourceURL(script.source, ContentSear chUtils::JavaScriptMagicComment, &deprecated); | |
1208 // FIXME: add deprecated console message here. | |
1209 } | |
1210 bool hasSourceURL = !sourceURL.isEmpty(); | |
1211 String scriptURL = hasSourceURL ? sourceURL : script.url; | |
1212 bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : 0; | 1222 bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : 0; |
1213 bool hasSyntaxError = compileResult != CompileSuccess; | |
1214 if (!hasSyntaxError) | 1223 if (!hasSyntaxError) |
1215 m_frontend->scriptParsed(scriptId, scriptURL, script.startLine, script.s tartColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam , hasSourceURLParam); | 1224 m_frontend->scriptParsed(scriptId, scriptURL, script.startLine, script.s tartColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam , hasSourceURLParam); |
1216 else | 1225 else |
1217 m_frontend->scriptFailedToParse(scriptId, scriptURL, script.startLine, s cript.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapU RLParam, hasSourceURLParam); | 1226 m_frontend->scriptFailedToParse(scriptId, scriptURL, script.startLine, s cript.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapU RLParam, hasSourceURLParam); |
1218 | 1227 |
1219 m_scripts.set(scriptId, script); | 1228 m_scripts.set(scriptId, script); |
1220 | 1229 |
1221 if (scriptURL.isEmpty() || hasSyntaxError) | 1230 if (scriptURL.isEmpty() || hasSyntaxError) |
1222 return; | 1231 return; |
1223 | 1232 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1379 { | 1388 { |
1380 m_scripts.clear(); | 1389 m_scripts.clear(); |
1381 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1390 m_breakpointIdToDebugServerBreakpointIds.clear(); |
1382 m_asyncCallStackTracker.clear(); | 1391 m_asyncCallStackTracker.clear(); |
1383 if (m_frontend) | 1392 if (m_frontend) |
1384 m_frontend->globalObjectCleared(); | 1393 m_frontend->globalObjectCleared(); |
1385 } | 1394 } |
1386 | 1395 |
1387 } // namespace WebCore | 1396 } // namespace WebCore |
1388 | 1397 |
OLD | NEW |