diff options
author | Kristian Monsen <kristianm@google.com> | 2010-05-21 16:53:46 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2010-05-25 10:24:15 +0100 |
commit | 6c2af9490927c3c5959b5cb07461b646f8b32f6c (patch) | |
tree | f7111b9b22befab472616c1d50ec94eb50f1ec8c /WebCore/bindings/v8 | |
parent | a149172322a9067c14e8b474a53e63649aa17cad (diff) | |
download | external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.zip external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.gz external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.bz2 |
Merge WebKit at r59636: Initial merge by git
Change-Id: I59b289c4e6b18425f06ce41cc9d34c522515de91
Diffstat (limited to 'WebCore/bindings/v8')
31 files changed, 807 insertions, 650 deletions
diff --git a/WebCore/bindings/v8/ScriptCallStack.cpp b/WebCore/bindings/v8/ScriptCallStack.cpp index 10a31d6..9bc2953 100644 --- a/WebCore/bindings/v8/ScriptCallStack.cpp +++ b/WebCore/bindings/v8/ScriptCallStack.cpp @@ -37,7 +37,6 @@ #include <v8-debug.h> #include <v8.h> -#include <wtf/StdLibExtras.h> // For DEFINE_STATIC_LOCAL namespace WebCore { @@ -95,8 +94,8 @@ void ScriptCallStack::createUtilityContext() // Compile JavaScript function for retrieving the source line, the source // name and the symbol name for the top JavaScript stack frame. - DEFINE_STATIC_LOCAL(const char*, topStackFrame, - ("function topStackFrame(exec_state) {" + const char* topStackFrame = + "function topStackFrame(exec_state) {" " if (!exec_state.frameCount())" " return undefined;" " var frame = exec_state.frame(0);" @@ -105,7 +104,7 @@ void ScriptCallStack::createUtilityContext() " if (func.resolved() && func.script())" " scriptName = func.script().name();" " return [scriptName, frame.sourceLine(), (func.name() || func.inferredName())];" - "}")); + "}"; v8::Script::Compile(v8::String::New(topStackFrame))->Run(); } diff --git a/WebCore/bindings/v8/ScriptController.cpp b/WebCore/bindings/v8/ScriptController.cpp index 0f94a2e..7748f75 100644 --- a/WebCore/bindings/v8/ScriptController.cpp +++ b/WebCore/bindings/v8/ScriptController.cpp @@ -158,7 +158,7 @@ bool ScriptController::processingUserGesture(DOMWrapperWorld*) const // No script is running, so it is user-initiated unless the gesture stack // explicitly says it is not. if (!activeFrame) - return UserGestureIndicator::processingUserGesture(); + return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture; V8Proxy* activeProxy = activeFrame->script()->proxy(); diff --git a/WebCore/bindings/v8/ScriptController.h b/WebCore/bindings/v8/ScriptController.h index 7e13740..1400134 100644 --- a/WebCore/bindings/v8/ScriptController.h +++ b/WebCore/bindings/v8/ScriptController.h @@ -73,7 +73,7 @@ public: ScriptValue executeScript(const String& script, bool forceUserGesture = false); // Returns true if argument is a JavaScript URL. - bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, bool replaceDocument = true); + bool executeIfJavaScriptURL(const KURL&, bool userGesture = false, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL = ReplaceDocumentIfJavaScriptURL); // This function must be called from the main thread. It is safe to call it repeatedly. static void initializeThreading(); diff --git a/WebCore/bindings/v8/V8DOMWrapper.cpp b/WebCore/bindings/v8/V8DOMWrapper.cpp index b2eeeb4..f8426dc 100644 --- a/WebCore/bindings/v8/V8DOMWrapper.cpp +++ b/WebCore/bindings/v8/V8DOMWrapper.cpp @@ -47,8 +47,10 @@ #include "V8DOMWindow.h" #include "V8EventListenerList.h" #include "V8EventSource.h" +#include "V8FileReader.h" #include "V8HTMLCollection.h" #include "V8HTMLDocument.h" +#include "V8IDBRequest.h" #include "V8IsolatedContext.h" #include "V8Location.h" #include "V8MessageChannel.h" @@ -66,7 +68,7 @@ #include "V8WorkerContext.h" #include "V8WorkerContextEventListener.h" #include "V8XMLHttpRequest.h" -#include "WebGLArray.h" +#include "ArrayBufferView.h" #include "WebGLContextAttributes.h" #include "WebGLUniformLocation.h" #include "WorkerContextExecutionProxy.h" @@ -377,6 +379,11 @@ v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* ta return toV8(notification); #endif +#if ENABLE(INDEXED_DATABASE) + if (IDBRequest* idbRequest = target->toIDBRequest()) + return toV8(idbRequest); +#endif + #if ENABLE(WEB_SOCKETS) if (WebSocket* webSocket = target->toWebSocket()) return toV8(webSocket); @@ -418,6 +425,11 @@ v8::Handle<v8::Value> V8DOMWrapper::convertEventTargetToV8Object(EventTarget* ta return toV8(eventSource); #endif +#if ENABLE(FILE_READER) + if (FileReader* fileReader = target->toFileReader()) + return toV8(fileReader); +#endif + ASSERT(0); return notHandledByInterceptor(); } diff --git a/WebCore/bindings/v8/custom/V8WebGLArrayBufferCustom.cpp b/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp index d3e6cb5..3e48f4b 100644 --- a/WebCore/bindings/v8/custom/V8WebGLArrayBufferCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ArrayBufferCustom.cpp @@ -32,33 +32,33 @@ #if ENABLE(3D_CANVAS) -#include "WebGLArrayBuffer.h" +#include "ArrayBuffer.h" #include "V8Binding.h" -#include "V8WebGLArrayBuffer.h" +#include "V8ArrayBuffer.h" #include "V8Proxy.h" namespace WebCore { -v8::Handle<v8::Value> V8WebGLArrayBuffer::constructorCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8ArrayBuffer::constructorCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLArrayBuffer.Constructor"); + INC_STATS("DOM.ArrayBuffer.Constructor"); if (!args.IsConstructCall()) return throwError("DOM object constructor cannot be called as a function."); - // If we return a previously constructed WebGLArrayBuffer, - // e.g. from the call to WebGLArray.buffer, this code is called + // If we return a previously constructed ArrayBuffer, + // e.g. from the call to ArrayBufferView.buffer, this code is called // with a zero-length argument list. The V8DOMWrapper will then // set the internal pointer in the newly-created object. // Unfortunately it doesn't look like it's possible to distinguish // between this case and that where the user calls "new - // WebGLArrayBuffer()" from JavaScript. To guard against problems, - // we always create at least a zero-length WebGLArrayBuffer, even + // ArrayBuffer()" from JavaScript. To guard against problems, + // we always create at least a zero-length ArrayBuffer, even // if it is immediately overwritten by the V8DOMWrapper. // Supported constructors: - // WebGLArrayBuffer(n) where n is an integer: + // ArrayBuffer(n) where n is an integer: // -- create an empty buffer of n bytes int argLen = args.Length(); @@ -68,11 +68,11 @@ v8::Handle<v8::Value> V8WebGLArrayBuffer::constructorCallback(const v8::Argument int len = 0; if (argLen > 0) { if (!args[0]->IsInt32()) - return throwError("Argument to WebGLArrayBuffer constructor was not an integer"); + return throwError("Argument to ArrayBuffer constructor was not an integer"); len = toInt32(args[0]); } - RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(len, 1); + RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(len, 1); if (!buffer.get()) { V8Proxy::setDOMException(INDEX_SIZE_ERR); return v8::Undefined(); diff --git a/WebCore/bindings/v8/custom/V8WebGLArrayCustom.cpp b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp index e15fa11..6ae3a3e 100644 --- a/WebCore/bindings/v8/custom/V8WebGLArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp @@ -31,48 +31,48 @@ #include "config.h" #if ENABLE(3D_CANVAS) -#include "V8WebGLArray.h" +#include "V8ArrayBufferView.h" #include "V8Binding.h" #include "V8Proxy.h" -#include "V8WebGLByteArray.h" -#include "V8WebGLFloatArray.h" -#include "V8WebGLIntArray.h" -#include "V8WebGLShortArray.h" -#include "V8WebGLUnsignedByteArray.h" -#include "V8WebGLUnsignedIntArray.h" -#include "V8WebGLUnsignedShortArray.h" +#include "V8Int8Array.h" +#include "V8FloatArray.h" +#include "V8Int32Array.h" +#include "V8Int16Array.h" +#include "V8Uint8Array.h" +#include "V8Uint32Array.h" +#include "V8Uint16Array.h" namespace WebCore { -v8::Handle<v8::Value> toV8(WebGLArray* impl) +v8::Handle<v8::Value> toV8(ArrayBufferView* impl) { if (!impl) return v8::Null(); if (impl->isByteArray()) - return toV8(static_cast<WebGLByteArray*>(impl)); + return toV8(static_cast<Int8Array*>(impl)); if (impl->isFloatArray()) - return toV8(static_cast<WebGLFloatArray*>(impl)); + return toV8(static_cast<FloatArray*>(impl)); if (impl->isIntArray()) - return toV8(static_cast<WebGLIntArray*>(impl)); + return toV8(static_cast<Int32Array*>(impl)); if (impl->isShortArray()) - return toV8(static_cast<WebGLShortArray*>(impl)); + return toV8(static_cast<Int16Array*>(impl)); if (impl->isUnsignedByteArray()) - return toV8(static_cast<WebGLUnsignedByteArray*>(impl)); + return toV8(static_cast<Uint8Array*>(impl)); if (impl->isUnsignedIntArray()) - return toV8(static_cast<WebGLUnsignedIntArray*>(impl)); + return toV8(static_cast<Uint32Array*>(impl)); if (impl->isUnsignedShortArray()) - return toV8(static_cast<WebGLUnsignedShortArray*>(impl)); + return toV8(static_cast<Uint16Array*>(impl)); return v8::Handle<v8::Value>(); } -v8::Handle<v8::Value> V8WebGLArray::sliceCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8ArrayBufferView::sliceCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLArray.slice"); + INC_STATS("DOM.ArrayBufferView.slice"); // Forms: // * slice(long start, long end); - WebGLArray* imp = V8WebGLArray::toNative(args.Holder()); + ArrayBufferView* imp = V8ArrayBufferView::toNative(args.Holder()); int start, end; switch (args.Length()) { case 0: diff --git a/WebCore/bindings/v8/custom/V8WebGLArrayCustom.h b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h index 02bce9c..cc34778 100644 --- a/WebCore/bindings/v8/custom/V8WebGLArrayCustom.h +++ b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h @@ -32,15 +32,15 @@ #if ENABLE(3D_CANVAS) -#include "WebGLArrayBuffer.h" +#include "ArrayBuffer.h" #include "V8Binding.h" -#include "V8WebGLArrayBuffer.h" +#include "V8ArrayBuffer.h" #include "V8Proxy.h" namespace WebCore { -// Template function used by the WebGLArray*Constructor callbacks. +// Template function used by the ArrayBufferView*Constructor callbacks. template<class ArrayClass, class ElementType> v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperTypeInfo* type, v8::ExternalArrayType arrayType) { @@ -50,7 +50,7 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType int argLen = args.Length(); if (argLen == 0) { // This happens when we return a previously constructed - // WebGLArray, e.g. from the call to WebGL<T>Array.slice(). + // ArrayBufferView, e.g. from the call to WebGL<T>Array.slice(). // The V8DOMWrapper will set the internal pointer in the // created object. Unfortunately it doesn't look like it's // possible to distinguish between this case and that where @@ -64,15 +64,15 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType // WebGL<T>Array(arr) where arr is an array: // -- create a WebGL<T>Array containing the contents of "arr" // WebGL<T>Array(buf, offset, length) - // -- create a WebGL<T>Array pointing to the WebGLArrayBuffer + // -- create a WebGL<T>Array pointing to the ArrayBuffer // "buf", starting at the specified offset, for the given // length - // See whether the first argument is a WebGLArrayBuffer. - if (V8WebGLArrayBuffer::HasInstance(args[0])) { - WebGLArrayBuffer* buf = V8WebGLArrayBuffer::toNative(args[0]->ToObject()); + // See whether the first argument is a ArrayBuffer. + if (V8ArrayBuffer::HasInstance(args[0])) { + ArrayBuffer* buf = V8ArrayBuffer::toNative(args[0]->ToObject()); if (!buf) - return throwError("Could not convert argument 0 to a WebGLArrayBuffer"); + return throwError("Could not convert argument 0 to a ArrayBuffer"); bool ok; uint32_t offset = 0; if (argLen > 1) { @@ -115,7 +115,7 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType return v8::Undefined(); } if (!srcArray.IsEmpty()) { - // Need to copy the incoming array into the newly created WebGLArray. + // Need to copy the incoming array into the newly created ArrayBufferView. for (unsigned i = 0; i < len; i++) { v8::Local<v8::Value> val = srcArray->Get(v8::Integer::NewFromUnsigned(i)); array->set(i, val->NumberValue()); @@ -128,46 +128,15 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType return toV8(array.release(), args.Holder()); } -template <class T> -v8::Handle<v8::Value> setWebGLArrayFromArray(T* webGLArray, const v8::Arguments& args) -{ - if (args[0]->IsObject()) { - // void set(in sequence<long> array, [Optional] in unsigned long offset); - v8::Local<v8::Object> array = args[0]->ToObject(); - uint32_t offset = 0; - if (args.Length() == 2) - offset = toUInt32(args[1]); - uint32_t length = toUInt32(array->Get(v8::String::New("length"))); - if (offset > webGLArray->length() || - offset + length > webGLArray->length() || - offset + length < offset) - // Out of range offset or overflow - V8Proxy::setDOMException(INDEX_SIZE_ERR); - else - for (uint32_t i = 0; i < length; i++) - webGLArray->set(offset + i, array->Get(v8::Integer::NewFromUnsigned(i))->NumberValue()); - } - - return v8::Undefined(); -} - template <class CPlusPlusArrayType, class JavaScriptWrapperArrayType> -v8::Handle<v8::Value> setWebGLArray(const v8::Arguments& args) +v8::Handle<v8::Value> setWebGLArrayHelper(const v8::Arguments& args) { - if (args.Length() < 1 || args.Length() > 2) { + if (args.Length() < 1) { V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); } - CPlusPlusArrayType* array = JavaScriptWrapperArrayType::toNative(args.Holder()); - - // FIXME: change to IsUInt32() when available - if (args.Length() == 2 && args[0]->IsInt32()) { - // void set(in unsigned long index, in {long|float} value); - uint32_t index = toUInt32(args[0]); - array->set(index, args[1]->NumberValue()); - return v8::Undefined(); - } + CPlusPlusArrayType* impl = JavaScriptWrapperArrayType::toNative(args.Holder()); if (JavaScriptWrapperArrayType::HasInstance(args[0])) { // void set(in WebGL<T>Array array, [Optional] in unsigned long offset); @@ -176,12 +145,32 @@ v8::Handle<v8::Value> setWebGLArray(const v8::Arguments& args) if (args.Length() == 2) offset = toUInt32(args[1]); ExceptionCode ec = 0; - array->set(src, offset, ec); + impl->set(src, offset, ec); V8Proxy::setDOMException(ec); return v8::Undefined(); } - return setWebGLArrayFromArray(array, args); + if (args[0]->IsObject()) { + // void set(in sequence<long> array, [Optional] in unsigned long offset); + v8::Local<v8::Object> array = args[0]->ToObject(); + uint32_t offset = 0; + if (args.Length() == 2) + offset = toUInt32(args[1]); + uint32_t length = toUInt32(array->Get(v8::String::New("length"))); + if (offset > impl->length() + || offset + length > impl->length() + || offset + length < offset) + // Out of range offset or overflow + V8Proxy::setDOMException(INDEX_SIZE_ERR); + else + for (uint32_t i = 0; i < length; i++) + impl->set(offset + i, array->Get(v8::Integer::NewFromUnsigned(i))->NumberValue()); + + return v8::Undefined(); + } + + V8Proxy::setDOMException(SYNTAX_ERR); + return notHandledByInterceptor(); } } diff --git a/WebCore/bindings/v8/custom/V8BindingMacros.h b/WebCore/bindings/v8/custom/V8BindingMacros.h new file mode 100644 index 0000000..16c3651 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8BindingMacros.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010 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. + */ + +#define EXCEPTION_BLOCK(type, var, value) \ + type var; \ + { \ + v8::TryCatch block; \ + var = value; \ + if (block.HasCaught()) \ + return throwError(block.Exception()); \ + } diff --git a/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp b/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp index aa2816c..69742f8 100644 --- a/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ClipboardCustom.cpp @@ -96,19 +96,6 @@ v8::Handle<v8::Value> V8Clipboard::getDataCallback(const v8::Arguments& args) return v8::Undefined(); } -v8::Handle<v8::Value> V8Clipboard::setDataCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.Clipboard.setData()"); - Clipboard* clipboard = V8Clipboard::toNative(args.Holder()); - - if (args.Length() != 2) - return throwError("setData: Invalid number of arguments", V8Proxy::SyntaxError); - - String type = toWebCoreString(args[0]); - String data = toWebCoreString(args[1]); - return v8Boolean(clipboard->setData(type, data)); -} - v8::Handle<v8::Value> V8Clipboard::setDragImageCallback(const v8::Arguments& args) { INC_STATS("DOM.Clipboard.setDragImage()"); diff --git a/WebCore/bindings/v8/custom/V8CustomIDBCallbacks.h b/WebCore/bindings/v8/custom/V8CustomIDBCallbacks.h deleted file mode 100644 index 1517f15..0000000 --- a/WebCore/bindings/v8/custom/V8CustomIDBCallbacks.h +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (C) 2010 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 V8CustomIDBCallbacks_h -#define V8CustomIDBCallbacks_h - -#include "Document.h" -#include "Frame.h" -#include "IDBDatabaseError.h" -#include "V8CustomVoidCallback.h" -#include "V8IDBDatabaseError.h" -#include "WorldContextHandle.h" -#include <v8.h> -#include <wtf/PassRefPtr.h> -#include <wtf/RefCounted.h> -#include <wtf/RefPtr.h> - -#if ENABLE(INDEXED_DATABASE) - -namespace WebCore { - -// FIXME: Maybe split common parts into a base class. -template <typename ResultType, typename ResultWrapperType> -class V8CustomIDBCallbacks : public IDBCallbacks<ResultType> { -public: - static PassRefPtr<V8CustomIDBCallbacks> create(v8::Local<v8::Value> onSuccess, v8::Local<v8::Value> onError, ScriptExecutionContext* scriptExecutionContext) - { - return adoptRef(new V8CustomIDBCallbacks(onSuccess, onError, scriptExecutionContext)); - } - - virtual ~V8CustomIDBCallbacks() - { - m_onSuccess.Dispose(); - m_onError.Dispose(); - } - - // FIXME: Handle suspend/resume correctly. - -private: - V8CustomIDBCallbacks(v8::Local<v8::Value> onSuccess, v8::Local<v8::Value> onError, ScriptExecutionContext* scriptExecutionContext) - : IDBCallbacks<ResultType>(scriptExecutionContext, this) - , m_onSuccess(onSuccess->IsObject() ? v8::Persistent<v8::Object>::New(onSuccess->ToObject()) : v8::Persistent<v8::Object>()) - , m_onError(onError->IsObject() ? v8::Persistent<v8::Object>::New(onError->ToObject()) : v8::Persistent<v8::Object>()) - , m_worldContext(UseCurrentWorld) - { - } - - template <typename Type> - void onEvent(v8::Persistent<v8::Object> callback, PassRefPtr<Type> value) - { - if (!ActiveDOMObject::scriptExecutionContext()) - return; - if (callback.IsEmpty()) - return; - - v8::HandleScope handleScope; - v8::Handle<v8::Context> context = toV8Context(ActiveDOMObject::scriptExecutionContext(), m_worldContext); - if (context.IsEmpty()) - return; - - v8::Context::Scope scope(context); - v8::Handle<v8::Value> argv[] = { - toV8(value) - }; - - // FIXME: Make this work for workers. - ASSERT(ActiveDOMObject::scriptExecutionContext()->isDocument()); - RefPtr<Frame> protector(static_cast<Document*>(ActiveDOMObject::scriptExecutionContext())->frame()); - - bool callbackReturnValue = false; - // FIXME: Do we care if this thing returns true (i.e. it raised an exception)? - invokeCallback(callback, 1, argv, callbackReturnValue); - } - - virtual void onSuccessAsync(PassRefPtr<ResultType> result) - { - onEvent(m_onSuccess, ResultWrapperType::create(result)); - } - - virtual void onErrorAsync(PassRefPtr<IDBDatabaseError> error) - { - onEvent(m_onError, error); - } - - // FIXME: Use OwnHandles. - v8::Persistent<v8::Object> m_onSuccess; - v8::Persistent<v8::Object> m_onError; - - WorldContextHandle m_worldContext; -}; - -} - -#endif - -#endif // V8CustomIDBCallbacks_h diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp index ff2be37..de4fcbf 100644 --- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp @@ -52,6 +52,7 @@ #include "Storage.h" #include "V8Binding.h" #include "V8BindingDOMWindow.h" +#include "V8BindingMacros.h" #include "V8BindingState.h" #include "V8CustomEventListener.h" #include "V8Database.h" @@ -68,6 +69,16 @@ #if ENABLE(WEB_SOCKETS) #include "WebSocket.h" #endif +#if ENABLE(3D_CANVAS) +#include "V8ArrayBuffer.h" +#include "V8Int8Array.h" +#include "V8FloatArray.h" +#include "V8Int32Array.h" +#include "V8Int16Array.h" +#include "V8Uint8Array.h" +#include "V8Uint32Array.h" +#include "V8Uint16Array.h" +#endif #include "WindowFeatures.h" // Horizontal and vertical offset, from the parent content area, around newly @@ -248,6 +259,61 @@ v8::Handle<v8::Value> V8DOMWindow::OptionAccessorGetter(v8::Local<v8::String> na return V8DOMWrapper::getConstructor(&V8HTMLOptionElementConstructor::info, window); } +#if ENABLE(3D_CANVAS) + +// Temporary aliases to keep current WebGL content working during transition period to TypedArray spec. +// To be removed before WebGL spec is finalized. (FIXME) +v8::Handle<v8::Value> V8DOMWindow::WebGLArrayBufferAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + DOMWindow* window = V8DOMWindow::toNative(info.Holder()); + return V8DOMWrapper::getConstructor(&V8ArrayBuffer::info, window); +} + +v8::Handle<v8::Value> V8DOMWindow::WebGLByteArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + DOMWindow* window = V8DOMWindow::toNative(info.Holder()); + return V8DOMWrapper::getConstructor(&V8Int8Array::info, window); +} + +v8::Handle<v8::Value> V8DOMWindow::WebGLUnsignedByteArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + DOMWindow* window = V8DOMWindow::toNative(info.Holder()); + return V8DOMWrapper::getConstructor(&V8Uint8Array::info, window); +} + +v8::Handle<v8::Value> V8DOMWindow::WebGLShortArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + DOMWindow* window = V8DOMWindow::toNative(info.Holder()); + return V8DOMWrapper::getConstructor(&V8Int16Array::info, window); +} + +v8::Handle<v8::Value> V8DOMWindow::WebGLUnsignedShortArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + DOMWindow* window = V8DOMWindow::toNative(info.Holder()); + return V8DOMWrapper::getConstructor(&V8Uint16Array::info, window); +} + +v8::Handle<v8::Value> V8DOMWindow::WebGLIntArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + DOMWindow* window = V8DOMWindow::toNative(info.Holder()); + return V8DOMWrapper::getConstructor(&V8Int32Array::info, window); +} + +v8::Handle<v8::Value> V8DOMWindow::WebGLUnsignedIntArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + DOMWindow* window = V8DOMWindow::toNative(info.Holder()); + return V8DOMWrapper::getConstructor(&V8Uint32Array::info, window); +} + +v8::Handle<v8::Value> V8DOMWindow::WebGLFloatArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +{ + DOMWindow* window = V8DOMWindow::toNative(info.Holder()); + return V8DOMWrapper::getConstructor(&V8FloatArray::info, window); +} + +#endif + + v8::Handle<v8::Value> V8DOMWindow::addEventListenerCallback(const v8::Arguments& args) { INC_STATS("DOM.DOMWindow.addEventListener()"); @@ -719,21 +785,26 @@ v8::Handle<v8::Value> V8DOMWindow::openDatabaseCallback(const v8::Arguments& arg { INC_STATS("DOM.DOMWindow.openDatabase"); if (args.Length() < 4) - return v8::Undefined(); + return throwError(SYNTAX_ERR); + + EXCEPTION_BLOCK(String, name, toWebCoreString(args[0])); + EXCEPTION_BLOCK(String, version, toWebCoreString(args[1])); + EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2])); + EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value()); DOMWindow* imp = V8DOMWindow::toNative(args.Holder()); if (!V8BindingSecurity::canAccessFrame(V8BindingState::Only(), imp->frame(), true)) return v8::Undefined(); - ExceptionCode ec = 0; - String name = toWebCoreString(args[0]); - String version = toWebCoreString(args[1]); - String displayName = toWebCoreString(args[2]); - unsigned long estimatedSize = args[3]->IntegerValue(); RefPtr<DatabaseCallback> creationCallback; - if ((args.Length() >= 5) && args[4]->IsObject()) + if (args.Length() >= 5) { + if (!args[4]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + creationCallback = V8DatabaseCallback::create(args[4], imp->frame()); + } + ExceptionCode ec = 0; v8::Handle<v8::Value> result = toV8(imp->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec)); V8Proxy::setDOMException(ec); diff --git a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp index 39e6632..89d582e 100644 --- a/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DatabaseCustom.cpp @@ -1,10 +1,10 @@ /* * 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 @@ -14,7 +14,7 @@ * * 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 @@ -35,6 +35,7 @@ #include "Database.h" #include "V8Binding.h" +#include "V8BindingMacros.h" #include "V8SQLTransactionCallback.h" #include "V8SQLTransactionErrorCallback.h" #include "V8CustomVoidCallback.h" @@ -47,10 +48,10 @@ v8::Handle<v8::Value> V8Database::changeVersionCallback(const v8::Arguments& arg INC_STATS("DOM.Database.changeVersion()"); if (args.Length() < 2) - return throwError("The old and new version strings are required.", V8Proxy::SyntaxError); + return throwError(SYNTAX_ERR); - if (!(args[0]->IsString() && args[1]->IsString())) - return throwError("The old and new versions must be strings."); + EXCEPTION_BLOCK(String, oldVersion, toWebCoreString(args[0])); + EXCEPTION_BLOCK(String, newVersion, toWebCoreString(args[1])); Database* database = V8Database::toNative(args.Holder()); @@ -61,7 +62,7 @@ v8::Handle<v8::Value> V8Database::changeVersionCallback(const v8::Arguments& arg RefPtr<V8SQLTransactionCallback> callback; if (args.Length() > 2) { if (!args[2]->IsObject()) - return throwError("changeVersion transaction callback must be of valid type."); + return throwError(TYPE_MISMATCH_ERR); callback = V8SQLTransactionCallback::create(args[2], frame); } @@ -69,7 +70,7 @@ v8::Handle<v8::Value> V8Database::changeVersionCallback(const v8::Arguments& arg RefPtr<V8SQLTransactionErrorCallback> errorCallback; if (args.Length() > 3) { if (!args[3]->IsObject()) - return throwError("changeVersion error callback must be of valid type."); + return throwError(TYPE_MISMATCH_ERR); errorCallback = V8SQLTransactionErrorCallback::create(args[3], frame); } @@ -77,12 +78,12 @@ v8::Handle<v8::Value> V8Database::changeVersionCallback(const v8::Arguments& arg RefPtr<V8CustomVoidCallback> successCallback; if (args.Length() > 4) { if (!args[4]->IsObject()) - return throwError("changeVersion success callback must be of valid type."); + return throwError(TYPE_MISMATCH_ERR); successCallback = V8CustomVoidCallback::create(args[4], frame); } - database->changeVersion(toWebCoreString(args[0]), toWebCoreString(args[1]), callback.release(), errorCallback.release(), successCallback.release()); + database->changeVersion(oldVersion, newVersion, callback.release(), errorCallback.release(), successCallback.release()); return v8::Undefined(); } @@ -90,10 +91,10 @@ v8::Handle<v8::Value> V8Database::changeVersionCallback(const v8::Arguments& arg static v8::Handle<v8::Value> createTransaction(const v8::Arguments& args, bool readOnly) { if (!args.Length()) - return throwError("Transaction callback is required.", V8Proxy::SyntaxError); + return throwError(SYNTAX_ERR); if (!args[0]->IsObject()) - return throwError("Transaction callback must be of valid type."); + return throwError(TYPE_MISMATCH_ERR); Database* database = V8Database::toNative(args.Holder()); @@ -106,7 +107,7 @@ static v8::Handle<v8::Value> createTransaction(const v8::Arguments& args, bool r RefPtr<V8SQLTransactionErrorCallback> errorCallback; if (args.Length() > 1 && !isUndefinedOrNull(args[1])) { if (!args[1]->IsObject()) - return throwError("Transaction error callback must be of valid type."); + return throwError(TYPE_MISMATCH_ERR); errorCallback = V8SQLTransactionErrorCallback::create(args[1], frame); } @@ -114,7 +115,7 @@ static v8::Handle<v8::Value> createTransaction(const v8::Arguments& args, bool r RefPtr<V8CustomVoidCallback> successCallback; if (args.Length() > 2 && !isUndefinedOrNull(args[2])) { if (!args[2]->IsObject()) - return throwError("Transaction success callback must be of valid type."); + return throwError(TYPE_MISMATCH_ERR); successCallback = V8CustomVoidCallback::create(args[2], frame); } diff --git a/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp b/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp new file mode 100644 index 0000000..c7d6d1f --- /dev/null +++ b/WebCore/bindings/v8/custom/V8DatabaseSyncCustom.cpp @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2010 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" + +#if ENABLE(DATABASE) +#include "V8DatabaseSync.h" + +#include "DatabaseSync.h" +#include "V8Binding.h" +#include "V8BindingMacros.h" +#include "V8Proxy.h" +#include "V8SQLTransactionSyncCallback.h" + +namespace WebCore { + +v8::Handle<v8::Value> V8DatabaseSync::changeVersionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.DatabaseSync.changeVersion()"); + + if (args.Length() < 2) + return throwError(SYNTAX_ERR); + + EXCEPTION_BLOCK(String, oldVersion, toWebCoreString(args[0])); + EXCEPTION_BLOCK(String, newVersion, toWebCoreString(args[1])); + + DatabaseSync* database = V8DatabaseSync::toNative(args.Holder()); + + RefPtr<V8SQLTransactionSyncCallback> callback; + if (args.Length() > 2) { + if (!args[2]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + + callback = V8SQLTransactionSyncCallback::create(args[2], 0); + } + + ExceptionCode ec = 0; + database->changeVersion(oldVersion, newVersion, callback.release(), ec); + V8Proxy::setDOMException(ec); + + return v8::Undefined(); +} + +static v8::Handle<v8::Value> createTransaction(const v8::Arguments& args, bool readOnly) +{ + if (!args.Length()) + return throwError(SYNTAX_ERR); + + if (!args[0]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + + DatabaseSync* database = V8DatabaseSync::toNative(args.Holder()); + + RefPtr<V8SQLTransactionSyncCallback> callback = V8SQLTransactionSyncCallback::create(args[0], 0); + + ExceptionCode ec = 0; + database->transaction(callback.release(), readOnly, ec); + V8Proxy::setDOMException(ec); + + return v8::Undefined(); +} + +v8::Handle<v8::Value> V8DatabaseSync::transactionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.DatabaseSync.transaction()"); + return createTransaction(args, false); +} + +v8::Handle<v8::Value> V8DatabaseSync::readTransactionCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.DatabaseSync.readTransaction()"); + return createTransaction(args, true); +} + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/v8/custom/V8EventCustom.cpp b/WebCore/bindings/v8/custom/V8EventCustom.cpp index b2728ec..8a1a339 100644 --- a/WebCore/bindings/v8/custom/V8EventCustom.cpp +++ b/WebCore/bindings/v8/custom/V8EventCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2009 Google Inc. All rights reserved. + * Copyright (C) 2010 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 @@ -41,6 +41,8 @@ #include "V8CompositionEvent.h" #include "V8CustomEvent.h" #include "V8ErrorEvent.h" +#include "V8IDBErrorEvent.h" +#include "V8IDBSuccessEvent.h" #include "V8KeyboardEvent.h" #include "V8MessageEvent.h" #include "V8MouseEvent.h" @@ -143,6 +145,12 @@ v8::Handle<v8::Value> toV8(Event* impl) if (impl->isStorageEvent()) return toV8(static_cast<StorageEvent*>(impl)); #endif +#if ENABLE(INDEXED_DATABASE) + if (impl->isIDBErrorEvent()) + return toV8(static_cast<IDBErrorEvent*>(impl)); + if (impl->isIDBSuccessEvent()) + return toV8(static_cast<IDBSuccessEvent*>(impl)); +#endif if (impl->isBeforeLoadEvent()) return toV8(static_cast<BeforeLoadEvent*>(impl)); if (impl->isCustomEvent()) diff --git a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp b/WebCore/bindings/v8/custom/V8FloatArrayCustom.cpp index 77223ea..ebc65db 100644 --- a/WebCore/bindings/v8/custom/V8WebGLFloatArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8FloatArrayCustom.cpp @@ -32,35 +32,35 @@ #if ENABLE(3D_CANVAS) -#include "WebGLArrayBuffer.h" -#include "WebGLFloatArray.h" +#include "ArrayBuffer.h" +#include "FloatArray.h" #include "V8Binding.h" -#include "V8WebGLArrayBuffer.h" -#include "V8WebGLArrayCustom.h" -#include "V8WebGLFloatArray.h" +#include "V8ArrayBuffer.h" +#include "V8ArrayBufferViewCustom.h" +#include "V8FloatArray.h" #include "V8Proxy.h" namespace WebCore { -v8::Handle<v8::Value> V8WebGLFloatArray::constructorCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8FloatArray::constructorCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLFloatArray.Contructor"); + INC_STATS("DOM.FloatArray.Contructor"); - return constructWebGLArray<WebGLFloatArray, float>(args, &info, v8::kExternalFloatArray); + return constructWebGLArray<FloatArray, float>(args, &info, v8::kExternalFloatArray); } -v8::Handle<v8::Value> V8WebGLFloatArray::setCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8FloatArray::setCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLFloatArray.set()"); - return setWebGLArray<WebGLFloatArray, V8WebGLFloatArray>(args); + INC_STATS("DOM.FloatArray.set()"); + return setWebGLArrayHelper<FloatArray, V8FloatArray>(args); } -v8::Handle<v8::Value> toV8(WebGLFloatArray* impl) +v8::Handle<v8::Value> toV8(FloatArray* impl) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8WebGLFloatArray::wrap(impl); + v8::Handle<v8::Object> wrapper = V8FloatArray::wrap(impl); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalFloatArray, impl->length()); return wrapper; diff --git a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp index 67ba38b..072a28f 100644 --- a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp @@ -78,7 +78,7 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextCallback(const v8::Argument #endif CanvasRenderingContext* result = imp->getContext(contextId, attrs.get()); if (!result) - return v8::Undefined(); + return v8::Null(); if (result->is2d()) return toV8(static_cast<CanvasRenderingContext2D*>(result)); #if ENABLE(3D_CANVAS) @@ -86,7 +86,7 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::getContextCallback(const v8::Argument return toV8(static_cast<WebGLRenderingContext*>(result)); #endif ASSERT_NOT_REACHED(); - return v8::Undefined(); + return v8::Null(); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp b/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp new file mode 100644 index 0000000..2e20e82 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8IDBAnyCustom.cpp @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010 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" + +#if ENABLE(INDEXED_DATABASE) + +#include "V8IDBAny.h" + +#include "SerializedScriptValue.h" +#include "V8IDBDatabaseRequest.h" +#include "V8IndexedDatabaseRequest.h" + +namespace WebCore { + +v8::Handle<v8::Value> toV8(IDBAny* impl) +{ + if (!impl) + return v8::Null(); + + switch (impl->type()) { + case IDBAny::UndefinedType: + return v8::Undefined(); + case IDBAny::IDBDatabaseRequestType: + return toV8(impl->idbDatabaseRequest()); + case IDBAny::IndexedDatabaseRequestType: + return toV8(impl->indexedDatabaseRequest()); + case IDBAny::SerializedScriptValueType: + return impl->serializedScriptValue()->deserialize(); + } + + ASSERT_NOT_REACHED(); + return v8::Undefined(); +} + +#endif // ENABLE(INDEXED_DATABASE) + +} // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp b/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp deleted file mode 100644 index e8c2b68..0000000 --- a/WebCore/bindings/v8/custom/V8IndexedDatabaseRequestCustom.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2010 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" - -#if ENABLE(INDEXED_DATABASE) -#include "V8IndexedDatabaseRequest.h" - -#include "IDBDatabaseError.h" -#include "IDBDatabaseRequest.h" -#include "V8Binding.h" -#include "V8CustomIDBCallbacks.h" -#include "V8IDBDatabaseError.h" -#include "V8IDBDatabaseRequest.h" -#include "V8Proxy.h" - -namespace WebCore { - -v8::Handle<v8::Value> V8IndexedDatabaseRequest::openCallback(const v8::Arguments& args) -{ - IndexedDatabaseRequest* imp = V8IndexedDatabaseRequest::toNative(args.Holder()); - if (args.Length() < 2) - return throwError(V8Proxy::TypeError); - V8Parameter<> name = args[0]; - V8Parameter<> description = args[1]; - - bool modifyDatabase = true; - if (args.Length() > 2 && !args[2]->IsUndefined() && !args[2]->IsNull()) - modifyDatabase = args[2]->BooleanValue(); - - v8::Local<v8::Value> onError; - v8::Local<v8::Value> onSuccess; - if (args.Length() > 3 && !args[3]->IsUndefined() && !args[3]->IsNull()) { - if (!args[3]->IsObject()) - return throwError("onerror callback was not the proper type"); - onError = args[3]; - } - if (args.Length() > 4 && !args[4]->IsUndefined() && !args[4]->IsNull()) { - if (!args[4]->IsObject()) - return throwError("onsuccess callback was not the proper type"); - onSuccess = args[4]; - } - if (!onError->IsObject() && !onSuccess->IsObject()) - return throwError("Neither the onerror nor the onsuccess callbacks were set."); - - Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); - RefPtr<V8CustomIDBCallbacks<IDBDatabase, IDBDatabaseRequest> > callbacks = - V8CustomIDBCallbacks<IDBDatabase, IDBDatabaseRequest>::create(onSuccess, onError, frame->document()); - - ExceptionCode ec = 0; - imp->open(name, description, modifyDatabase, callbacks, ec); - if (ec) - return throwError(ec); - return v8::Handle<v8::Value>(); -} - -} // namespace WebCore - -#endif diff --git a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp index 328f227..515af24 100644 --- a/WebCore/bindings/v8/custom/V8WebGLShortArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8Int16ArrayCustom.cpp @@ -32,35 +32,35 @@ #if ENABLE(3D_CANVAS) -#include "WebGLArrayBuffer.h" -#include "WebGLShortArray.h" +#include "ArrayBuffer.h" +#include "Int16Array.h" #include "V8Binding.h" -#include "V8WebGLArrayBuffer.h" -#include "V8WebGLArrayCustom.h" -#include "V8WebGLShortArray.h" +#include "V8ArrayBuffer.h" +#include "V8ArrayBufferViewCustom.h" +#include "V8Int16Array.h" #include "V8Proxy.h" namespace WebCore { -v8::Handle<v8::Value> V8WebGLShortArray::constructorCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Int16Array::constructorCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLShortArray.Contructor"); + INC_STATS("DOM.Int16Array.Contructor"); - return constructWebGLArray<WebGLShortArray, short>(args, &info, v8::kExternalShortArray); + return constructWebGLArray<Int16Array, short>(args, &info, v8::kExternalShortArray); } -v8::Handle<v8::Value> V8WebGLShortArray::setCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Int16Array::setCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLShortArray.set()"); - return setWebGLArray<WebGLShortArray, V8WebGLShortArray>(args); + INC_STATS("DOM.Int16Array.set()"); + return setWebGLArrayHelper<Int16Array, V8Int16Array>(args); } -v8::Handle<v8::Value> toV8(WebGLShortArray* impl) +v8::Handle<v8::Value> toV8(Int16Array* impl) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8WebGLShortArray::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Int16Array::wrap(impl); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalShortArray, impl->length()); return wrapper; diff --git a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp index 532bdef..46087aa 100644 --- a/WebCore/bindings/v8/custom/V8WebGLIntArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8Int32ArrayCustom.cpp @@ -32,35 +32,35 @@ #if ENABLE(3D_CANVAS) -#include "WebGLArrayBuffer.h" -#include "WebGLIntArray.h" +#include "ArrayBuffer.h" +#include "Int32Array.h" #include "V8Binding.h" -#include "V8WebGLArrayBuffer.h" -#include "V8WebGLArrayCustom.h" -#include "V8WebGLIntArray.h" +#include "V8ArrayBuffer.h" +#include "V8ArrayBufferViewCustom.h" +#include "V8Int32Array.h" #include "V8Proxy.h" namespace WebCore { -v8::Handle<v8::Value> V8WebGLIntArray::constructorCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Int32Array::constructorCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLIntArray.Contructor"); + INC_STATS("DOM.Int32Array.Contructor"); - return constructWebGLArray<WebGLIntArray, int>(args, &info, v8::kExternalIntArray); + return constructWebGLArray<Int32Array, int>(args, &info, v8::kExternalIntArray); } -v8::Handle<v8::Value> V8WebGLIntArray::setCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Int32Array::setCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLIntArray.set()"); - return setWebGLArray<WebGLIntArray, V8WebGLIntArray>(args); + INC_STATS("DOM.Int32Array.set()"); + return setWebGLArrayHelper<Int32Array, V8Int32Array>(args); } -v8::Handle<v8::Value> toV8(WebGLIntArray* impl) +v8::Handle<v8::Value> toV8(Int32Array* impl) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8WebGLIntArray::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Int32Array::wrap(impl); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalIntArray, impl->length()); return wrapper; diff --git a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp index 8487ace..f941111 100644 --- a/WebCore/bindings/v8/custom/V8WebGLByteArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8Int8ArrayCustom.cpp @@ -32,35 +32,35 @@ #if ENABLE(3D_CANVAS) -#include "WebGLArrayBuffer.h" -#include "WebGLByteArray.h" +#include "ArrayBuffer.h" +#include "Int8Array.h" #include "V8Binding.h" -#include "V8WebGLArrayBuffer.h" -#include "V8WebGLArrayCustom.h" -#include "V8WebGLByteArray.h" +#include "V8ArrayBuffer.h" +#include "V8ArrayBufferViewCustom.h" +#include "V8Int8Array.h" #include "V8Proxy.h" namespace WebCore { -v8::Handle<v8::Value> V8WebGLByteArray::constructorCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Int8Array::constructorCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLByteArray.Contructor"); + INC_STATS("DOM.Int8Array.Contructor"); - return constructWebGLArray<WebGLByteArray, signed char>(args, &info, v8::kExternalByteArray); + return constructWebGLArray<Int8Array, signed char>(args, &info, v8::kExternalByteArray); } -v8::Handle<v8::Value> V8WebGLByteArray::setCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Int8Array::setCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLByteArray.set()"); - return setWebGLArray<WebGLByteArray, V8WebGLByteArray>(args); + INC_STATS("DOM.Int8Array.set()"); + return setWebGLArrayHelper<Int8Array, V8Int8Array>(args); } -v8::Handle<v8::Value> toV8(WebGLByteArray* impl) +v8::Handle<v8::Value> toV8(Int8Array* impl) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8WebGLByteArray::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Int8Array::wrap(impl); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalByteArray, impl->length()); return wrapper; diff --git a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp index 4e68b30..e6ffe30 100644 --- a/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp +++ b/WebCore/bindings/v8/custom/V8SQLTransactionCustom.cpp @@ -1,10 +1,10 @@ /* * 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 @@ -14,7 +14,7 @@ * * 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 @@ -37,6 +37,7 @@ #include "Database.h" #include "SQLValue.h" #include "V8Binding.h" +#include "V8BindingMacros.h" #include "V8SQLStatementCallback.h" #include "V8SQLStatementErrorCallback.h" #include "V8Proxy.h" @@ -51,48 +52,39 @@ v8::Handle<v8::Value> V8SQLTransaction::executeSqlCallback(const v8::Arguments& INC_STATS("DOM.SQLTransaction.executeSql()"); if (args.Length() == 0) - return throwError("SQL statement is required.", V8Proxy::SyntaxError); + return throwError(SYNTAX_ERR); - String statement = toWebCoreString(args[0]); + EXCEPTION_BLOCK(String, statement, toWebCoreString(args[0])); Vector<SQLValue> sqlValues; if (args.Length() > 1 && !isUndefinedOrNull(args[1])) { - if (args[1]->IsObject()) { - uint32_t sqlArgsLength = 0; - v8::Local<v8::Object> sqlArgsObject = args[1]->ToObject(); - v8::Local<v8::Value> lengthGetter; - { - v8::TryCatch block; - lengthGetter = sqlArgsObject->Get(v8::String::New("length")); - if (block.HasCaught()) - return throwError(block.Exception()); + if (!args[1]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + + uint32_t sqlArgsLength = 0; + v8::Local<v8::Object> sqlArgsObject = args[1]->ToObject(); + EXCEPTION_BLOCK(v8::Local<v8::Value>, length, sqlArgsObject->Get(v8::String::New("length"))); + + if (isUndefinedOrNull(length)) + sqlArgsLength = sqlArgsObject->GetPropertyNames()->Length(); + else + sqlArgsLength = length->Uint32Value(); + + for (unsigned int i = 0; i < sqlArgsLength; ++i) { + v8::Local<v8::Integer> key = v8::Integer::New(i); + EXCEPTION_BLOCK(v8::Local<v8::Value>, value, sqlArgsObject->Get(key)); + + if (value.IsEmpty() || value->IsNull()) + sqlValues.append(SQLValue()); + else if (value->IsNumber()) { + EXCEPTION_BLOCK(double, sqlValue, value->NumberValue()); + sqlValues.append(SQLValue(sqlValue)); + } else { + EXCEPTION_BLOCK(String, sqlValue, toWebCoreString(value)); + sqlValues.append(SQLValue(sqlValue)); } - - if (isUndefinedOrNull(lengthGetter)) - sqlArgsLength = sqlArgsObject->GetPropertyNames()->Length(); - else - sqlArgsLength = lengthGetter->Uint32Value(); - - for (unsigned int i = 0; i < sqlArgsLength; ++i) { - v8::Local<v8::Integer> key = v8::Integer::New(i); - v8::Local<v8::Value> value; - { - v8::TryCatch block; - value = sqlArgsObject->Get(key); - if (block.HasCaught()) - return throwError(block.Exception()); - } - - if (value.IsEmpty() || value->IsNull()) - sqlValues.append(SQLValue()); - else if (value->IsNumber()) - sqlValues.append(SQLValue(value->NumberValue())); - else - sqlValues.append(SQLValue(toWebCoreString(value))); - } - } else - return throwError("sqlArgs should be array or object!", V8Proxy::TypeError); + } } SQLTransaction* transaction = V8SQLTransaction::toNative(args.Holder()); @@ -102,7 +94,7 @@ v8::Handle<v8::Value> V8SQLTransaction::executeSqlCallback(const v8::Arguments& RefPtr<SQLStatementCallback> callback; if (args.Length() > 2 && !isUndefinedOrNull(args[2])) { if (!args[2]->IsObject()) - return throwError("Statement callback must be of valid type.", V8Proxy::TypeError); + return throwError(TYPE_MISMATCH_ERR); if (frame) callback = V8SQLStatementCallback::create(args[2], frame); @@ -111,7 +103,7 @@ v8::Handle<v8::Value> V8SQLTransaction::executeSqlCallback(const v8::Arguments& RefPtr<SQLStatementErrorCallback> errorCallback; if (args.Length() > 3 && !isUndefinedOrNull(args[3])) { if (!args[3]->IsObject()) - return throwError("Statement error callback must be of valid type.", V8Proxy::TypeError); + return throwError(TYPE_MISMATCH_ERR); if (frame) errorCallback = V8SQLStatementErrorCallback::create(args[3], frame); diff --git a/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp b/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp new file mode 100644 index 0000000..651c79b --- /dev/null +++ b/WebCore/bindings/v8/custom/V8SQLTransactionSyncCustom.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2010 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" + +#if ENABLE(DATABASE) + +#include "V8SQLTransactionSync.h" + +#include "DatabaseSync.h" +#include "SQLResultSet.h" +#include "SQLValue.h" +#include "V8Binding.h" +#include "V8BindingMacros.h" +#include "V8Proxy.h" +#include <wtf/Vector.h> + +using namespace WTF; + +namespace WebCore { + +v8::Handle<v8::Value> V8SQLTransactionSync::executeSqlCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.SQLTransactionSync.executeSql()"); + + if (!args.Length()) + return throwError(SYNTAX_ERR); + + EXCEPTION_BLOCK(String, statement, toWebCoreString(args[0])); + + Vector<SQLValue> sqlValues; + + if (args.Length() > 1 && !isUndefinedOrNull(args[1])) { + if (!args[1]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + + uint32_t sqlArgsLength = 0; + v8::Local<v8::Object> sqlArgsObject = args[1]->ToObject(); + EXCEPTION_BLOCK(v8::Local<v8::Value>, length, sqlArgsObject->Get(v8::String::New("length"))); + + if (isUndefinedOrNull(length)) + sqlArgsLength = sqlArgsObject->GetPropertyNames()->Length(); + else + sqlArgsLength = length->Uint32Value(); + + for (unsigned int i = 0; i < sqlArgsLength; ++i) { + v8::Local<v8::Integer> key = v8::Integer::New(i); + EXCEPTION_BLOCK(v8::Local<v8::Value>, value, sqlArgsObject->Get(key)); + + if (value.IsEmpty() || value->IsNull()) + sqlValues.append(SQLValue()); + else if (value->IsNumber()) { + EXCEPTION_BLOCK(double, sqlValue, value->NumberValue()); + sqlValues.append(SQLValue(sqlValue)); + } else { + EXCEPTION_BLOCK(String, sqlValue, toWebCoreString(value)); + sqlValues.append(SQLValue(sqlValue)); + } + } + } + + SQLTransactionSync* transaction = V8SQLTransactionSync::toNative(args.Holder()); + + ExceptionCode ec = 0; + transaction->executeSQL(statement, sqlValues, ec); + V8Proxy::setDOMException(ec); + + return v8::Undefined(); +} + +} // namespace WebCore + +#endif diff --git a/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp b/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp new file mode 100644 index 0000000..5569253 --- /dev/null +++ b/WebCore/bindings/v8/custom/V8Uint16ArrayCustom.cpp @@ -0,0 +1,71 @@ +/* + * 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" + +#if ENABLE(3D_CANVAS) + +#include "ArrayBuffer.h" +#include "Uint16Array.h" + +#include "V8Binding.h" +#include "V8ArrayBuffer.h" +#include "V8ArrayBufferViewCustom.h" +#include "V8Uint16Array.h" +#include "V8Proxy.h" + +namespace WebCore { + +v8::Handle<v8::Value> V8Uint16Array::constructorCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.Uint16Array.Contructor"); + + return constructWebGLArray<Uint16Array, unsigned short>(args, &info, v8::kExternalUnsignedShortArray); +} + +v8::Handle<v8::Value> V8Uint16Array::setCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.Uint16Array.set()"); + return setWebGLArrayHelper<Uint16Array, V8Uint16Array>(args); +} + +v8::Handle<v8::Value> toV8(Uint16Array* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8Uint16Array::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedShortArray, impl->length()); + return wrapper; +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp b/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp index 14aa1bb..c1521cf 100644 --- a/WebCore/bindings/v8/custom/V8WebGLUnsignedIntArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8Uint32ArrayCustom.cpp @@ -32,35 +32,35 @@ #if ENABLE(3D_CANVAS) -#include "WebGLArrayBuffer.h" -#include "WebGLUnsignedIntArray.h" +#include "ArrayBuffer.h" +#include "Uint32Array.h" #include "V8Binding.h" -#include "V8WebGLArrayBuffer.h" -#include "V8WebGLArrayCustom.h" -#include "V8WebGLUnsignedIntArray.h" +#include "V8ArrayBuffer.h" +#include "V8ArrayBufferViewCustom.h" +#include "V8Uint32Array.h" #include "V8Proxy.h" namespace WebCore { -v8::Handle<v8::Value> V8WebGLUnsignedIntArray::constructorCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Uint32Array::constructorCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLUnsignedIntArray.Contructor"); + INC_STATS("DOM.Uint32Array.Contructor"); - return constructWebGLArray<WebGLUnsignedIntArray, unsigned int>(args, &info, v8::kExternalUnsignedIntArray); + return constructWebGLArray<Uint32Array, unsigned int>(args, &info, v8::kExternalUnsignedIntArray); } -v8::Handle<v8::Value> V8WebGLUnsignedIntArray::setCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Uint32Array::setCallback(const v8::Arguments& args) { - INC_STATS("DOM.WebGLUnsignedIntArray.set()"); - return setWebGLArray<WebGLUnsignedIntArray, V8WebGLUnsignedIntArray>(args); + INC_STATS("DOM.Uint32Array.set()"); + return setWebGLArrayHelper<Uint32Array, V8Uint32Array>(args); } -v8::Handle<v8::Value> toV8(WebGLUnsignedIntArray* impl) +v8::Handle<v8::Value> toV8(Uint32Array* impl) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8WebGLUnsignedIntArray::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Uint32Array::wrap(impl); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedIntArray, impl->length()); return wrapper; diff --git a/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp b/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp new file mode 100644 index 0000000..73f995c --- /dev/null +++ b/WebCore/bindings/v8/custom/V8Uint8ArrayCustom.cpp @@ -0,0 +1,71 @@ +/* + * 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" + +#if ENABLE(3D_CANVAS) + +#include "ArrayBuffer.h" +#include "Uint8Array.h" + +#include "V8Binding.h" +#include "V8ArrayBuffer.h" +#include "V8ArrayBufferViewCustom.h" +#include "V8Uint8Array.h" +#include "V8Proxy.h" + +namespace WebCore { + +v8::Handle<v8::Value> V8Uint8Array::constructorCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.Uint8Array.Contructor"); + + return constructWebGLArray<Uint8Array, unsigned char>(args, &info, v8::kExternalUnsignedByteArray); +} + +v8::Handle<v8::Value> V8Uint8Array::setCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.Uint8Array.set()"); + return setWebGLArrayHelper<Uint8Array, V8Uint8Array>(args); +} + +v8::Handle<v8::Value> toV8(Uint8Array* impl) +{ + if (!impl) + return v8::Null(); + v8::Handle<v8::Object> wrapper = V8Uint8Array::wrap(impl); + if (!wrapper.IsEmpty()) + wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedByteArray, impl->length()); + return wrapper; +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 75eff67..7a031b1 100644 --- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -41,21 +41,21 @@ #include <wtf/FastMalloc.h> #include "V8Binding.h" -#include "V8WebGLArray.h" +#include "V8ArrayBufferView.h" #include "V8WebGLBuffer.h" -#include "V8WebGLByteArray.h" -#include "V8WebGLFloatArray.h" +#include "V8Int8Array.h" +#include "V8FloatArray.h" #include "V8WebGLFramebuffer.h" -#include "V8WebGLIntArray.h" +#include "V8Int32Array.h" #include "V8WebGLProgram.h" #include "V8WebGLRenderbuffer.h" #include "V8WebGLShader.h" -#include "V8WebGLShortArray.h" +#include "V8Int16Array.h" #include "V8WebGLTexture.h" #include "V8WebGLUniformLocation.h" -#include "V8WebGLUnsignedByteArray.h" -#include "V8WebGLUnsignedIntArray.h" -#include "V8WebGLUnsignedShortArray.h" +#include "V8Uint8Array.h" +#include "V8Uint32Array.h" +#include "V8Uint16Array.h" #include "V8HTMLCanvasElement.h" #include "V8HTMLImageElement.h" #include "V8HTMLVideoElement.h" @@ -392,21 +392,21 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments& FunctionToCall functionToCall) { // Forms: // * glUniform1fv(WebGLUniformLocation location, Array data); - // * glUniform1fv(WebGLUniformLocation location, WebGLFloatArray data); + // * glUniform1fv(WebGLUniformLocation location, FloatArray data); // * glUniform2fv(WebGLUniformLocation location, Array data); - // * glUniform2fv(WebGLUniformLocation location, WebGLFloatArray data); + // * glUniform2fv(WebGLUniformLocation location, FloatArray data); // * glUniform3fv(WebGLUniformLocation location, Array data); - // * glUniform3fv(WebGLUniformLocation location, WebGLFloatArray data); + // * glUniform3fv(WebGLUniformLocation location, FloatArray data); // * glUniform4fv(WebGLUniformLocation location, Array data); - // * glUniform4fv(WebGLUniformLocation location, WebGLFloatArray data); + // * glUniform4fv(WebGLUniformLocation location, FloatArray data); // * glVertexAttrib1fv(GLint index, Array data); - // * glVertexAttrib1fv(GLint index, WebGLFloatArray data); + // * glVertexAttrib1fv(GLint index, FloatArray data); // * glVertexAttrib2fv(GLint index, Array data); - // * glVertexAttrib2fv(GLint index, WebGLFloatArray data); + // * glVertexAttrib2fv(GLint index, FloatArray data); // * glVertexAttrib3fv(GLint index, Array data); - // * glVertexAttrib3fv(GLint index, WebGLFloatArray data); + // * glVertexAttrib3fv(GLint index, FloatArray data); // * glVertexAttrib4fv(GLint index, Array data); - // * glVertexAttrib4fv(GLint index, WebGLFloatArray data); + // * glVertexAttrib4fv(GLint index, FloatArray data); if (args.Length() != 2) { V8Proxy::setDOMException(SYNTAX_ERR); @@ -424,8 +424,8 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments& WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); - if (V8WebGLFloatArray::HasInstance(args[1])) { - WebGLFloatArray* array = V8WebGLFloatArray::toNative(args[1]->ToObject()); + if (V8FloatArray::HasInstance(args[1])) { + FloatArray* array = V8FloatArray::toNative(args[1]->ToObject()); ASSERT(array != NULL); ExceptionCode ec = 0; switch (functionToCall) { @@ -479,13 +479,13 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args, FunctionToCall functionToCall) { // Forms: // * glUniform1iv(GLUniformLocation location, Array data); - // * glUniform1iv(GLUniformLocation location, WebGLIntArray data); + // * glUniform1iv(GLUniformLocation location, Int32Array data); // * glUniform2iv(GLUniformLocation location, Array data); - // * glUniform2iv(GLUniformLocation location, WebGLIntArray data); + // * glUniform2iv(GLUniformLocation location, Int32Array data); // * glUniform3iv(GLUniformLocation location, Array data); - // * glUniform3iv(GLUniformLocation location, WebGLIntArray data); + // * glUniform3iv(GLUniformLocation location, Int32Array data); // * glUniform4iv(GLUniformLocation location, Array data); - // * glUniform4iv(GLUniformLocation location, WebGLIntArray data); + // * glUniform4iv(GLUniformLocation location, Int32Array data); if (args.Length() != 2) { V8Proxy::setDOMException(SYNTAX_ERR); @@ -496,8 +496,8 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args, bool ok = false; WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok); - if (V8WebGLIntArray::HasInstance(args[1])) { - WebGLIntArray* array = V8WebGLIntArray::toNative(args[1]->ToObject()); + if (V8Int32Array::HasInstance(args[1])) { + Int32Array* array = V8Int32Array::toNative(args[1]->ToObject()); ASSERT(array != NULL); ExceptionCode ec = 0; switch (functionToCall) { @@ -592,13 +592,13 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args, { // Forms: // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); - // * glUniformMatrix2fv(GLint location, GLboolean transpose, WebGLFloatArray data); + // * glUniformMatrix2fv(GLint location, GLboolean transpose, FloatArray data); // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); - // * glUniformMatrix3fv(GLint location, GLboolean transpose, WebGLFloatArray data); + // * glUniformMatrix3fv(GLint location, GLboolean transpose, FloatArray data); // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); - // * glUniformMatrix4fv(GLint location, GLboolean transpose, WebGLFloatArray data); + // * glUniformMatrix4fv(GLint location, GLboolean transpose, FloatArray data); // - // FIXME: need to change to accept WebGLFloatArray as well. + // FIXME: need to change to accept FloatArray as well. if (args.Length() != 3) { V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); @@ -610,8 +610,8 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args, WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok); bool transpose = args[1]->BooleanValue(); - if (V8WebGLFloatArray::HasInstance(args[2])) { - WebGLFloatArray* array = V8WebGLFloatArray::toNative(args[2]->ToObject()); + if (V8FloatArray::HasInstance(args[2])) { + FloatArray* array = V8FloatArray::toNative(args[2]->ToObject()); ASSERT(array != NULL); ExceptionCode ec = 0; switch (matrixSize) { diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp deleted file mode 100644 index 5185298..0000000 --- a/WebCore/bindings/v8/custom/V8WebGLUnsignedByteArrayCustom.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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" - -#if ENABLE(3D_CANVAS) - -#include "WebGLArrayBuffer.h" -#include "WebGLUnsignedByteArray.h" - -#include "V8Binding.h" -#include "V8WebGLArrayBuffer.h" -#include "V8WebGLArrayCustom.h" -#include "V8WebGLUnsignedByteArray.h" -#include "V8Proxy.h" - -namespace WebCore { - -v8::Handle<v8::Value> V8WebGLUnsignedByteArray::constructorCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.WebGLUnsignedByteArray.Contructor"); - - return constructWebGLArray<WebGLUnsignedByteArray, unsigned char>(args, &info, v8::kExternalUnsignedByteArray); -} - -v8::Handle<v8::Value> V8WebGLUnsignedByteArray::setCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.WebGLUnsignedByteArray.set()"); - return setWebGLArray<WebGLUnsignedByteArray, V8WebGLUnsignedByteArray>(args); -} - -v8::Handle<v8::Value> toV8(WebGLUnsignedByteArray* impl) -{ - if (!impl) - return v8::Null(); - v8::Handle<v8::Object> wrapper = V8WebGLUnsignedByteArray::wrap(impl); - if (!wrapper.IsEmpty()) - wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedByteArray, impl->length()); - return wrapper; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp deleted file mode 100644 index e9ebb4f..0000000 --- a/WebCore/bindings/v8/custom/V8WebGLUnsignedShortArrayCustom.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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" - -#if ENABLE(3D_CANVAS) - -#include "WebGLArrayBuffer.h" -#include "WebGLUnsignedShortArray.h" - -#include "V8Binding.h" -#include "V8WebGLArrayBuffer.h" -#include "V8WebGLArrayCustom.h" -#include "V8WebGLUnsignedShortArray.h" -#include "V8Proxy.h" - -namespace WebCore { - -v8::Handle<v8::Value> V8WebGLUnsignedShortArray::constructorCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.WebGLUnsignedShortArray.Contructor"); - - return constructWebGLArray<WebGLUnsignedShortArray, unsigned short>(args, &info, v8::kExternalUnsignedShortArray); -} - -v8::Handle<v8::Value> V8WebGLUnsignedShortArray::setCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.WebGLUnsignedShortArray.set()"); - return setWebGLArray<WebGLUnsignedShortArray, V8WebGLUnsignedShortArray>(args); -} - -v8::Handle<v8::Value> toV8(WebGLUnsignedShortArray* impl) -{ - if (!impl) - return v8::Null(); - v8::Handle<v8::Object> wrapper = V8WebGLUnsignedShortArray::wrap(impl); - if (!wrapper.IsEmpty()) - wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalUnsignedShortArray, impl->length()); - return wrapper; -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp index 46bd966..446a8ea 100755 --- a/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WorkerContextCustom.cpp @@ -33,10 +33,16 @@ #if ENABLE(WORKERS) #include "V8WorkerContext.h" +#if ENABLE(DATABASE) +#include "V8Database.h" +#include "V8DatabaseCallback.h" +#include "V8DatabaseSync.h" +#endif #include "DOMTimer.h" #include "ExceptionCode.h" #include "ScheduledAction.h" #include "V8Binding.h" +#include "V8BindingMacros.h" #include "V8Proxy.h" #include "V8Utilities.h" #include "V8WorkerContextEventListener.h" @@ -136,6 +142,43 @@ v8::Handle<v8::Value> toV8(WorkerContext* impl) return global; } +#if ENABLE(DATABASE) +v8::Handle<v8::Value> V8WorkerContext::openDatabaseCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.WorkerContext.openDatabase()"); + // Implementation coming soon. + return throwError(NOT_SUPPORTED_ERR); +} + +v8::Handle<v8::Value> V8WorkerContext::openDatabaseSyncCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.V8WorkerContext.openDatabaseSync()"); + if (args.Length() < 4) + return throwError(SYNTAX_ERR); + + EXCEPTION_BLOCK(String, name, toWebCoreString(args[0])); + EXCEPTION_BLOCK(String, version, toWebCoreString(args[1])); + EXCEPTION_BLOCK(String, displayName, toWebCoreString(args[2])); + EXCEPTION_BLOCK(unsigned long, estimatedSize, args[3]->Uint32Value()); + + WorkerContext* workerContext = V8WorkerContext::toNative(args.Holder()); + + RefPtr<DatabaseCallback> creationCallback; + if (args.Length() >= 5) { + if (!args[4]->IsObject()) + return throwError(TYPE_MISMATCH_ERR); + + creationCallback = V8DatabaseCallback::create(args[4], 0); + } + + ExceptionCode ec = 0; + v8::Handle<v8::Value> result = toV8(workerContext->openDatabaseSync(name, version, displayName, estimatedSize, creationCallback.release(), ec)); + + V8Proxy::setDOMException(ec); + return result; +} +#endif + } // namespace WebCore #endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp index 4e9c715..3da664f 100644 --- a/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp +++ b/WebCore/bindings/v8/custom/V8XMLHttpRequestCustom.cpp @@ -141,47 +141,4 @@ v8::Handle<v8::Value> V8XMLHttpRequest::sendCallback(const v8::Arguments& args) return v8::Undefined(); } -v8::Handle<v8::Value> V8XMLHttpRequest::setRequestHeaderCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.XMLHttpRequest.setRequestHeader()"); - if (args.Length() < 2) - return throwError("Not enough arguments", V8Proxy::SyntaxError); - - XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); - ExceptionCode ec = 0; - String header = toWebCoreString(args[0]); - String value = toWebCoreString(args[1]); - xmlHttpRequest->setRequestHeader(header, value, ec); - if (ec) - return throwError(ec); - return v8::Undefined(); -} - -v8::Handle<v8::Value> V8XMLHttpRequest::getResponseHeaderCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.XMLHttpRequest.getResponseHeader()"); - if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::SyntaxError); - - XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); - ExceptionCode ec = 0; - String header = toWebCoreString(args[0]); - String result = xmlHttpRequest->getResponseHeader(header, ec); - if (ec) - return throwError(ec); - return v8StringOrNull(result); -} - -v8::Handle<v8::Value> V8XMLHttpRequest::overrideMimeTypeCallback(const v8::Arguments& args) -{ - INC_STATS("DOM.XMLHttpRequest.overrideMimeType()"); - if (args.Length() < 1) - return throwError("Not enough arguments", V8Proxy::SyntaxError); - - XMLHttpRequest* xmlHttpRequest = V8XMLHttpRequest::toNative(args.Holder()); - String value = toWebCoreString(args[0]); - xmlHttpRequest->overrideMimeType(value); - return v8::Undefined(); -} - } // namespace WebCore |