| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007-2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2007-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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "bindings/core/v8/custom/V8Int8ArrayCustom.h" | 51 #include "bindings/core/v8/custom/V8Int8ArrayCustom.h" |
| 52 #include "bindings/core/v8/custom/V8Uint16ArrayCustom.h" | 52 #include "bindings/core/v8/custom/V8Uint16ArrayCustom.h" |
| 53 #include "bindings/core/v8/custom/V8Uint32ArrayCustom.h" | 53 #include "bindings/core/v8/custom/V8Uint32ArrayCustom.h" |
| 54 #include "bindings/core/v8/custom/V8Uint8ArrayCustom.h" | 54 #include "bindings/core/v8/custom/V8Uint8ArrayCustom.h" |
| 55 #include "bindings/core/v8/custom/V8Uint8ClampedArrayCustom.h" | 55 #include "bindings/core/v8/custom/V8Uint8ClampedArrayCustom.h" |
| 56 #include "core/events/EventTarget.h" | 56 #include "core/events/EventTarget.h" |
| 57 #include "core/frame/LocalDOMWindow.h" | 57 #include "core/frame/LocalDOMWindow.h" |
| 58 #include "core/inspector/InjectedScript.h" | 58 #include "core/inspector/InjectedScript.h" |
| 59 #include "core/inspector/InjectedScriptHost.h" | 59 #include "core/inspector/InjectedScriptHost.h" |
| 60 #include "core/inspector/InspectorDOMAgent.h" | 60 #include "core/inspector/InspectorDOMAgent.h" |
| 61 #include "core/inspector/JavaScriptCallFrame.h" | |
| 62 #include "platform/JSONValues.h" | 61 #include "platform/JSONValues.h" |
| 63 | 62 |
| 64 namespace WebCore { | 63 namespace WebCore { |
| 65 | 64 |
| 66 Node* InjectedScriptHost::scriptValueAsNode(ScriptState* scriptState, ScriptValu
e value) | 65 Node* InjectedScriptHost::scriptValueAsNode(ScriptState* scriptState, ScriptValu
e value) |
| 67 { | 66 { |
| 68 ScriptState::Scope scope(scriptState); | 67 ScriptState::Scope scope(scriptState); |
| 69 if (!value.isObject() || value.isNull()) | 68 if (!value.isObject() || value.isNull()) |
| 70 return 0; | 69 return 0; |
| 71 return V8Node::toNative(v8::Handle<v8::Object>::Cast(value.v8Value())); | 70 return V8Node::toNative(v8::Handle<v8::Object>::Cast(value.v8Value())); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 if (info.Length() < 2) | 328 if (info.Length() < 2) |
| 330 return; | 329 return; |
| 331 | 330 |
| 332 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); | 331 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 333 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | 332 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| 334 ScriptValue object(scriptState, info[0]); | 333 ScriptValue object(scriptState, info[0]); |
| 335 ScriptValue hints(scriptState, info[1]); | 334 ScriptValue hints(scriptState, info[1]); |
| 336 host->inspectImpl(object.toJSONValue(scriptState), hints.toJSONValue(scriptS
tate)); | 335 host->inspectImpl(object.toJSONValue(scriptState), hints.toJSONValue(scriptS
tate)); |
| 337 } | 336 } |
| 338 | 337 |
| 339 void V8InjectedScriptHost::evalMethodCustom(const v8::FunctionCallbackInfo<v8::V
alue>& info) | 338 void V8InjectedScriptHost::evaluateMethodCustom(const v8::FunctionCallbackInfo<v
8::Value>& info) |
| 340 { | 339 { |
| 341 v8::Isolate* isolate = info.GetIsolate(); | 340 v8::Isolate* isolate = info.GetIsolate(); |
| 342 if (info.Length() < 1) { | 341 if (info.Length() < 1) { |
| 343 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "One argument expected."))); | 342 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "One argument expected."))); |
| 344 return; | 343 return; |
| 345 } | 344 } |
| 346 | 345 |
| 347 v8::Handle<v8::String> expression = info[0]->ToString(); | 346 v8::Handle<v8::String> expression = info[0]->ToString(); |
| 348 if (expression.IsEmpty()) { | 347 if (expression.IsEmpty()) { |
| 349 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); | 348 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); |
| 350 return; | 349 return; |
| 351 } | 350 } |
| 352 | 351 |
| 353 ASSERT(isolate->InContext()); | 352 ASSERT(isolate->InContext()); |
| 354 v8::TryCatch tryCatch; | 353 v8::TryCatch tryCatch; |
| 355 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e
xpression, info.GetIsolate()); | 354 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e
xpression, info.GetIsolate()); |
| 356 if (tryCatch.HasCaught()) { | 355 if (tryCatch.HasCaught()) { |
| 357 v8SetReturnValue(info, tryCatch.ReThrow()); | 356 v8SetReturnValue(info, tryCatch.ReThrow()); |
| 358 return; | 357 return; |
| 359 } | 358 } |
| 360 v8SetReturnValue(info, result); | 359 v8SetReturnValue(info, result); |
| 361 } | 360 } |
| 362 | 361 |
| 363 void V8InjectedScriptHost::evaluateWithExceptionDetailsMethodCustom(const v8::Fu
nctionCallbackInfo<v8::Value>& info) | |
| 364 { | |
| 365 v8::Isolate* isolate = info.GetIsolate(); | |
| 366 if (info.Length() < 1) { | |
| 367 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "One argument expected."))); | |
| 368 return; | |
| 369 } | |
| 370 | |
| 371 v8::Handle<v8::String> expression = info[0]->ToString(); | |
| 372 if (expression.IsEmpty()) { | |
| 373 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso
late, "The argument must be a string."))); | |
| 374 return; | |
| 375 } | |
| 376 | |
| 377 ASSERT(isolate->InContext()); | |
| 378 v8::TryCatch tryCatch; | |
| 379 v8::Handle<v8::Value> result = V8ScriptRunner::compileAndRunInternalScript(e
xpression, info.GetIsolate()); | |
| 380 | |
| 381 v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate); | |
| 382 if (tryCatch.HasCaught()) { | |
| 383 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch.
Exception()); | |
| 384 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"),
JavaScriptCallFrame::createExceptionDetails(tryCatch.Message(), isolate)); | |
| 385 } else { | |
| 386 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "result"), result); | |
| 387 wrappedResult->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"),
v8::Undefined(isolate)); | |
| 388 } | |
| 389 v8SetReturnValue(info, wrappedResult); | |
| 390 } | |
| 391 | |
| 392 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi
onCallbackInfo<v8::Value>& info) | 362 void V8InjectedScriptHost::setFunctionVariableValueMethodCustom(const v8::Functi
onCallbackInfo<v8::Value>& info) |
| 393 { | 363 { |
| 394 v8::Handle<v8::Value> functionValue = info[0]; | 364 v8::Handle<v8::Value> functionValue = info[0]; |
| 395 int scopeIndex = info[1]->Int32Value(); | 365 int scopeIndex = info[1]->Int32Value(); |
| 396 String variableName = toCoreStringWithUndefinedOrNullCheck(info[2]); | 366 String variableName = toCoreStringWithUndefinedOrNullCheck(info[2]); |
| 397 v8::Handle<v8::Value> newValue = info[3]; | 367 v8::Handle<v8::Value> newValue = info[3]; |
| 398 | 368 |
| 399 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); | 369 InjectedScriptHost* host = V8InjectedScriptHost::toNative(info.Holder()); |
| 400 ScriptDebugServer& debugServer = host->scriptDebugServer(); | 370 ScriptDebugServer& debugServer = host->scriptDebugServer(); |
| 401 v8SetReturnValue(info, debugServer.setFunctionVariableValue(functionValue, s
copeIndex, variableName, newValue)); | 371 v8SetReturnValue(info, debugServer.setFunctionVariableValue(functionValue, s
copeIndex, variableName, newValue)); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu
e>[argc]); | 458 OwnPtr<v8::Handle<v8::Value>[]> argv = adoptArrayPtr(new v8::Handle<v8::Valu
e>[argc]); |
| 489 for (size_t i = 0; i < argc; ++i) | 459 for (size_t i = 0; i < argc; ++i) |
| 490 argv[i] = info[i + 2]; | 460 argv[i] = info[i + 2]; |
| 491 | 461 |
| 492 v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get()); | 462 v8::Local<v8::Value> result = function->Call(receiver, argc, argv.get()); |
| 493 debugServer.unmuteWarningsAndDeprecations(); | 463 debugServer.unmuteWarningsAndDeprecations(); |
| 494 v8SetReturnValue(info, result); | 464 v8SetReturnValue(info, result); |
| 495 } | 465 } |
| 496 | 466 |
| 497 } // namespace WebCore | 467 } // namespace WebCore |
| OLD | NEW |