diff options
Diffstat (limited to 'WebCore/bindings')
108 files changed, 2701 insertions, 1786 deletions
diff --git a/WebCore/bindings/ScriptControllerBase.cpp b/WebCore/bindings/ScriptControllerBase.cpp index 41d2e0a..cbd4214 100644 --- a/WebCore/bindings/ScriptControllerBase.cpp +++ b/WebCore/bindings/ScriptControllerBase.cpp @@ -67,8 +67,7 @@ ScriptValue ScriptController::executeScript(const ScriptSourceCode& sourceCode) return result; } - -bool ScriptController::executeIfJavaScriptURL(const KURL& url, bool userGesture, bool replaceDocument) +bool ScriptController::executeIfJavaScriptURL(const KURL& url, bool userGesture, ShouldReplaceDocumentIfJavaScriptURL shouldReplaceDocumentIfJavaScriptURL) { if (!protocolIsJavaScript(url)) return false; @@ -100,7 +99,7 @@ bool ScriptController::executeIfJavaScriptURL(const KURL& url, bool userGesture, // FIXME: We should always replace the document, but doing so // synchronously can cause crashes: // http://bugs.webkit.org/show_bug.cgi?id=16782 - if (replaceDocument) + if (shouldReplaceDocumentIfJavaScriptURL == ReplaceDocumentIfJavaScriptURL) m_frame->loader()->writer()->replaceDocument(scriptResult); return true; diff --git a/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp b/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp index 2044a20..a3e488e 100644 --- a/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp +++ b/WebCore/bindings/generic/RuntimeEnabledFeatures.cpp @@ -32,6 +32,7 @@ #include "RuntimeEnabledFeatures.h" #include "Database.h" +#include "DatabaseSync.h" #include "MediaPlayer.h" #include "SharedWorkerRepository.h" #include "WebSocket.h" @@ -96,6 +97,11 @@ bool RuntimeEnabledFeatures::openDatabaseEnabled() { return Database::isAvailable(); } + +bool RuntimeEnabledFeatures::openDatabaseSyncEnabled() +{ + return DatabaseSync::isAvailable(); +} #endif } // namespace WebCore diff --git a/WebCore/bindings/generic/RuntimeEnabledFeatures.h b/WebCore/bindings/generic/RuntimeEnabledFeatures.h index 1534353..c84465a 100644 --- a/WebCore/bindings/generic/RuntimeEnabledFeatures.h +++ b/WebCore/bindings/generic/RuntimeEnabledFeatures.h @@ -75,10 +75,19 @@ public: #if ENABLE(DATABASE) static bool openDatabaseEnabled(); + static bool openDatabaseSyncEnabled(); #endif #if ENABLE(3D_CANVAS) static void setWebGLEnabled(bool isEnabled) { isWebGLEnabled = isEnabled; } + static bool arrayBufferEnabled() { return isWebGLEnabled; } + static bool int8ArrayEnabled() { return isWebGLEnabled; } + static bool uint8ArrayEnabled() { return isWebGLEnabled; } + static bool int16ArrayEnabled() { return isWebGLEnabled; } + static bool uint16ArrayEnabled() { return isWebGLEnabled; } + static bool int32ArrayEnabled() { return isWebGLEnabled; } + static bool uint32ArrayEnabled() { return isWebGLEnabled; } + static bool floatArrayEnabled() { return isWebGLEnabled; } static bool webGLRenderingContextEnabled() { return isWebGLEnabled; } static bool webGLArrayBufferEnabled() { return isWebGLEnabled; } static bool webGLByteArrayEnabled() { return isWebGLEnabled; } diff --git a/WebCore/bindings/js/JSWebGLArrayBufferConstructor.cpp b/WebCore/bindings/js/JSArrayBufferConstructor.cpp index 5f1f643..2930be8 100644 --- a/WebCore/bindings/js/JSWebGLArrayBufferConstructor.cpp +++ b/WebCore/bindings/js/JSArrayBufferConstructor.cpp @@ -27,28 +27,28 @@ #if ENABLE(3D_CANVAS) -#include "JSWebGLArrayBufferConstructor.h" +#include "JSArrayBufferConstructor.h" #include "Document.h" #include "ExceptionCode.h" -#include "JSWebGLArrayBuffer.h" +#include "JSArrayBuffer.h" namespace WebCore { using namespace JSC; -const ClassInfo JSWebGLArrayBufferConstructor::s_info = { "WebGLArrayBufferConstructor", 0, 0, 0 }; +const ClassInfo JSArrayBufferConstructor::s_info = { "ArrayBufferConstructor", 0, 0, 0 }; -JSWebGLArrayBufferConstructor::JSWebGLArrayBufferConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebGLArrayBufferConstructor::createStructure(globalObject->objectPrototype()), globalObject) +JSArrayBufferConstructor::JSArrayBufferConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSArrayBufferConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebGLArrayBufferPrototype::self(exec, globalObject), None); + putDirect(exec->propertyNames().prototype, JSArrayBufferPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); } static JSObject* constructCanvasArrayBuffer(ExecState* exec, JSObject* constructor, const ArgList& args) { - JSWebGLArrayBufferConstructor* jsConstructor = static_cast<JSWebGLArrayBufferConstructor*>(constructor); + JSArrayBufferConstructor* jsConstructor = static_cast<JSArrayBufferConstructor*>(constructor); unsigned int size = 0; if (args.size() == 1) { @@ -56,7 +56,7 @@ static JSObject* constructCanvasArrayBuffer(ExecState* exec, JSObject* construct if (isnan(size)) size = 0; } - RefPtr<WebGLArrayBuffer> buffer = WebGLArrayBuffer::create(size, 1); + RefPtr<ArrayBuffer> buffer = ArrayBuffer::create(size, 1); if (!buffer.get()){ setDOMException(exec, INDEX_SIZE_ERR); return 0; @@ -64,7 +64,7 @@ static JSObject* constructCanvasArrayBuffer(ExecState* exec, JSObject* construct return asObject(toJS(exec, jsConstructor->globalObject(), buffer.get())); } -JSC::ConstructType JSWebGLArrayBufferConstructor::getConstructData(JSC::ConstructData& constructData) +JSC::ConstructType JSArrayBufferConstructor::getConstructData(JSC::ConstructData& constructData) { constructData.native.function = constructCanvasArrayBuffer; return ConstructTypeHost; diff --git a/WebCore/bindings/js/JSWebGLArrayBufferConstructor.h b/WebCore/bindings/js/JSArrayBufferConstructor.h index c7a927e..fd03815 100644 --- a/WebCore/bindings/js/JSWebGLArrayBufferConstructor.h +++ b/WebCore/bindings/js/JSArrayBufferConstructor.h @@ -23,27 +23,27 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSWebGLArrayBufferConstructor_h -#define JSWebGLArrayBufferConstructor_h +#ifndef JSArrayBufferConstructor_h +#define JSArrayBufferConstructor_h #include "JSDOMBinding.h" #include "JSDocument.h" -#include "JSWebGLArrayBuffer.h" +#include "JSArrayBuffer.h" #include <runtime/Error.h> -#include "WebGLArrayBuffer.h" +#include "ArrayBuffer.h" namespace WebCore { - class WebGLArray; + class ArrayBufferView; // Template function used by CanvasXXXArrayConstructors template<class C, typename T> - PassRefPtr<WebGLArray> construct(JSC::ExecState* exec, const JSC::ArgList& args) + PassRefPtr<ArrayBufferView> construct(JSC::ExecState* exec, const JSC::ArgList& args) { // There are 3 constructors: // // 1) (in int size) - // 2) (in WebGLArrayBuffer buffer, [Optional] in int offset, [Optional] in unsigned int length) + // 2) (in ArrayBuffer buffer, [Optional] in int offset, [Optional] in unsigned int length) // 3) (in sequence<T>) - This ends up being a JS "array-like" object // RefPtr<C> arrayObject; @@ -57,7 +57,7 @@ namespace WebCore { return 0; if (args.at(0).isObject()) { - RefPtr<WebGLArrayBuffer> buffer = toWebGLArrayBuffer(args.at(0)); + RefPtr<ArrayBuffer> buffer = toArrayBuffer(args.at(0)); if (buffer) { unsigned offset = (args.size() > 1) ? args.at(1).toUInt32(exec) : 0; unsigned int length = (buffer->byteLength() - offset) / sizeof(T); @@ -89,9 +89,9 @@ namespace WebCore { return C::create(size); } - class JSWebGLArrayBufferConstructor : public DOMConstructorObject { + class JSArrayBufferConstructor : public DOMConstructorObject { public: - JSWebGLArrayBufferConstructor(JSC::ExecState*, JSDOMGlobalObject*); + JSArrayBufferConstructor(JSC::ExecState*, JSDOMGlobalObject*); static const JSC::ClassInfo s_info; private: @@ -101,4 +101,4 @@ namespace WebCore { } -#endif // JSWebGLArrayBufferConstructor_h +#endif // JSArrayBufferConstructor_h diff --git a/WebCore/bindings/js/JSWebGLArrayCustom.cpp b/WebCore/bindings/js/JSArrayBufferViewCustom.cpp index d111d4e..271d096 100644 --- a/WebCore/bindings/js/JSWebGLArrayCustom.cpp +++ b/WebCore/bindings/js/JSArrayBufferViewCustom.cpp @@ -28,48 +28,48 @@ #if ENABLE(3D_CANVAS) #include "config.h" -#include "JSWebGLArray.h" -#include "JSWebGLByteArray.h" -#include "JSWebGLUnsignedByteArray.h" -#include "JSWebGLShortArray.h" -#include "JSWebGLUnsignedShortArray.h" -#include "JSWebGLIntArray.h" -#include "JSWebGLUnsignedIntArray.h" -#include "JSWebGLFloatArray.h" +#include "JSArrayBufferView.h" +#include "JSInt8Array.h" +#include "JSUint8Array.h" +#include "JSInt16Array.h" +#include "JSUint16Array.h" +#include "JSInt32Array.h" +#include "JSUint32Array.h" +#include "JSFloatArray.h" -#include "WebGLArray.h" +#include "ArrayBufferView.h" using namespace JSC; namespace WebCore { -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLArray* object) +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, ArrayBufferView* object) { if (!object) return jsUndefined(); if (object) { if (object->isFloatArray()) - return getDOMObjectWrapper<JSWebGLFloatArray>(exec, globalObject, static_cast<WebGLFloatArray*>(object)); + return getDOMObjectWrapper<JSFloatArray>(exec, globalObject, static_cast<FloatArray*>(object)); if (object->isUnsignedByteArray()) - return getDOMObjectWrapper<JSWebGLUnsignedByteArray>(exec, globalObject, static_cast<WebGLUnsignedByteArray*>(object)); + return getDOMObjectWrapper<JSUint8Array>(exec, globalObject, static_cast<Uint8Array*>(object)); if (object->isByteArray()) - return getDOMObjectWrapper<JSWebGLByteArray>(exec, globalObject, static_cast<WebGLByteArray*>(object)); + return getDOMObjectWrapper<JSInt8Array>(exec, globalObject, static_cast<Int8Array*>(object)); if (object->isIntArray()) - return getDOMObjectWrapper<JSWebGLIntArray>(exec, globalObject, static_cast<WebGLIntArray*>(object)); + return getDOMObjectWrapper<JSInt32Array>(exec, globalObject, static_cast<Int32Array*>(object)); if (object->isUnsignedIntArray()) - return getDOMObjectWrapper<JSWebGLUnsignedIntArray>(exec, globalObject, static_cast<WebGLUnsignedIntArray*>(object)); + return getDOMObjectWrapper<JSUint32Array>(exec, globalObject, static_cast<Uint32Array*>(object)); if (object->isShortArray()) - return getDOMObjectWrapper<JSWebGLShortArray>(exec, globalObject, static_cast<WebGLShortArray*>(object)); + return getDOMObjectWrapper<JSInt16Array>(exec, globalObject, static_cast<Int16Array*>(object)); if (object->isUnsignedShortArray()) - return getDOMObjectWrapper<JSWebGLUnsignedShortArray>(exec, globalObject, static_cast<WebGLUnsignedShortArray*>(object)); + return getDOMObjectWrapper<JSUint16Array>(exec, globalObject, static_cast<Uint16Array*>(object)); } return jsUndefined(); } -JSValue JSWebGLArray::slice(ExecState* exec, const ArgList& args) +JSValue JSArrayBufferView::slice(ExecState* exec, const ArgList& args) { - WebGLArray* array = reinterpret_cast<WebGLArray*>(impl()); + ArrayBufferView* array = reinterpret_cast<ArrayBufferView*>(impl()); int start, end; switch (args.size()) { diff --git a/WebCore/bindings/js/JSWebGLArrayHelper.h b/WebCore/bindings/js/JSArrayBufferViewHelper.h index 481c68f..7243db6 100644 --- a/WebCore/bindings/js/JSWebGLArrayHelper.h +++ b/WebCore/bindings/js/JSArrayBufferViewHelper.h @@ -24,8 +24,8 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSWebGLArrayHelper_h -#define JSWebGLArrayHelper_h +#ifndef JSArrayBufferViewHelper_h +#define JSArrayBufferViewHelper_h #include "ExceptionCode.h" #include "JSDOMBinding.h" @@ -38,8 +38,23 @@ namespace WebCore { template <class T> -JSC::JSValue setWebGLArrayFromArray(JSC::ExecState* exec, T* webGLArray, JSC::ArgList const& args) +JSC::JSValue setWebGLArrayHelper(JSC::ExecState* exec, T* impl, JSC::ArgList const& args, T* (*conversionFunc)(JSC::JSValue)) { + if (args.size() < 1) + return throwError(exec, JSC::SyntaxError); + + T* array = (*conversionFunc)(args.at(0)); + if (array) { + // void set(in WebGL<T>Array array, [Optional] in unsigned long offset); + unsigned offset = 0; + if (args.size() == 2) + offset = args.at(1).toInt32(exec); + ExceptionCode ec = 0; + impl->set(array, offset, ec); + setDOMException(exec, ec); + return JSC::jsUndefined(); + } + if (args.at(0).isObject()) { // void set(in sequence<long> array, [Optional] in unsigned long offset); JSC::JSObject* array = JSC::asObject(args.at(0)); @@ -47,16 +62,16 @@ JSC::JSValue setWebGLArrayFromArray(JSC::ExecState* exec, T* webGLArray, JSC::Ar if (args.size() == 2) offset = args.at(1).toInt32(exec); uint32_t length = array->get(exec, JSC::Identifier(exec, "length")).toInt32(exec); - if (offset > webGLArray->length() || - offset + length > webGLArray->length() || - offset + length < offset) + if (offset > impl->length() + || offset + length > impl->length() + || offset + length < offset) setDOMException(exec, INDEX_SIZE_ERR); else { for (uint32_t i = 0; i < length; i++) { JSC::JSValue v = array->get(exec, i); if (exec->hadException()) return JSC::jsUndefined(); - webGLArray->set(i + offset, v.toNumber(exec)); + impl->set(i + offset, v.toNumber(exec)); } } @@ -68,4 +83,4 @@ JSC::JSValue setWebGLArrayFromArray(JSC::ExecState* exec, T* webGLArray, JSC::Ar } -#endif // JSWebGLArrayHelper_h +#endif // JSArrayBufferViewHelper_h diff --git a/WebCore/bindings/js/JSBindingsAllInOne.cpp b/WebCore/bindings/js/JSBindingsAllInOne.cpp index e275397..cd6ddfb 100644 --- a/WebCore/bindings/js/JSBindingsAllInOne.cpp +++ b/WebCore/bindings/js/JSBindingsAllInOne.cpp @@ -51,6 +51,7 @@ #include "JSDataGridColumnListCustom.cpp" #include "JSDataGridDataSource.cpp" #include "JSDatabaseCustom.cpp" +#include "JSDatabaseSyncCustom.cpp" #include "JSDedicatedWorkerContextCustom.cpp" #include "JSDesktopNotificationsCustom.cpp" #include "JSDocumentCustom.cpp" @@ -102,6 +103,7 @@ #include "JSPluginElementFunctions.cpp" #include "JSSQLResultSetRowListCustom.cpp" #include "JSSQLTransactionCustom.cpp" +#include "JSSQLTransactionSyncCustom.cpp" #include "JSSVGElementInstanceCustom.cpp" #include "JSSVGLengthCustom.cpp" #include "JSSVGMatrixCustom.cpp" diff --git a/WebCore/bindings/js/JSCallbackData.h b/WebCore/bindings/js/JSCallbackData.h index b939c01..f7b8bfe 100644 --- a/WebCore/bindings/js/JSCallbackData.h +++ b/WebCore/bindings/js/JSCallbackData.h @@ -31,14 +31,15 @@ #include "JSDOMBinding.h" #include "JSDOMGlobalObject.h" +#include "ScriptExecutionContext.h" #include <runtime/JSObject.h> #include <runtime/Protect.h> #include <wtf/Threading.h> namespace WebCore { -// We have to clean up this data on the main thread because unprotecting a -// JSObject on a non-main thread without synchronization would corrupt the heap +// We have to clean up this data on the context thread because unprotecting a +// JSObject on the wrong thread without synchronization would corrupt the heap // (and synchronization would be slow). class JSCallbackData { @@ -48,12 +49,15 @@ public: JSCallbackData(JSC::JSObject* callback, JSDOMGlobalObject* globalObject) : m_callback(callback) , m_globalObject(globalObject) +#ifndef NDEBUG + , m_thread(currentThread()) +#endif { } ~JSCallbackData() { - ASSERT(isMainThread()); + ASSERT(m_thread == currentThread()); } JSC::JSObject* callback() { return m_callback.get(); } @@ -64,6 +68,28 @@ public: private: JSC::ProtectedPtr<JSC::JSObject> m_callback; JSC::ProtectedPtr<JSDOMGlobalObject> m_globalObject; +#ifndef NDEBUG + ThreadIdentifier m_thread; +#endif +}; + +class DeleteCallbackDataTask : public ScriptExecutionContext::Task { +public: + static PassOwnPtr<DeleteCallbackDataTask> create(JSCallbackData* data) + { + return new DeleteCallbackDataTask(data); + } + + virtual void performTask(ScriptExecutionContext*) + { + delete m_data; + } + virtual bool isCleanupTask() const { return true; } +private: + + DeleteCallbackDataTask(JSCallbackData* data) : m_data(data) {} + + JSCallbackData* m_data; }; } // namespace WebCore diff --git a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp index 7a776db..f8aa5a7 100644 --- a/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp +++ b/WebCore/bindings/js/JSCanvasRenderingContext2DCustom.cpp @@ -361,6 +361,24 @@ JSValue JSCanvasRenderingContext2D::createPattern(ExecState* exec, const ArgList return jsUndefined(); } +JSValue JSCanvasRenderingContext2D::createImageData(ExecState* exec, const ArgList& args) +{ + // createImageData has two variants + // createImageData(ImageData) + // createImageData(width, height) + CanvasRenderingContext2D* context = static_cast<CanvasRenderingContext2D*>(impl()); + RefPtr<ImageData> imageData = 0; + + ExceptionCode ec = 0; + if (args.size() == 1) + imageData = context->createImageData(toImageData(args.at(0)), ec); + else if (args.size() == 2) + imageData = context->createImageData(args.at(0).toFloat(exec), args.at(1).toFloat(exec), ec); + + setDOMException(exec, ec); + return toJS(exec, globalObject(), WTF::getPtr(imageData)); +} + JSValue JSCanvasRenderingContext2D::putImageData(ExecState* exec, const ArgList& args) { // putImageData has two variants diff --git a/WebCore/bindings/js/JSClipboardCustom.cpp b/WebCore/bindings/js/JSClipboardCustom.cpp index 7efd2b0..ca06d92 100644 --- a/WebCore/bindings/js/JSClipboardCustom.cpp +++ b/WebCore/bindings/js/JSClipboardCustom.cpp @@ -97,17 +97,6 @@ JSValue JSClipboard::getData(ExecState* exec, const ArgList& args) return jsString(exec, result); } -JSValue JSClipboard::setData(ExecState* exec, const ArgList& args) -{ - Clipboard* clipboard = impl(); - - // FIXME: It does not match the rest of the JS bindings to throw on invalid number of arguments. - if (args.size() != 2) - return throwError(exec, SyntaxError, "setData: Invalid number of arguments"); - - return jsBoolean(clipboard->setData(ustringToString(args.at(0).toString(exec)), ustringToString(args.at(1).toString(exec)))); -} - JSValue JSClipboard::setDragImage(ExecState* exec, const ArgList& args) { Clipboard* clipboard = impl(); diff --git a/WebCore/bindings/js/JSCustomVoidCallback.cpp b/WebCore/bindings/js/JSCustomVoidCallback.cpp index 0edd66f..d5c4ac3 100644 --- a/WebCore/bindings/js/JSCustomVoidCallback.cpp +++ b/WebCore/bindings/js/JSCustomVoidCallback.cpp @@ -42,12 +42,13 @@ using namespace JSC; JSCustomVoidCallback::JSCustomVoidCallback(JSObject* callback, JSDOMGlobalObject* globalObject) : m_data(new JSCallbackData(callback, globalObject)) + , m_scriptExecutionContext(globalObject->scriptExecutionContext()) { } JSCustomVoidCallback::~JSCustomVoidCallback() { - callOnMainThread(JSCallbackData::deleteData, m_data); + m_scriptExecutionContext->postTask(DeleteCallbackDataTask::create(m_data)); #ifndef NDEBUG m_data = 0; #endif diff --git a/WebCore/bindings/js/JSCustomVoidCallback.h b/WebCore/bindings/js/JSCustomVoidCallback.h index 4b8d7ea..8ffee48 100644 --- a/WebCore/bindings/js/JSCustomVoidCallback.h +++ b/WebCore/bindings/js/JSCustomVoidCallback.h @@ -53,6 +53,7 @@ private: JSCustomVoidCallback(JSC::JSObject* callback, JSDOMGlobalObject*); JSCallbackData* m_data; + ScriptExecutionContext* m_scriptExecutionContext; }; } // namespace WebCore diff --git a/WebCore/bindings/js/JSDOMWindowCustom.cpp b/WebCore/bindings/js/JSDOMWindowCustom.cpp index 05ea9b1..656d580 100644 --- a/WebCore/bindings/js/JSDOMWindowCustom.cpp +++ b/WebCore/bindings/js/JSDOMWindowCustom.cpp @@ -58,14 +58,14 @@ #endif #if ENABLE(3D_CANVAS) -#include "JSWebGLArrayBufferConstructor.h" -#include "JSWebGLByteArrayConstructor.h" -#include "JSWebGLUnsignedByteArrayConstructor.h" -#include "JSWebGLIntArrayConstructor.h" -#include "JSWebGLUnsignedIntArrayConstructor.h" -#include "JSWebGLShortArrayConstructor.h" -#include "JSWebGLUnsignedShortArrayConstructor.h" -#include "JSWebGLFloatArrayConstructor.h" +#include "JSArrayBufferConstructor.h" +#include "JSInt8ArrayConstructor.h" +#include "JSUint8ArrayConstructor.h" +#include "JSInt32ArrayConstructor.h" +#include "JSUint32ArrayConstructor.h" +#include "JSInt16ArrayConstructor.h" +#include "JSUint16ArrayConstructor.h" +#include "JSFloatArrayConstructor.h" #endif #include "JSWebKitCSSMatrixConstructor.h" #include "JSWebKitPointConstructor.h" @@ -571,44 +571,86 @@ JSValue JSDOMWindow::webKitCSSMatrix(ExecState* exec) const } #if ENABLE(3D_CANVAS) -JSValue JSDOMWindow::webGLArrayBuffer(ExecState* exec) const +JSValue JSDOMWindow::arrayBuffer(ExecState* exec) const { - return getDOMConstructor<JSWebGLArrayBufferConstructor>(exec, this); + return getDOMConstructor<JSArrayBufferConstructor>(exec, this); } -JSValue JSDOMWindow::webGLByteArray(ExecState* exec) const +JSValue JSDOMWindow::int8Array(ExecState* exec) const { - return getDOMConstructor<JSWebGLByteArrayConstructor>(exec, this); + return getDOMConstructor<JSInt8ArrayConstructor>(exec, this); } -JSValue JSDOMWindow::webGLUnsignedByteArray(ExecState* exec) const +JSValue JSDOMWindow::uint8Array(ExecState* exec) const { - return getDOMConstructor<JSWebGLUnsignedByteArrayConstructor>(exec, this); + return getDOMConstructor<JSUint8ArrayConstructor>(exec, this); } -JSValue JSDOMWindow::webGLIntArray(ExecState* exec) const +JSValue JSDOMWindow::int32Array(ExecState* exec) const { - return getDOMConstructor<JSWebGLIntArrayConstructor>(exec, this); + return getDOMConstructor<JSInt32ArrayConstructor>(exec, this); } -JSValue JSDOMWindow::webGLUnsignedIntArray(ExecState* exec) const +JSValue JSDOMWindow::uint32Array(ExecState* exec) const { - return getDOMConstructor<JSWebGLUnsignedIntArrayConstructor>(exec, this); + return getDOMConstructor<JSUint32ArrayConstructor>(exec, this); } -JSValue JSDOMWindow::webGLShortArray(ExecState* exec) const +JSValue JSDOMWindow::int16Array(ExecState* exec) const { - return getDOMConstructor<JSWebGLShortArrayConstructor>(exec, this); + return getDOMConstructor<JSInt16ArrayConstructor>(exec, this); } -JSValue JSDOMWindow::webGLUnsignedShortArray(ExecState* exec) const +JSValue JSDOMWindow::uint16Array(ExecState* exec) const { - return getDOMConstructor<JSWebGLUnsignedShortArrayConstructor>(exec, this); + return getDOMConstructor<JSUint16ArrayConstructor>(exec, this); } +JSValue JSDOMWindow::floatArray(ExecState* exec) const +{ + return getDOMConstructor<JSFloatArrayConstructor>(exec, this); +} + +// Temporary aliases to keep current WebGL content working during transition period to TypedArray spec. +// To be removed before WebGL spec is finalized. (FIXME) +JSValue JSDOMWindow::webGLArrayBuffer(ExecState* exec) const +{ + return getDOMConstructor<JSArrayBufferConstructor>(exec, this); +} + +JSValue JSDOMWindow::webGLByteArray(ExecState* exec) const +{ + return getDOMConstructor<JSInt8ArrayConstructor>(exec, this); +} + +JSValue JSDOMWindow::webGLUnsignedByteArray(ExecState* exec) const +{ + return getDOMConstructor<JSUint8ArrayConstructor>(exec, this); +} + +JSValue JSDOMWindow::webGLIntArray(ExecState* exec) const +{ + return getDOMConstructor<JSInt32ArrayConstructor>(exec, this); +} + +JSValue JSDOMWindow::webGLUnsignedIntArray(ExecState* exec) const +{ + return getDOMConstructor<JSUint32ArrayConstructor>(exec, this); +} + +JSValue JSDOMWindow::webGLShortArray(ExecState* exec) const +{ + return getDOMConstructor<JSInt16ArrayConstructor>(exec, this); +} + +JSValue JSDOMWindow::webGLUnsignedShortArray(ExecState* exec) const +{ + return getDOMConstructor<JSUint16ArrayConstructor>(exec, this); +} + JSValue JSDOMWindow::webGLFloatArray(ExecState* exec) const { - return getDOMConstructor<JSWebGLFloatArrayConstructor>(exec, this); + return getDOMConstructor<JSFloatArrayConstructor>(exec, this); } #endif @@ -967,18 +1009,40 @@ JSValue JSDOMWindow::removeEventListener(ExecState* exec, const ArgList& args) #if ENABLE(DATABASE) JSValue JSDOMWindow::openDatabase(ExecState* exec, const ArgList& args) { - if (!allowsAccessFrom(exec) || (args.size() < 4)) + if (!allowsAccessFrom(exec) || (args.size() < 4)) { + setDOMException(exec, SYNTAX_ERR); return jsUndefined(); - ExceptionCode ec = 0; - const UString& name = args.at(0).toString(exec); - const UString& version = args.at(1).toString(exec); - const UString& displayName = args.at(2).toString(exec); - unsigned long estimatedSize = args.at(3).toInt32(exec); + } + + String name = ustringToString(args.at(0).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + String version = ustringToString(args.at(1).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + String displayName = ustringToString(args.at(2).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + // args.at(3) = estimated size + unsigned long estimatedSize = args.at(3).toUInt32(exec); + if (exec->hadException()) + return jsUndefined(); + RefPtr<DatabaseCallback> creationCallback; - if ((args.size() >= 5) && args.at(4).isObject()) + if (args.size() >= 5) { + if (!args.at(4).isObject()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return jsUndefined(); + } + creationCallback = JSDatabaseCallback::create(asObject(args.at(4)), globalObject()); + } - JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(ustringToString(name), ustringToString(version), ustringToString(displayName), estimatedSize, creationCallback.release(), ec))); + ExceptionCode ec = 0; + JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec))); setDOMException(exec, ec); return result; diff --git a/WebCore/bindings/js/JSDataGridColumnListCustom.cpp b/WebCore/bindings/js/JSDataGridColumnListCustom.cpp index 9a6982a..5ee790c 100644 --- a/WebCore/bindings/js/JSDataGridColumnListCustom.cpp +++ b/WebCore/bindings/js/JSDataGridColumnListCustom.cpp @@ -40,13 +40,13 @@ namespace WebCore { bool JSDataGridColumnList::canGetItemsForName(ExecState*, DataGridColumnList* impl, const Identifier& propertyName) { - return impl->itemWithName(propertyName); + return impl->itemWithName(identifierToAtomicString(propertyName)); } JSValue JSDataGridColumnList::nameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName) { JSDataGridColumnList* thisObj = static_cast<JSDataGridColumnList*>(asObject(slotBase)); - return toJS(exec, thisObj->globalObject(), thisObj->impl()->itemWithName(propertyName)); + return toJS(exec, thisObj->globalObject(), thisObj->impl()->itemWithName(identifierToAtomicString(propertyName))); } } // namespace WebCore diff --git a/WebCore/bindings/js/JSDatabaseCustom.cpp b/WebCore/bindings/js/JSDatabaseCustom.cpp index ccc5c0d..a86cc18 100644 --- a/WebCore/bindings/js/JSDatabaseCustom.cpp +++ b/WebCore/bindings/js/JSDatabaseCustom.cpp @@ -50,54 +50,62 @@ using namespace JSC; JSValue JSDatabase::changeVersion(ExecState* exec, const ArgList& args) { String oldVersion = ustringToString(args.at(0).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + String newVersion = ustringToString(args.at(1).toString(exec)); + if (exec->hadException()) + return jsUndefined(); - JSObject* object; - if (!(object = args.at(2).getObject())) { + JSObject* object = args.at(2).getObject(); + if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } - - RefPtr<SQLTransactionCallback> callback(JSSQLTransactionCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()))); - + + RefPtr<SQLTransactionCallback> callback(JSSQLTransactionCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject()))); + RefPtr<SQLTransactionErrorCallback> errorCallback; if (!args.at(3).isNull()) { - if (!(object = args.at(3).getObject())) { + object = args.at(3).getObject(); + if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } - - errorCallback = JSSQLTransactionErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); + + errorCallback = JSSQLTransactionErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject())); } - + RefPtr<VoidCallback> successCallback; if (!args.at(4).isNull()) { - if (!(object = args.at(4).getObject())) { + object = args.at(4).getObject(); + if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } - successCallback = JSCustomVoidCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); + successCallback = JSCustomVoidCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject())); } m_impl->changeVersion(oldVersion, newVersion, callback.release(), errorCallback.release(), successCallback.release()); - + return jsUndefined(); } static JSValue createTransaction(ExecState* exec, const ArgList& args, Database* database, JSDOMGlobalObject* globalObject, bool readOnly) { - JSObject* object; - - if (!(object = args.at(0).getObject())) { + JSObject* object = args.at(0).getObject(); + + if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); - } - + } + RefPtr<SQLTransactionCallback> callback(JSSQLTransactionCallback::create(object, globalObject)); RefPtr<SQLTransactionErrorCallback> errorCallback; if (args.size() > 1 && !args.at(1).isNull()) { - if (!(object = args.at(1).getObject())) { + object = args.at(1).getObject(); + if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } @@ -107,26 +115,27 @@ static JSValue createTransaction(ExecState* exec, const ArgList& args, Database* RefPtr<VoidCallback> successCallback; if (args.size() > 2 && !args.at(2).isNull()) { - if (!(object = args.at(2).getObject())) { + object = args.at(2).getObject(); + if (!object) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } successCallback = JSCustomVoidCallback::create(object, globalObject); } - + database->transaction(callback.release(), errorCallback.release(), successCallback.release(), readOnly); return jsUndefined(); } JSValue JSDatabase::transaction(ExecState* exec, const ArgList& args) { - return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()), false); + return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(globalObject()), false); } - + JSValue JSDatabase::readTransaction(ExecState* exec, const ArgList& args) { - return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject()), true); + return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(globalObject()), true); } } diff --git a/WebCore/bindings/js/JSDatabaseSyncCustom.cpp b/WebCore/bindings/js/JSDatabaseSyncCustom.cpp new file mode 100644 index 0000000..272cb83 --- /dev/null +++ b/WebCore/bindings/js/JSDatabaseSyncCustom.cpp @@ -0,0 +1,99 @@ +/* + * 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: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "JSDatabaseSync.h" + +#if ENABLE(DATABASE) + +#include "DatabaseSync.h" +#include "ExceptionCode.h" +#include "JSSQLTransactionSyncCallback.h" +#include "PlatformString.h" +#include "SQLValue.h" +#include <runtime/JSArray.h> + +namespace WebCore { + +using namespace JSC; + +JSValue JSDatabaseSync::changeVersion(ExecState* exec, const ArgList& args) +{ + String oldVersion = ustringToString(args.at(0).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + String newVersion = ustringToString(args.at(1).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + JSObject* object = args.at(2).getObject(); + if (!object) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return jsUndefined(); + } + + RefPtr<SQLTransactionSyncCallback> callback(JSSQLTransactionSyncCallback::create(object, static_cast<JSDOMGlobalObject*>(globalObject()))); + + ExceptionCode ec = 0; + m_impl->changeVersion(oldVersion, newVersion, callback.release(), ec); + setDOMException(exec, ec); + + return jsUndefined(); +} + +static JSValue createTransaction(ExecState* exec, const ArgList& args, DatabaseSync* database, JSDOMGlobalObject* globalObject, bool readOnly) +{ + JSObject* object = args.at(0).getObject(); + if (!object) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return jsUndefined(); + } + + RefPtr<SQLTransactionSyncCallback> callback(JSSQLTransactionSyncCallback::create(object, globalObject)); + + ExceptionCode ec = 0; + database->transaction(callback.release(), readOnly, ec); + setDOMException(exec, ec); + + return jsUndefined(); +} + +JSValue JSDatabaseSync::transaction(ExecState* exec, const ArgList& args) +{ + return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(globalObject()), false); +} + +JSValue JSDatabaseSync::readTransaction(ExecState* exec, const ArgList& args) +{ + return createTransaction(exec, args, m_impl.get(), static_cast<JSDOMGlobalObject*>(globalObject()), true); +} + +} + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/js/JSDocumentCustom.cpp b/WebCore/bindings/js/JSDocumentCustom.cpp index 8abd8ce..7407e86 100644 --- a/WebCore/bindings/js/JSDocumentCustom.cpp +++ b/WebCore/bindings/js/JSDocumentCustom.cpp @@ -56,6 +56,7 @@ void JSDocument::markChildren(MarkStack& markStack) markActiveObjectsForContext(markStack, globalData, document); markDOMObjectWrapper(markStack, globalData, document->implementation()); markDOMObjectWrapper(markStack, globalData, document->styleSheets()); + document->markCachedNodeLists(markStack, globalData); } JSValue JSDocument::location(ExecState* exec) const diff --git a/WebCore/bindings/js/JSEventCustom.cpp b/WebCore/bindings/js/JSEventCustom.cpp index 6686d7a..e5fdbe7 100644 --- a/WebCore/bindings/js/JSEventCustom.cpp +++ b/WebCore/bindings/js/JSEventCustom.cpp @@ -38,6 +38,10 @@ #include "JSCustomEvent.h" #include "JSCompositionEvent.h" #include "JSErrorEvent.h" +#if ENABLE(INDEXED_DATABASE) +#include "JSIDBErrorEvent.h" +#include "JSIDBSuccessEvent.h" +#endif #include "JSKeyboardEvent.h" #include "JSMessageEvent.h" #include "JSMouseEvent.h" @@ -54,6 +58,10 @@ #include "JSXMLHttpRequestProgressEvent.h" #include "BeforeLoadEvent.h" #include "ErrorEvent.h" +#if ENABLE(INDEXED_DATABASE) +#include "IDBErrorEvent.h" +#include "IDBSuccessEvent.h" +#endif #include "KeyboardEvent.h" #include "MessageEvent.h" #include "MouseEvent.h" @@ -145,6 +153,12 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, Event* event) else if (event->isStorageEvent()) wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, StorageEvent, event); #endif +#if ENABLE(INDEXED_DATABASE) + else if (event->isIDBErrorEvent()) + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, IDBErrorEvent, event); + else if (event->isIDBSuccessEvent()) + wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, IDBSuccessEvent, event); +#endif else if (event->isWebKitAnimationEvent()) wrapper = CREATE_DOM_OBJECT_WRAPPER(exec, globalObject, WebKitAnimationEvent, event); else if (event->isWebKitTransitionEvent()) diff --git a/WebCore/bindings/js/JSEventTarget.cpp b/WebCore/bindings/js/JSEventTarget.cpp index 6ea1135..c5fce64 100644 --- a/WebCore/bindings/js/JSEventTarget.cpp +++ b/WebCore/bindings/js/JSEventTarget.cpp @@ -78,11 +78,21 @@ #include "Notification.h" #endif +#if ENABLE(INDEXED_DATABASE) +#include "IDBRequest.h" +#include "JSIDBRequest.h" +#endif + #if ENABLE(WEB_SOCKETS) #include "JSWebSocket.h" #include "WebSocket.h" #endif +#if ENABLE(FILE_READER) +#include "JSFileReader.h" +#include "FileReader.h" +#endif + using namespace JSC; namespace WebCore { @@ -144,11 +154,21 @@ JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, EventTarget* targ return toJS(exec, notification); #endif +#if ENABLE(INDEXED_DATABASE) + if (IDBRequest* idbRequest = target->toIDBRequest()) + return toJS(exec, idbRequest); +#endif + #if ENABLE(WEB_SOCKETS) if (WebSocket* webSocket = target->toWebSocket()) return toJS(exec, webSocket); #endif +#if ENABLE(FILE_READER) + if (FileReader* fileReader = target->toFileReader()) + return toJS(exec, globalObject, fileReader); +#endif + ASSERT_NOT_REACHED(); return jsNull(); } diff --git a/WebCore/bindings/js/JSWebGLFloatArrayConstructor.cpp b/WebCore/bindings/js/JSFloatArrayConstructor.cpp index e6375ac..57374af 100644 --- a/WebCore/bindings/js/JSWebGLFloatArrayConstructor.cpp +++ b/WebCore/bindings/js/JSFloatArrayConstructor.cpp @@ -27,32 +27,32 @@ #if ENABLE(3D_CANVAS) -#include "JSWebGLFloatArrayConstructor.h" +#include "JSFloatArrayConstructor.h" #include "Document.h" -#include "WebGLFloatArray.h" -#include "JSWebGLArrayBuffer.h" -#include "JSWebGLArrayBufferConstructor.h" -#include "JSWebGLFloatArray.h" +#include "FloatArray.h" +#include "JSArrayBuffer.h" +#include "JSArrayBufferConstructor.h" +#include "JSFloatArray.h" #include <runtime/Error.h> namespace WebCore { using namespace JSC; -const ClassInfo JSWebGLFloatArrayConstructor::s_info = { "WebGLFloatArrayConstructor", &JSWebGLArray::s_info, 0, 0 }; +const ClassInfo JSFloatArrayConstructor::s_info = { "FloatArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; -JSWebGLFloatArrayConstructor::JSWebGLFloatArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebGLFloatArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) +JSFloatArrayConstructor::JSFloatArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSFloatArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebGLFloatArrayPrototype::self(exec, globalObject), None); + putDirect(exec->propertyNames().prototype, JSFloatArrayPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); } static JSObject* constructCanvasFloatArray(ExecState* exec, JSObject* constructor, const ArgList& args) { - JSWebGLFloatArrayConstructor* jsConstructor = static_cast<JSWebGLFloatArrayConstructor*>(constructor); - RefPtr<WebGLFloatArray> array = static_cast<WebGLFloatArray*>(construct<WebGLFloatArray, float>(exec, args).get()); + JSFloatArrayConstructor* jsConstructor = static_cast<JSFloatArrayConstructor*>(constructor); + RefPtr<FloatArray> array = static_cast<FloatArray*>(construct<FloatArray, float>(exec, args).get()); if (!array.get()) { setDOMException(exec, INDEX_SIZE_ERR); return 0; @@ -60,7 +60,7 @@ static JSObject* constructCanvasFloatArray(ExecState* exec, JSObject* constructo return asObject(toJS(exec, jsConstructor->globalObject(), array.get())); } -JSC::ConstructType JSWebGLFloatArrayConstructor::getConstructData(JSC::ConstructData& constructData) +JSC::ConstructType JSFloatArrayConstructor::getConstructData(JSC::ConstructData& constructData) { constructData.native.function = constructCanvasFloatArray; return ConstructTypeHost; diff --git a/WebCore/bindings/js/JSWebGLIntArrayConstructor.h b/WebCore/bindings/js/JSFloatArrayConstructor.h index d42c046..6d2dae7 100644 --- a/WebCore/bindings/js/JSWebGLIntArrayConstructor.h +++ b/WebCore/bindings/js/JSFloatArrayConstructor.h @@ -23,17 +23,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSWebGLIntArrayConstructor_h -#define JSWebGLIntArrayConstructor_h +#ifndef JSFloatArrayConstructor_h +#define JSFloatArrayConstructor_h #include "JSDOMBinding.h" #include "JSDocument.h" namespace WebCore { - class JSWebGLIntArrayConstructor : public DOMConstructorObject { + class JSFloatArrayConstructor : public DOMConstructorObject { public: - JSWebGLIntArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); + JSFloatArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); static const JSC::ClassInfo s_info; private: @@ -43,4 +43,4 @@ namespace WebCore { } -#endif // JSWebGLIntArrayConstructor_h +#endif // JSFloatArrayConstructor_h diff --git a/WebCore/bindings/js/JSFloatArrayCustom.cpp b/WebCore/bindings/js/JSFloatArrayCustom.cpp new file mode 100644 index 0000000..9e52762 --- /dev/null +++ b/WebCore/bindings/js/JSFloatArrayCustom.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSArrayBufferViewHelper.h" +#include "JSFloatArray.h" + +#include "FloatArray.h" + +using namespace JSC; + +namespace WebCore { + +void JSFloatArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast<float>(value.toNumber(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, FloatArray* object) +{ + return getDOMObjectWrapper<JSFloatArray>(exec, globalObject, object); +} + +JSC::JSValue JSFloatArray::set(JSC::ExecState* exec, JSC::ArgList const& args) +{ + return setWebGLArrayHelper(exec, impl(), args, toFloatArray); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp b/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp index 89f62f8..419f9e9 100644 --- a/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp +++ b/WebCore/bindings/js/JSHTMLCanvasElementCustom.cpp @@ -78,7 +78,10 @@ JSValue JSHTMLCanvasElement::getContext(ExecState* exec, const ArgList& args) } } #endif - return toJS(exec, globalObject(), WTF::getPtr(canvas->getContext(ustringToString(contextId), attrs.get()))); + CanvasRenderingContext* context = canvas->getContext(ustringToString(contextId), attrs.get()); + if (!context) + return jsNull(); + return toJS(exec, globalObject(), WTF::getPtr(context)); } } // namespace WebCore diff --git a/WebCore/bindings/js/JSIDBAnyCustom.cpp b/WebCore/bindings/js/JSIDBAnyCustom.cpp new file mode 100644 index 0000000..f7674b8 --- /dev/null +++ b/WebCore/bindings/js/JSIDBAnyCustom.cpp @@ -0,0 +1,70 @@ +/* + * 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 "JSIDBAny.h" + +#include "IDBAny.h" +#include "IDBDatabaseRequest.h" +#include "IndexedDatabaseRequest.h" +#include "JSIDBDatabaseRequest.h" +#include "JSIndexedDatabaseRequest.h" +#include "SerializedScriptValue.h" + +using namespace JSC; + +namespace WebCore { + +JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, IDBAny* idbAny) +{ + if (!idbAny) + return jsNull(); + + switch (idbAny->type()) { + case IDBAny::UndefinedType: + return jsUndefined(); + case IDBAny::IDBDatabaseRequestType: + return toJS(exec, globalObject, idbAny->idbDatabaseRequest()); + case IDBAny::IndexedDatabaseRequestType: + return toJS(exec, globalObject, idbAny->indexedDatabaseRequest()); + case IDBAny::SerializedScriptValueType: + return idbAny->serializedScriptValue()->deserialize(exec, globalObject); + } + + ASSERT_NOT_REACHED(); + return jsUndefined(); +} + +} // namespace WebCore + +#endif // ENABLE(INDEXED_DATABASE) diff --git a/WebCore/bindings/js/JSWebGLShortArrayConstructor.cpp b/WebCore/bindings/js/JSInt16ArrayConstructor.cpp index a33779b..c8f725f 100644 --- a/WebCore/bindings/js/JSWebGLShortArrayConstructor.cpp +++ b/WebCore/bindings/js/JSInt16ArrayConstructor.cpp @@ -27,33 +27,33 @@ #if ENABLE(3D_CANVAS) -#include "JSWebGLShortArrayConstructor.h" +#include "JSInt16ArrayConstructor.h" #include "Document.h" -#include "WebGLShortArray.h" -#include "JSWebGLArray.h" -#include "JSWebGLArrayBuffer.h" -#include "JSWebGLArrayBufferConstructor.h" -#include "JSWebGLShortArray.h" +#include "Int16Array.h" +#include "JSArrayBufferView.h" +#include "JSArrayBuffer.h" +#include "JSArrayBufferConstructor.h" +#include "JSInt16Array.h" #include <runtime/Error.h> namespace WebCore { using namespace JSC; -const ClassInfo JSWebGLShortArrayConstructor::s_info = { "WebGLShortArrayConstructor", &JSWebGLArray::s_info, 0, 0 }; +const ClassInfo JSInt16ArrayConstructor::s_info = { "Int16ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; -JSWebGLShortArrayConstructor::JSWebGLShortArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebGLShortArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) +JSInt16ArrayConstructor::JSInt16ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSInt16ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebGLShortArrayPrototype::self(exec, globalObject), None); + putDirect(exec->propertyNames().prototype, JSInt16ArrayPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); } static JSObject* constructCanvasShortArray(ExecState* exec, JSObject* constructor, const ArgList& args) { - JSWebGLShortArrayConstructor* jsConstructor = static_cast<JSWebGLShortArrayConstructor*>(constructor); - RefPtr<WebGLShortArray> array = static_cast<WebGLShortArray*>(construct<WebGLShortArray, short>(exec, args).get()); + JSInt16ArrayConstructor* jsConstructor = static_cast<JSInt16ArrayConstructor*>(constructor); + RefPtr<Int16Array> array = static_cast<Int16Array*>(construct<Int16Array, short>(exec, args).get()); if (!array.get()) { setDOMException(exec, INDEX_SIZE_ERR); return 0; @@ -61,7 +61,7 @@ static JSObject* constructCanvasShortArray(ExecState* exec, JSObject* constructo return asObject(toJS(exec, jsConstructor->globalObject(), array.get())); } -JSC::ConstructType JSWebGLShortArrayConstructor::getConstructData(JSC::ConstructData& constructData) +JSC::ConstructType JSInt16ArrayConstructor::getConstructData(JSC::ConstructData& constructData) { constructData.native.function = constructCanvasShortArray; return ConstructTypeHost; diff --git a/WebCore/bindings/js/JSWebGLByteArrayConstructor.h b/WebCore/bindings/js/JSInt16ArrayConstructor.h index a201567..fb132e3 100644 --- a/WebCore/bindings/js/JSWebGLByteArrayConstructor.h +++ b/WebCore/bindings/js/JSInt16ArrayConstructor.h @@ -23,17 +23,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSWebGLByteArrayConstructor_h -#define JSWebGLByteArrayConstructor_h +#ifndef JSInt16ArrayConstructor_h +#define JSInt16ArrayConstructor_h #include "JSDOMBinding.h" #include "JSDocument.h" namespace WebCore { - class JSWebGLByteArrayConstructor : public DOMConstructorObject { + class JSInt16ArrayConstructor : public DOMConstructorObject { public: - JSWebGLByteArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); + JSInt16ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); static const JSC::ClassInfo s_info; private: @@ -43,4 +43,4 @@ namespace WebCore { } -#endif // JSWebGLByteArrayConstructor_h +#endif // JSInt16ArrayConstructor_h diff --git a/WebCore/bindings/js/JSInt16ArrayCustom.cpp b/WebCore/bindings/js/JSInt16ArrayCustom.cpp new file mode 100644 index 0000000..d557c3d --- /dev/null +++ b/WebCore/bindings/js/JSInt16ArrayCustom.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSArrayBufferViewHelper.h" +#include "JSInt16Array.h" + +#include "Int16Array.h" + +using namespace JSC; + +namespace WebCore { + +void JSInt16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast<signed short>(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int16Array* object) +{ + return getDOMObjectWrapper<JSInt16Array>(exec, globalObject, object); +} + +JSC::JSValue JSInt16Array::set(JSC::ExecState* exec, JSC::ArgList const& args) +{ + return setWebGLArrayHelper(exec, impl(), args, toInt16Array); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLIntArrayConstructor.cpp b/WebCore/bindings/js/JSInt32ArrayConstructor.cpp index 5b14803..5f79f1f 100644 --- a/WebCore/bindings/js/JSWebGLIntArrayConstructor.cpp +++ b/WebCore/bindings/js/JSInt32ArrayConstructor.cpp @@ -27,32 +27,32 @@ #if ENABLE(3D_CANVAS) -#include "JSWebGLIntArrayConstructor.h" +#include "JSInt32ArrayConstructor.h" #include "Document.h" -#include "WebGLIntArray.h" -#include "JSWebGLArrayBuffer.h" -#include "JSWebGLArrayBufferConstructor.h" -#include "JSWebGLIntArray.h" +#include "Int32Array.h" +#include "JSArrayBuffer.h" +#include "JSArrayBufferConstructor.h" +#include "JSInt32Array.h" #include <runtime/Error.h> namespace WebCore { using namespace JSC; -const ClassInfo JSWebGLIntArrayConstructor::s_info = { "WebGLIntArrayConstructor", &JSWebGLArray::s_info, 0, 0 }; +const ClassInfo JSInt32ArrayConstructor::s_info = { "Int32ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; -JSWebGLIntArrayConstructor::JSWebGLIntArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebGLIntArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) +JSInt32ArrayConstructor::JSInt32ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSInt32ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebGLIntArrayPrototype::self(exec, globalObject), None); + putDirect(exec->propertyNames().prototype, JSInt32ArrayPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); } static JSObject* constructCanvasIntArray(ExecState* exec, JSObject* constructor, const ArgList& args) { - JSWebGLIntArrayConstructor* jsConstructor = static_cast<JSWebGLIntArrayConstructor*>(constructor); - RefPtr<WebGLIntArray> array = static_cast<WebGLIntArray*>(construct<WebGLIntArray, int>(exec, args).get()); + JSInt32ArrayConstructor* jsConstructor = static_cast<JSInt32ArrayConstructor*>(constructor); + RefPtr<Int32Array> array = static_cast<Int32Array*>(construct<Int32Array, int>(exec, args).get()); if (!array.get()) { setDOMException(exec, INDEX_SIZE_ERR); return 0; @@ -60,7 +60,7 @@ static JSObject* constructCanvasIntArray(ExecState* exec, JSObject* constructor, return asObject(toJS(exec, jsConstructor->globalObject(), array.get())); } -JSC::ConstructType JSWebGLIntArrayConstructor::getConstructData(JSC::ConstructData& constructData) +JSC::ConstructType JSInt32ArrayConstructor::getConstructData(JSC::ConstructData& constructData) { constructData.native.function = constructCanvasIntArray; return ConstructTypeHost; diff --git a/WebCore/bindings/js/JSWebGLFloatArrayConstructor.h b/WebCore/bindings/js/JSInt32ArrayConstructor.h index faf90ff..f15358c 100644 --- a/WebCore/bindings/js/JSWebGLFloatArrayConstructor.h +++ b/WebCore/bindings/js/JSInt32ArrayConstructor.h @@ -23,17 +23,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSWebGLFloatArrayConstructor_h -#define JSWebGLFloatArrayConstructor_h +#ifndef JSInt32ArrayConstructor_h +#define JSInt32ArrayConstructor_h #include "JSDOMBinding.h" #include "JSDocument.h" namespace WebCore { - class JSWebGLFloatArrayConstructor : public DOMConstructorObject { + class JSInt32ArrayConstructor : public DOMConstructorObject { public: - JSWebGLFloatArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); + JSInt32ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); static const JSC::ClassInfo s_info; private: @@ -43,4 +43,4 @@ namespace WebCore { } -#endif // JSWebGLFloatArrayConstructor_h +#endif // JSInt32ArrayConstructor_h diff --git a/WebCore/bindings/js/JSInt32ArrayCustom.cpp b/WebCore/bindings/js/JSInt32ArrayCustom.cpp new file mode 100644 index 0000000..3d0ca79 --- /dev/null +++ b/WebCore/bindings/js/JSInt32ArrayCustom.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSArrayBufferViewHelper.h" +#include "JSInt32Array.h" + +#include "Int32Array.h" + +using namespace JSC; + +namespace WebCore { + +void JSInt32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast<signed int>(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int32Array* object) +{ + return getDOMObjectWrapper<JSInt32Array>(exec, globalObject, object); +} + +JSC::JSValue JSInt32Array::set(JSC::ExecState* exec, JSC::ArgList const& args) +{ + return setWebGLArrayHelper(exec, impl(), args, toInt32Array); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLByteArrayConstructor.cpp b/WebCore/bindings/js/JSInt8ArrayConstructor.cpp index f76fb1d..ad922fe 100644 --- a/WebCore/bindings/js/JSWebGLByteArrayConstructor.cpp +++ b/WebCore/bindings/js/JSInt8ArrayConstructor.cpp @@ -27,32 +27,32 @@ #if ENABLE(3D_CANVAS) -#include "JSWebGLByteArrayConstructor.h" +#include "JSInt8ArrayConstructor.h" #include "Document.h" -#include "WebGLByteArray.h" -#include "JSWebGLArrayBuffer.h" -#include "JSWebGLArrayBufferConstructor.h" -#include "JSWebGLByteArray.h" +#include "Int8Array.h" +#include "JSArrayBuffer.h" +#include "JSArrayBufferConstructor.h" +#include "JSInt8Array.h" #include <runtime/Error.h> namespace WebCore { using namespace JSC; -const ClassInfo JSWebGLByteArrayConstructor::s_info = { "WebGLByteArrayConstructor", &JSWebGLArray::s_info, 0, 0 }; +const ClassInfo JSInt8ArrayConstructor::s_info = { "Int8ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; -JSWebGLByteArrayConstructor::JSWebGLByteArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebGLByteArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) +JSInt8ArrayConstructor::JSInt8ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSInt8ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebGLByteArrayPrototype::self(exec, globalObject), None); + putDirect(exec->propertyNames().prototype, JSInt8ArrayPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); } static JSObject* constructCanvasByteArray(ExecState* exec, JSObject* constructor, const ArgList& args) { - JSWebGLByteArrayConstructor* jsConstructor = static_cast<JSWebGLByteArrayConstructor*>(constructor); - RefPtr<WebGLByteArray> array = static_cast<WebGLByteArray*>(construct<WebGLByteArray, signed char>(exec, args).get()); + JSInt8ArrayConstructor* jsConstructor = static_cast<JSInt8ArrayConstructor*>(constructor); + RefPtr<Int8Array> array = static_cast<Int8Array*>(construct<Int8Array, signed char>(exec, args).get()); if (!array.get()) { setDOMException(exec, INDEX_SIZE_ERR); return 0; @@ -60,7 +60,7 @@ static JSObject* constructCanvasByteArray(ExecState* exec, JSObject* constructor return asObject(toJS(exec, jsConstructor->globalObject(), array.get())); } -JSC::ConstructType JSWebGLByteArrayConstructor::getConstructData(JSC::ConstructData& constructData) +JSC::ConstructType JSInt8ArrayConstructor::getConstructData(JSC::ConstructData& constructData) { constructData.native.function = constructCanvasByteArray; return ConstructTypeHost; diff --git a/WebCore/bindings/js/JSWebGLShortArrayConstructor.h b/WebCore/bindings/js/JSInt8ArrayConstructor.h index 7807a13..4a9bd3a 100644 --- a/WebCore/bindings/js/JSWebGLShortArrayConstructor.h +++ b/WebCore/bindings/js/JSInt8ArrayConstructor.h @@ -23,17 +23,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef JSWebGLShortArrayConstructor_h -#define JSWebGLShortArrayConstructor_h +#ifndef JSInt8ArrayConstructor_h +#define JSInt8ArrayConstructor_h #include "JSDOMBinding.h" #include "JSDocument.h" namespace WebCore { - class JSWebGLShortArrayConstructor : public DOMConstructorObject { + class JSInt8ArrayConstructor : public DOMConstructorObject { public: - JSWebGLShortArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); + JSInt8ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); static const JSC::ClassInfo s_info; private: @@ -43,4 +43,4 @@ namespace WebCore { } -#endif // JSWebGLShortArrayConstructor_h +#endif // JSInt8ArrayConstructor_h diff --git a/WebCore/bindings/js/JSInt8ArrayCustom.cpp b/WebCore/bindings/js/JSInt8ArrayCustom.cpp new file mode 100644 index 0000000..3c94002 --- /dev/null +++ b/WebCore/bindings/js/JSInt8ArrayCustom.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSArrayBufferViewHelper.h" +#include "JSInt8Array.h" + +#include "Int8Array.h" + +#include <runtime/Error.h> + +using namespace JSC; + +namespace WebCore { + +void JSInt8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast<signed char>(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Int8Array* object) +{ + return getDOMObjectWrapper<JSInt8Array>(exec, globalObject, object); +} + +JSC::JSValue JSInt8Array::set(JSC::ExecState* exec, JSC::ArgList const& args) +{ + return setWebGLArrayHelper(exec, impl(), args, toInt8Array); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSNodeCustom.cpp b/WebCore/bindings/js/JSNodeCustom.cpp index 6d61037..9fbcffd 100644 --- a/WebCore/bindings/js/JSNodeCustom.cpp +++ b/WebCore/bindings/js/JSNodeCustom.cpp @@ -179,7 +179,6 @@ void JSNode::markChildren(MarkStack& markStack) Node* node = m_impl.get(); node->markJSEventListeners(markStack); - node->markCachedNodeLists(markStack, *Heap::heap(this)->globalData()); // Nodes in the document are kept alive by JSDocument::mark, so, if we're in // the document, we need to mark the document, but we don't need to explicitly diff --git a/WebCore/bindings/js/JSSQLTransactionCustom.cpp b/WebCore/bindings/js/JSSQLTransactionCustom.cpp index 802a384..13cc0bc 100644 --- a/WebCore/bindings/js/JSSQLTransactionCustom.cpp +++ b/WebCore/bindings/js/JSSQLTransactionCustom.cpp @@ -41,7 +41,7 @@ using namespace JSC; namespace WebCore { - + JSValue JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) { if (args.isEmpty()) { @@ -68,13 +68,13 @@ JSValue JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) unsigned length = lengthValue.toUInt32(exec); if (exec->hadException()) return jsUndefined(); - + for (unsigned i = 0 ; i < length; ++i) { JSValue value = object->get(exec, i); if (exec->hadException()) return jsUndefined(); - - if (value.isNull()) + + if (value.isUndefinedOrNull()) sqlValues.append(SQLValue()); else if (value.isNumber()) sqlValues.append(value.uncheckedGetNumber()); @@ -94,10 +94,10 @@ JSValue JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } - + callback = JSSQLStatementCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); } - + RefPtr<SQLStatementErrorCallback> errorCallback; if (!args.at(3).isUndefinedOrNull()) { JSObject* object = args.at(3).getObject(); @@ -105,14 +105,14 @@ JSValue JSSQLTransaction::executeSql(ExecState* exec, const ArgList& args) setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } - + errorCallback = JSSQLStatementErrorCallback::create(object, static_cast<JSDOMGlobalObject*>(exec->dynamicGlobalObject())); } - + ExceptionCode ec = 0; m_impl->executeSQL(sqlStatement, sqlValues, callback.release(), errorCallback.release(), ec); setDOMException(exec, ec); - + return jsUndefined(); } diff --git a/WebCore/bindings/js/JSSQLTransactionSyncCustom.cpp b/WebCore/bindings/js/JSSQLTransactionSyncCustom.cpp new file mode 100644 index 0000000..69fc6cf --- /dev/null +++ b/WebCore/bindings/js/JSSQLTransactionSyncCustom.cpp @@ -0,0 +1,98 @@ +/* + * 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: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * 3. Neither the name of Apple Computer, Inc. ("Apple") 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 APPLE AND ITS 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 APPLE OR ITS 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 "JSSQLTransactionSync.h" + +#if ENABLE(DATABASE) + +#include "ExceptionCode.h" +#include "JSSQLResultSet.h" +#include "SQLResultSet.h" +#include "SQLTransactionSync.h" +#include "SQLValue.h" + +using namespace JSC; + +namespace WebCore { + +JSValue JSSQLTransactionSync::executeSql(ExecState* exec, const ArgList& args) +{ + if (args.isEmpty()) { + setDOMException(exec, SYNTAX_ERR); + return jsUndefined(); + } + + String sqlStatement = ustringToString(args.at(0).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + // Now assemble the list of SQL arguments + Vector<SQLValue> sqlValues; + if (!args.at(1).isUndefinedOrNull()) { + JSObject* object = args.at(1).getObject(); + if (!object) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return jsUndefined(); + } + + JSValue lengthValue = object->get(exec, exec->propertyNames().length); + if (exec->hadException()) + return jsUndefined(); + unsigned length = lengthValue.toUInt32(exec); + if (exec->hadException()) + return jsUndefined(); + + for (unsigned i = 0 ; i < length; ++i) { + JSValue value = object->get(exec, i); + if (exec->hadException()) + return jsUndefined(); + + if (value.isUndefinedOrNull()) + sqlValues.append(SQLValue()); + else if (value.isNumber()) + sqlValues.append(value.uncheckedGetNumber()); + else { + // Convert the argument to a string and append it + sqlValues.append(ustringToString(value.toString(exec))); + if (exec->hadException()) + return jsUndefined(); + } + } + } + + ExceptionCode ec = 0; + JSValue result = toJS(exec, globalObject(), WTF::getPtr(m_impl->executeSQL(sqlStatement, sqlValues, ec))); + setDOMException(exec, ec); + + return result; +} + +} + +#endif // ENABLE(DATABASE) diff --git a/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp b/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp index ccf5ccd..dec4be0 100644 --- a/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp +++ b/WebCore/bindings/js/JSSVGElementInstanceCustom.cpp @@ -25,20 +25,14 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "JSSVGElementInstance.h" -#include "JSDOMWindow.h" -#include "JSEventListener.h" -#include "JSSVGElement.h" +#if ENABLE(SVG) #include "SVGElementInstance.h" -using namespace JSC; - namespace WebCore { -void JSSVGElementInstance::markChildren(MarkStack& markStack) +void JSSVGElementInstance::markChildren(JSC::MarkStack& markStack) { Base::markChildren(markStack); @@ -46,21 +40,6 @@ void JSSVGElementInstance::markChildren(MarkStack& markStack) markDOMNodeWrapper(markStack, impl()->correspondingElement()->document(), impl()->correspondingElement()); } -void JSSVGElementInstance::pushEventHandlerScope(ExecState*, ScopeChain&) const -{ -} - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, SVGElementInstance* object) -{ - JSValue result = getDOMObjectWrapper<JSSVGElementInstance>(exec, globalObject, object); - - // Ensure that our corresponding element has a JavaScript wrapper to keep its event handlers alive. - if (object) - toJS(exec, object->correspondingElement()); - - return result; -} - } // namespace WebCore #endif // ENABLE(SVG) diff --git a/WebCore/bindings/js/JSWebGLUnsignedShortArrayConstructor.cpp b/WebCore/bindings/js/JSUint16ArrayConstructor.cpp index d8c2cfb..243c3a1 100644 --- a/WebCore/bindings/js/JSWebGLUnsignedShortArrayConstructor.cpp +++ b/WebCore/bindings/js/JSUint16ArrayConstructor.cpp @@ -27,32 +27,32 @@ #if ENABLE(3D_CANVAS) -#include "JSWebGLUnsignedShortArrayConstructor.h" +#include "JSUint16ArrayConstructor.h" #include "Document.h" -#include "WebGLUnsignedShortArray.h" -#include "JSWebGLArrayBuffer.h" -#include "JSWebGLArrayBufferConstructor.h" -#include "JSWebGLUnsignedShortArray.h" +#include "Uint16Array.h" +#include "JSArrayBuffer.h" +#include "JSArrayBufferConstructor.h" +#include "JSUint16Array.h" #include <runtime/Error.h> namespace WebCore { using namespace JSC; -const ClassInfo JSWebGLUnsignedShortArrayConstructor::s_info = { "WebGLUnsignedShortArrayConstructor", &JSWebGLArray::s_info, 0, 0 }; +const ClassInfo JSUint16ArrayConstructor::s_info = { "Uint16ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; -JSWebGLUnsignedShortArrayConstructor::JSWebGLUnsignedShortArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebGLUnsignedShortArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) +JSUint16ArrayConstructor::JSUint16ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSUint16ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebGLUnsignedShortArrayPrototype::self(exec, globalObject), None); + putDirect(exec->propertyNames().prototype, JSUint16ArrayPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); } static JSObject* constructCanvasUnsignedShortArray(ExecState* exec, JSObject* constructor, const ArgList& args) { - JSWebGLUnsignedShortArrayConstructor* jsConstructor = static_cast<JSWebGLUnsignedShortArrayConstructor*>(constructor); - RefPtr<WebGLUnsignedShortArray> array = static_cast<WebGLUnsignedShortArray*>(construct<WebGLUnsignedShortArray, unsigned short>(exec, args).get()); + JSUint16ArrayConstructor* jsConstructor = static_cast<JSUint16ArrayConstructor*>(constructor); + RefPtr<Uint16Array> array = static_cast<Uint16Array*>(construct<Uint16Array, unsigned short>(exec, args).get()); if (!array.get()) { setDOMException(exec, INDEX_SIZE_ERR); return 0; @@ -60,7 +60,7 @@ static JSObject* constructCanvasUnsignedShortArray(ExecState* exec, JSObject* co return asObject(toJS(exec, jsConstructor->globalObject(), array.get())); } -JSC::ConstructType JSWebGLUnsignedShortArrayConstructor::getConstructData(JSC::ConstructData& constructData) +JSC::ConstructType JSUint16ArrayConstructor::getConstructData(JSC::ConstructData& constructData) { constructData.native.function = constructCanvasUnsignedShortArray; return ConstructTypeHost; diff --git a/WebCore/bindings/js/JSUint16ArrayConstructor.h b/WebCore/bindings/js/JSUint16ArrayConstructor.h new file mode 100644 index 0000000..a146d00 --- /dev/null +++ b/WebCore/bindings/js/JSUint16ArrayConstructor.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 JSUint16ArrayConstructor_h +#define JSUint16ArrayConstructor_h + +#include "JSDOMBinding.h" +#include "JSDocument.h" + +namespace WebCore { + + class JSUint16ArrayConstructor : public DOMConstructorObject { + public: + JSUint16ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); + static const JSC::ClassInfo s_info; + + private: + virtual JSC::ConstructType getConstructData(JSC::ConstructData&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + }; + +} + +#endif // JSUint16ArrayConstructor_h diff --git a/WebCore/bindings/js/JSUint16ArrayCustom.cpp b/WebCore/bindings/js/JSUint16ArrayCustom.cpp new file mode 100644 index 0000000..bac5220 --- /dev/null +++ b/WebCore/bindings/js/JSUint16ArrayCustom.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSArrayBufferViewHelper.h" +#include "JSUint16Array.h" + +#include "Uint16Array.h" + +using namespace JSC; + +namespace WebCore { + +void JSUint16Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast<unsigned short>(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint16Array* object) +{ + return getDOMObjectWrapper<JSUint16Array>(exec, globalObject, object); +} + +JSC::JSValue JSUint16Array::set(JSC::ExecState* exec, JSC::ArgList const& args) +{ + return setWebGLArrayHelper(exec, impl(), args, toUint16Array); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLUnsignedIntArrayConstructor.cpp b/WebCore/bindings/js/JSUint32ArrayConstructor.cpp index 23fccce..b03f093 100644 --- a/WebCore/bindings/js/JSWebGLUnsignedIntArrayConstructor.cpp +++ b/WebCore/bindings/js/JSUint32ArrayConstructor.cpp @@ -27,32 +27,32 @@ #if ENABLE(3D_CANVAS) -#include "JSWebGLUnsignedIntArrayConstructor.h" +#include "JSUint32ArrayConstructor.h" #include "Document.h" -#include "WebGLUnsignedIntArray.h" -#include "JSWebGLArrayBuffer.h" -#include "JSWebGLArrayBufferConstructor.h" -#include "JSWebGLUnsignedIntArray.h" +#include "Uint32Array.h" +#include "JSArrayBuffer.h" +#include "JSArrayBufferConstructor.h" +#include "JSUint32Array.h" #include <runtime/Error.h> namespace WebCore { using namespace JSC; -const ClassInfo JSWebGLUnsignedIntArrayConstructor::s_info = { "WebGLUnsignedIntArrayConstructor", &JSWebGLArray::s_info, 0, 0 }; +const ClassInfo JSUint32ArrayConstructor::s_info = { "Uint32ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; -JSWebGLUnsignedIntArrayConstructor::JSWebGLUnsignedIntArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebGLUnsignedIntArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) +JSUint32ArrayConstructor::JSUint32ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSUint32ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebGLUnsignedIntArrayPrototype::self(exec, globalObject), None); + putDirect(exec->propertyNames().prototype, JSUint32ArrayPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); } static JSObject* constructCanvasUnsignedIntArray(ExecState* exec, JSObject* constructor, const ArgList& args) { - JSWebGLUnsignedIntArrayConstructor* jsConstructor = static_cast<JSWebGLUnsignedIntArrayConstructor*>(constructor); - RefPtr<WebGLUnsignedIntArray> array = static_cast<WebGLUnsignedIntArray*>(construct<WebGLUnsignedIntArray, unsigned int>(exec, args).get()); + JSUint32ArrayConstructor* jsConstructor = static_cast<JSUint32ArrayConstructor*>(constructor); + RefPtr<Uint32Array> array = static_cast<Uint32Array*>(construct<Uint32Array, unsigned int>(exec, args).get()); if (!array.get()) { setDOMException(exec, INDEX_SIZE_ERR); return 0; @@ -60,7 +60,7 @@ static JSObject* constructCanvasUnsignedIntArray(ExecState* exec, JSObject* cons return asObject(toJS(exec, jsConstructor->globalObject(), array.get())); } -JSC::ConstructType JSWebGLUnsignedIntArrayConstructor::getConstructData(JSC::ConstructData& constructData) +JSC::ConstructType JSUint32ArrayConstructor::getConstructData(JSC::ConstructData& constructData) { constructData.native.function = constructCanvasUnsignedIntArray; return ConstructTypeHost; diff --git a/WebCore/bindings/js/JSUint32ArrayConstructor.h b/WebCore/bindings/js/JSUint32ArrayConstructor.h new file mode 100644 index 0000000..a00c071 --- /dev/null +++ b/WebCore/bindings/js/JSUint32ArrayConstructor.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 JSUint32ArrayConstructor_h +#define JSUint32ArrayConstructor_h + +#include "JSDOMBinding.h" +#include "JSDocument.h" + +namespace WebCore { + + class JSUint32ArrayConstructor : public DOMConstructorObject { + public: + JSUint32ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); + static const JSC::ClassInfo s_info; + + private: + virtual JSC::ConstructType getConstructData(JSC::ConstructData&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + }; + +} + +#endif // JSUint32ArrayConstructor_h diff --git a/WebCore/bindings/js/JSUint32ArrayCustom.cpp b/WebCore/bindings/js/JSUint32ArrayCustom.cpp new file mode 100644 index 0000000..926079d --- /dev/null +++ b/WebCore/bindings/js/JSUint32ArrayCustom.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSArrayBufferViewHelper.h" +#include "JSUint32Array.h" + +#include "Uint32Array.h" + +using namespace JSC; + +namespace WebCore { + +void JSUint32Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast<unsigned int>(value.toUInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint32Array* object) +{ + return getDOMObjectWrapper<JSUint32Array>(exec, globalObject, object); +} + +JSC::JSValue JSUint32Array::set(JSC::ExecState* exec, JSC::ArgList const& args) +{ + return setWebGLArrayHelper(exec, impl(), args, toUint32Array); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLUnsignedByteArrayConstructor.cpp b/WebCore/bindings/js/JSUint8ArrayConstructor.cpp index dcb940e..531b860 100644 --- a/WebCore/bindings/js/JSWebGLUnsignedByteArrayConstructor.cpp +++ b/WebCore/bindings/js/JSUint8ArrayConstructor.cpp @@ -27,33 +27,33 @@ #if ENABLE(3D_CANVAS) -#include "JSWebGLUnsignedByteArrayConstructor.h" +#include "JSUint8ArrayConstructor.h" #include "Document.h" #include "ExceptionCode.h" -#include "WebGLUnsignedByteArray.h" -#include "JSWebGLArrayBuffer.h" -#include "JSWebGLArrayBufferConstructor.h" -#include "JSWebGLUnsignedByteArray.h" +#include "Uint8Array.h" +#include "JSArrayBuffer.h" +#include "JSArrayBufferConstructor.h" +#include "JSUint8Array.h" #include <runtime/Error.h> namespace WebCore { using namespace JSC; -const ClassInfo JSWebGLUnsignedByteArrayConstructor::s_info = { "WebGLUnsignedByteArrayConstructor", &JSWebGLArray::s_info, 0, 0 }; +const ClassInfo JSUint8ArrayConstructor::s_info = { "Uint8ArrayConstructor", &JSArrayBufferView::s_info, 0, 0 }; -JSWebGLUnsignedByteArrayConstructor::JSWebGLUnsignedByteArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) - : DOMConstructorObject(JSWebGLUnsignedByteArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) +JSUint8ArrayConstructor::JSUint8ArrayConstructor(ExecState* exec, JSDOMGlobalObject* globalObject) + : DOMConstructorObject(JSUint8ArrayConstructor::createStructure(globalObject->objectPrototype()), globalObject) { - putDirect(exec->propertyNames().prototype, JSWebGLUnsignedByteArrayPrototype::self(exec, globalObject), None); + putDirect(exec->propertyNames().prototype, JSUint8ArrayPrototype::self(exec, globalObject), None); putDirect(exec->propertyNames().length, jsNumber(exec, 2), ReadOnly|DontDelete|DontEnum); } static JSObject* constructCanvasUnsignedByteArray(ExecState* exec, JSObject* constructor, const ArgList& args) { - JSWebGLUnsignedByteArrayConstructor* jsConstructor = static_cast<JSWebGLUnsignedByteArrayConstructor*>(constructor); - RefPtr<WebGLUnsignedByteArray> array = static_cast<WebGLUnsignedByteArray*>(construct<WebGLUnsignedByteArray, unsigned char>(exec, args).get()); + JSUint8ArrayConstructor* jsConstructor = static_cast<JSUint8ArrayConstructor*>(constructor); + RefPtr<Uint8Array> array = static_cast<Uint8Array*>(construct<Uint8Array, unsigned char>(exec, args).get()); if (!array.get()) { setDOMException(exec, INDEX_SIZE_ERR); return 0; @@ -61,7 +61,7 @@ static JSObject* constructCanvasUnsignedByteArray(ExecState* exec, JSObject* con return asObject(toJS(exec, jsConstructor->globalObject(), array.get())); } -JSC::ConstructType JSWebGLUnsignedByteArrayConstructor::getConstructData(JSC::ConstructData& constructData) +JSC::ConstructType JSUint8ArrayConstructor::getConstructData(JSC::ConstructData& constructData) { constructData.native.function = constructCanvasUnsignedByteArray; return ConstructTypeHost; diff --git a/WebCore/bindings/js/JSUint8ArrayConstructor.h b/WebCore/bindings/js/JSUint8ArrayConstructor.h new file mode 100644 index 0000000..05db4ee --- /dev/null +++ b/WebCore/bindings/js/JSUint8ArrayConstructor.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 JSUint8ArrayConstructor_h +#define JSUint8ArrayConstructor_h + +#include "JSDOMBinding.h" +#include "JSDocument.h" + +namespace WebCore { + + class JSUint8ArrayConstructor : public DOMConstructorObject { + public: + JSUint8ArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); + static const JSC::ClassInfo s_info; + + private: + virtual JSC::ConstructType getConstructData(JSC::ConstructData&); + virtual const JSC::ClassInfo* classInfo() const { return &s_info; } + }; + +} + +#endif // JSUint8ArrayConstructor_h diff --git a/WebCore/bindings/js/JSUint8ArrayCustom.cpp b/WebCore/bindings/js/JSUint8ArrayCustom.cpp new file mode 100644 index 0000000..40bfda3 --- /dev/null +++ b/WebCore/bindings/js/JSUint8ArrayCustom.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2009 Apple 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: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. 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. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSArrayBufferViewHelper.h" +#include "JSUint8Array.h" + +#include "Uint8Array.h" + +using namespace JSC; + +namespace WebCore { + +void JSUint8Array::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) +{ + impl()->set(index, static_cast<unsigned char>(value.toInt32(exec))); +} + +JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, Uint8Array* object) +{ + return getDOMObjectWrapper<JSUint8Array>(exec, globalObject, object); +} + +JSC::JSValue JSUint8Array::set(JSC::ExecState* exec, JSC::ArgList const& args) +{ + return setWebGLArrayHelper(exec, impl(), args, toUint8Array); +} + +} // namespace WebCore + +#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLByteArrayCustom.cpp b/WebCore/bindings/js/JSWebGLByteArrayCustom.cpp deleted file mode 100644 index f7872a8..0000000 --- a/WebCore/bindings/js/JSWebGLByteArrayCustom.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSWebGLArrayHelper.h" -#include "JSWebGLByteArray.h" - -#include "WebGLByteArray.h" - -#include <runtime/Error.h> - -using namespace JSC; - -namespace WebCore { - -void JSWebGLByteArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) -{ - impl()->set(index, static_cast<signed char>(value.toInt32(exec))); -} - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLByteArray* object) -{ - return getDOMObjectWrapper<JSWebGLByteArray>(exec, globalObject, object); -} - -JSC::JSValue JSWebGLByteArray::set(JSC::ExecState* exec, JSC::ArgList const& args) -{ - if (args.size() < 1 || args.size() > 2) - return throwError(exec, SyntaxError); - - if (args.size() == 2 && args.at(0).isInt32()) { - // void set(in unsigned long index, in long value); - unsigned index = args.at(0).toUInt32(exec); - impl()->set(index, static_cast<signed char>(args.at(1).toInt32(exec))); - return jsUndefined(); - } - - WebGLByteArray* array = toWebGLByteArray(args.at(0)); - if (array) { - // void set(in WebGLByteArray array, [Optional] in unsigned long offset); - unsigned offset = 0; - if (args.size() == 2) - offset = args.at(1).toInt32(exec); - ExceptionCode ec = 0; - impl()->set(array, offset, ec); - setDOMException(exec, ec); - return jsUndefined(); - } - - return setWebGLArrayFromArray(exec, impl(), args); -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLFloatArrayCustom.cpp b/WebCore/bindings/js/JSWebGLFloatArrayCustom.cpp deleted file mode 100644 index f4acbcf..0000000 --- a/WebCore/bindings/js/JSWebGLFloatArrayCustom.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSWebGLArrayHelper.h" -#include "JSWebGLFloatArray.h" - -#include "WebGLFloatArray.h" - -using namespace JSC; - -namespace WebCore { - -void JSWebGLFloatArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) -{ - impl()->set(index, static_cast<float>(value.toNumber(exec))); -} - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLFloatArray* object) -{ - return getDOMObjectWrapper<JSWebGLFloatArray>(exec, globalObject, object); -} - -JSC::JSValue JSWebGLFloatArray::set(JSC::ExecState* exec, JSC::ArgList const& args) -{ - if (args.size() > 2) - return throwError(exec, SyntaxError); - - if (args.size() == 2 && args.at(0).isInt32()) { - // void set(in unsigned long index, in float value); - unsigned index = args.at(0).toUInt32(exec); - impl()->set(index, static_cast<float>(args.at(1).toNumber(exec))); - return jsUndefined(); - } - - WebGLFloatArray* array = toWebGLFloatArray(args.at(0)); - if (array) { - // void set(in WebGLFloatArray array, [Optional] in unsigned long offset); - unsigned offset = 0; - if (args.size() == 2) - offset = args.at(1).toInt32(exec); - ExceptionCode ec = 0; - impl()->set(array, offset, ec); - setDOMException(exec, ec); - return jsUndefined(); - } - - return setWebGLArrayFromArray(exec, impl(), args); -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLIntArrayCustom.cpp b/WebCore/bindings/js/JSWebGLIntArrayCustom.cpp deleted file mode 100644 index de08256..0000000 --- a/WebCore/bindings/js/JSWebGLIntArrayCustom.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSWebGLArrayHelper.h" -#include "JSWebGLIntArray.h" - -#include "WebGLIntArray.h" - -using namespace JSC; - -namespace WebCore { - -void JSWebGLIntArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) -{ - impl()->set(index, static_cast<signed int>(value.toInt32(exec))); -} - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLIntArray* object) -{ - return getDOMObjectWrapper<JSWebGLIntArray>(exec, globalObject, object); -} - -JSC::JSValue JSWebGLIntArray::set(JSC::ExecState* exec, JSC::ArgList const& args) -{ - if (args.size() > 2) - return throwError(exec, SyntaxError); - - if (args.size() == 2 && args.at(0).isInt32()) { - // void set(in unsigned long index, in long value); - unsigned index = args.at(0).toUInt32(exec); - impl()->set(index, static_cast<signed int>(args.at(1).toInt32(exec))); - return jsUndefined(); - } - - WebGLIntArray* array = toWebGLIntArray(args.at(0)); - if (array) { - // void set(in WebGLIntArray array, [Optional] in unsigned long offset); - unsigned offset = 0; - if (args.size() == 2) - offset = args.at(1).toInt32(exec); - ExceptionCode ec = 0; - impl()->set(array, offset, ec); - setDOMException(exec, ec); - return jsUndefined(); - } - - return setWebGLArrayFromArray(exec, impl(), args); -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp b/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp index 41000fd..c938aec 100644 --- a/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp +++ b/WebCore/bindings/js/JSWebGLRenderingContextCustom.cpp @@ -36,22 +36,22 @@ #include "JSHTMLImageElement.h" #include "JSImageData.h" #include "JSWebGLBuffer.h" -#include "JSWebGLFloatArray.h" +#include "JSFloatArray.h" #include "JSWebGLFramebuffer.h" -#include "JSWebGLIntArray.h" +#include "JSInt32Array.h" #include "JSWebGLProgram.h" #include "JSWebGLRenderbuffer.h" #include "JSWebGLShader.h" #include "JSWebGLTexture.h" #include "JSWebGLUniformLocation.h" -#include "JSWebGLUnsignedByteArray.h" +#include "JSUint8Array.h" #include "JSWebKitCSSMatrix.h" #include "NotImplemented.h" #include "WebGLBuffer.h" -#include "WebGLFloatArray.h" +#include "FloatArray.h" #include "WebGLFramebuffer.h" #include "WebGLGetInfo.h" -#include "WebGLIntArray.h" +#include "Int32Array.h" #include "WebGLProgram.h" #include "WebGLRenderingContext.h" #include <runtime/Error.h> @@ -81,7 +81,7 @@ JSValue JSWebGLRenderingContext::bufferData(JSC::ExecState* exec, JSC::ArgList c unsigned int count = args.at(1).toInt32(exec); static_cast<WebGLRenderingContext*>(impl())->bufferData(target, count, usage, ec); } else { - WebGLArray* array = toWebGLArray(args.at(1)); + ArrayBufferView* array = toArrayBufferView(args.at(1)); static_cast<WebGLRenderingContext*>(impl())->bufferData(target, array, usage, ec); } @@ -98,7 +98,7 @@ JSValue JSWebGLRenderingContext::bufferSubData(JSC::ExecState* exec, JSC::ArgLis unsigned offset = args.at(1).toInt32(exec); ExceptionCode ec = 0; - WebGLArray* array = toWebGLArray(args.at(2)); + ArrayBufferView* array = toArrayBufferView(args.at(2)); static_cast<WebGLRenderingContext*>(impl())->bufferSubData(target, offset, array, ec); @@ -311,7 +311,7 @@ JSValue JSWebGLRenderingContext::getVertexAttrib(ExecState* exec, const ArgList& return getObjectParameter(this, exec, args, kVertexAttrib); } -// void texImage2D(in GLenum target, in GLint level, in GLenum internalformat, in GLsizei width, in GLsizei height, in GLint border, in GLenum format, in GLenum type, in WebGLArray pixels); +// void texImage2D(in GLenum target, in GLint level, in GLenum internalformat, in GLsizei width, in GLsizei height, in GLint border, in GLenum format, in GLenum type, in ArrayBufferView pixels); // void texImage2D(in GLenum target, in GLint level, in ImageData pixels, [Optional] GLboolean flipY, [Optional] in premultiplyAlpha); // void texImage2D(in GLenum target, in GLint level, in HTMLImageElement image, [Optional] in GLboolean flipY, [Optional] in premultiplyAlpha); // void texImage2D(in GLenum target, in GLint level, in HTMLCanvasElement canvas, [Optional] in GLboolean flipY, [Optional] in premultiplyAlpha); @@ -366,7 +366,7 @@ JSValue JSWebGLRenderingContext::texImage2D(ExecState* exec, const ArgList& args if (args.size() != 9) return throwError(exec, SyntaxError); - // This must be the WebGLArray case + // This must be the ArrayBufferView case unsigned internalformat = args.at(2).toInt32(exec); if (exec->hadException()) return jsUndefined(); @@ -399,10 +399,10 @@ JSValue JSWebGLRenderingContext::texImage2D(ExecState* exec, const ArgList& args else if (value.isObject()) { o = asObject(value); - if (o->inherits(&JSWebGLArray::s_info)) { - // FIXME: Need to check to make sure WebGLArray is a WebGLByteArray or WebGLShortArray, + if (o->inherits(&JSArrayBufferView::s_info)) { + // FIXME: Need to check to make sure ArrayBufferView is a Int8Array or Int16Array, // depending on the passed type parameter. - WebGLArray* obj = static_cast<WebGLArray*>(static_cast<JSWebGLArray*>(o)->impl()); + ArrayBufferView* obj = static_cast<ArrayBufferView*>(static_cast<JSArrayBufferView*>(o)->impl()); context->texImage2D(target, level, internalformat, width, height, border, format, type, obj, ec); } else return throwError(exec, TypeError); @@ -414,7 +414,7 @@ JSValue JSWebGLRenderingContext::texImage2D(ExecState* exec, const ArgList& args return jsUndefined(); } -// void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, in GLsizei width, in GLsizei height, in GLenum format, in GLenum type, in WebGLArray pixels); +// void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, in GLsizei width, in GLsizei height, in GLenum format, in GLenum type, in ArrayBufferView pixels); // void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, in ImageData pixels, [Optional] GLboolean flipY, [Optional] in premultiplyAlpha); // void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, in HTMLImageElement image, [Optional] GLboolean flipY, [Optional] in premultiplyAlpha); // void texSubImage2D(in GLenum target, in GLint level, in GLint xoffset, in GLint yoffset, in HTMLCanvasElement canvas, [Optional] GLboolean flipY, [Optional] in premultiplyAlpha); @@ -474,7 +474,7 @@ JSValue JSWebGLRenderingContext::texSubImage2D(ExecState* exec, const ArgList& a } else ec = TYPE_MISMATCH_ERR; } else { - // This must be the WebGLArray form + // This must be the ArrayBufferView form if (args.size() != 9) return throwError(exec, SyntaxError); @@ -500,8 +500,8 @@ JSValue JSWebGLRenderingContext::texSubImage2D(ExecState* exec, const ArgList& a else { o = asObject(value); - if (o->inherits(&JSWebGLArray::s_info)) { - WebGLArray* obj = static_cast<WebGLArray*>(static_cast<JSWebGLArray*>(o)->impl()); + if (o->inherits(&JSArrayBufferView::s_info)) { + ArrayBufferView* obj = static_cast<ArrayBufferView*>(static_cast<JSArrayBufferView*>(o)->impl()); context->texSubImage2D(target, level, xoff, yoff, width, height, format, type, obj, ec); } else return throwError(exec, TypeError); @@ -571,7 +571,7 @@ static JSC::JSValue dataFunctionf(DataFunctionToCall f, JSC::ExecState* exec, co if (exec->hadException()) return jsUndefined(); - RefPtr<WebGLFloatArray> webGLArray = toWebGLFloatArray(args.at(1)); + RefPtr<FloatArray> webGLArray = toFloatArray(args.at(1)); if (exec->hadException()) return jsUndefined(); @@ -653,7 +653,7 @@ static JSC::JSValue dataFunctioni(DataFunctionToCall f, JSC::ExecState* exec, co if (exec->hadException()) return jsUndefined(); - RefPtr<WebGLIntArray> webGLArray = toWebGLIntArray(args.at(1)); + RefPtr<Int32Array> webGLArray = toInt32Array(args.at(1)); if (exec->hadException()) return jsUndefined(); @@ -720,7 +720,7 @@ static JSC::JSValue dataFunctionMatrix(DataFunctionMatrixToCall f, JSC::ExecStat if (exec->hadException()) return jsUndefined(); - RefPtr<WebGLFloatArray> webGLArray = toWebGLFloatArray(args.at(2)); + RefPtr<FloatArray> webGLArray = toFloatArray(args.at(2)); if (exec->hadException()) return jsUndefined(); diff --git a/WebCore/bindings/js/JSWebGLShortArrayCustom.cpp b/WebCore/bindings/js/JSWebGLShortArrayCustom.cpp deleted file mode 100644 index 899b0c9..0000000 --- a/WebCore/bindings/js/JSWebGLShortArrayCustom.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSWebGLArrayHelper.h" -#include "JSWebGLShortArray.h" - -#include "WebGLShortArray.h" - -using namespace JSC; - -namespace WebCore { - -void JSWebGLShortArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) -{ - impl()->set(index, static_cast<signed short>(value.toInt32(exec))); -} - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLShortArray* object) -{ - return getDOMObjectWrapper<JSWebGLShortArray>(exec, globalObject, object); -} - -JSC::JSValue JSWebGLShortArray::set(JSC::ExecState* exec, JSC::ArgList const& args) -{ - if (args.size() > 2) - return throwError(exec, SyntaxError); - - if (args.size() == 2 && args.at(0).isInt32()) { - // void set(in unsigned long index, in long value); - unsigned index = args.at(0).toUInt32(exec); - impl()->set(index, static_cast<signed short>(args.at(1).toInt32(exec))); - return jsUndefined(); - } - - WebGLShortArray* shortArray = toWebGLShortArray(args.at(0)); - if (shortArray) { - // void set(in WebGLShortArray array, [Optional] in unsigned long offset); - unsigned offset = 0; - if (args.size() == 2) - offset = args.at(1).toInt32(exec); - ExceptionCode ec = 0; - impl()->set(shortArray, offset, ec); - setDOMException(exec, ec); - return jsUndefined(); - } - - return setWebGLArrayFromArray(exec, impl(), args); -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLUnsignedByteArrayConstructor.h b/WebCore/bindings/js/JSWebGLUnsignedByteArrayConstructor.h deleted file mode 100644 index d90ce96..0000000 --- a/WebCore/bindings/js/JSWebGLUnsignedByteArrayConstructor.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 JSWebGLUnsignedByteArrayConstructor_h -#define JSWebGLUnsignedByteArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSWebGLUnsignedByteArrayConstructor : public DOMConstructorObject { - public: - JSWebGLUnsignedByteArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static const JSC::ClassInfo s_info; - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - }; - -} - -#endif // JSWebGLUnsignedByteArrayConstructor_h diff --git a/WebCore/bindings/js/JSWebGLUnsignedByteArrayCustom.cpp b/WebCore/bindings/js/JSWebGLUnsignedByteArrayCustom.cpp deleted file mode 100644 index b576374..0000000 --- a/WebCore/bindings/js/JSWebGLUnsignedByteArrayCustom.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSWebGLArrayHelper.h" -#include "JSWebGLUnsignedByteArray.h" - -#include "WebGLUnsignedByteArray.h" - -using namespace JSC; - -namespace WebCore { - -void JSWebGLUnsignedByteArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) -{ - impl()->set(index, static_cast<unsigned char>(value.toInt32(exec))); -} - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLUnsignedByteArray* object) -{ - return getDOMObjectWrapper<JSWebGLUnsignedByteArray>(exec, globalObject, object); -} - -JSC::JSValue JSWebGLUnsignedByteArray::set(JSC::ExecState* exec, JSC::ArgList const& args) -{ - if (args.size() > 2) - return throwError(exec, SyntaxError); - - if (args.size() == 2 && args.at(0).isInt32()) { - // void set(in unsigned long index, in long value); - unsigned index = args.at(0).toUInt32(exec); - impl()->set(index, static_cast<unsigned char>(args.at(1).toInt32(exec))); - return jsUndefined(); - } - - WebGLUnsignedByteArray* array = toWebGLUnsignedByteArray(args.at(0)); - if (array) { - // void set(in WebGLUnsignedByteArray array, [Optional] in unsigned long offset); - unsigned offset = 0; - if (args.size() == 2) - offset = args.at(1).toInt32(exec); - ExceptionCode ec = 0; - impl()->set(array, offset, ec); - setDOMException(exec, ec); - return jsUndefined(); - } - - return setWebGLArrayFromArray(exec, impl(), args); -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLUnsignedIntArrayConstructor.h b/WebCore/bindings/js/JSWebGLUnsignedIntArrayConstructor.h deleted file mode 100644 index 7eabbc1..0000000 --- a/WebCore/bindings/js/JSWebGLUnsignedIntArrayConstructor.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 JSWebGLUnsignedIntArrayConstructor_h -#define JSWebGLUnsignedIntArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSWebGLUnsignedIntArrayConstructor : public DOMConstructorObject { - public: - JSWebGLUnsignedIntArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static const JSC::ClassInfo s_info; - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - }; - -} - -#endif // JSWebGLUnsignedIntArrayConstructor_h diff --git a/WebCore/bindings/js/JSWebGLUnsignedIntArrayCustom.cpp b/WebCore/bindings/js/JSWebGLUnsignedIntArrayCustom.cpp deleted file mode 100644 index c8b7454..0000000 --- a/WebCore/bindings/js/JSWebGLUnsignedIntArrayCustom.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSWebGLArrayHelper.h" -#include "JSWebGLUnsignedIntArray.h" - -#include "WebGLUnsignedIntArray.h" - -using namespace JSC; - -namespace WebCore { - -void JSWebGLUnsignedIntArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) -{ - impl()->set(index, static_cast<unsigned int>(value.toUInt32(exec))); -} - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLUnsignedIntArray* object) -{ - return getDOMObjectWrapper<JSWebGLUnsignedIntArray>(exec, globalObject, object); -} - -JSC::JSValue JSWebGLUnsignedIntArray::set(JSC::ExecState* exec, JSC::ArgList const& args) -{ - if (args.size() > 2) - return throwError(exec, SyntaxError); - - if (args.size() == 2 && args.at(0).isInt32()) { - // void set(in unsigned long index, in long value); - unsigned index = args.at(0).toUInt32(exec); - impl()->set(index, static_cast<unsigned int>(args.at(1).toUInt32(exec))); - return jsUndefined(); - } - - WebGLUnsignedIntArray* array = toWebGLUnsignedIntArray(args.at(0)); - if (array) { - // void set(in WebGLUnsignedIntArray array, [Optional] in unsigned long offset); - unsigned offset = 0; - if (args.size() == 2) - offset = args.at(1).toInt32(exec); - ExceptionCode ec = 0; - impl()->set(array, offset, ec); - setDOMException(exec, ec); - return jsUndefined(); - } - - return setWebGLArrayFromArray(exec, impl(), args); -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWebGLUnsignedShortArrayConstructor.h b/WebCore/bindings/js/JSWebGLUnsignedShortArrayConstructor.h deleted file mode 100644 index 5eba20d..0000000 --- a/WebCore/bindings/js/JSWebGLUnsignedShortArrayConstructor.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 JSWebGLUnsignedShortArrayConstructor_h -#define JSWebGLUnsignedShortArrayConstructor_h - -#include "JSDOMBinding.h" -#include "JSDocument.h" - -namespace WebCore { - - class JSWebGLUnsignedShortArrayConstructor : public DOMConstructorObject { - public: - JSWebGLUnsignedShortArrayConstructor(JSC::ExecState*, JSDOMGlobalObject*); - static const JSC::ClassInfo s_info; - - private: - virtual JSC::ConstructType getConstructData(JSC::ConstructData&); - virtual const JSC::ClassInfo* classInfo() const { return &s_info; } - }; - -} - -#endif // JSWebGLUnsignedShortArrayConstructor_h diff --git a/WebCore/bindings/js/JSWebGLUnsignedShortArrayCustom.cpp b/WebCore/bindings/js/JSWebGLUnsignedShortArrayCustom.cpp deleted file mode 100644 index 0c82c3e..0000000 --- a/WebCore/bindings/js/JSWebGLUnsignedShortArrayCustom.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2009 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "JSWebGLArrayHelper.h" -#include "JSWebGLUnsignedShortArray.h" - -#include "WebGLUnsignedShortArray.h" - -using namespace JSC; - -namespace WebCore { - -void JSWebGLUnsignedShortArray::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) -{ - impl()->set(index, static_cast<unsigned short>(value.toInt32(exec))); -} - -JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, WebGLUnsignedShortArray* object) -{ - return getDOMObjectWrapper<JSWebGLUnsignedShortArray>(exec, globalObject, object); -} - -JSC::JSValue JSWebGLUnsignedShortArray::set(JSC::ExecState* exec, JSC::ArgList const& args) -{ - if (args.size() > 2) - return throwError(exec, SyntaxError); - - if (args.size() == 2 && args.at(0).isInt32()) { - // void set(in unsigned long index, in long value); - unsigned index = args.at(0).toUInt32(exec); - impl()->set(index, static_cast<unsigned short>(args.at(1).toInt32(exec))); - return jsUndefined(); - } - - WebGLUnsignedShortArray* array = toWebGLUnsignedShortArray(args.at(0)); - if (array) { - // void set(in WebGLUnsignedShortArray array, [Optional] in unsigned long offset); - unsigned offset = 0; - if (args.size() == 2) - offset = args.at(1).toInt32(exec); - ExceptionCode ec = 0; - impl()->set(array, offset, ec); - setDOMException(exec, ec); - return jsUndefined(); - } - - return setWebGLArrayFromArray(exec, impl(), args); -} - -} // namespace WebCore - -#endif // ENABLE(3D_CANVAS) diff --git a/WebCore/bindings/js/JSWorkerContextCustom.cpp b/WebCore/bindings/js/JSWorkerContextCustom.cpp index a70c1b3..925a5c3 100644 --- a/WebCore/bindings/js/JSWorkerContextCustom.cpp +++ b/WebCore/bindings/js/JSWorkerContextCustom.cpp @@ -29,6 +29,13 @@ #include "JSWorkerContext.h" +#if ENABLE(DATABASE) +#include "Database.h" +#include "JSDatabase.h" +#include "JSDatabaseCallback.h" +#include "JSDatabaseSync.h" +#endif +#include "ExceptionCode.h" #include "JSDOMBinding.h" #include "JSDOMGlobalObject.h" #include "JSEventListener.h" @@ -142,6 +149,89 @@ JSValue JSWorkerContext::messageChannel(ExecState* exec) const } #endif +#if ENABLE(DATABASE) +JSValue JSWorkerContext::openDatabase(ExecState* exec, const ArgList& args) +{ + if (args.size() < 4) { + setDOMException(exec, SYNTAX_ERR); + return jsUndefined(); + } + + String name = ustringToString(args.at(0).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + String version = ustringToString(args.at(1).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + String displayName = ustringToString(args.at(2).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + // args.at(3) = estimated size + unsigned long estimatedSize = args.at(3).toUInt32(exec); + if (exec->hadException()) + return jsUndefined(); + + RefPtr<DatabaseCallback> creationCallback; + if (args.size() >= 5) { + if (!args.at(4).isObject()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return jsUndefined(); + } + + creationCallback = JSDatabaseCallback::create(asObject(args.at(4)), globalObject()); + } + + ExceptionCode ec = 0; + JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabase(name, version, displayName, estimatedSize, creationCallback.release(), ec))); + setDOMException(exec, ec); + return result; +} + +JSValue JSWorkerContext::openDatabaseSync(ExecState* exec, const ArgList& args) +{ + if (args.size() < 4) { + setDOMException(exec, SYNTAX_ERR); + return jsUndefined(); + } + + String name = ustringToString(args.at(0).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + String version = ustringToString(args.at(1).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + String displayName = ustringToString(args.at(2).toString(exec)); + if (exec->hadException()) + return jsUndefined(); + + // args.at(3) = estimated size + unsigned long estimatedSize = args.at(3).toUInt32(exec); + if (exec->hadException()) + return jsUndefined(); + + RefPtr<DatabaseCallback> creationCallback; + if (args.size() >= 5) { + if (!args.at(4).isObject()) { + setDOMException(exec, TYPE_MISMATCH_ERR); + return jsUndefined(); + } + + creationCallback = JSDatabaseCallback::create(asObject(args.at(4)), globalObject()); + } + + ExceptionCode ec = 0; + JSValue result = toJS(exec, globalObject(), WTF::getPtr(impl()->openDatabaseSync(name, version, displayName, estimatedSize, creationCallback.release(), ec))); + + setDOMException(exec, ec); + return result; +} +#endif + } // namespace WebCore #endif // ENABLE(WORKERS) diff --git a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp index fc72154..086b89d 100644 --- a/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp +++ b/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp @@ -91,17 +91,6 @@ JSValue JSXMLHttpRequest::open(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue JSXMLHttpRequest::setRequestHeader(ExecState* exec, const ArgList& args) -{ - if (args.size() < 2) - return throwError(exec, SyntaxError, "Not enough arguments"); - - ExceptionCode ec = 0; - impl()->setRequestHeader(ustringToAtomicString(args.at(0).toString(exec)), ustringToString(args.at(1).toString(exec)), ec); - setDOMException(exec, ec); - return jsUndefined(); -} - JSValue JSXMLHttpRequest::send(ExecState* exec, const ArgList& args) { ExceptionCode ec = 0; @@ -133,26 +122,6 @@ JSValue JSXMLHttpRequest::send(ExecState* exec, const ArgList& args) return jsUndefined(); } -JSValue JSXMLHttpRequest::getResponseHeader(ExecState* exec, const ArgList& args) -{ - if (args.size() < 1) - return throwError(exec, SyntaxError, "Not enough arguments"); - - ExceptionCode ec = 0; - JSValue header = jsStringOrNull(exec, impl()->getResponseHeader(ustringToAtomicString(args.at(0).toString(exec)), ec)); - setDOMException(exec, ec); - return header; -} - -JSValue JSXMLHttpRequest::overrideMimeType(ExecState* exec, const ArgList& args) -{ - if (args.size() < 1) - return throwError(exec, SyntaxError, "Not enough arguments"); - - impl()->overrideMimeType(ustringToString(args.at(0).toString(exec))); - return jsUndefined(); -} - JSValue JSXMLHttpRequest::responseText(ExecState* exec) const { return jsOwnedStringOrNull(exec, impl()->responseText()); diff --git a/WebCore/bindings/js/ScriptController.h b/WebCore/bindings/js/ScriptController.h index 468ac5c..ed6c0a0 100644 --- a/WebCore/bindings/js/ScriptController.h +++ b/WebCore/bindings/js/ScriptController.h @@ -102,7 +102,7 @@ public: ScriptValue executeScriptInWorld(DOMWrapperWorld* world, 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. // Darwin is an exception to this rule: it is OK to call this function from any thread, even reentrantly. diff --git a/WebCore/bindings/js/ScriptGCEvent.cpp b/WebCore/bindings/js/ScriptGCEvent.cpp new file mode 100644 index 0000000..4b39799 --- /dev/null +++ b/WebCore/bindings/js/ScriptGCEvent.cpp @@ -0,0 +1,53 @@ +/* + * 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" +#include "ScriptGCEvent.h" + +#if ENABLE(INSPECTOR) + +#include "JSDOMWindow.h" +#include <runtime/Collector.h> +#include <runtime/JSGlobalData.h> +#include <wtf/CurrentTime.h> + +namespace WebCore { + +using namespace JSC; + +void ScriptGCEvent::getHeapSize(size_t& usedHeapSize, size_t& totalHeapSize) +{ + JSGlobalData* globalData = JSDOMWindow::commonJSGlobalData(); + totalHeapSize = globalData->heap.size(); + usedHeapSize = totalHeapSize; +} +} // namespace WebCore + +#endif // !ENABLE(INSPECTOR) diff --git a/WebCore/bindings/js/ScriptGCEvent.h b/WebCore/bindings/js/ScriptGCEvent.h index 57892e7..86d4f68 100644 --- a/WebCore/bindings/js/ScriptGCEvent.h +++ b/WebCore/bindings/js/ScriptGCEvent.h @@ -42,7 +42,7 @@ class ScriptGCEvent public: static void addEventListener(ScriptGCEventListener*) { } static void removeEventListener(ScriptGCEventListener*) { } - static void getHeapSize(size_t&, size_t&) { } + static void getHeapSize(size_t& usedHeapSize, size_t& totalHeapSize); }; } // namespace WebCore diff --git a/WebCore/bindings/scripts/CodeGenerator.pm b/WebCore/bindings/scripts/CodeGenerator.pm index 487a4b3..b8f23dd 100644 --- a/WebCore/bindings/scripts/CodeGenerator.pm +++ b/WebCore/bindings/scripts/CodeGenerator.pm @@ -363,4 +363,21 @@ sub NamespaceForAttributeName return "HTMLNames"; } +# Identifies overloaded functions and for each function adds an array with +# links to its respective overloads (including itself). +sub LinkOverloadedFunctions +{ + my ($object, $dataNode) = @_; + + my %nameToFunctionsMap = (); + foreach my $function (@{$dataNode->functions}) { + my $name = $function->signature->name; + $nameToFunctionsMap{$name} = [] if !exists $nameToFunctionsMap{$name}; + push(@{$nameToFunctionsMap{$name}}, $function); + $function->{overloads} = $nameToFunctionsMap{$name}; + $function->{overloadIndex} = @{$nameToFunctionsMap{$name}}; + } +} + + 1; diff --git a/WebCore/bindings/scripts/CodeGeneratorJS.pm b/WebCore/bindings/scripts/CodeGeneratorJS.pm index dc21314..46ac42d 100644 --- a/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -5,7 +5,8 @@ # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> # Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> -# +# Copyright (C) Research In Motion Limited 2010. All rights reserved. +# # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either @@ -100,6 +101,8 @@ sub GenerateInterface my $dataNode = shift; my $defines = shift; + $codeGenerator->LinkOverloadedFunctions($dataNode); + # Start actual generation if ($dataNode->extendedAttributes->{"Callback"}) { $object->GenerateCallbackHeader($dataNode); @@ -126,6 +129,32 @@ sub GenerateInterface } } +sub GenerateAttributeEventListenerCall +{ + my $className = shift; + my $implSetterFunctionName = shift; + my $windowEventListener = shift; + + my $wrapperObject = $windowEventListener ? "globalObject" : "thisObject"; + my @GenerateEventListenerImpl = (); + + if ($className eq "JSSVGElementInstance") { + # SVGElementInstances have to create JSEventListeners with the wrapper equal to the correspondingElement + $wrapperObject = "asObject(correspondingElementWrapper)"; + + push(@GenerateEventListenerImpl, <<END); + JSValue correspondingElementWrapper = toJS(exec, imp->correspondingElement()); + if (correspondingElementWrapper.isObject()) +END + + # Add leading whitespace to format the imp->set... line correctly + push(@GenerateEventListenerImpl, " "); + } + + push(@GenerateEventListenerImpl, " imp->set$implSetterFunctionName(createJSAttributeEventListener(exec, value, $wrapperObject));\n"); + return @GenerateEventListenerImpl; +} + sub GenerateEventListenerCall { my $className = shift; @@ -135,11 +164,23 @@ sub GenerateEventListenerCall $implIncludes{"JSEventListener.h"} = 1; my @GenerateEventListenerImpl = (); + my $wrapperObject = "castedThis"; + if ($className eq "JSSVGElementInstance") { + # SVGElementInstances have to create JSEventListeners with the wrapper equal to the correspondingElement + $wrapperObject = "asObject(correspondingElementWrapper)"; + + push(@GenerateEventListenerImpl, <<END); + JSValue correspondingElementWrapper = toJS(exec, imp->correspondingElement()); + if (!correspondingElementWrapper.isObject()) + return jsUndefined(); +END + } + push(@GenerateEventListenerImpl, <<END); JSValue listener = args.at(1); if (!listener.isObject()) return jsUndefined(); - imp->${functionName}EventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), castedThis, false, currentWorld(exec))$passRefPtrHandling, args.at(2).toBoolean(exec)); + imp->${functionName}EventListener(ustringToAtomicString(args.at(0).toString(exec)), JSEventListener::create(asObject(listener), $wrapperObject, false, currentWorld(exec))$passRefPtrHandling, args.at(2).toBoolean(exec)); return jsUndefined(); END return @GenerateEventListenerImpl; @@ -944,6 +985,7 @@ sub GenerateHeader if ($numFunctions > 0) { push(@headerContent,"// Functions\n\n"); foreach my $function (@{$dataNode->functions}) { + next if $function->{overloadIndex} > 1; my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name); push(@headerContent, "JSC::JSValue JSC_HOST_CALL ${functionName}(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&);\n"); } @@ -1019,7 +1061,7 @@ sub GenerateAttributesHashTable($$) push(@specials, "DontDelete") unless $attribute->signature->extendedAttributes->{"Deletable"}; push(@specials, "DontEnum") if $attribute->signature->extendedAttributes->{"DontEnum"}; push(@specials, "ReadOnly") if $attribute->type =~ /readonly/; - my $special = (@specials > 0) ? join("|", @specials) : "0"; + my $special = (@specials > 0) ? join(" | ", @specials) : "0"; push(@hashSpecials, $special); my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($attribute->signature->name) . ($attribute->signature->type =~ /Constructor$/ ? "Constructor" : ""); @@ -1043,7 +1085,7 @@ sub GenerateAttributesHashTable($$) my $getter = "js" . $interfaceName . "Constructor"; push(@hashValue1, $getter); push(@hashValue2, "0"); - push(@hashSpecials, "DontEnum|ReadOnly"); # FIXME: Setting the constructor should be possible. + push(@hashSpecials, "DontEnum | ReadOnly"); # FIXME: Setting the constructor should be possible. } $object->GenerateHashTable($hashName, $hashSize, @@ -1053,6 +1095,79 @@ sub GenerateAttributesHashTable($$) return $numAttributes; } +sub GenerateParametersCheckExpression +{ + my $numParameters = shift; + my $function = shift; + + my @andExpression = (); + push(@andExpression, "args.size() == $numParameters"); + my $parameterIndex = 0; + foreach $parameter (@{$function->parameters}) { + last if $parameterIndex >= $numParameters; + my $value = "args.at($parameterIndex)"; + my $type = $codeGenerator->StripModule($parameter->type); + + # Only DOMString or wrapper types are checked. + # For DOMString, Null, Undefined and any Object are accepted too, as + # these are acceptable values for a DOMString argument (any Object can + # be converted to a string via .toString). + push(@andExpression, "(${value}.isNull() || ${value}.isUndefined() || ${value}.isString() || ${value}.isObject())") if $codeGenerator->IsStringType($type); + push(@andExpression, "(${value}.isNull() || asObject(${value})->inherits(JS${type}::s_info)") unless IsNativeType($type); + + $parameterIndex++; + } + my $res = join(" && ", @andExpression); + $res = "($res)" if @andExpression > 1; + return $res; +} + +sub GenerateFunctionParametersCheck +{ + my $function = shift; + + my @orExpression = (); + my $numParameters = 0; + foreach $parameter (@{$function->parameters}) { + if ($parameter->extendedAttributes->{"Optional"}) { + push(@orExpression, GenerateParametersCheckExpression($numParameters, $function)); + } + $numParameters++; + } + push(@orExpression, GenerateParametersCheckExpression($numParameters, $function)); + return join(" || ", @orExpression); +} + +sub GenerateOverloadedPrototypeFunction +{ + my $function = shift; + my $dataNode = shift; + my $implClassName = shift; + + # Generate code for choosing the correct overload to call. Overloads are + # chosen based on the total number of arguments passed and the type of + # values passed in non-primitive argument slots. When more than a single + # overload is applicable, precedence is given according to the order of + # declaration in the IDL. + + my $functionName = "js${implClassName}PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name); + + push(@implContent, "JSValue JSC_HOST_CALL ${functionName}(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)\n"); + push(@implContent, <<END); +{ +END + foreach my $overload (@{$function->{overloads}}) { + my $parametersCheck = GenerateFunctionParametersCheck($overload); + push(@implContent, " if ($parametersCheck)\n"); + push(@implContent, " return ${functionName}$overload->{overloadIndex}(exec, thisValue, args);\n"); + } + push(@implContent, <<END); + return throwError(exec, TypeError); +} + +END +} + sub GenerateImplementation { my ($object, $dataNode) = @_; @@ -1107,7 +1222,7 @@ sub GenerateImplementation my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($constant->name); push(@hashValue1, $getter); push(@hashValue2, "0"); - push(@hashSpecials, "DontDelete|ReadOnly"); + push(@hashSpecials, "DontDelete | ReadOnly"); } $object->GenerateHashTable($hashName, $hashSize, @@ -1135,10 +1250,11 @@ sub GenerateImplementation my $getter = "js" . $interfaceName . $codeGenerator->WK_ucfirst($constant->name); push(@hashValue1, $getter); push(@hashValue2, "0"); - push(@hashSpecials, "DontDelete|ReadOnly"); + push(@hashSpecials, "DontDelete | ReadOnly"); } foreach my $function (@{$dataNode->functions}) { + next if $function->{overloadIndex} > 1; my $name = $function->signature->name; push(@hashKeys, $name); @@ -1152,7 +1268,7 @@ sub GenerateImplementation push(@specials, "DontDelete") unless $function->signature->extendedAttributes->{"Deletable"}; push(@specials, "DontEnum") if $function->signature->extendedAttributes->{"DontEnum"}; push(@specials, "Function"); - my $special = (@specials > 0) ? join("|", @specials) : "0"; + my $special = (@specials > 0) ? join(" | ", @specials) : "0"; push(@hashSpecials, $special); } @@ -1584,11 +1700,7 @@ sub GenerateImplementation $implIncludes{"JSWorkerContextErrorHandler.h"} = 1; push(@implContent, " imp->set$implSetterFunctionName(createJSWorkerContextErrorHandler(exec, value, thisObject));\n"); } else { - if ($windowEventListener) { - push(@implContent, " imp->set$implSetterFunctionName(createJSAttributeEventListener(exec, value, globalObject));\n"); - } else { - push(@implContent, " imp->set$implSetterFunctionName(createJSAttributeEventListener(exec, value, thisObject));\n"); - } + push(@implContent, GenerateAttributeEventListenerCall($className, $implSetterFunctionName, $windowEventListener)); } } elsif ($attribute->signature->type =~ /Constructor$/) { my $constructorType = $attribute->signature->type; @@ -1668,6 +1780,12 @@ sub GenerateImplementation AddIncludesForType($function->signature->type); my $functionName = $codeGenerator->WK_lcfirst($className) . "PrototypeFunction" . $codeGenerator->WK_ucfirst($function->signature->name); + + if (@{$function->{overloads}} > 1) { + # Append a number to an overloaded method's name to make it unique: + $functionName = $functionName . $function->{overloadIndex}; + } + my $functionImplementationName = $function->signature->extendedAttributes->{"ImplementationFunction"} || $codeGenerator->WK_lcfirst($function->signature->name); push(@implContent, "JSValue JSC_HOST_CALL ${functionName}(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args)\n"); @@ -1724,9 +1842,14 @@ sub GenerateImplementation my $numParameters = @{$function->parameters}; - if ($function->signature->extendedAttributes->{"RequiresAllArguments"}) { + my $requiresAllArguments = $function->signature->extendedAttributes->{"RequiresAllArguments"}; + if ($requiresAllArguments) { push(@implContent, " if (args.size() < $numParameters)\n"); - push(@implContent, " return jsUndefined();\n"); + if ($requiresAllArguments eq "Raise") { + push(@implContent, " return throwError(exec, SyntaxError, \"Not enough arguments\");\n"); + } else { + push(@implContent, " return jsUndefined();\n"); + } } if (@{$function->raisesExceptions}) { @@ -1771,12 +1894,12 @@ sub GenerateImplementation } foreach my $parameter (@{$function->parameters}) { - if (!$hasOptionalArguments && $parameter->extendedAttributes->{"Optional"}) { - push(@implContent, "\n int argsCount = args.size();\n"); - $hasOptionalArguments = 1; - } - - if ($hasOptionalArguments) { + if ($parameter->extendedAttributes->{"Optional"}) { + # Generate early call if there are enough parameters. + if (!$hasOptionalArguments) { + push(@implContent, "\n int argsCount = args.size();\n"); + $hasOptionalArguments = 1; + } push(@implContent, " if (argsCount < " . ($paramIndex + 1) . ") {\n"); GenerateImplementationFunctionCall($function, $functionString, $paramIndex, " " x 2, $podType, $implClassName); push(@implContent, " }\n\n"); @@ -1829,6 +1952,11 @@ sub GenerateImplementation } } push(@implContent, "}\n\n"); + + if (@{$function->{overloads}} > 1 && $function->{overloadIndex} == @{$function->{overloads}}) { + # Generate a function dispatching call to the rest of the overloads. + GenerateOverloadedPrototypeFunction($function, $dataNode, $implClassName); + } } } @@ -1972,6 +2100,7 @@ sub GenerateCallbackHeader # Private members push(@headerContent, " JSCallbackData* m_data;\n"); push(@headerContent, " RefPtr<DOMWrapperWorld> m_isolatedWorld;\n"); + push(@headerContent, " ScriptExecutionContext* m_scriptExecutionContext;\n"); push(@headerContent, "};\n\n"); push(@headerContent, "} // namespace WebCore\n\n"); @@ -2003,13 +2132,14 @@ sub GenerateCallbackImplementation push(@implContent, "${className}::${className}(JSObject* callback, JSDOMGlobalObject* globalObject)\n"); push(@implContent, " : m_data(new JSCallbackData(callback, globalObject))\n"); push(@implContent, " , m_isolatedWorld(globalObject->world())\n"); + push(@implContent, " , m_scriptExecutionContext(globalObject->scriptExecutionContext())\n"); push(@implContent, "{\n"); push(@implContent, "}\n\n"); # Destructor push(@implContent, "${className}::~${className}()\n"); push(@implContent, "{\n"); - push(@implContent, " callOnMainThread(JSCallbackData::deleteData, m_data);\n"); + push(@implContent, " m_scriptExecutionContext->postTask(DeleteCallbackDataTask::create(m_data));\n"); push(@implContent, "#ifndef NDEBUG\n"); push(@implContent, " m_data = 0;\n"); push(@implContent, "#endif\n"); @@ -2158,6 +2288,12 @@ sub GetNativeType return "${type}*"; } +sub IsNativeType +{ + my $type = shift; + return exists $nativeType{$type}; +} + sub JSValueToNative { my $signature = shift; @@ -2344,17 +2480,8 @@ sub GenerateHashTable my $value2 = shift; my $conditionals = shift; - # Generate size data for two hash tables - # - The 'perfect' size makes a table large enough for perfect hashing - # - The 'compact' size uses the legacy table format for smaller table sizes - - # Perfect size - my @hashes = (); - foreach my $key (@{$keys}) { - push @hashes, $object->GenerateHashValue($key); - } + # Generate size data for compact' size hash table - # Compact size my @table = (); my @links = (); @@ -2387,20 +2514,6 @@ sub GenerateHashTable $maxDepth = $depth if ($depth > $maxDepth); } - # Collect hashtable information - my $perfectSize; -tableSizeLoop: - for ($perfectSize = ceilingToPowerOf2(scalar @{$keys}); ; $perfectSize += $perfectSize) { - my @table = (); - my $i = 0; - foreach my $hash (@hashes) { - my $h = $hash % $perfectSize; - next tableSizeLoop if defined $table[$h]; - $table[$h] = $i++; - } - last; - } - # Start outputing the hashtables my $nameEntries = "${name}Values"; $nameEntries =~ s/:/_/g; @@ -2457,14 +2570,8 @@ tableSizeLoop: push(@implContent, " { 0, 0, 0, 0 THUNK_GENERATOR(0) }\n"); push(@implContent, "};\n\n"); push(@implContent, "#undef THUNK_GENERATOR\n"); - my $perfectSizeMask = $perfectSize - 1; my $compactSizeMask = $numEntries - 1; - push(@implContent, "static JSC_CONST_HASHTABLE HashTable $name =\n"); - push(@implContent, "#if ENABLE(PERFECT_HASH_SIZE)\n"); - push(@implContent, " { $perfectSizeMask, $nameEntries, 0 };\n"); - push(@implContent, "#else\n"); - push(@implContent, " { $compactSize, $compactSizeMask, $nameEntries, 0 };\n"); - push(@implContent, "#endif\n\n"); + push(@implContent, "static JSC_CONST_HASHTABLE HashTable $name = { $compactSize, $compactSizeMask, $nameEntries, 0 };\n"); } # Internal helper diff --git a/WebCore/bindings/scripts/CodeGeneratorV8.pm b/WebCore/bindings/scripts/CodeGeneratorV8.pm index 9553b8b..f38e0d1 100644 --- a/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -206,23 +206,6 @@ sub GenerateConditionalString } } -sub LinkOverloadedFunctions -{ - my $dataNode = shift; - - # Identifies overloaded functions and for each function adds an array with - # links to its respective overloads (including itself). - my %nameToFunctionsMap = (); - foreach my $function (@{$dataNode->functions}) { - my $name = $function->signature->name; - $nameToFunctionsMap{$name} = [] if !exists $nameToFunctionsMap{$name}; - push(@{$nameToFunctionsMap{$name}}, $function); - $function->{overloads} = $nameToFunctionsMap{$name}; - $function->{overloadIndex} = @{$nameToFunctionsMap{$name}}; - } - -} - sub GenerateHeader { my $object = shift; @@ -1141,8 +1124,14 @@ END my $numParameters = @{$function->parameters}; - if ($function->signature->extendedAttributes->{"RequiresAllArguments"}) { - push(@implContentDecls, " if (args.Length() < $numParameters)\n return v8::Handle<v8::Value>();\n"); + my $requiresAllArguments = $function->signature->extendedAttributes->{"RequiresAllArguments"}; + if ($requiresAllArguments) { + push(@implContentDecls, " if (args.Length() < $numParameters)\n"); + if ($requiresAllArguments eq "Raise") { + push(@implContentDecls, " return throwError(\"Not enough arguments\", V8Proxy::SyntaxError);\n"); + } else { + push(@implContentDecls, " return v8::Handle<v8::Value>();\n"); + } } if (IsPodType($implClassName)) { @@ -1658,7 +1647,7 @@ sub GenerateImplementation GenerateConstructorGetter($implClassName); } - LinkOverloadedFunctions($dataNode); + $codeGenerator->LinkOverloadedFunctions($dataNode); my $indexer; my $namedPropertyGetter; @@ -2463,6 +2452,7 @@ sub IsActiveDomType return 1 if $type eq "WebSocket"; return 1 if $type eq "Worker"; return 1 if $type eq "SharedWorker"; + return 1 if $type eq "IDBRequest"; return 0; } @@ -3067,7 +3057,7 @@ sub ReturnNativeToJSValue die "Unknown value for ConvertNullStringTo extended attribute"; } $conv = $signature->extendedAttributes->{"ConvertScriptString"}; - return "v8StringOrNull(exec, $value)" if $conv; + return "return v8StringOrNull($value)" if $conv; return "return v8String($value)"; } diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp index 8c1bae2..996bd01 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp @@ -123,6 +123,44 @@ webkit_dom_test_obj_obj_method_with_args (WebKitDOMTestObj *self, glong int_arg, } +WebKitDOMTestObj* +webkit_dom_test_obj_method_that_requires_all_args (WebKitDOMTestObj *self, gchar* str_arg, WebKitDOMTestObj* obj_arg) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail (str_arg, 0); + g_return_val_if_fail (obj_arg, 0); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail (_g_obj_arg, 0); + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgs(_g_str_arg, _g_obj_arg)); + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + +WebKitDOMTestObj* +webkit_dom_test_obj_method_that_requires_all_args_and_throws (WebKitDOMTestObj *self, gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error) +{ + g_return_val_if_fail (self, 0); + WebCore::TestObj * item = WebKit::core(self); + g_return_val_if_fail (str_arg, 0); + g_return_val_if_fail (obj_arg, 0); + WebCore::String _g_str_arg = WebCore::String::fromUTF8(str_arg); + WebCore::TestObj * _g_obj_arg = WebKit::core(obj_arg); + g_return_val_if_fail (_g_obj_arg, 0); + WebCore::ExceptionCode ec = 0; + PassRefPtr<WebCore::TestObj> g_res = WTF::getPtr(item->methodThatRequiresAllArgsAndThrows(_g_str_arg, _g_obj_arg, ec)); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } + WebKitDOMTestObj* res = static_cast<WebKitDOMTestObj* >(WebKit::kit(g_res.get())); + return res; + +} + void webkit_dom_test_obj_serialized_value (WebKitDOMTestObj *self, WebKitDOMSerializedScriptValue* serialized_arg) { @@ -432,21 +470,33 @@ webkit_dom_test_obj_set_attr_with_exception (WebKitDOMTestObj *self, glong value } glong -webkit_dom_test_obj_get_attr_with_setter_exception (WebKitDOMTestObj *self) +webkit_dom_test_obj_get_attr_with_setter_exception (WebKitDOMTestObj *self, GError **error) { g_return_val_if_fail (self, 0); WebCore::TestObj * item = WebKit::core(self); - glong res = item->attrWithSetterException(); + WebCore::ExceptionCode ec = 0; + glong res = item->attrWithSetterException(ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } return res; } void -webkit_dom_test_obj_set_attr_with_setter_exception (WebKitDOMTestObj *self, glong value) +webkit_dom_test_obj_set_attr_with_setter_exception (WebKitDOMTestObj *self, glong value, GError **error) { g_return_if_fail (self); WebCore::TestObj * item = WebKit::core(self); - item->setAttrWithSetterException(value); + WebCore::ExceptionCode ec = 0; + item->setAttrWithSetterException(value, ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } } @@ -461,11 +511,17 @@ webkit_dom_test_obj_get_attr_with_getter_exception (WebKitDOMTestObj *self) } void -webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value) +webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value, GError **error) { g_return_if_fail (self); WebCore::TestObj * item = WebKit::core(self); - item->setAttrWithGetterException(value); + WebCore::ExceptionCode ec = 0; + item->setAttrWithGetterException(value, ec); + if (ec) { + WebCore::ExceptionCodeDescription ecdesc; + WebCore::getExceptionCodeDescription(ec, ecdesc); + g_set_error_literal(error, g_quark_from_string("WEBKIT_DOM"), ecdesc.code, ecdesc.name); + } } @@ -574,12 +630,14 @@ static void webkit_dom_test_obj_set_property(GObject* object, guint prop_id, con } case PROP_ATTR_WITH_SETTER_EXCEPTION: { - coreSelf->setAttrWithSetterException((g_value_get_long(value)) ); + WebCore::ExceptionCode ec = 0; + coreSelf->setAttrWithSetterException((g_value_get_long(value)) , ec ); break; } case PROP_ATTR_WITH_GETTER_EXCEPTION: { - coreSelf->setAttrWithGetterException((g_value_get_long(value)) ); + WebCore::ExceptionCode ec = 0; + coreSelf->setAttrWithGetterException((g_value_get_long(value)) , ec ); break; } default: @@ -643,7 +701,8 @@ static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GVa } case PROP_ATTR_WITH_SETTER_EXCEPTION: { - g_value_set_long(value, coreSelf->attrWithSetterException()); + WebCore::ExceptionCode ec = 0; + g_value_set_long(value, coreSelf->attrWithSetterException(ec)); break; } case PROP_ATTR_WITH_GETTER_EXCEPTION: diff --git a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h index f8ad9c4..282edb8 100644 --- a/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h +++ b/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h @@ -64,6 +64,12 @@ webkit_dom_test_obj_obj_method (WebKitDOMTestObj *self); WEBKIT_API WebKitDOMTestObj* webkit_dom_test_obj_obj_method_with_args (WebKitDOMTestObj *self, glong int_arg, gchar* str_arg, WebKitDOMTestObj* obj_arg); +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_method_that_requires_all_args (WebKitDOMTestObj *self, gchar* str_arg, WebKitDOMTestObj* obj_arg); + +WEBKIT_API WebKitDOMTestObj* +webkit_dom_test_obj_method_that_requires_all_args_and_throws (WebKitDOMTestObj *self, gchar* str_arg, WebKitDOMTestObj* obj_arg, GError **error); + WEBKIT_API void webkit_dom_test_obj_serialized_value (WebKitDOMTestObj *self, WebKitDOMSerializedScriptValue* serialized_arg); @@ -158,16 +164,16 @@ WEBKIT_API void webkit_dom_test_obj_set_attr_with_exception (WebKitDOMTestObj *self, glong value); WEBKIT_API glong -webkit_dom_test_obj_get_attr_with_setter_exception (WebKitDOMTestObj *self); +webkit_dom_test_obj_get_attr_with_setter_exception (WebKitDOMTestObj *self, GError **error); WEBKIT_API void -webkit_dom_test_obj_set_attr_with_setter_exception (WebKitDOMTestObj *self, glong value); +webkit_dom_test_obj_set_attr_with_setter_exception (WebKitDOMTestObj *self, glong value, GError **error); WEBKIT_API glong webkit_dom_test_obj_get_attr_with_getter_exception (WebKitDOMTestObj *self); WEBKIT_API void -webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value); +webkit_dom_test_obj_set_attr_with_getter_exception (WebKitDOMTestObj *self, glong value, GError **error); WEBKIT_API gchar* webkit_dom_test_obj_get_script_string_attr (WebKitDOMTestObj *self); diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp index 2d0cfae..df403c6 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.cpp @@ -37,12 +37,13 @@ namespace WebCore { JSTestCallback::JSTestCallback(JSObject* callback, JSDOMGlobalObject* globalObject) : m_data(new JSCallbackData(callback, globalObject)) , m_isolatedWorld(globalObject->world()) + , m_scriptExecutionContext(globalObject->scriptExecutionContext()) { } JSTestCallback::~JSTestCallback() { - callOnMainThread(JSCallbackData::deleteData, m_data); + m_scriptExecutionContext->postTask(DeleteCallbackDataTask::create(m_data)); #ifndef NDEBUG m_data = 0; #endif diff --git a/WebCore/bindings/scripts/test/JS/JSTestCallback.h b/WebCore/bindings/scripts/test/JS/JSTestCallback.h index 6e8f083..47a5e95 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestCallback.h +++ b/WebCore/bindings/scripts/test/JS/JSTestCallback.h @@ -49,6 +49,7 @@ private: JSCallbackData* m_data; RefPtr<DOMWrapperWorld> m_isolatedWorld; + ScriptExecutionContext* m_scriptExecutionContext; }; } // namespace WebCore diff --git a/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp b/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp index 8855481..233ba21 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp @@ -39,7 +39,7 @@ ASSERT_CLASS_FITS_IN_CELL(JSTestInterface); static const HashTableValue JSTestInterfaceTableValues[2] = { - { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestInterfaceConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestInterfaceConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, { 0, 0, 0, 0 THUNK_GENERATOR(0) } }; diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp index da99de2..de5a171 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestObj.cpp +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.cpp @@ -48,9 +48,9 @@ ASSERT_CLASS_FITS_IN_CELL(JSTestObj); static const HashTableValue JSTestObjTableValues[15] = { - { "readOnlyIntAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyIntAttr), (intptr_t)0 THUNK_GENERATOR(0) }, - { "readOnlyStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, - { "readOnlyTestObjAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyTestObjAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "readOnlyIntAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyIntAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "readOnlyStringAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "readOnlyTestObjAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjReadOnlyTestObjAttr), (intptr_t)0 THUNK_GENERATOR(0) }, { "intAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjIntAttr), (intptr_t)setJSTestObjIntAttr THUNK_GENERATOR(0) }, { "longLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjLongLongAttr), (intptr_t)setJSTestObjLongLongAttr THUNK_GENERATOR(0) }, { "unsignedLongLongAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjUnsignedLongLongAttr), (intptr_t)setJSTestObjUnsignedLongLongAttr THUNK_GENERATOR(0) }, @@ -60,8 +60,8 @@ static const HashTableValue JSTestObjTableValues[15] = { "attrWithSetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithSetterException), (intptr_t)setJSTestObjAttrWithSetterException THUNK_GENERATOR(0) }, { "attrWithGetterException", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjAttrWithGetterException), (intptr_t)setJSTestObjAttrWithGetterException THUNK_GENERATOR(0) }, { "customAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCustomAttr), (intptr_t)setJSTestObjCustomAttr THUNK_GENERATOR(0) }, - { "scriptStringAttr", DontDelete|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjScriptStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, - { "constructor", DontEnum|ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, + { "scriptStringAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjScriptStringAttr), (intptr_t)0 THUNK_GENERATOR(0) }, + { "constructor", DontEnum | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructor), (intptr_t)0 THUNK_GENERATOR(0) }, { 0, 0, 0, 0 THUNK_GENERATOR(0) } }; @@ -133,33 +133,36 @@ bool JSTestObjConstructor::getOwnPropertyDescriptor(ExecState* exec, const Ident #define THUNK_GENERATOR(generator) #endif -static const HashTableValue JSTestObjPrototypeTableValues[26] = -{ - { "voidMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) }, - { "voidMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, - { "intMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethod), (intptr_t)0 THUNK_GENERATOR(0) }, - { "intMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, - { "objMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethod), (intptr_t)0 THUNK_GENERATOR(0) }, - { "objMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, - { "serializedValue", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSerializedValue), (intptr_t)1 THUNK_GENERATOR(0) }, - { "methodWithException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithException), (intptr_t)0 THUNK_GENERATOR(0) }, - { "customMethod", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethod), (intptr_t)0 THUNK_GENERATOR(0) }, - { "customMethodWithArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, - { "customArgsAndException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomArgsAndException), (intptr_t)1 THUNK_GENERATOR(0) }, - { "addEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, - { "removeEventListener", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, - { "withDynamicFrame", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrame), (intptr_t)0 THUNK_GENERATOR(0) }, - { "withDynamicFrameAndArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndArg), (intptr_t)1 THUNK_GENERATOR(0) }, - { "withDynamicFrameAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, - { "withDynamicFrameAndUserGesture", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture), (intptr_t)1 THUNK_GENERATOR(0) }, - { "withDynamicFrameAndUserGestureASAD", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD), (intptr_t)2 THUNK_GENERATOR(0) }, - { "withScriptStateVoid", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t)0 THUNK_GENERATOR(0) }, - { "withScriptStateObj", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObj), (intptr_t)0 THUNK_GENERATOR(0) }, - { "withScriptStateVoidException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoidException), (intptr_t)0 THUNK_GENERATOR(0) }, - { "withScriptStateObjException", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObjException), (intptr_t)0 THUNK_GENERATOR(0) }, - { "methodWithOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) }, - { "methodWithNonOptionalArgAndOptionalArg", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, - { "methodWithNonOptionalArgAndTwoOptionalArgs", DontDelete|Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t)3 THUNK_GENERATOR(0) }, +static const HashTableValue JSTestObjPrototypeTableValues[29] = +{ + { "voidMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "voidMethodWithArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionVoidMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "intMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "intMethodWithArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionIntMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "objMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "objMethodWithArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionObjMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "methodThatRequiresAllArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodThatRequiresAllArgs), (intptr_t)2 THUNK_GENERATOR(0) }, + { "methodThatRequiresAllArgsAndThrows", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows), (intptr_t)2 THUNK_GENERATOR(0) }, + { "serializedValue", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionSerializedValue), (intptr_t)1 THUNK_GENERATOR(0) }, + { "methodWithException", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "customMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethod), (intptr_t)0 THUNK_GENERATOR(0) }, + { "customMethodWithArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomMethodWithArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "customArgsAndException", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionCustomArgsAndException), (intptr_t)1 THUNK_GENERATOR(0) }, + { "addEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionAddEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "removeEventListener", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionRemoveEventListener), (intptr_t)3 THUNK_GENERATOR(0) }, + { "withDynamicFrame", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrame), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndOptionalArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndUserGesture", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGesture), (intptr_t)1 THUNK_GENERATOR(0) }, + { "withDynamicFrameAndUserGestureASAD", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithDynamicFrameAndUserGestureASAD), (intptr_t)2 THUNK_GENERATOR(0) }, + { "withScriptStateVoid", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoid), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateObj", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObj), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateVoidException", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateVoidException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "withScriptStateObjException", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionWithScriptStateObjException), (intptr_t)0 THUNK_GENERATOR(0) }, + { "methodWithOptionalArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithOptionalArg), (intptr_t)1 THUNK_GENERATOR(0) }, + { "methodWithNonOptionalArgAndOptionalArg", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg), (intptr_t)2 THUNK_GENERATOR(0) }, + { "methodWithNonOptionalArgAndTwoOptionalArgs", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs), (intptr_t)3 THUNK_GENERATOR(0) }, + { "overloadedMethod", DontDelete | Function, (intptr_t)static_cast<NativeFunction>(jsTestObjPrototypeFunctionOverloadedMethod), (intptr_t)2 THUNK_GENERATOR(0) }, { 0, 0, 0, 0 THUNK_GENERATOR(0) } }; @@ -168,7 +171,7 @@ static JSC_CONST_HASHTABLE HashTable JSTestObjPrototypeTable = #if ENABLE(PERFECT_HASH_SIZE) { 8191, JSTestObjPrototypeTableValues, 0 }; #else - { 67, 63, JSTestObjPrototypeTableValues, 0 }; + { 69, 63, JSTestObjPrototypeTableValues, 0 }; #endif const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", 0, &JSTestObjPrototypeTable, 0 }; @@ -300,9 +303,10 @@ JSValue jsTestObjAttrWithException(ExecState* exec, JSValue slotBase, const Iden JSValue jsTestObjAttrWithSetterException(ExecState* exec, JSValue slotBase, const Identifier&) { JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase)); - UNUSED_PARAM(exec); + ExceptionCode ec = 0; TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - JSValue result = jsNumber(exec, imp->attrWithSetterException()); + JSC::JSValue result = jsNumber(exec, imp->attrWithSetterException(ec)); + setDOMException(exec, ec); return result; } @@ -386,14 +390,18 @@ void setJSTestObjAttrWithSetterException(ExecState* exec, JSObject* thisObject, { JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - imp->setAttrWithSetterException(value.toInt32(exec)); + ExceptionCode ec = 0; + imp->setAttrWithSetterException(value.toInt32(exec), ec); + setDOMException(exec, ec); } void setJSTestObjAttrWithGetterException(ExecState* exec, JSObject* thisObject, JSValue value) { JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject); TestObj* imp = static_cast<TestObj*>(castedThis->impl()); - imp->setAttrWithGetterException(value.toInt32(exec)); + ExceptionCode ec = 0; + imp->setAttrWithGetterException(value.toInt32(exec), ec); + setDOMException(exec, ec); } void setJSTestObjCustomAttr(ExecState* exec, JSObject* thisObject, JSValue value) @@ -491,6 +499,42 @@ JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(ExecState* exe return result; } +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + if (args.size() < 2) + return jsUndefined(); + const String& strArg = ustringToString(args.at(0).toString(exec)); + TestObj* objArg = toTestObj(args.at(1)); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgs(strArg, objArg))); + return result; +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + if (args.size() < 2) + return throwError(exec, SyntaxError, "Not enough arguments"); + ExceptionCode ec = 0; + const String& strArg = ustringToString(args.at(0).toString(exec)); + TestObj* objArg = toTestObj(args.at(1)); + + + JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec))); + setDOMException(exec, ec); + return result; +} + JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); @@ -790,17 +834,86 @@ JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOp } int opt1 = args.at(1).toInt32(exec); - if (argsCount < 3) { - imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1); + int opt2 = args.at(2).toInt32(exec); + + imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod1(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + TestObj* objArg = toTestObj(args.at(0)); + const String& strArg = ustringToString(args.at(1).toString(exec)); + + imp->overloadedMethod(objArg, strArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod2(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + TestObj* objArg = toTestObj(args.at(0)); + + int argsCount = args.size(); + if (argsCount < 2) { + imp->overloadedMethod(objArg); return jsUndefined(); } - int opt2 = args.at(2).toInt32(exec); + int intArg = args.at(1).toInt32(exec); - imp->methodWithNonOptionalArgAndTwoOptionalArgs(nonOpt, opt1, opt2); + imp->overloadedMethod(objArg, intArg); return jsUndefined(); } +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod3(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + const String& strArg = ustringToString(args.at(0).toString(exec)); + + imp->overloadedMethod(strArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod4(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + UNUSED_PARAM(args); + if (!thisValue.inherits(&JSTestObj::s_info)) + return throwError(exec, TypeError); + JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(thisValue)); + TestObj* imp = static_cast<TestObj*>(castedThis->impl()); + int intArg = args.at(0).toInt32(exec); + + imp->overloadedMethod(intArg); + return jsUndefined(); +} + +JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) +{ + if ((args.size() == 2 && (args.at(0).isNull() || asObject(args.at(0))->inherits(JSTestObj::s_info) && (args.at(1).isNull() || args.at(1).isUndefined() || args.at(1).isString() || args.at(1).isObject()))) + return jsTestObjPrototypeFunctionOverloadedMethod1(exec, thisValue, args); + if ((args.size() == 1 && (args.at(0).isNull() || asObject(args.at(0))->inherits(JSTestObj::s_info)) || (args.size() == 2 && (args.at(0).isNull() || asObject(args.at(0))->inherits(JSTestObj::s_info))) + return jsTestObjPrototypeFunctionOverloadedMethod2(exec, thisValue, args); + if ((args.size() == 1 && (args.at(0).isNull() || args.at(0).isUndefined() || args.at(0).isString() || args.at(0).isObject()))) + return jsTestObjPrototypeFunctionOverloadedMethod3(exec, thisValue, args); + if (args.size() == 1) + return jsTestObjPrototypeFunctionOverloadedMethod4(exec, thisValue, args); + return throwError(exec, TypeError); +} + JSC::JSValue toJS(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, TestObj* object) { return getDOMObjectWrapper<JSTestObj>(exec, globalObject, object); diff --git a/WebCore/bindings/scripts/test/JS/JSTestObj.h b/WebCore/bindings/scripts/test/JS/JSTestObj.h index f726efb..a1f208d 100644 --- a/WebCore/bindings/scripts/test/JS/JSTestObj.h +++ b/WebCore/bindings/scripts/test/JS/JSTestObj.h @@ -91,6 +91,8 @@ JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethod(JSC::ExecState*, JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionIntMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionObjMethodWithArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodThatRequiresAllArgsAndThrows(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionSerializedValue(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithException(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionCustomMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); @@ -110,6 +112,7 @@ JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionWithScriptStateObjException JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndOptionalArg(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodWithNonOptionalArgAndTwoOptionalArgs(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); +JSC::JSValue JSC_HOST_CALL jsTestObjPrototypeFunctionOverloadedMethod(JSC::ExecState*, JSC::JSObject*, JSC::JSValue, const JSC::ArgList&); // Attributes JSC::JSValue jsTestObjReadOnlyIntAttr(JSC::ExecState*, JSC::JSValue, const JSC::Identifier&); diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h index dd9d2ee..247f4a3 100644 --- a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h @@ -62,6 +62,8 @@ - (int)intMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; - (DOMTestObj *)objMethod; - (DOMTestObj *)objMethodWithArgs:(int)intArg strArg:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (DOMTestObj *)methodThatRequiresAllArgs:(NSString *)strArg objArg:(DOMTestObj *)objArg; +- (DOMTestObj *)methodThatRequiresAllArgsAndThrows:(NSString *)strArg objArg:(DOMTestObj *)objArg; - (void)serializedValue:(NSString *)serializedArg; - (void)methodWithException; - (void)customMethod; diff --git a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm index b964e36..a24f6fe 100644 --- a/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm +++ b/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm @@ -149,12 +149,17 @@ - (int)attrWithSetterException { - return IMPL->attrWithSetterException(); + WebCore::ExceptionCode ec = 0; + int result = IMPL->attrWithSetterException(ec); + WebCore::raiseOnDOMError(ec); + return result; } - (void)setAttrWithSetterException:(int)newAttrWithSetterException { - IMPL->setAttrWithSetterException(newAttrWithSetterException); + WebCore::ExceptionCode ec = 0; + IMPL->setAttrWithSetterException(newAttrWithSetterException, ec); + WebCore::raiseOnDOMError(ec); } - (int)attrWithGetterException @@ -164,7 +169,9 @@ - (void)setAttrWithGetterException:(int)newAttrWithGetterException { - IMPL->setAttrWithGetterException(newAttrWithGetterException); + WebCore::ExceptionCode ec = 0; + IMPL->setAttrWithGetterException(newAttrWithGetterException, ec); + WebCore::raiseOnDOMError(ec); } - (int)customAttr @@ -212,6 +219,19 @@ return kit(WTF::getPtr(IMPL->objMethodWithArgs(intArg, strArg, core(objArg)))); } +- (DOMTestObj *)methodThatRequiresAllArgs:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + return kit(WTF::getPtr(IMPL->methodThatRequiresAllArgs(strArg, core(objArg)))); +} + +- (DOMTestObj *)methodThatRequiresAllArgsAndThrows:(NSString *)strArg objArg:(DOMTestObj *)objArg +{ + WebCore::ExceptionCode ec = 0; + DOMTestObj *result = kit(WTF::getPtr(IMPL->methodThatRequiresAllArgsAndThrows(strArg, core(objArg), ec))); + WebCore::raiseOnDOMError(ec); + return result; +} + - (void)serializedValue:(NSString *)serializedArg { IMPL->serializedValue(WebCore::SerializedScriptValue::create(WebCore::String(serializedArg))); diff --git a/WebCore/bindings/scripts/test/TestObj.idl b/WebCore/bindings/scripts/test/TestObj.idl index b14328d..bda2586 100644 --- a/WebCore/bindings/scripts/test/TestObj.idl +++ b/WebCore/bindings/scripts/test/TestObj.idl @@ -48,13 +48,17 @@ module test { TestObj objMethod(); TestObj objMethodWithArgs(in long intArg, in DOMString strArg, in TestObj objArg); + [RequiresAllArguments] TestObj methodThatRequiresAllArgs(in DOMString strArg, in TestObj objArg); + [RequiresAllArguments=Raise] TestObj methodThatRequiresAllArgsAndThrows(in DOMString strArg, in TestObj objArg) + raises(DOMException); + void serializedValue(in SerializedScriptValue serializedArg); // Exceptions void methodWithException() raises(DOMException); attribute long attrWithException raises(DOMException); - attribute long attrWithSetterException getraises(DOMException); - attribute long attrWithGetterException setraises(DOMException); + attribute long attrWithSetterException getter raises(DOMException); + attribute long attrWithGetterException setter raises(DOMException); // 'Custom' extended attribute attribute [Custom] long customAttr; @@ -92,7 +96,7 @@ module test { // 'ConvertScriptString' extended attribute readonly attribute [ConvertScriptString] DOMString scriptStringAttr; -#ifdef TESTING_V8 +#if defined(TESTING_V8) || defined(TESTING_JS) // Overloads void overloadedMethod(in TestObj objArg, in DOMString strArg); void overloadedMethod(in TestObj objArg, in [Optional] long intArg); diff --git a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp index 94dcd5e..449e086 100644 --- a/WebCore/bindings/scripts/test/V8/V8TestObj.cpp +++ b/WebCore/bindings/scripts/test/V8/V8TestObj.cpp @@ -171,7 +171,13 @@ static v8::Handle<v8::Value> attrWithSetterExceptionAttrGetter(v8::Local<v8::Str { INC_STATS("DOM.TestObj.attrWithSetterException._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - return v8::Integer::New(imp->attrWithSetterException()); + ExceptionCode ec = 0; + int v = imp->attrWithSetterException(ec); + if (UNLIKELY(ec)) { + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); + } + return v8::Integer::New(v); } static void attrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) @@ -179,7 +185,10 @@ static void attrWithSetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Lo INC_STATS("DOM.TestObj.attrWithSetterException._set"); TestObj* imp = V8TestObj::toNative(info.Holder()); int v = toInt32(value); - imp->setAttrWithSetterException(v); + ExceptionCode ec = 0; + imp->setAttrWithSetterException(v, ec); + if (UNLIKELY(ec)) + V8Proxy::setDOMException(ec); return; } @@ -195,7 +204,10 @@ static void attrWithGetterExceptionAttrSetter(v8::Local<v8::String> name, v8::Lo INC_STATS("DOM.TestObj.attrWithGetterException._set"); TestObj* imp = V8TestObj::toNative(info.Holder()); int v = toInt32(value); - imp->setAttrWithGetterException(v); + ExceptionCode ec = 0; + imp->setAttrWithGetterException(v, ec); + if (UNLIKELY(ec)) + V8Proxy::setDOMException(ec); return; } @@ -203,7 +215,7 @@ static v8::Handle<v8::Value> scriptStringAttrAttrGetter(v8::Local<v8::String> na { INC_STATS("DOM.TestObj.scriptStringAttr._get"); TestObj* imp = V8TestObj::toNative(info.Holder()); - v8StringOrNull(exec, imp->scriptStringAttr()); + return v8StringOrNull(imp->scriptStringAttr()); } static v8::Handle<v8::Value> voidMethodCallback(const v8::Arguments& args) @@ -259,6 +271,37 @@ static v8::Handle<v8::Value> objMethodWithArgsCallback(const v8::Arguments& args return toV8(imp->objMethodWithArgs(intArg, strArg, objArg)); } +static v8::Handle<v8::Value> methodThatRequiresAllArgsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodThatRequiresAllArgs"); + if (args.Length() < 2) + return v8::Handle<v8::Value>(); + TestObj* imp = V8TestObj::toNative(args.Holder()); + V8Parameter<> strArg = args[0]; + TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0; + return toV8(imp->methodThatRequiresAllArgs(strArg, objArg)); +} + +static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8::Arguments& args) +{ + INC_STATS("DOM.TestObj.methodThatRequiresAllArgsAndThrows"); + if (args.Length() < 2) + return throwError("Not enough arguments", V8Proxy::SyntaxError); + TestObj* imp = V8TestObj::toNative(args.Holder()); + ExceptionCode ec = 0; + { + V8Parameter<> strArg = args[0]; + TestObj* objArg = V8TestObj::HasInstance(args[1]) ? V8TestObj::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0; + RefPtr<TestObj> result = imp->methodThatRequiresAllArgsAndThrows(strArg, objArg, ec); + if (UNLIKELY(ec)) + goto fail; + return toV8(result.release()); + } + fail: + V8Proxy::setDOMException(ec); + return v8::Handle<v8::Value>(); +} + static v8::Handle<v8::Value> serializedValueCallback(const v8::Arguments& args) { INC_STATS("DOM.TestObj.serializedValue"); @@ -644,6 +687,18 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persi v8::Handle<v8::Signature> objMethodWithArgsSignature = v8::Signature::New(desc, objMethodWithArgsArgc, objMethodWithArgsArgv); proto->Set(v8::String::New("objMethodWithArgs"), v8::FunctionTemplate::New(TestObjInternal::objMethodWithArgsCallback, v8::Handle<v8::Value>(), objMethodWithArgsSignature)); + // Custom Signature 'methodThatRequiresAllArgs' + const int methodThatRequiresAllArgsArgc = 2; + v8::Handle<v8::FunctionTemplate> methodThatRequiresAllArgsArgv[methodThatRequiresAllArgsArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> methodThatRequiresAllArgsSignature = v8::Signature::New(desc, methodThatRequiresAllArgsArgc, methodThatRequiresAllArgsArgv); + proto->Set(v8::String::New("methodThatRequiresAllArgs"), v8::FunctionTemplate::New(TestObjInternal::methodThatRequiresAllArgsCallback, v8::Handle<v8::Value>(), methodThatRequiresAllArgsSignature)); + + // Custom Signature 'methodThatRequiresAllArgsAndThrows' + const int methodThatRequiresAllArgsAndThrowsArgc = 2; + v8::Handle<v8::FunctionTemplate> methodThatRequiresAllArgsAndThrowsArgv[methodThatRequiresAllArgsAndThrowsArgc] = { v8::Handle<v8::FunctionTemplate>(), V8TestObj::GetRawTemplate() }; + v8::Handle<v8::Signature> methodThatRequiresAllArgsAndThrowsSignature = v8::Signature::New(desc, methodThatRequiresAllArgsAndThrowsArgc, methodThatRequiresAllArgsAndThrowsArgv); + proto->Set(v8::String::New("methodThatRequiresAllArgsAndThrows"), v8::FunctionTemplate::New(TestObjInternal::methodThatRequiresAllArgsAndThrowsCallback, v8::Handle<v8::Value>(), methodThatRequiresAllArgsAndThrowsSignature)); + // Custom Signature 'customArgsAndException' const int customArgsAndExceptionArgc = 1; v8::Handle<v8::FunctionTemplate> customArgsAndExceptionArgv[customArgsAndExceptionArgc] = { V8log::GetRawTemplate() }; 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 |