diff options
Diffstat (limited to 'third_party/WebKit/Source/bindings/v8')
24 files changed, 1445 insertions, 338 deletions
diff --git a/third_party/WebKit/Source/bindings/v8/Dictionary.cpp b/third_party/WebKit/Source/bindings/v8/Dictionary.cpp index a25d7fa..199197b 100644 --- a/third_party/WebKit/Source/bindings/v8/Dictionary.cpp +++ b/third_party/WebKit/Source/bindings/v8/Dictionary.cpp @@ -36,12 +36,13 @@ #include "V8SpeechRecognitionResult.h" #include "V8SpeechRecognitionResultList.h" #include "V8Storage.h" -#include "V8Uint8Array.h" #include "V8VoidCallback.h" #include "V8Window.h" #include "bindings/v8/ArrayValue.h" #include "bindings/v8/V8Binding.h" #include "bindings/v8/V8Utilities.h" +#include "bindings/v8/custom/V8ArrayBufferViewCustom.h" +#include "bindings/v8/custom/V8Uint8ArrayCustom.h" #include "core/dom/DOMStringList.h" #include "modules/indexeddb/IDBKeyRange.h" #include "modules/speech/SpeechRecognitionError.h" diff --git a/third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp b/third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp index 1e34ad8..e7c30bb 100644 --- a/third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp +++ b/third_party/WebKit/Source/bindings/v8/ScriptProfiler.cpp @@ -31,7 +31,6 @@ #include "config.h" #include "bindings/v8/ScriptProfiler.h" -#include "V8ArrayBufferView.h" #include "V8Node.h" #include "V8Window.h" #include "bindings/v8/RetainedDOMInfo.h" @@ -39,6 +38,7 @@ #include "bindings/v8/V8Binding.h" #include "bindings/v8/V8DOMWrapper.h" #include "bindings/v8/WrapperTypeInfo.h" +#include "bindings/v8/custom/V8ArrayBufferViewCustom.h" #include "core/dom/Document.h" #include "core/inspector/BindingVisitors.h" @@ -320,7 +320,7 @@ void ScriptProfiler::visitExternalArrays(ExternalArrayVisitor* visitor) // GCd during visiting. ASSERT((*reinterpret_cast<v8::Handle<v8::Value>*>(value))->IsObject()); v8::Handle<v8::Object>* wrapper = reinterpret_cast<v8::Handle<v8::Object>*>(value); - if (!toWrapperTypeInfo(*wrapper)->isSubclass(&V8ArrayBufferView::info)) + if (!(*wrapper)->IsArrayBufferView()) return; m_visitor->visitJSExternalArray(V8ArrayBufferView::toNative(*wrapper)); } diff --git a/third_party/WebKit/Source/bindings/v8/SerializedScriptValue.cpp b/third_party/WebKit/Source/bindings/v8/SerializedScriptValue.cpp index 6de4de2..7bd247f 100644 --- a/third_party/WebKit/Source/bindings/v8/SerializedScriptValue.cpp +++ b/third_party/WebKit/Source/bindings/v8/SerializedScriptValue.cpp @@ -31,26 +31,26 @@ #include "config.h" #include "bindings/v8/SerializedScriptValue.h" -#include "V8ArrayBufferView.h" #include "V8Blob.h" #include "V8DOMFileSystem.h" -#include "V8DataView.h" #include "V8File.h" #include "V8FileList.h" -#include "V8Float32Array.h" #include "V8ImageData.h" -#include "V8Int16Array.h" -#include "V8Int32Array.h" -#include "V8Int8Array.h" #include "V8MessagePort.h" -#include "V8Uint16Array.h" -#include "V8Uint32Array.h" -#include "V8Uint8Array.h" -#include "V8Uint8ClampedArray.h" -#include "bindings/tests/results/V8Float64Array.h" #include "bindings/v8/V8Binding.h" #include "bindings/v8/V8Utilities.h" #include "bindings/v8/custom/V8ArrayBufferCustom.h" +#include "bindings/v8/custom/V8ArrayBufferViewCustom.h" +#include "bindings/v8/custom/V8DataViewCustom.h" +#include "bindings/v8/custom/V8Float32ArrayCustom.h" +#include "bindings/v8/custom/V8Float64ArrayCustom.h" +#include "bindings/v8/custom/V8Int16ArrayCustom.h" +#include "bindings/v8/custom/V8Int32ArrayCustom.h" +#include "bindings/v8/custom/V8Int8ArrayCustom.h" +#include "bindings/v8/custom/V8Uint16ArrayCustom.h" +#include "bindings/v8/custom/V8Uint32ArrayCustom.h" +#include "bindings/v8/custom/V8Uint8ArrayCustom.h" +#include "bindings/v8/custom/V8Uint8ClampedArrayCustom.h" #include "core/dom/ExceptionCode.h" #include "core/dom/MessagePort.h" #include "core/fileapi/Blob.h" diff --git a/third_party/WebKit/Source/bindings/v8/V8Binding.cpp b/third_party/WebKit/Source/bindings/v8/V8Binding.cpp index 137a7a4..8e01e2d 100644 --- a/third_party/WebKit/Source/bindings/v8/V8Binding.cpp +++ b/third_party/WebKit/Source/bindings/v8/V8Binding.cpp @@ -110,6 +110,13 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { return data; } + virtual void* AllocateUninitialized(size_t size) OVERRIDE + { + void* data; + WTF::ArrayBufferContents::allocateMemory(size, WTF::ArrayBufferContents::DontInitialize, data); + return data; + } + virtual void Free(void* data) { WTF::ArrayBufferContents::freeMemory(data); diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8ArrayBufferViewCustom.cpp b/third_party/WebKit/Source/bindings/v8/custom/V8ArrayBufferViewCustom.cpp index 367a723..1d83f4d 100644 --- a/third_party/WebKit/Source/bindings/v8/custom/V8ArrayBufferViewCustom.cpp +++ b/third_party/WebKit/Source/bindings/v8/custom/V8ArrayBufferViewCustom.cpp @@ -25,32 +25,63 @@ #include "config.h" #include "bindings/v8/custom/V8ArrayBufferViewCustom.h" -#include "V8ArrayBufferViewCustomScript.h" -#include "bindings/v8/V8HiddenPropertyName.h" -#include "bindings/v8/V8ScriptRunner.h" +#include "bindings/v8/custom/V8DataViewCustom.h" +#include "bindings/v8/custom/V8Float32ArrayCustom.h" +#include "bindings/v8/custom/V8Float64ArrayCustom.h" +#include "bindings/v8/custom/V8Int16ArrayCustom.h" +#include "bindings/v8/custom/V8Int32ArrayCustom.h" +#include "bindings/v8/custom/V8Int8ArrayCustom.h" +#include "bindings/v8/custom/V8Uint16ArrayCustom.h" +#include "bindings/v8/custom/V8Uint32ArrayCustom.h" +#include "bindings/v8/custom/V8Uint8ArrayCustom.h" +#include "bindings/v8/custom/V8Uint8ClampedArrayCustom.h" #include <v8.h> namespace WebCore { -bool copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray, uint32_t length, uint32_t offset, v8::Isolate* isolate) +using namespace WTF; + +ArrayBufferView* V8ArrayBufferView::toNative(v8::Handle<v8::Object> object) { - v8::Handle<v8::Value> prototype_value = destArray->GetPrototype(); - if (prototype_value.IsEmpty() || !prototype_value->IsObject()) - return false; - v8::Handle<v8::Object> prototype = prototype_value.As<v8::Object>(); - v8::Handle<v8::Value> value = prototype->GetHiddenValue(V8HiddenPropertyName::typedArrayHiddenCopyMethod()); - if (value.IsEmpty()) { - String source(reinterpret_cast<const char*>(V8ArrayBufferViewCustomScript_js), sizeof(V8ArrayBufferViewCustomScript_js)); - value = V8ScriptRunner::compileAndRunInternalScript(v8String(source, isolate), isolate); - prototype->SetHiddenValue(V8HiddenPropertyName::typedArrayHiddenCopyMethod(), value); - } - if (value.IsEmpty() || !value->IsFunction()) - return false; - v8::Handle<v8::Function> copy_method = value.As<v8::Function>(); - v8::Handle<v8::Value> arguments[3] = { srcArray, v8::Uint32::New(length), v8::Uint32::New(offset) }; - V8ScriptRunner::callInternalFunction(copy_method, destArray, WTF_ARRAY_LENGTH(arguments), arguments, isolate); - return true; -} + ASSERT(object->IsArrayBufferView()); + void* viewPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex); + if (viewPtr) + return reinterpret_cast<ArrayBufferView*>(viewPtr); + if (object->IsUint8Array()) { + return V8Uint8Array::toNative(object); + } + if (object->IsInt8Array()) { + return V8Int8Array::toNative(object); + } + if (object->IsUint16Array()) { + return V8Uint16Array::toNative(object); + } + if (object->IsInt16Array()) { + return V8Int16Array::toNative(object); + } + if (object->IsUint32Array()) { + return V8Uint32Array::toNative(object); + } + if (object->IsInt32Array()) { + return V8Int32Array::toNative(object); + } + if (object->IsFloat32Array()) { + return V8Float32Array::toNative(object); + } + if (object->IsFloat64Array()) { + return V8Float64Array::toNative(object); + } + if (object->IsUint8ClampedArray()) { + return V8Uint8ClampedArray::toNative(object); + } + if (object->IsDataView()) { + return V8DataView::toNative(object); + } + ASSERT_NOT_REACHED(); + return 0; } + + +} // namespace WebCore diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8ArrayBufferViewCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8ArrayBufferViewCustom.h index 98de7f5..d39a9d2 100644 --- a/third_party/WebKit/Source/bindings/v8/custom/V8ArrayBufferViewCustom.h +++ b/third_party/WebKit/Source/bindings/v8/custom/V8ArrayBufferViewCustom.h @@ -37,273 +37,29 @@ #include "core/dom/ExceptionCode.h" #include "wtf/ArrayBuffer.h" +#include "wtf/ArrayBufferView.h" namespace WebCore { -const char tooLargeSize[] = "Size is too large (or is negative)."; -const char outOfRangeLengthAndOffset[] = "Index is out of range."; -// Copy the elements from the source array to the typed destination array. -// Returns true if it succeeded, otherwise returns false. -bool copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray, uint32_t length, uint32_t offset, v8::Isolate*); - -template<class JavaScriptWrapperArrayType, class ArrayClass> -void wrapArrayBufferView(const v8::FunctionCallbackInfo<v8::Value>& args, WrapperTypeInfo* type, ArrayClass array, v8::ExternalArrayType arrayType, bool hasIndexer) -{ - // Transform the holder into a wrapper object for the array. - ASSERT(!hasIndexer || static_cast<int32_t>(array.get()->length()) >= 0); - if (hasIndexer) - args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddress(), arrayType, array.get()->length()); - v8::Handle<v8::Object> wrapper = args.Holder(); - V8DOMWrapper::associateObjectWithWrapper<JavaScriptWrapperArrayType>(array.release(), type, wrapper, args.GetIsolate(), WrapperConfiguration::Independent); - args.GetReturnValue().Set(wrapper); -} - -// Template function used by the ArrayBufferView*Constructor callbacks. -template<class ArrayClass, class ElementType, class JavaScriptWrapperArrayType> -void constructWebGLArrayWithArrayBufferArgument(const v8::FunctionCallbackInfo<v8::Value>& args, WrapperTypeInfo* type, v8::ExternalArrayType arrayType, bool hasIndexer) -{ - ArrayBuffer* buf = V8ArrayBuffer::toNative(args[0]->ToObject()); - if (!buf) { - throwTypeError("Could not convert argument 0 to a ArrayBuffer", args.GetIsolate()); - return; - } - bool ok; - uint32_t offset = 0; - int argLen = args.Length(); - if (argLen > 1) { - offset = toUInt32(args[1], ok); - if (!ok) { - throwTypeError("Could not convert argument 1 to a number", args.GetIsolate()); - return; - } - } - uint32_t length = 0; - if (argLen > 2) { - length = toUInt32(args[2], ok); - if (!ok) { - throwTypeError("Could not convert argument 2 to a number", args.GetIsolate()); - return; - } - } else { - if ((buf->byteLength() - offset) % sizeof(ElementType)) { - throwError(v8RangeError, "ArrayBuffer length minus the byteOffset is not a multiple of the element size.", args.GetIsolate()); - return; - } - length = (buf->byteLength() - offset) / sizeof(ElementType); - } - - if (static_cast<int32_t>(length) < 0) { - throwError(v8RangeError, tooLargeSize, args.GetIsolate()); - return; - } - - RefPtr<ArrayClass> array = ArrayClass::create(buf, offset, length); - if (!array) { - throwError(v8RangeError, tooLargeSize, args.GetIsolate()); - return; - } - - wrapArrayBufferView<JavaScriptWrapperArrayType>(args, type, array, arrayType, hasIndexer); -} - -// Template function used by the ArrayBufferView*Constructor callbacks. -template<class ArrayClass, class JavaScriptWrapperArrayType, class ElementType> -void constructWebGLArray(const v8::FunctionCallbackInfo<v8::Value>& args, WrapperTypeInfo* type, v8::ExternalArrayType arrayType) -{ - if (!args.IsConstructCall()) { - throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate()); - return; - } - - if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { - args.GetReturnValue().Set(args.Holder()); - return; - } - - int argLen = args.Length(); - if (!argLen) { - // This happens when we return a previously constructed - // ArrayBufferView, e.g. from the call to <Type>Array.subset(). - // The V8DOMWrapper will set the internal pointer in the - // created object. Unfortunately it doesn't look like it's - // possible to distinguish between this case and that where - // the user calls "new <Type>Array()" from JavaScript. We must - // construct an empty view to avoid crashes when fetching the - // length. - RefPtr<ArrayClass> array = ArrayClass::create(0); - // Do not call SetIndexedPropertiesToExternalArrayData on this - // object. Not only is there no point from a performance - // perspective, but doing so causes errors in the subset() case. - wrapArrayBufferView<JavaScriptWrapperArrayType>(args, type, array, arrayType, false); - return; - } - - // Supported constructors: - // WebGL<T>Array(n) where n is an integer: - // -- create an empty array of n elements - // WebGL<T>Array(arr) where arr is an array: - // -- create a WebGL<T>Array containing the contents of "arr" - // WebGL<T>Array(buf, offset, length) - // -- create a WebGL<T>Array pointing to the ArrayBuffer - // "buf", starting at the specified offset, for the given - // length - - if (args[0]->IsNull()) { - // Invalid first argument - throwTypeError(args.GetIsolate()); - return; - } - - // See whether the first argument is a ArrayBuffer. - if (V8ArrayBuffer::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { - constructWebGLArrayWithArrayBufferArgument<ArrayClass, ElementType, JavaScriptWrapperArrayType>(args, type, arrayType, true); - return; - } - - // See whether the first argument is the same type as impl. In that case, - // we can simply memcpy data from source to impl. - if (JavaScriptWrapperArrayType::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { - ArrayClass* source = JavaScriptWrapperArrayType::toNative(args[0]->ToObject()); - uint32_t length = source->length(); - - if (static_cast<int32_t>(length) < 0) { - throwError(v8RangeError, tooLargeSize, args.GetIsolate()); - return; - } - - RefPtr<ArrayClass> array = ArrayClass::createUninitialized(length); - if (!array.get()) { - throwError(v8RangeError, tooLargeSize, args.GetIsolate()); - return; - } - - array->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance()); - v8::V8::AdjustAmountOfExternalAllocatedMemory(array->byteLength()); - - memcpy(array->baseAddress(), source->baseAddress(), length * sizeof(ElementType)); - - wrapArrayBufferView<JavaScriptWrapperArrayType>(args, type, array, arrayType, true); - return; - } - - uint32_t len = 0; - v8::Handle<v8::Object> srcArray; - bool doInstantiation = false; - - if (args[0]->IsObject()) { - srcArray = args[0]->ToObject(); - if (srcArray.IsEmpty()) { - throwTypeError("Could not convert argument 0 to an array", args.GetIsolate()); - return; - } - v8::Local<v8::Value> val = srcArray->Get(v8::String::NewSymbol("length")); - if (val.IsEmpty()) { - // Exception thrown during fetch of length property. - return; - } - len = toUInt32(val); - doInstantiation = true; - } else { - bool ok = false; - int32_t tempLength = toInt32(args[0], ok); // NaN/+inf/-inf returns 0, this is intended by WebIDL - if (ok && tempLength >= 0) { - len = static_cast<uint32_t>(tempLength); - doInstantiation = true; - } - } - - if (static_cast<int32_t>(len) < 0) { - throwError(v8RangeError, tooLargeSize, args.GetIsolate()); - return; - } - - RefPtr<ArrayClass> array; - if (doInstantiation) { - if (srcArray.IsEmpty()) - array = ArrayClass::create(len); - else - array = ArrayClass::createUninitialized(len); - } - - if (!array.get()) { - throwError(v8RangeError, tooLargeSize, args.GetIsolate()); - return; +class V8ArrayBufferView { +public: + static bool HasInstance(v8::Handle<v8::Value> value, v8::Isolate*, WrapperWorldType) + { + return value->IsArrayBufferView(); } - - if (doInstantiation) { - array->buffer()->setDeallocationObserver(V8ArrayBufferDeallocationObserver::instance()); - v8::V8::AdjustAmountOfExternalAllocatedMemory(array->byteLength()); - } - - - // Transform the holder into a wrapper object for the array. - args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddress(), arrayType, array.get()->length()); - - if (!srcArray.IsEmpty()) { - bool copied = copyElements(args.Holder(), srcArray, len, 0, args.GetIsolate()); - if (!copied) { - for (unsigned i = 0; i < len; i++) { - v8::Local<v8::Value> val = srcArray->Get(i); - if (val.IsEmpty()) { - // Exception thrown during fetch. - return; - } - array->set(i, val->NumberValue()); - } - } - } - - v8::Handle<v8::Object> wrapper = args.Holder(); - V8DOMWrapper::associateObjectWithWrapper<JavaScriptWrapperArrayType>(array.release(), type, wrapper, args.GetIsolate(), WrapperConfiguration::Independent); - args.GetReturnValue().Set(wrapper); -} - -template <class CPlusPlusArrayType, class JavaScriptWrapperArrayType> -void setWebGLArrayHelper(const v8::FunctionCallbackInfo<v8::Value>& args) -{ - if (args.Length() < 1) { - throwNotEnoughArgumentsError(args.GetIsolate()); - return; - } - - CPlusPlusArrayType* impl = JavaScriptWrapperArrayType::toNative(args.Holder()); - - if (JavaScriptWrapperArrayType::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { - // void set(in WebGL<T>Array array, [Optional] in unsigned long offset); - CPlusPlusArrayType* src = JavaScriptWrapperArrayType::toNative(args[0]->ToObject()); - uint32_t offset = 0; - if (args.Length() == 2) - offset = toUInt32(args[1]); - if (!impl->set(src, offset)) { - throwError(v8RangeError, outOfRangeLengthAndOffset, args.GetIsolate()); - return; - } - return; + static bool HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isolate*) + { + return value->IsArrayBufferView(); } + static ArrayBufferView* toNative(v8::Handle<v8::Object>); - if (args[0]->IsObject()) { - // void set(in sequence<long> array, [Optional] in unsigned long offset); - v8::Local<v8::Object> array = args[0]->ToObject(); - uint32_t offset = 0; - if (args.Length() == 2) - offset = toUInt32(args[1]); - uint32_t length = toUInt32(array->Get(v8::String::NewSymbol("length"))); - if (!impl->checkInboundData(offset, length)) { - throwError(v8RangeError, outOfRangeLengthAndOffset, args.GetIsolate()); - return; - } - bool copied = copyElements(args.Holder(), array, length, offset, args.GetIsolate()); - if (!copied) { - for (uint32_t i = 0; i < length; i++) - impl->set(offset + i, array->Get(i)->NumberValue()); - } - return; + static inline void* toInternalPointer(ArrayBufferView* impl) + { + return impl; } +}; - throwTypeError("Invalid argument", args.GetIsolate()); -} - -} +} // namespace WebCore #endif // V8ArrayBufferViewCustom_h diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8BlobCustom.cpp b/third_party/WebKit/Source/bindings/v8/custom/V8BlobCustom.cpp index b13f701..32e35c3 100644 --- a/third_party/WebKit/Source/bindings/v8/custom/V8BlobCustom.cpp +++ b/third_party/WebKit/Source/bindings/v8/custom/V8BlobCustom.cpp @@ -31,13 +31,13 @@ #include "config.h" #include "core/fileapi/Blob.h" -#include "V8ArrayBufferView.h" #include "V8Blob.h" #include "V8File.h" #include "bindings/v8/Dictionary.h" #include "bindings/v8/V8Binding.h" #include "bindings/v8/V8Utilities.h" #include "bindings/v8/custom/V8ArrayBufferCustom.h" +#include "bindings/v8/custom/V8ArrayBufferViewCustom.h" #include "core/fileapi/BlobBuilder.h" #include "wtf/RefPtr.h" diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8CryptoCustom.cpp b/third_party/WebKit/Source/bindings/v8/custom/V8CryptoCustom.cpp index 569e9c3..6c6e2fc 100644 --- a/third_party/WebKit/Source/bindings/v8/custom/V8CryptoCustom.cpp +++ b/third_party/WebKit/Source/bindings/v8/custom/V8CryptoCustom.cpp @@ -25,10 +25,11 @@ #include "config.h" #include "V8Crypto.h" -#include "V8ArrayBufferView.h" #include "bindings/v8/ExceptionState.h" #include "bindings/v8/V8Binding.h" #include "bindings/v8/V8Utilities.h" +#include "bindings/v8/custom/V8ArrayBufferViewCustom.h" +#include "core/dom/ExceptionCode.h" #include "modules/crypto/Crypto.h" #include "wtf/ArrayBufferView.h" diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8DataViewCustom.cpp b/third_party/WebKit/Source/bindings/v8/custom/V8DataViewCustom.cpp index 72b7af1..e07dfa5 100644 --- a/third_party/WebKit/Source/bindings/v8/custom/V8DataViewCustom.cpp +++ b/third_party/WebKit/Source/bindings/v8/custom/V8DataViewCustom.cpp @@ -24,37 +24,29 @@ */ #include "config.h" -#include "core/html/canvas/DataView.h" +#include "bindings/v8/custom/V8DataViewCustom.h" -#include "V8DataView.h" #include "bindings/v8/V8Binding.h" #include "bindings/v8/custom/V8ArrayBufferViewCustom.h" +#include "core/html/canvas/DataView.h" namespace WebCore { -void V8DataView::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& args) +static void initializeScriptWrappableForInterface(DataView* object) { - if (!args.Length()) { - // see constructWebGLArray -- we don't seem to be able to distingish between - // 'new DataView()' and the call used to construct the cached DataView object. - RefPtr<DataView> dataView = DataView::create(0); - v8::Handle<v8::Object> wrapper = args.Holder(); - V8DOMWrapper::associateObjectWithWrapper<V8DataView>(dataView.release(), &info, wrapper, args.GetIsolate(), WrapperConfiguration::Dependent); - args.GetReturnValue().Set(wrapper); - return; - } - if (args[0]->IsNull() || !V8ArrayBuffer::HasInstance(args[0], args.GetIsolate(), worldType(args.GetIsolate()))) { - throwTypeError(args.GetIsolate()); - return; - } - constructWebGLArrayWithArrayBufferArgument<DataView, char, V8DataView>(args, &info, v8::kExternalByteArray, false); + if (ScriptWrappable::wrapperCanBeStoredInObject(object)) + ScriptWrappable::setTypeInfoInObject(object, &V8DataView::info); + else + ASSERT_NOT_REACHED(); } -// FIXME: Don't need this override. -v8::Handle<v8::Object> wrap(DataView* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +} // namespace WebCore + +// In ScriptWrappable::init, the use of a local function declaration has an issue on Windows: +// the local declaration does not pick up the surrounding namespace. Therefore, we provide this function +// in the global namespace. +// (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c) +void webCoreInitializeScriptWrappableForInterface(WebCore::DataView* object) { - ASSERT(impl); - return V8DataView::createWrapper(impl, creationContext, isolate); + WebCore::initializeScriptWrappableForInterface(object); } - -} // namespace WebCore diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8DataViewCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8DataViewCustom.h new file mode 100644 index 0000000..67f9781 --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8DataViewCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8DataViewCustom_h +#define V8DataViewCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "core/html/canvas/DataView.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<DataView> { +public: + typedef v8::DataView V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsDataView(); + } + + static size_t length(v8::Handle<v8::DataView> value) + { + return value->ByteLength(); + } + + static size_t length(DataView* array) + { + return array->byteLength(); + } +}; + +typedef V8TypedArray<DataView> V8DataView; + +template<> +class WrapperTypeTraits<DataView> : public TypedArrayWrapperTraits<DataView> { }; + + +inline v8::Handle<v8::Object> wrap(DataView* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<DataView>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(DataView* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<DataView>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(DataView* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<DataView>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(DataView* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<DataView>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(DataView* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<DataView>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< DataView > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< DataView > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< DataView > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8Float32ArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8Float32ArrayCustom.h new file mode 100644 index 0000000..f980ea0 --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8Float32ArrayCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8Float32ArrayCustom_h +#define V8Float32ArrayCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "wtf/Float32Array.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<Float32Array> { +public: + typedef v8::Float32Array V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsFloat32Array(); + } + + static size_t length(v8::Handle<v8::Float32Array> value) + { + return value->Length(); + } + + static size_t length(Float32Array* array) + { + return array->length(); + } +}; + +typedef V8TypedArray<Float32Array> V8Float32Array; + +template<> +class WrapperTypeTraits<Float32Array> : public TypedArrayWrapperTraits<Float32Array> { }; + + +inline v8::Handle<v8::Object> wrap(Float32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Float32Array>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(Float32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Float32Array>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(Float32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Float32Array>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(Float32Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Float32Array>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(Float32Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Float32Array>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< Float32Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< Float32Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< Float32Array > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8Float64ArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8Float64ArrayCustom.h new file mode 100644 index 0000000..1cabb08 --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8Float64ArrayCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8Float64ArrayCustom_h +#define V8Float64ArrayCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "wtf/Float64Array.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<Float64Array> { +public: + typedef v8::Float64Array V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsFloat64Array(); + } + + static size_t length(v8::Handle<v8::Float64Array> value) + { + return value->Length(); + } + + static size_t length(Float64Array* array) + { + return array->length(); + } +}; + +typedef V8TypedArray<Float64Array> V8Float64Array; + +template<> +class WrapperTypeTraits<Float64Array> : public TypedArrayWrapperTraits<Float64Array> { }; + + +inline v8::Handle<v8::Object> wrap(Float64Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Float64Array>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(Float64Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Float64Array>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(Float64Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Float64Array>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(Float64Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Float64Array>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(Float64Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Float64Array>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< Float64Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< Float64Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< Float64Array > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8ImageDataCustom.cpp b/third_party/WebKit/Source/bindings/v8/custom/V8ImageDataCustom.cpp index cb35401..3e2e670 100644 --- a/third_party/WebKit/Source/bindings/v8/custom/V8ImageDataCustom.cpp +++ b/third_party/WebKit/Source/bindings/v8/custom/V8ImageDataCustom.cpp @@ -31,7 +31,7 @@ #include "config.h" #include "V8ImageData.h" -#include "V8Uint8ClampedArray.h" +#include "bindings/v8/custom/V8Uint8ClampedArrayCustom.h" namespace WebCore { diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp b/third_party/WebKit/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp index 1ac446e..73b8d63 100644 --- a/third_party/WebKit/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp +++ b/third_party/WebKit/Source/bindings/v8/custom/V8InjectedScriptHostCustom.cpp @@ -32,20 +32,11 @@ #include "V8InjectedScriptHost.h" #include "V8Database.h" -#include "V8Float32Array.h" #include "V8HTMLAllCollection.h" #include "V8HTMLCollection.h" -#include "V8Int16Array.h" -#include "V8Int32Array.h" -#include "V8Int8Array.h" #include "V8Node.h" #include "V8NodeList.h" #include "V8Storage.h" -#include "V8Uint16Array.h" -#include "V8Uint32Array.h" -#include "V8Uint8Array.h" -#include "V8Uint8ClampedArray.h" -#include "bindings/tests/results/V8Float64Array.h" #include "bindings/v8/BindingSecurity.h" #include "bindings/v8/ScriptDebugServer.h" #include "bindings/v8/ScriptValue.h" @@ -53,6 +44,15 @@ #include "bindings/v8/V8Binding.h" #include "bindings/v8/V8HiddenPropertyName.h" #include "bindings/v8/V8ScriptRunner.h" +#include "bindings/v8/custom/V8Float32ArrayCustom.h" +#include "bindings/v8/custom/V8Float64ArrayCustom.h" +#include "bindings/v8/custom/V8Int16ArrayCustom.h" +#include "bindings/v8/custom/V8Int32ArrayCustom.h" +#include "bindings/v8/custom/V8Int8ArrayCustom.h" +#include "bindings/v8/custom/V8Uint16ArrayCustom.h" +#include "bindings/v8/custom/V8Uint32ArrayCustom.h" +#include "bindings/v8/custom/V8Uint8ArrayCustom.h" +#include "bindings/v8/custom/V8Uint8ClampedArrayCustom.h" #include "core/inspector/InjectedScript.h" #include "core/inspector/InjectedScriptHost.h" #include "core/inspector/InspectorDOMAgent.h" diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8Int16ArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8Int16ArrayCustom.h new file mode 100644 index 0000000..f5a7c83 --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8Int16ArrayCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8Int16ArrayCustom_h +#define V8Int16ArrayCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "wtf/Int16Array.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<Int16Array> { +public: + typedef v8::Int16Array V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsInt16Array(); + } + + static size_t length(v8::Handle<v8::Int16Array> value) + { + return value->Length(); + } + + static size_t length(Int16Array* array) + { + return array->length(); + } +}; + +typedef V8TypedArray<Int16Array> V8Int16Array; + +template<> +class WrapperTypeTraits<Int16Array> : public TypedArrayWrapperTraits<Int16Array> { }; + + +inline v8::Handle<v8::Object> wrap(Int16Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Int16Array>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(Int16Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Int16Array>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(Int16Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Int16Array>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(Int16Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Int16Array>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(Int16Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Int16Array>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< Int16Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< Int16Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< Int16Array > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8Int32ArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8Int32ArrayCustom.h new file mode 100644 index 0000000..29a927b --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8Int32ArrayCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8Int32ArrayCustom_h +#define V8Int32ArrayCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "wtf/Int32Array.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<Int32Array> { +public: + typedef v8::Int32Array V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsInt32Array(); + } + + static size_t length(v8::Handle<v8::Int32Array> value) + { + return value->Length(); + } + + static size_t length(Int32Array* array) + { + return array->length(); + } +}; + +typedef V8TypedArray<Int32Array> V8Int32Array; + +template<> +class WrapperTypeTraits<Int32Array> : public TypedArrayWrapperTraits<Int32Array> { }; + + +inline v8::Handle<v8::Object> wrap(Int32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Int32Array>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(Int32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Int32Array>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(Int32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Int32Array>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(Int32Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Int32Array>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(Int32Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Int32Array>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< Int32Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< Int32Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< Int32Array > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8Int8ArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8Int8ArrayCustom.h new file mode 100644 index 0000000..f325aba --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8Int8ArrayCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8Int8ArrayCustom_h +#define V8Int8ArrayCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "wtf/Int8Array.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<Int8Array> { +public: + typedef v8::Int8Array V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsInt8Array(); + } + + static size_t length(v8::Handle<v8::Int8Array> value) + { + return value->Length(); + } + + static size_t length(Int8Array* array) + { + return array->length(); + } +}; + +typedef V8TypedArray<Int8Array> V8Int8Array; + +template<> +class WrapperTypeTraits<Int8Array> : public TypedArrayWrapperTraits<Int8Array> { }; + + +inline v8::Handle<v8::Object> wrap(Int8Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Int8Array>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(Int8Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Int8Array>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(Int8Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Int8Array>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(Int8Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Int8Array>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(Int8Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Int8Array>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< Int8Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< Int8Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< Int8Array > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8TypedArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8TypedArrayCustom.h new file mode 100644 index 0000000..44997bf --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8TypedArrayCustom.h @@ -0,0 +1,189 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8TypedArrayCustom_h +#define V8TypedArrayCustom_h + +#include "bindings/v8/V8Binding.h" +#include "bindings/v8/V8DOMWrapper.h" +#include "bindings/v8/WrapperTypeInfo.h" +#include "bindings/v8/custom/V8ArrayBufferCustom.h" + +#include "wtf/ArrayBuffer.h" + +#include <v8.h> + +namespace WebCore { + +template<typename T> +class TypedArrayTraits +{ }; + +template<typename TypedArray> +class V8TypedArray { +public: + static bool HasInstance(v8::Handle<v8::Value> value, v8::Isolate*, WrapperWorldType) + { + return TypedArrayTraits<TypedArray>::IsInstance(value); + } + + static bool HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::Isolate*) + { + return TypedArrayTraits<TypedArray>::IsInstance(value); + } + + static TypedArray* toNative(v8::Handle<v8::Object>); + static void derefObject(void*); + static WrapperTypeInfo info; + static const int internalFieldCount = v8DefaultWrapperInternalFieldCount; + + static v8::Handle<v8::Object> wrap(TypedArray* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) + { + ASSERT(impl); + ASSERT((DOMDataStore::template getWrapper<Binding>(impl, isolate).IsEmpty())); + return V8TypedArray<TypedArray>::createWrapper(impl, creationContext, isolate); + } + + static v8::Handle<v8::Value> toV8(TypedArray* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) + { + if (UNLIKELY(!impl)) + return v8NullWithCheck(isolate); + v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper<Binding>(impl, isolate); + if (!wrapper.IsEmpty()) + return wrapper; + return wrap(impl, creationContext, isolate); + } + + static v8::Handle<v8::Value> toV8ForMainWorld(TypedArray* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) + { + ASSERT(worldType(isolate) == MainWorld); + if (UNLIKELY(!impl)) + return v8NullWithCheck(isolate); + v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapperForMainWorld<Binding>(impl); + if (!wrapper.IsEmpty()) + return wrapper; + return wrap(impl, creationContext, isolate); + } + + template<class HolderContainer, class Wrappable> + static v8::Handle<v8::Value> toV8Fast(TypedArray* impl, const HolderContainer& container, Wrappable* wrappable) + { + if (UNLIKELY(!impl)) + return v8::Null(container.GetIsolate()); + v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperFast<Binding>(impl, container, wrappable); + if (!wrapper.IsEmpty()) + return wrapper; + return wrap(impl, container.Holder(), container.GetIsolate()); + } + + template<class HolderContainer, class Wrappable> + static v8::Handle<v8::Value> toV8FastForMainWorld(TypedArray* impl, const HolderContainer& container, Wrappable* wrappable) + { + ASSERT(worldType(container.GetIsolate()) == MainWorld); + if (UNLIKELY(!impl)) + return v8::Null(container.GetIsolate()); + v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperForMainWorld<Binding>(impl); + if (!wrapper.IsEmpty()) + return wrapper; + return wrap(impl, container.Holder(), container.GetIsolate()); + } + + static inline void* toInternalPointer(TypedArray* impl) + { + return impl; + } +private: + typedef TypedArrayTraits<TypedArray> Traits; + typedef typename Traits::V8Type V8Type; + typedef V8TypedArray<TypedArray> Binding; + + static v8::Handle<v8::Object> createWrapper(PassRefPtr<TypedArray>, v8::Handle<v8::Object> creationContext, v8::Isolate*); +}; + +template<typename TypedArray> +class TypedArrayWrapperTraits { +public: + static WrapperTypeInfo* info() { return &V8TypedArray<TypedArray>::info; } +}; + + +template <typename TypedArray> +v8::Handle<v8::Object> V8TypedArray<TypedArray>::createWrapper(PassRefPtr<TypedArray> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + ASSERT(impl.get()); + ASSERT(DOMDataStore::getWrapper<Binding>(impl.get(), isolate).IsEmpty()); + + RefPtr<ArrayBuffer> buffer = impl->buffer(); + v8::Local<v8::Value> v8Buffer = v8::Local<v8::Value>::New(WebCore::toV8(buffer.get(), creationContext, isolate)); + + ASSERT(v8Buffer->IsArrayBuffer()); + + v8::Local<v8::Object> wrapper = V8Type::New(v8Buffer.As<v8::ArrayBuffer>(), impl->byteOffset(), Traits::length(impl.get())); + + V8DOMWrapper::associateObjectWithWrapper<Binding>(impl, &info, wrapper, isolate, WrapperConfiguration::Independent); + return wrapper; +} + +template <typename TypedArray> +TypedArray* V8TypedArray<TypedArray>::toNative(v8::Handle<v8::Object> object) +{ + ASSERT(Traits::IsInstance(object)); + void* typedarrayPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex); + if (typedarrayPtr) + return reinterpret_cast<TypedArray*>(typedarrayPtr); + + v8::Handle<V8Type> view = object.As<V8Type>(); + RefPtr<ArrayBuffer> arrayBuffer = V8ArrayBuffer::toNative(view->Buffer()); + RefPtr<TypedArray> typedArray = TypedArray::create(arrayBuffer, view->ByteOffset(), Traits::length(view)); + ASSERT(typedArray.get()); + V8DOMWrapper::associateObjectWithWrapper<Binding>(typedArray.release(), &info, object, v8::Isolate::GetCurrent(), WrapperConfiguration::Independent); + + typedarrayPtr = object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex); + ASSERT(typedarrayPtr); + return reinterpret_cast<TypedArray*>(typedarrayPtr); +} + + +template <typename TypedArray> +WrapperTypeInfo V8TypedArray<TypedArray>::info = { + 0, V8TypedArray<TypedArray>::derefObject, + 0, 0, 0, 0, 0, WrapperTypeObjectPrototype +}; + +template <typename TypedArray> +void V8TypedArray<TypedArray>::derefObject(void* object) +{ + static_cast<TypedArray*>(object)->deref(); +} + + +} // namespace WebCode + +#endif // V8TypedArrayCustom_h diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8Uint16ArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8Uint16ArrayCustom.h new file mode 100644 index 0000000..30a7403 --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8Uint16ArrayCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8Uint16ArrayCustom_h +#define V8Uint16ArrayCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "wtf/Uint16Array.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<Uint16Array> { +public: + typedef v8::Uint16Array V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsUint16Array(); + } + + static size_t length(v8::Handle<v8::Uint16Array> value) + { + return value->Length(); + } + + static size_t length(Uint16Array* array) + { + return array->length(); + } +}; + +typedef V8TypedArray<Uint16Array> V8Uint16Array; + +template<> +class WrapperTypeTraits<Uint16Array> : public TypedArrayWrapperTraits<Uint16Array> { }; + + +inline v8::Handle<v8::Object> wrap(Uint16Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint16Array>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(Uint16Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint16Array>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(Uint16Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint16Array>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(Uint16Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Uint16Array>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(Uint16Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Uint16Array>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< Uint16Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< Uint16Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< Uint16Array > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8Uint32ArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8Uint32ArrayCustom.h new file mode 100644 index 0000000..0f86baa --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8Uint32ArrayCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8Uint32ArrayCustom_h +#define V8Uint32ArrayCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "wtf/Uint32Array.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<Uint32Array> { +public: + typedef v8::Uint32Array V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsUint32Array(); + } + + static size_t length(v8::Handle<v8::Uint32Array> value) + { + return value->Length(); + } + + static size_t length(Uint32Array* array) + { + return array->length(); + } +}; + +typedef V8TypedArray<Uint32Array> V8Uint32Array; + +template<> +class WrapperTypeTraits<Uint32Array> : public TypedArrayWrapperTraits<Uint32Array> { }; + + +inline v8::Handle<v8::Object> wrap(Uint32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint32Array>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(Uint32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint32Array>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(Uint32Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint32Array>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(Uint32Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Uint32Array>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(Uint32Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Uint32Array>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< Uint32Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< Uint32Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< Uint32Array > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8Uint8ArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8Uint8ArrayCustom.h new file mode 100644 index 0000000..fffaecd --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8Uint8ArrayCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8Uint8ArrayCustom_h +#define V8Uint8ArrayCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "wtf/Uint8Array.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<Uint8Array> { +public: + typedef v8::Uint8Array V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsUint8Array(); + } + + static size_t length(v8::Handle<v8::Uint8Array> value) + { + return value->Length(); + } + + static size_t length(Uint8Array* array) + { + return array->length(); + } +}; + +typedef V8TypedArray<Uint8Array> V8Uint8Array; + +template<> +class WrapperTypeTraits<Uint8Array> : public TypedArrayWrapperTraits<Uint8Array> { }; + + +inline v8::Handle<v8::Object> wrap(Uint8Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint8Array>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(Uint8Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint8Array>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(Uint8Array* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint8Array>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(Uint8Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Uint8Array>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(Uint8Array* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Uint8Array>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< Uint8Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< Uint8Array > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< Uint8Array > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8Uint8ClampedArrayCustom.h b/third_party/WebKit/Source/bindings/v8/custom/V8Uint8ClampedArrayCustom.h new file mode 100644 index 0000000..2edd476 --- /dev/null +++ b/third_party/WebKit/Source/bindings/v8/custom/V8Uint8ClampedArrayCustom.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2013 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef V8Uint8ClampedArrayCustom_h +#define V8Uint8ClampedArrayCustom_h + +#include "bindings/v8/custom/V8TypedArrayCustom.h" +#include "wtf/Uint8ClampedArray.h" + +namespace WebCore { + +template<> +class TypedArrayTraits<Uint8ClampedArray> { +public: + typedef v8::Uint8ClampedArray V8Type; + + static bool IsInstance(v8::Handle<v8::Value> value) + { + return value->IsUint8ClampedArray(); + } + + static size_t length(v8::Handle<v8::Uint8ClampedArray> value) + { + return value->Length(); + } + + static size_t length(Uint8ClampedArray* array) + { + return array->length(); + } +}; + +typedef V8TypedArray<Uint8ClampedArray> V8Uint8ClampedArray; + +template<> +class WrapperTypeTraits<Uint8ClampedArray> : public TypedArrayWrapperTraits<Uint8ClampedArray> { }; + + +inline v8::Handle<v8::Object> wrap(Uint8ClampedArray* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint8ClampedArray>::wrap(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8(Uint8ClampedArray* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint8ClampedArray>::toV8(impl, creationContext, isolate); +} + +inline v8::Handle<v8::Value> toV8ForMainWorld(Uint8ClampedArray* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return V8TypedArray<Uint8ClampedArray>::toV8ForMainWorld(impl, creationContext, isolate); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(Uint8ClampedArray* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Uint8ClampedArray>::toV8Fast(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(Uint8ClampedArray* impl, const HolderContainer& container, Wrappable* wrappable) +{ + return V8TypedArray<Uint8ClampedArray>::toV8FastForMainWorld(impl, container, wrappable); +} + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8FastForMainWorld(PassRefPtr< Uint8ClampedArray > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8FastForMainWorld(impl.get(), container, wrappable); +} + + +template<class HolderContainer, class Wrappable> +inline v8::Handle<v8::Value> toV8Fast(PassRefPtr< Uint8ClampedArray > impl, const HolderContainer& container, Wrappable* wrappable) +{ + return toV8Fast(impl.get(), container, wrappable); +} + +inline v8::Handle<v8::Value> toV8(PassRefPtr< Uint8ClampedArray > impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) +{ + return toV8(impl.get(), creationContext, isolate); +} + +} // namespace WebCore + +#endif diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/third_party/WebKit/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 18ec9ce..3d2c55a 100644 --- a/third_party/WebKit/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/third_party/WebKit/Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -32,17 +32,12 @@ #include "V8WebGLRenderingContext.h" #include "V8ANGLEInstancedArrays.h" -#include "V8ArrayBufferView.h" #include "V8EXTFragDepth.h" #include "V8EXTTextureFilterAnisotropic.h" -#include "V8Float32Array.h" #include "V8HTMLCanvasElement.h" #include "V8HTMLImageElement.h" #include "V8HTMLVideoElement.h" #include "V8ImageData.h" -#include "V8Int16Array.h" -#include "V8Int32Array.h" -#include "V8Int8Array.h" #include "V8OESElementIndexUint.h" #include "V8OESStandardDerivatives.h" #include "V8OESTextureFloat.h" @@ -50,9 +45,6 @@ #include "V8OESTextureHalfFloat.h" #include "V8OESTextureHalfFloatLinear.h" #include "V8OESVertexArrayObject.h" -#include "V8Uint16Array.h" -#include "V8Uint32Array.h" -#include "V8Uint8Array.h" #include "V8WebGLBuffer.h" #include "V8WebGLCompressedTextureATC.h" #include "V8WebGLCompressedTexturePVRTC.h" @@ -72,6 +64,14 @@ #include "bindings/v8/ExceptionState.h" #include "bindings/v8/V8Binding.h" #include "bindings/v8/V8HiddenPropertyName.h" +#include "bindings/v8/custom/V8ArrayBufferViewCustom.h" +#include "bindings/v8/custom/V8Float32ArrayCustom.h" +#include "bindings/v8/custom/V8Int16ArrayCustom.h" +#include "bindings/v8/custom/V8Int32ArrayCustom.h" +#include "bindings/v8/custom/V8Int8ArrayCustom.h" +#include "bindings/v8/custom/V8Uint16ArrayCustom.h" +#include "bindings/v8/custom/V8Uint32ArrayCustom.h" +#include "bindings/v8/custom/V8Uint8ArrayCustom.h" #include "core/dom/ExceptionCode.h" #include "core/html/canvas/WebGLRenderingContext.h" #include "core/platform/NotImplemented.h" diff --git a/third_party/WebKit/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp b/third_party/WebKit/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp index 4302221..e9eabc2 100644 --- a/third_party/WebKit/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp +++ b/third_party/WebKit/Source/bindings/v8/custom/V8XMLHttpRequestCustom.cpp @@ -31,7 +31,6 @@ #include "config.h" #include "V8XMLHttpRequest.h" -#include "V8ArrayBufferView.h" #include "V8Blob.h" #include "V8Document.h" #include "V8FormData.h" @@ -40,6 +39,7 @@ #include "bindings/v8/V8Binding.h" #include "bindings/v8/V8Utilities.h" #include "bindings/v8/custom/V8ArrayBufferCustom.h" +#include "bindings/v8/custom/V8ArrayBufferViewCustom.h" #include "core/dom/Document.h" #include "core/inspector/InspectorInstrumentation.h" #include "core/page/Frame.h" |