void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg) { if (!canInvokeCallback()) return; v8::HandleScope handleScope(m_isolate); v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get()); if (v8Context.IsEmpty()) return; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, v8::Handle<v8::Object>(), m_isolate); if (testInterfaceEmptyArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> stringArgHandle = v8String(m_isolate, stringArg); if (stringArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle, stringArgHandle }; invokeCallback(m_callback.newLocal(m_isolate), 2, argv, executionContext(), m_isolate); }
bool V8TestCallback::callbackWithTestObjectParam(TestObj* class2Param, const String& strArg) { if (!canInvokeCallback()) return true; v8::HandleScope handleScope; v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get()); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> class2ParamHandle = toV8(class2Param, v8::Handle<v8::Object>(), v8Context->GetIsolate()); if (class2ParamHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> strArgHandle = v8String(strArg, v8Context->GetIsolate()); if (strArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { class2ParamHandle, strArgHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext()); }
bool V8TestCallback::callbackWithThisArg(ScriptValue thisValue, int arg) { if (!canInvokeCallback()) return true; v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handleScope(isolate); v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get()); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> thisHandle = thisValue.v8Value(); if (thisHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } ASSERT(thisHandle->IsObject()); v8::Handle<v8::Value> argHandle = v8::Integer::New(arg, isolate); if (argHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { argHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.newLocal(isolate), v8::Handle<v8::Object>::Cast(thisHandle), 1, argv, callbackReturnValue, executionContext(), isolate); }
bool V8TestCallback::callbackWithTestInterfaceEmptyArg(TestInterfaceEmpty* class2Arg, const String& strArg) { if (!canInvokeCallback()) return true; v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handleScope(isolate); v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get()); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> class2ArgHandle = toV8(class2Arg, v8::Handle<v8::Object>(), isolate); if (class2ArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> strArgHandle = v8String(strArg, isolate); if (strArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { class2ArgHandle, strArgHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, executionContext(), isolate); }
void V8TestCallbackInterface::voidMethodTestInterfaceEmptyStringArg(TestInterfaceEmpty* testInterfaceEmptyArg, const String& stringArg) { if (!canInvokeCallback()) return; v8::Isolate* isolate = m_scriptState->isolate(); if (m_scriptState->contextIsEmpty()) return; ScriptState::Scope scope(m_scriptState.get()); v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, v8::Handle<v8::Object>(), isolate); if (testInterfaceEmptyArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> stringArgHandle = v8String(isolate, stringArg); if (stringArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle, stringArgHandle }; invokeCallback(m_callback.newLocal(isolate), 2, argv, executionContext(), isolate); }
void V8TestCallbackInterface::callbackWithThisValueVoidMethodStringArg(ScriptValue thisValue, const String& stringArg) { if (!canInvokeCallback()) return; v8::Isolate* isolate = m_scriptState->isolate(); if (m_scriptState->contextIsEmpty()) return; ScriptState::Scope scope(m_scriptState.get()); v8::Handle<v8::Value> thisHandle = thisValue.v8Value(); if (thisHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } ASSERT(thisHandle->IsObject()); v8::Handle<v8::Value> stringArgHandle = v8String(isolate, stringArg); if (stringArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { stringArgHandle }; invokeCallback(m_callback.newLocal(isolate), v8::Handle<v8::Object>::Cast(thisHandle), 1, argv, executionContext(), isolate); }
bool V8SQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLResultSet* resultSet) { if (!canInvokeCallback()) return true; v8::HandleScope handleScope; v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> transactionHandle = toV8(transaction); if (transactionHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> resultSetHandle = toV8(resultSet); if (resultSetHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { transactionHandle, resultSetHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext()); }
bool V8TestCallback::callbackWithSequence(Vector<RefPtr<TestObj> > sequenceParam) { if (!canInvokeCallback()) return true; v8::HandleScope handleScope; v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get()); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> sequenceParamHandle = v8Array(sequenceParam, v8Context->GetIsolate()); if (sequenceParamHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { sequenceParamHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext()); }
bool V8TestCallback::callbackWithStringList(RefPtr<DOMStringList> listParam) { if (!canInvokeCallback()) return true; v8::HandleScope handleScope; v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get()); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> listParamHandle = toV8(listParam, v8::Handle<v8::Object>(), v8Context->GetIsolate()); if (listParamHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { listParamHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext()); }
bool V8RTCErrorCallback::handleEvent(const String& errorInformation) { if (!canInvokeCallback()) return true; v8::HandleScope handleScope; v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> errorInformationHandle = deprecatedV8String(errorInformation); if (errorInformationHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { errorInformationHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext()); }
void V8MutationCallback::call(const Vector<RefPtr<MutationRecord> >& mutations, MutationObserver* observer) { if (!canInvokeCallback()) return; v8::HandleScope handleScope(m_isolate); v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get()); if (v8Context.IsEmpty()) return; v8::Context::Scope scope(v8Context); v8::Handle<v8::Function> callback = m_callback.newLocal(m_isolate); if (callback.IsEmpty()) return; v8::Handle<v8::Value> observerHandle = toV8(observer, v8::Handle<v8::Object>(), m_isolate); if (observerHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } if (!observerHandle->IsObject()) return; v8::Handle<v8::Object> thisObject = v8::Handle<v8::Object>::Cast(observerHandle); v8::Handle<v8::Value> argv[] = { v8Array(mutations, m_isolate), observerHandle }; v8::TryCatch exceptionCatcher; exceptionCatcher.SetVerbose(true); ScriptController::callFunction(executionContext(), callback, thisObject, 2, argv, m_isolate); }
bool V8SQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error) { if (!canInvokeCallback()) return true; v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handleScope(isolate); v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get()); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> transactionHandle = toV8(transaction, v8::Handle<v8::Object>(), v8Context->GetIsolate()); v8::Handle<v8::Value> errorHandle = toV8(error, v8::Handle<v8::Object>(), isolate); if (transactionHandle.IsEmpty() || errorHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { transactionHandle, errorHandle }; bool callbackReturnValue = false; // Step 6: If the error callback returns false, then move on to the next // statement, if any, or onto the next overall step otherwise. Otherwise, // the error callback did not return false, or there was no error callback. // Jump to the last step in the overall steps. return invokeCallback(m_callback.newLocal(isolate), 2, argv, callbackReturnValue, scriptExecutionContext(), isolate) || callbackReturnValue; }
void V8MutationCallback::call(const WillBeHeapVector<RefPtrWillBeMember<MutationRecord> >& mutations, MutationObserver* observer) { if (!canInvokeCallback()) return; v8::Isolate* isolate = m_scriptState->isolate(); if (m_scriptState->contextIsValid()) return; ScriptState::Scope scope(m_scriptState.get()); if (m_callback.isEmpty()) return; v8::Handle<v8::Value> observerHandle = toV8(observer, m_scriptState->context()->Global(), isolate); if (observerHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } if (!observerHandle->IsObject()) return; v8::Handle<v8::Object> thisObject = v8::Handle<v8::Object>::Cast(observerHandle); v8::Handle<v8::Value> argv[] = { v8Array(mutations, m_scriptState->context()->Global(), isolate), observerHandle }; v8::TryCatch exceptionCatcher; exceptionCatcher.SetVerbose(true); ScriptController::callFunction(executionContext(), m_callback.newLocal(isolate), thisObject, WTF_ARRAY_LENGTH(argv), argv, isolate); }
bool V8PositionErrorCallback::handleEvent(PositionError* error) { if (!canInvokeCallback()) return true; v8::HandleScope handleScope; v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> errorHandle = toV8(error); if (errorHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { errorHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext()); }
void V8TestCallbackInterface::voidMethodSequenceArg(const Vector<RefPtr<TestInterfaceEmpty> >& sequenceArg) { if (!canInvokeCallback()) return; v8::Isolate* isolate = m_scriptState->isolate(); if (m_scriptState->contextIsEmpty()) return; ScriptState::Scope scope(m_scriptState.get()); v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, isolate); if (sequenceArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { sequenceArgHandle }; invokeCallback(m_callback.newLocal(isolate), 1, argv, executionContext(), isolate); }
void V8TestCallbackInterface::voidMethodWillBeGarbageCollectedArrayArg(const WillBeHeapVector<RefPtrWillBeMember<TestInterfaceWillBeGarbageCollected> >& arrayArg) { if (!canInvokeCallback()) return; v8::Isolate* isolate = m_scriptState->isolate(); if (m_scriptState->contextIsEmpty()) return; ScriptState::Scope scope(m_scriptState.get()); v8::Handle<v8::Value> arrayArgHandle = v8Array(arrayArg, isolate); if (arrayArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { arrayArgHandle }; invokeCallback(m_callback.newLocal(isolate), 1, argv, executionContext(), isolate); }
void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg) { if (!canInvokeCallback()) return; v8::Isolate* isolate = m_scriptState->isolate(); if (m_scriptState->contextIsEmpty()) return; ScriptState::Scope scope(m_scriptState.get()); v8::Handle<v8::Value> boolArgHandle = v8Boolean(boolArg, isolate); if (boolArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { boolArgHandle }; invokeCallback(m_callback.newLocal(isolate), 1, argv, executionContext(), isolate); }
void V8TestCallbackInterface::voidMethodTestInterfaceEmptyArg(TestInterfaceEmpty* testInterfaceEmptyArg) { if (!canInvokeCallback()) return; v8::Isolate* isolate = m_scriptState->isolate(); if (m_scriptState->contextIsEmpty()) return; ScriptState::Scope scope(m_scriptState.get()); v8::Handle<v8::Value> testInterfaceEmptyArgHandle = toV8(testInterfaceEmptyArg, m_scriptState->context()->Global(), isolate); if (testInterfaceEmptyArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { testInterfaceEmptyArgHandle }; ScriptController::callFunction(m_scriptState->executionContext(), m_callback.newLocal(isolate), m_scriptState->context()->Global(), 1, argv, m_scriptState->isolate()); }
void V8TestCallbackInterface::voidMethodFloatArg(float floatArg) { if (!canInvokeCallback()) return; v8::Isolate* isolate = m_scriptState->isolate(); if (m_scriptState->contextIsEmpty()) return; NewScriptState::Scope scope(m_scriptState.get()); v8::Handle<v8::Value> floatArgHandle = v8::Number::New(isolate, floatArg); if (floatArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { floatArgHandle }; invokeCallback(m_callback.newLocal(isolate), 1, argv, executionContext(), isolate); }
bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, MutationObserver* observer) { ASSERT(mutations); if (!mutations) return true; if (!canInvokeCallback()) return true; v8::HandleScope handleScope; v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_worldContext); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Local<v8::Array> mutationsArray = v8::Array::New(mutations->size()); for (size_t i = 0; i < mutations->size(); ++i) mutationsArray->Set(v8Integer(i, v8Context->GetIsolate()), toV8(mutations->at(i).get(), v8::Handle<v8::Object>(), v8Context->GetIsolate())); v8::Handle<v8::Value> observerHandle = toV8(observer, v8::Handle<v8::Object>(), v8Context->GetIsolate()); if (observerHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } if (!observerHandle->IsObject()) return true; v8::Handle<v8::Value> argv[] = { mutationsArray, observerHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext()); }
void V8TestCallbackInterface::voidMethodWillBeGarbageCollectedArrayArg(const WillBeHeapVector<RefPtrWillBeMember<TestInterfaceWillBeGarbageCollected> >& arrayArg) { if (!canInvokeCallback()) return; v8::HandleScope handleScope(m_isolate); v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get()); if (v8Context.IsEmpty()) return; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> arrayArgHandle = v8Array(arrayArg, m_isolate); if (arrayArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { arrayArgHandle }; invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(), m_isolate); }
void V8TestCallbackInterface::voidMethodBooleanArg(bool boolArg) { if (!canInvokeCallback()) return; v8::HandleScope handleScope(m_isolate); v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get()); if (v8Context.IsEmpty()) return; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> boolArgHandle = v8Boolean(boolArg, m_isolate); if (boolArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { boolArgHandle }; invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(), m_isolate); }
void V8TestCallbackInterface::voidMethodSequenceArg(const Vector<RefPtr<TestInterfaceEmpty> >& sequenceArg) { if (!canInvokeCallback()) return; v8::HandleScope handleScope(m_isolate); v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get()); if (v8Context.IsEmpty()) return; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, m_isolate); if (sequenceArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return; } v8::Handle<v8::Value> argv[] = { sequenceArgHandle }; invokeCallback(m_callback.newLocal(m_isolate), 1, argv, executionContext(), m_isolate); }
bool V8TestCallback::callbackWithFloatArg(float floatArg) { if (!canInvokeCallback()) return true; v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handleScope(isolate); v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get()); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> floatArgHandle = v8::Number::New(isolate, floatArg); if (floatArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { floatArgHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, executionContext(), isolate); }
bool V8TestCallback::callbackWithSequenceArg(const Vector<RefPtr<TestInterfaceEmpty> >& sequenceArg) { if (!canInvokeCallback()) return true; v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::HandleScope handleScope(isolate); v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.get()); if (v8Context.IsEmpty()) return true; v8::Context::Scope scope(v8Context); v8::Handle<v8::Value> sequenceArgHandle = v8Array(sequenceArg, isolate); if (sequenceArgHandle.IsEmpty()) { if (!isScriptControllerTerminating()) CRASH(); return true; } v8::Handle<v8::Value> argv[] = { sequenceArgHandle }; bool callbackReturnValue = false; return !invokeCallback(m_callback.newLocal(isolate), 1, argv, callbackReturnValue, executionContext(), isolate); }