| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010-2011 Google Inc. All rights reserved. | 2 * Copyright (c) 2010-2011 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 { | 165 { |
| 166 } | 166 } |
| 167 | 167 |
| 168 String ScriptDebugServer::setBreakpoint(const String& sourceID, const ScriptBrea
kpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber) | 168 String ScriptDebugServer::setBreakpoint(const String& sourceID, const ScriptBrea
kpoint& scriptBreakpoint, int* actualLineNumber, int* actualColumnNumber) |
| 169 { | 169 { |
| 170 v8::HandleScope scope; | 170 v8::HandleScope scope; |
| 171 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | 171 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); |
| 172 v8::Context::Scope contextScope(debuggerContext); | 172 v8::Context::Scope contextScope(debuggerContext); |
| 173 | 173 |
| 174 v8::Local<v8::Object> args = v8::Object::New(); | 174 v8::Local<v8::Object> args = v8::Object::New(); |
| 175 args->Set(v8::String::NewSymbol("sourceID"), v8String(sourceID, debuggerCont
ext->GetIsolate())); | 175 args->Set(v8::String::NewSymbol("sourceID"), deprecatedV8String(sourceID)); |
| 176 args->Set(v8::String::NewSymbol("lineNumber"), v8Integer(scriptBreakpoint.li
neNumber, debuggerContext->GetIsolate())); | 176 args->Set(v8::String::NewSymbol("lineNumber"), deprecatedV8Integer(scriptBre
akpoint.lineNumber)); |
| 177 args->Set(v8::String::NewSymbol("columnNumber"), v8Integer(scriptBreakpoint.
columnNumber, debuggerContext->GetIsolate())); | 177 args->Set(v8::String::NewSymbol("columnNumber"), deprecatedV8Integer(scriptB
reakpoint.columnNumber)); |
| 178 args->Set(v8::String::NewSymbol("condition"), v8String(scriptBreakpoint.cond
ition, debuggerContext->GetIsolate())); | 178 args->Set(v8::String::NewSymbol("condition"), deprecatedV8String(scriptBreak
point.condition)); |
| 179 | 179 |
| 180 v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Ca
st(m_debuggerScript.get()->Get(v8::String::NewSymbol("setBreakpoint"))); | 180 v8::Handle<v8::Function> setBreakpointFunction = v8::Local<v8::Function>::Ca
st(m_debuggerScript.get()->Get(v8::String::NewSymbol("setBreakpoint"))); |
| 181 v8::Handle<v8::Value> breakpointId = v8::Debug::Call(setBreakpointFunction,
args); | 181 v8::Handle<v8::Value> breakpointId = v8::Debug::Call(setBreakpointFunction,
args); |
| 182 if (!breakpointId->IsString()) | 182 if (!breakpointId->IsString()) |
| 183 return ""; | 183 return ""; |
| 184 *actualLineNumber = args->Get(v8::String::NewSymbol("lineNumber"))->Int32Val
ue(); | 184 *actualLineNumber = args->Get(v8::String::NewSymbol("lineNumber"))->Int32Val
ue(); |
| 185 *actualColumnNumber = args->Get(v8::String::NewSymbol("columnNumber"))->Int3
2Value(); | 185 *actualColumnNumber = args->Get(v8::String::NewSymbol("columnNumber"))->Int3
2Value(); |
| 186 return toWebCoreString(breakpointId->ToString()); | 186 return toWebCoreString(breakpointId->ToString()); |
| 187 } | 187 } |
| 188 | 188 |
| 189 void ScriptDebugServer::removeBreakpoint(const String& breakpointId) | 189 void ScriptDebugServer::removeBreakpoint(const String& breakpointId) |
| 190 { | 190 { |
| 191 v8::HandleScope scope; | 191 v8::HandleScope scope; |
| 192 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | 192 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); |
| 193 v8::Context::Scope contextScope(debuggerContext); | 193 v8::Context::Scope contextScope(debuggerContext); |
| 194 | 194 |
| 195 v8::Local<v8::Object> args = v8::Object::New(); | 195 v8::Local<v8::Object> args = v8::Object::New(); |
| 196 args->Set(v8::String::NewSymbol("breakpointId"), v8String(breakpointId, debu
ggerContext->GetIsolate())); | 196 args->Set(v8::String::NewSymbol("breakpointId"), deprecatedV8String(breakpoi
ntId)); |
| 197 | 197 |
| 198 v8::Handle<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>:
:Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("removeBreakpoint"))); | 198 v8::Handle<v8::Function> removeBreakpointFunction = v8::Local<v8::Function>:
:Cast(m_debuggerScript.get()->Get(v8::String::NewSymbol("removeBreakpoint"))); |
| 199 v8::Debug::Call(removeBreakpointFunction, args); | 199 v8::Debug::Call(removeBreakpointFunction, args); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void ScriptDebugServer::clearBreakpoints() | 202 void ScriptDebugServer::clearBreakpoints() |
| 203 { | 203 { |
| 204 ensureDebuggerScriptCompiled(); | 204 ensureDebuggerScriptCompiled(); |
| 205 v8::HandleScope scope; | 205 v8::HandleScope scope; |
| 206 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | 206 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 class EnableLiveEditScope { | 321 class EnableLiveEditScope { |
| 322 public: | 322 public: |
| 323 EnableLiveEditScope() { v8::Debug::SetLiveEditEnabled(true); } | 323 EnableLiveEditScope() { v8::Debug::SetLiveEditEnabled(true); } |
| 324 ~EnableLiveEditScope() { v8::Debug::SetLiveEditEnabled(false); } | 324 ~EnableLiveEditScope() { v8::Debug::SetLiveEditEnabled(false); } |
| 325 }; | 325 }; |
| 326 | 326 |
| 327 ensureDebuggerScriptCompiled(); | 327 ensureDebuggerScriptCompiled(); |
| 328 v8::HandleScope scope; | 328 v8::HandleScope scope; |
| 329 | 329 |
| 330 OwnPtr<v8::Context::Scope> contextScope; | 330 OwnPtr<v8::Context::Scope> contextScope; |
| 331 v8::Handle<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | |
| 332 if (!isPaused()) | 331 if (!isPaused()) |
| 333 contextScope = adoptPtr(new v8::Context::Scope(debuggerContext)); | 332 contextScope = adoptPtr(new v8::Context::Scope(v8::Debug::GetDebugContex
t())); |
| 334 | 333 |
| 335 v8::Handle<v8::Value> argv[] = { v8String(sourceID, debuggerContext->GetIsol
ate()), v8String(newContent, debuggerContext->GetIsolate()), v8Boolean(preview)
}; | 334 v8::Handle<v8::Value> argv[] = { deprecatedV8String(sourceID), deprecatedV8S
tring(newContent), v8Boolean(preview) }; |
| 336 | 335 |
| 337 v8::Local<v8::Value> v8result; | 336 v8::Local<v8::Value> v8result; |
| 338 { | 337 { |
| 339 EnableLiveEditScope enableLiveEditScope; | 338 EnableLiveEditScope enableLiveEditScope; |
| 340 v8::TryCatch tryCatch; | 339 v8::TryCatch tryCatch; |
| 341 tryCatch.SetVerbose(false); | 340 tryCatch.SetVerbose(false); |
| 342 v8result = callDebuggerMethod("liveEditScriptSource", 3, argv); | 341 v8result = callDebuggerMethod("liveEditScriptSource", 3, argv); |
| 343 if (tryCatch.HasCaught()) { | 342 if (tryCatch.HasCaught()) { |
| 344 v8::Local<v8::Message> message = tryCatch.Message(); | 343 v8::Local<v8::Message> message = tryCatch.Message(); |
| 345 if (!message.IsEmpty()) | 344 if (!message.IsEmpty()) |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 } | 528 } |
| 530 | 529 |
| 531 void ScriptDebugServer::ensureDebuggerScriptCompiled() | 530 void ScriptDebugServer::ensureDebuggerScriptCompiled() |
| 532 { | 531 { |
| 533 if (m_debuggerScript.get().IsEmpty()) { | 532 if (m_debuggerScript.get().IsEmpty()) { |
| 534 v8::HandleScope scope; | 533 v8::HandleScope scope; |
| 535 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); | 534 v8::Local<v8::Context> debuggerContext = v8::Debug::GetDebugContext(); |
| 536 v8::Context::Scope contextScope(debuggerContext); | 535 v8::Context::Scope contextScope(debuggerContext); |
| 537 String debuggerScriptSource(reinterpret_cast<const char*>(DebuggerScript
Source_js), sizeof(DebuggerScriptSource_js)); | 536 String debuggerScriptSource(reinterpret_cast<const char*>(DebuggerScript
Source_js), sizeof(DebuggerScriptSource_js)); |
| 538 V8RecursionScope::MicrotaskSuppression recursionScope; | 537 V8RecursionScope::MicrotaskSuppression recursionScope; |
| 539 m_debuggerScript.set(v8::Handle<v8::Object>::Cast(v8::Script::Compile(v8
String(debuggerScriptSource, debuggerContext->GetIsolate()))->Run())); | 538 m_debuggerScript.set(v8::Handle<v8::Object>::Cast(v8::Script::Compile(de
precatedV8String(debuggerScriptSource))->Run())); |
| 540 } | 539 } |
| 541 } | 540 } |
| 542 | 541 |
| 543 v8::Local<v8::Value> ScriptDebugServer::functionScopes(v8::Handle<v8::Function>
function) | 542 v8::Local<v8::Value> ScriptDebugServer::functionScopes(v8::Handle<v8::Function>
function) |
| 544 { | 543 { |
| 545 ensureDebuggerScriptCompiled(); | 544 ensureDebuggerScriptCompiled(); |
| 546 | 545 |
| 547 v8::Handle<v8::Value> argv[] = { function }; | 546 v8::Handle<v8::Value> argv[] = { function }; |
| 548 return callDebuggerMethod("getFunctionScopes", 1, argv); | 547 return callDebuggerMethod("getFunctionScopes", 1, argv); |
| 549 } | 548 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 564 } | 563 } |
| 565 | 564 |
| 566 void ScriptDebugServer::compileScript(ScriptState* state, const String& expressi
on, const String& sourceURL, String* scriptId, String* exceptionMessage) | 565 void ScriptDebugServer::compileScript(ScriptState* state, const String& expressi
on, const String& sourceURL, String* scriptId, String* exceptionMessage) |
| 567 { | 566 { |
| 568 v8::HandleScope handleScope; | 567 v8::HandleScope handleScope; |
| 569 v8::Handle<v8::Context> context = state->context(); | 568 v8::Handle<v8::Context> context = state->context(); |
| 570 if (context.IsEmpty()) | 569 if (context.IsEmpty()) |
| 571 return; | 570 return; |
| 572 v8::Context::Scope contextScope(context); | 571 v8::Context::Scope contextScope(context); |
| 573 | 572 |
| 574 v8::Handle<v8::String> code = v8String(expression, context->GetIsolate()); | 573 v8::Handle<v8::String> code = deprecatedV8String(expression); |
| 575 v8::TryCatch tryCatch; | 574 v8::TryCatch tryCatch; |
| 576 | 575 |
| 577 v8::ScriptOrigin origin(v8String(sourceURL, context->GetIsolate()), v8Intege
r(0, context->GetIsolate()), v8Integer(0, context->GetIsolate())); | 576 v8::ScriptOrigin origin(deprecatedV8String(sourceURL), deprecatedV8Integer(0
), deprecatedV8Integer(0)); |
| 578 v8::Handle<v8::Script> script = v8::Script::New(code, &origin); | 577 v8::Handle<v8::Script> script = v8::Script::New(code, &origin); |
| 579 | 578 |
| 580 if (tryCatch.HasCaught()) { | 579 if (tryCatch.HasCaught()) { |
| 581 v8::Local<v8::Message> message = tryCatch.Message(); | 580 v8::Local<v8::Message> message = tryCatch.Message(); |
| 582 if (!message.IsEmpty()) | 581 if (!message.IsEmpty()) |
| 583 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message-
>Get()); | 582 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message-
>Get()); |
| 584 return; | 583 return; |
| 585 } | 584 } |
| 586 if (script.IsEmpty()) | 585 if (script.IsEmpty()) |
| 587 return; | 586 return; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 v8::Local<v8::Message> message = tryCatch.Message(); | 624 v8::Local<v8::Message> message = tryCatch.Message(); |
| 626 if (!message.IsEmpty()) | 625 if (!message.IsEmpty()) |
| 627 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message-
>Get()); | 626 *exceptionMessage = toWebCoreStringWithUndefinedOrNullCheck(message-
>Get()); |
| 628 } else | 627 } else |
| 629 *result = ScriptValue(value); | 628 *result = ScriptValue(value); |
| 630 } | 629 } |
| 631 | 630 |
| 632 } // namespace WebCore | 631 } // namespace WebCore |
| 633 | 632 |
| 634 #endif // ENABLE(JAVASCRIPT_DEBUGGER) | 633 #endif // ENABLE(JAVASCRIPT_DEBUGGER) |
| OLD | NEW |