* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::):
+2009-02-05 Dimitri Glazkov <dglazkov@chromium.org>
+
+ Reviewed by Eric Seidel.
+
+ https://bugs.webkit.org/show_bug.cgi?id=23767
+ Add custom V8 bindings for HTML5 database.
+
+ * bindings/v8/custom/V8CustomSQLStatementCallback.cpp: Added.
+ (WebCore::V8CustomSQLStatementCallback::V8CustomSQLStatementCallback):
+ (WebCore::V8CustomSQLStatementCallback::~V8CustomSQLStatementCallback):
+ (WebCore::V8CustomSQLStatementCallback::handleEvent):
+ * bindings/v8/custom/V8CustomSQLStatementCallback.h: Added.
+ (WebCore::V8CustomSQLStatementCallback::create):
+ * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp: Added.
+ (WebCore::V8CustomSQLStatementErrorCallback::V8CustomSQLStatementErrorCallback):
+ (WebCore::V8CustomSQLStatementErrorCallback::~V8CustomSQLStatementErrorCallback):
+ (WebCore::V8CustomSQLStatementErrorCallback::handleEvent):
+ * bindings/v8/custom/V8CustomSQLStatementErrorCallback.h: Added.
+ (WebCore::V8CustomSQLStatementErrorCallback::create):
+ * bindings/v8/custom/V8CustomSQLTransactionCallback.cpp: Added.
+ (WebCore::V8CustomSQLTransactionCallback::V8CustomSQLTransactionCallback):
+ (WebCore::V8CustomSQLTransactionCallback::~V8CustomSQLTransactionCallback):
+ (WebCore::V8CustomSQLTransactionCallback::handleEvent):
+ * bindings/v8/custom/V8CustomSQLTransactionCallback.h: Added.
+ (WebCore::V8CustomSQLTransactionCallback::create):
+ * bindings/v8/custom/V8CustomSQLTransactionErrorCallback.cpp: Added.
+ (WebCore::V8CustomSQLTransactionErrorCallback::V8CustomSQLTransactionErrorCallback):
+ (WebCore::V8CustomSQLTransactionErrorCallback::~V8CustomSQLTransactionErrorCallback):
+ (WebCore::V8CustomSQLTransactionErrorCallback::handleEvent):
+ * bindings/v8/custom/V8CustomSQLTransactionErrorCallback.h: Added.
+ (WebCore::V8CustomSQLTransactionErrorCallback::create):
+ * bindings/v8/custom/V8CustomVoidCallback.cpp: Added.
+ (WebCore::V8CustomVoidCallback::V8CustomVoidCallback):
+ (WebCore::V8CustomVoidCallback::~V8CustomVoidCallback):
+ (WebCore::V8CustomVoidCallback::handleEvent):
+ (WebCore::invokeCallback):
+ * bindings/v8/custom/V8CustomVoidCallback.h: Added.
+ (WebCore::V8CustomVoidCallback::create):
+ * bindings/v8/custom/V8DatabaseCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8SQLResultSetRowListCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+ * bindings/v8/custom/V8SQLTransactionCustom.cpp: Added.
+ (WebCore::CALLBACK_FUNC_DECL):
+
2009-02-05 Dimitri Glazkov <dglazkov@chromium.org>
Reviewed by Eric Seidel.
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8CustomSQLStatementCallback.h"
+
+#include "Frame.h"
+#include "V8CustomVoidCallback.h"
+
+namespace WebCore {
+
+V8CustomSQLStatementCallback::V8CustomSQLStatementCallback(v8::Local<v8::Object> callback, Frame* frame)
+ : m_callback(v8::Persistent<v8::Object>::New(callback))
+ , m_frame(frame)
+{
+}
+
+V8CustomSQLStatementCallback::~V8CustomSQLStatementCallback()
+{
+ m_callback.Dispose();
+}
+
+void V8CustomSQLStatementCallback::handleEvent(SQLTransaction* transaction, SQLResultSet* resultSet, bool& raisedException)
+{
+ v8::HandleScope handleScope;
+
+ v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get());
+ if (context.IsEmpty())
+ return;
+
+ v8::Context::Scope scope(context);
+
+ v8::Handle<v8::Value> argv[] = {
+ V8Proxy::ToV8Object(V8ClassIndex::SQLTRANSACTION, transaction),
+ V8Proxy::ToV8Object(V8ClassIndex::SQLRESULTSET, resultSet)
+ };
+
+ // Protect the frame until the callback returns.
+ RefPtr<Frame> protector(m_frame);
+
+ bool callbackReturnValue = false;
+ raisedException = invokeCallback(m_callback, 2, argv, callbackReturnValue);
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8CustomSQLStatementCallback_h
+#define V8CustomSQLStatementCallback_h
+
+#include "SQLStatementCallback.h"
+#include <v8.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+
+class V8CustomSQLStatementCallback : public SQLStatementCallback {
+public:
+ static PassRefPtr<V8CustomSQLStatementCallback> create(v8::Local<v8::Value> value, Frame* frame)
+ {
+ ASSERT(value->IsObject());
+ return adoptRef(new V8CustomSQLStatementCallback(value->ToObject(), frame));
+ }
+ virtual ~V8CustomSQLStatementCallback();
+
+ virtual void handleEvent(SQLTransaction*, SQLResultSet*, bool& raisedException);
+private:
+ V8CustomSQLStatementCallback(v8::Local<v8::Object>, Frame*);
+
+ v8::Persistent<v8::Object> m_callback;
+ RefPtr<Frame> m_frame;
+};
+
+} // namespace WebCore
+
+#endif // V8CustomSQLStatementCallback_h
--- /dev/null
+/*
+ * Copyright (c) 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8CustomSQLStatementErrorCallback.h"
+
+#include "Frame.h"
+#include "V8CustomVoidCallback.h"
+
+namespace WebCore {
+
+V8CustomSQLStatementErrorCallback::V8CustomSQLStatementErrorCallback(v8::Local<v8::Object> callback, Frame* frame)
+ : m_callback(v8::Persistent<v8::Object>::New(callback))
+ , m_frame(frame)
+{
+}
+
+V8CustomSQLStatementErrorCallback::~V8CustomSQLStatementErrorCallback()
+{
+ m_callback.Dispose();
+}
+
+bool V8CustomSQLStatementErrorCallback::handleEvent(SQLTransaction* transaction, SQLError* error)
+{
+ v8::HandleScope handleScope;
+
+ v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get());
+ if (context.IsEmpty())
+ return true;
+
+ v8::Context::Scope scope(context);
+
+ v8::Handle<v8::Value> argv[] = {
+ V8Proxy::ToV8Object(V8ClassIndex::SQLTRANSACTION, transaction),
+ V8Proxy::ToV8Object(V8ClassIndex::SQLERROR, error)
+ };
+
+ // Protect the frame until the callback returns.
+ RefPtr<Frame> protector(m_frame);
+
+ 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, 2, argv, callbackReturnValue) && !callbackReturnValue;
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8CustomSQLStatementErrorCallback_h
+#define V8CustomSQLStatementErrorCallback_h
+
+#include "SQLStatementErrorCallback.h"
+
+#include "SQLStatementErrorCallback.h"
+#include <v8.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+
+class V8CustomSQLStatementErrorCallback : public SQLStatementErrorCallback {
+public:
+ static PassRefPtr<V8CustomSQLStatementErrorCallback> create(v8::Local<v8::Value> value, Frame* frame)
+ {
+ ASSERT(value->IsObject());
+ return adoptRef(new V8CustomSQLStatementErrorCallback(value->ToObject(), frame));
+ }
+ virtual ~V8CustomSQLStatementErrorCallback();
+
+ virtual bool handleEvent(SQLTransaction*, SQLError*);
+private:
+ V8CustomSQLStatementErrorCallback(v8::Local<v8::Object>, Frame*);
+
+ v8::Persistent<v8::Object> m_callback;
+ RefPtr<Frame> m_frame;
+};
+
+} // namespace WebCore
+
+#endif // V8CustomSQLStatementErrorCallback_h
--- /dev/null
+/*
+ * Copyright (c) 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8CustomSQLTransactionCallback.h"
+
+#include "Frame.h"
+#include "V8CustomVoidCallback.h"
+
+namespace WebCore {
+
+V8CustomSQLTransactionCallback::V8CustomSQLTransactionCallback(v8::Local<v8::Object> callback, Frame* frame)
+ : m_callback(v8::Persistent<v8::Object>::New(callback))
+ , m_frame(frame)
+{
+}
+
+V8CustomSQLTransactionCallback::~V8CustomSQLTransactionCallback()
+{
+ m_callback.Dispose();
+}
+
+
+void V8CustomSQLTransactionCallback::handleEvent(SQLTransaction* transaction, bool& raisedException)
+{
+ v8::HandleScope handleScope;
+
+ v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get());
+ if (context.IsEmpty())
+ return;
+
+ v8::Context::Scope scope(context);
+
+ v8::Handle<v8::Value> argv[] = {
+ V8Proxy::ToV8Object(V8ClassIndex::SQLTRANSACTION, transaction)
+ };
+
+ // Protect the frame until the callback returns.
+ RefPtr<Frame> protector(m_frame);
+
+ // Step 5: If the callback couldn't be called (e.g. it was null) or if
+ // the callback was invoked and raised an exception, jump to the last
+ // step (rollback transaction).
+ bool callbackReturnValue = false;
+ raisedException = invokeCallback(m_callback, 1, argv, callbackReturnValue);
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8CustomSQLTransactionCallback_h
+#define V8CustomSQLTransactionCallback_h
+
+#include "SQLTransactionCallback.h"
+#include <v8.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+
+class V8CustomSQLTransactionCallback : public SQLTransactionCallback {
+public:
+ static PassRefPtr<V8CustomSQLTransactionCallback> create(v8::Local<v8::Value> value, Frame* frame)
+ {
+ ASSERT(value->IsObject());
+ return adoptRef(new V8CustomSQLTransactionCallback(value->ToObject(), frame));
+ }
+ virtual ~V8CustomSQLTransactionCallback();
+
+ virtual void handleEvent(SQLTransaction*, bool& raisedException);
+private:
+ V8CustomSQLTransactionCallback(v8::Local<v8::Object>, Frame*);
+
+ v8::Persistent<v8::Object> m_callback;
+ RefPtr<Frame> m_frame;
+};
+
+} // namespace WebCore
+
+#endif // V8CustomSQLTransactionCallback_h
--- /dev/null
+/*
+ * Copyright (c) 2009, Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8CustomSQLTransactionErrorCallback.h"
+
+#include "Frame.h"
+#include "V8CustomVoidCallback.h"
+
+namespace WebCore {
+
+V8CustomSQLTransactionErrorCallback::V8CustomSQLTransactionErrorCallback(v8::Local<v8::Object> callback, Frame* frame)
+ : m_callback(v8::Persistent<v8::Object>::New(callback))
+ , m_frame(frame)
+{
+}
+
+V8CustomSQLTransactionErrorCallback::~V8CustomSQLTransactionErrorCallback()
+{
+ m_callback.Dispose();
+}
+
+bool V8CustomSQLTransactionErrorCallback::handleEvent(SQLError* error)
+{
+ v8::HandleScope handleScope;
+
+ v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get());
+ if (context.IsEmpty())
+ return true;
+
+ v8::Context::Scope scope(context);
+
+ v8::Handle<v8::Value> argv[] = {
+ V8Proxy::ToV8Object(V8ClassIndex::SQLERROR, error)
+ };
+
+ // Protect the frame until the callback returns.
+ RefPtr<Frame> protector(m_frame);
+
+ bool callbackReturnValue = false;
+ invokeCallback(m_callback, 1, argv, callbackReturnValue);
+
+ // FIXME: Eliminate return value once SQLTransactionErrorCallback is changed
+ // to match the spec.
+ return true;
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8CustomSQLTransactionErrorCallback_h
+#define V8CustomSQLTransactionErrorCallback_h
+
+#include "SQLTransactionErrorCallback.h"
+#include <v8.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+
+class V8CustomSQLTransactionErrorCallback : public SQLTransactionErrorCallback {
+public:
+ static PassRefPtr<V8CustomSQLTransactionErrorCallback> create(v8::Local<v8::Value> value, Frame* frame)
+ {
+ ASSERT(value->IsObject());
+ return adoptRef(new V8CustomSQLTransactionErrorCallback(value->ToObject(), frame));
+ }
+ virtual ~V8CustomSQLTransactionErrorCallback();
+
+ virtual bool handleEvent(SQLError*);
+
+private:
+ V8CustomSQLTransactionErrorCallback(v8::Local<v8::Object>, Frame*);
+
+ v8::Persistent<v8::Object> m_callback;
+ RefPtr<Frame> m_frame;
+};
+
+} // namespace WebCore
+
+#endif // V8CustomSQLTransactionErrorCallback_h
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "V8CustomVoidCallback.h"
+
+#include "Frame.h"
+
+namespace WebCore {
+
+V8CustomVoidCallback::V8CustomVoidCallback(v8::Local<v8::Object> callback, Frame* frame)
+ : m_callback(v8::Persistent<v8::Object>::New(callback))
+ , m_frame(frame)
+{
+}
+
+V8CustomVoidCallback::~V8CustomVoidCallback()
+{
+ m_callback.Dispose();
+}
+
+void V8CustomVoidCallback::handleEvent()
+{
+ v8::HandleScope handleScope;
+
+ v8::Handle<v8::Context> context = V8Proxy::GetContext(m_frame.get());
+ if (context.IsEmpty())
+ return;
+
+ v8::Context::Scope scope(context);
+
+ // Protect the frame until the callback returns.
+ RefPtr<Frame> protector(m_frame);
+
+ bool callbackReturnValue = false;
+ invokeCallback(m_callback, 0, 0, callbackReturnValue);
+}
+
+bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue)
+{
+ // FIXME: If an exception was thrown by the callback, we should report it
+ v8::TryCatch exceptionCatcher;
+
+ v8::Local<v8::Function> callbackFunction;
+ if (callback->IsFunction()) {
+ callbackFunction = v8::Local<v8::Function>::New(v8::Persistent<v8::Function>::Cast(callback));
+ } else if (callback->IsObject()) {
+ v8::Local<v8::Value> handleEventFunction = callback->Get(v8::String::NewSymbol("handleEvent"));
+ if (handleEventFunction->IsFunction()) {
+ callbackFunction = v8::Local<v8::Function>::Cast(handleEventFunction);
+ }
+ } else
+ return false;
+
+ if (callbackFunction.IsEmpty())
+ return false;
+
+ v8::Handle<v8::Object> thisObject = v8::Context::GetCurrent()->Global();
+
+ V8Proxy* proxy = V8Proxy::retrieve();
+ ASSERT(proxy);
+
+ v8::Handle<v8::Value> result = proxy->CallFunction(callbackFunction, thisObject, argc, argv);
+
+ callbackReturnValue = result.IsEmpty() && result->IsBoolean() && result->BooleanValue();
+
+ return exceptionCatcher.HasCaught();
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef V8CustomVoidCallback_h
+#define V8CustomVoidCallback_h
+
+#include "VoidCallback.h"
+#include <v8.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+class Frame;
+
+class V8CustomVoidCallback : public VoidCallback {
+public:
+ static PassRefPtr<V8CustomVoidCallback> create(v8::Local<v8::Value> value, Frame* frame)
+ {
+ ASSERT(value->IsObject());
+ return adoptRef(new V8CustomVoidCallback(value->ToObject(), frame));
+ }
+ virtual ~V8CustomVoidCallback();
+
+ virtual void handleEvent();
+
+private:
+ V8CustomVoidCallback(v8::Local<v8::Object>, Frame*);
+
+ v8::Persistent<v8::Object> m_callback;
+ RefPtr<Frame> m_frame;
+};
+
+// Returns false if callback failed (null, wrong type, or threw exception).
+bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue);
+
+} // namespace WebCore
+
+#endif // V8CustomVoidCallback_h
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "v8_binding.h"
+#include "v8_custom.h"
+#include "v8_proxy.h"
+
+#include "Database.h"
+#include "V8CustomSQLTransactionCallback.h"
+#include "V8CustomSQLTransactionErrorCallback.h"
+#include "V8CustomVoidCallback.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(DatabaseChangeVersion)
+{
+ INC_STATS("DOM.Database.changeVersion()");
+ return v8::Undefined();
+}
+
+CALLBACK_FUNC_DECL(DatabaseTransaction)
+{
+ INC_STATS("DOM.Database.transaction()");
+
+ if (args.Length() == 0) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Transaction callback is required.");
+ return v8::Undefined();
+ }
+
+ if (!args[0]->IsObject()) {
+ V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Transaction callback must be of valid type.");
+ return v8::Undefined();
+ }
+
+ Database* database = V8Proxy::ToNativeObject<Database>(V8ClassIndex::DATABASE, args.Holder());
+
+ Frame* frame = V8Proxy::retrieveFrame();
+
+ RefPtr<V8CustomSQLTransactionCallback> callback = V8CustomSQLTransactionCallback::create(args[0], frame);
+
+ RefPtr<V8CustomSQLTransactionErrorCallback> errorCallback;
+ if (args.Length() > 1) {
+ if (!args[1]->IsObject()) {
+ V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Transaction error callback must be of valid type.");
+ return v8::Undefined();
+ }
+ errorCallback = V8CustomSQLTransactionErrorCallback::create(args[1], frame);
+ }
+
+ RefPtr<V8CustomVoidCallback> successCallback;
+ if (args.Length() > 2) {
+ if (!args[1]->IsObject()) {
+ V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Transaction success callback must be of valid type.");
+ return v8::Undefined();
+ }
+ successCallback = V8CustomVoidCallback::create(args[2], frame);
+ }
+
+ database->transaction(callback.release(), errorCallback.release(), successCallback.release());
+
+ return v8::Undefined();
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "v8_binding.h"
+#include "v8_custom.h"
+#include "v8_proxy.h"
+
+#include "SQLResultSetRowList.h"
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(SQLResultSetRowListItem)
+{
+ INC_STATS("DOM.SQLResultSetRowList.item()");
+
+ if (args.Length() == 0) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "Item index is required.");
+ return v8::Undefined();
+ }
+
+ if (!args[0]->IsNumber()) {
+ V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Item index must be a number.");
+ return v8::Undefined();
+ }
+
+ SQLResultSetRowList* rowList = V8Proxy::ToNativeObject<SQLResultSetRowList>(V8ClassIndex::SQLRESULTSETROWLIST, args.Holder());
+
+ unsigned long index = args[0]->IntegerValue();
+ if (index < 0 || index >= rowList->length()) {
+ V8Proxy::ThrowError(V8Proxy::RANGE_ERROR, "Item index is out of range.");
+ return v8::Undefined();
+ }
+
+ v8::Local<v8::Object> item = v8::Object::New();
+ unsigned numColumns = rowList->columnNames().size();
+ unsigned valuesIndex = index * numColumns;
+
+ for (unsigned i = 0; i < numColumns; ++i) {
+ const SQLValue& sqlValue = rowList->values()[valuesIndex + i];
+ v8::Handle<v8::Value> value;
+ switch(sqlValue.type()) {
+ case SQLValue::StringValue:
+ value = v8String(sqlValue.string());
+ break;
+ case SQLValue::NullValue:
+ value = v8::Null();
+ break;
+ case SQLValue::NumberValue:
+ value = v8::Number::New(sqlValue.number());
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ }
+
+ item->Set(v8String(rowList->columnNames()[i]), value, static_cast<v8::PropertyAttribute>(v8::DontDelete|v8::ReadOnly));
+ }
+
+ return item;
+}
+
+} // namespace WebCore
--- /dev/null
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "v8_binding.h"
+#include "v8_custom.h"
+#include "v8_proxy.h"
+
+#include "Database.h"
+#include "SQLValue.h"
+#include "V8CustomSQLStatementCallback.h"
+#include "V8CustomSQLStatementErrorCallback.h"
+#include <wtf/Vector.h>
+
+using namespace WTF;
+
+namespace WebCore {
+
+CALLBACK_FUNC_DECL(SQLTransactionExecuteSql)
+{
+ INC_STATS("DOM.SQLTransaction.executeSql()");
+
+ if (args.Length() == 0) {
+ V8Proxy::ThrowError(V8Proxy::SYNTAX_ERROR, "SQL statement is required.");
+ return v8::Undefined();
+ }
+
+ String statement = ToWebCoreString(args[0]);
+
+ Vector<SQLValue> sqlValues;
+
+ if (args.Length() > 1) {
+ // FIXME: Make this work for v8::Arrayish objects, as well
+ if (!args[1]->IsArray()) {
+ V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Statement arguments must be an v8::Array.");
+ return v8::Undefined();
+ }
+
+ v8::Local<v8::Array> arguments = v8::Local<v8::Array>::Cast(args[1]);
+ uint32_t length = arguments->Length();
+
+ for (unsigned int i = 0; i < length; ++i) {
+ v8::Local<v8::Value> value = arguments->Get(v8::Integer::New(i));
+ if (value.IsEmpty() || value->IsNull())
+ sqlValues.append(SQLValue());
+ else if (value->IsNumber())
+ sqlValues.append(SQLValue(value->NumberValue()));
+ else
+ sqlValues.append(SQLValue(ToWebCoreString(value)));
+ }
+ }
+
+ SQLTransaction* transaction = V8Proxy::ToNativeObject<SQLTransaction>(V8ClassIndex::SQLTRANSACTION, args.Holder());
+
+ Frame* frame = V8Proxy::retrieveFrame();
+
+ RefPtr<SQLStatementCallback> callback;
+ if (args.Length() > 2) {
+ if (!args[2]->IsObject()) {
+ V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Statement callback must be of valid type.");
+ return v8::Undefined();
+ }
+
+ if (frame)
+ callback = V8CustomSQLStatementCallback::create(args[2], frame);
+ }
+
+ RefPtr<SQLStatementErrorCallback> errorCallback;
+ if (args.Length() > 3) {
+ if (!args[2]->IsObject()) {
+ V8Proxy::ThrowError(V8Proxy::TYPE_ERROR, "Statement error callback must be of valid type.");
+ return v8::Undefined();
+ }
+
+ if (frame)
+ errorCallback = V8CustomSQLStatementErrorCallback::create(args[3], frame);
+ }
+
+ ExceptionCode ec = 0;
+ transaction->executeSQL(statement, sqlValues, callback, errorCallback, ec);
+ V8Proxy::SetDOMException(ec);
+
+ return v8::Undefined();
+}
+
+} // namespace WebCore