diff options
Diffstat (limited to 'WebCore/bindings/js')
60 files changed, 1361 insertions, 995 deletions
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 |