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, const Script
& parsedScript, CompileResult compileResult) |
1199 { | 1203 { |
1200 // Don't send script content to the front end until it's really needed. | 1204 Script script = parsedScript; |
1201 const bool* isContentScript = script.isContentScript ? &script.isContentScri
pt : 0; | 1205 const bool* isContentScript = script.isContentScript ? &script.isContentScri
pt : 0; |
1202 String sourceMapURL = sourceMapURLForScript(script); | 1206 |
| 1207 bool hasSyntaxError = compileResult != CompileSuccess; |
| 1208 if (!script.startLine && !script.startColumn) { |
| 1209 if (hasSyntaxError) { |
| 1210 bool deprecated; |
| 1211 script.sourceURL = ContentSearchUtils::findSourceURL(script.source,
ContentSearchUtils::JavaScriptMagicComment, &deprecated); |
| 1212 } |
| 1213 } else { |
| 1214 script.sourceURL = String(); |
| 1215 } |
| 1216 |
| 1217 bool hasSourceURL = !script.sourceURL.isEmpty(); |
| 1218 String scriptURL = hasSourceURL ? script.sourceURL : script.url; |
| 1219 |
| 1220 String sourceMapURL = sourceMapURLForScript(script, compileResult); |
1203 String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL; | 1221 String* sourceMapURLParam = sourceMapURL.isNull() ? 0 : &sourceMapURL; |
1204 String sourceURL; | 1222 |
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; | 1223 bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : 0; |
1213 bool hasSyntaxError = compileResult != CompileSuccess; | |
1214 if (!hasSyntaxError) | 1224 if (!hasSyntaxError) |
1215 m_frontend->scriptParsed(scriptId, scriptURL, script.startLine, script.s
tartColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam
, hasSourceURLParam); | 1225 m_frontend->scriptParsed(scriptId, scriptURL, script.startLine, script.s
tartColumn, script.endLine, script.endColumn, isContentScript, sourceMapURLParam
, hasSourceURLParam); |
1216 else | 1226 else |
1217 m_frontend->scriptFailedToParse(scriptId, scriptURL, script.startLine, s
cript.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapU
RLParam, hasSourceURLParam); | 1227 m_frontend->scriptFailedToParse(scriptId, scriptURL, script.startLine, s
cript.startColumn, script.endLine, script.endColumn, isContentScript, sourceMapU
RLParam, hasSourceURLParam); |
1218 | 1228 |
1219 m_scripts.set(scriptId, script); | 1229 m_scripts.set(scriptId, script); |
1220 | 1230 |
1221 if (scriptURL.isEmpty() || hasSyntaxError) | 1231 if (scriptURL.isEmpty() || hasSyntaxError) |
1222 return; | 1232 return; |
1223 | 1233 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1379 { | 1389 { |
1380 m_scripts.clear(); | 1390 m_scripts.clear(); |
1381 m_breakpointIdToDebugServerBreakpointIds.clear(); | 1391 m_breakpointIdToDebugServerBreakpointIds.clear(); |
1382 m_asyncCallStackTracker.clear(); | 1392 m_asyncCallStackTracker.clear(); |
1383 if (m_frontend) | 1393 if (m_frontend) |
1384 m_frontend->globalObjectCleared(); | 1394 m_frontend->globalObjectCleared(); |
1385 } | 1395 } |
1386 | 1396 |
1387 } // namespace WebCore | 1397 } // namespace WebCore |
1388 | 1398 |
OLD | NEW |