Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Unified Diff: Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h

Issue 10543046: Merge 118955 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1132/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
===================================================================
--- Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h (revision 119657)
+++ Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h (working copy)
@@ -40,20 +40,11 @@
namespace WebCore {
+// 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);
-// Check if the JavaScript 'set' method was already installed
-// on the prototype of the given typed array.
-bool fastSetInstalled(v8::Handle<v8::Object> array);
-// Install the JavaScript 'set' method on the prototype of
-// the given typed array.
-void installFastSet(v8::Handle<v8::Object> array);
-
-// Copy the elements from the source array to the typed destination array by
-// invoking the 'set' method of the destination array in JS.
-void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcArray, uint32_t offset);
-
-
// Template function used by the ArrayBufferView*Constructor callbacks.
template<class ArrayClass, class ElementType>
v8::Handle<v8::Value> constructWebGLArrayWithArrayBufferArgument(const v8::Arguments& args, WrapperTypeInfo* type, v8::ExternalArrayType arrayType, bool hasIndexer)
@@ -176,8 +167,13 @@
V8DOMWrapper::setDOMWrapper(args.Holder(), type, array.get());
args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddress(), arrayType, array.get()->length());
- if (!srcArray.IsEmpty())
- copyElements(args.Holder(), srcArray, 0);
+ if (!srcArray.IsEmpty()) {
+ bool copied = copyElements(args.Holder(), srcArray, len, 0);
+ if (!copied) {
+ for (unsigned i = 0; i < len; i++)
+ array->set(i, srcArray->Get(i)->NumberValue());
+ }
+ }
v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>::New(args.Holder());
wrapper.MarkIndependent();
@@ -219,10 +215,8 @@
// Out of range offset or overflow
V8Proxy::setDOMException(INDEX_SIZE_ERR, args.GetIsolate());
else {
- if (!fastSetInstalled(args.Holder())) {
- installFastSet(args.Holder());
- copyElements(args.Holder(), array, offset);
- } else {
+ bool copied = copyElements(args.Holder(), array, length, offset);
+ if (!copied) {
for (uint32_t i = 0; i < length; i++)
impl->set(offset + i, array->Get(i)->NumberValue());
}

Powered by Google App Engine
This is Rietveld 408576698