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

Side by Side Diff: Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h

Issue 9186030: Merge 104736 - [v8] Int16Array.set(array, offset) fails on first execution (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 11 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 // Check if the JavaScript 'set' method was already installed 44 // Check if the JavaScript 'set' method was already installed
45 // on the prototype of the given typed array. 45 // on the prototype of the given typed array.
46 bool fastSetInstalled(v8::Handle<v8::Object> array); 46 bool fastSetInstalled(v8::Handle<v8::Object> array);
47 47
48 // Install the JavaScript 'set' method on the prototype of 48 // Install the JavaScript 'set' method on the prototype of
49 // the given typed array. 49 // the given typed array.
50 void installFastSet(v8::Handle<v8::Object> array); 50 void installFastSet(v8::Handle<v8::Object> array);
51 51
52 // Copy the elements from the source array to the typed destination array by 52 // Copy the elements from the source array to the typed destination array by
53 // invoking the 'set' method of the destination array in JS. 53 // invoking the 'set' method of the destination array in JS.
54 void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcAr ray); 54 void copyElements(v8::Handle<v8::Object> destArray, v8::Handle<v8::Object> srcAr ray, uint32_t offset);
55 55
56 56
57 // Template function used by the ArrayBufferView*Constructor callbacks. 57 // Template function used by the ArrayBufferView*Constructor callbacks.
58 template<class ArrayClass, class ElementType> 58 template<class ArrayClass, class ElementType>
59 v8::Handle<v8::Value> constructWebGLArrayWithArrayBufferArgument(const v8::Argum ents& args, WrapperTypeInfo* type, v8::ExternalArrayType arrayType, bool hasInde xer) 59 v8::Handle<v8::Value> constructWebGLArrayWithArrayBufferArgument(const v8::Argum ents& args, WrapperTypeInfo* type, v8::ExternalArrayType arrayType, bool hasInde xer)
60 { 60 {
61 ArrayBuffer* buf = V8ArrayBuffer::toNative(args[0]->ToObject()); 61 ArrayBuffer* buf = V8ArrayBuffer::toNative(args[0]->ToObject());
62 if (!buf) 62 if (!buf)
63 return throwError("Could not convert argument 0 to a ArrayBuffer"); 63 return throwError("Could not convert argument 0 to a ArrayBuffer");
64 bool ok; 64 bool ok;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 array = ArrayClass::create(len); 164 array = ArrayClass::create(len);
165 if (!array.get()) 165 if (!array.get())
166 return throwError("ArrayBufferView size is not a small enough positive i nteger.", V8Proxy::RangeError); 166 return throwError("ArrayBufferView size is not a small enough positive i nteger.", V8Proxy::RangeError);
167 167
168 168
169 // Transform the holder into a wrapper object for the array. 169 // Transform the holder into a wrapper object for the array.
170 V8DOMWrapper::setDOMWrapper(args.Holder(), type, array.get()); 170 V8DOMWrapper::setDOMWrapper(args.Holder(), type, array.get());
171 args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddr ess(), arrayType, array.get()->length()); 171 args.Holder()->SetIndexedPropertiesToExternalArrayData(array.get()->baseAddr ess(), arrayType, array.get()->length());
172 172
173 if (!srcArray.IsEmpty()) 173 if (!srcArray.IsEmpty())
174 copyElements(args.Holder(), srcArray); 174 copyElements(args.Holder(), srcArray, 0);
175 175
176 return toV8(array.release(), args.Holder(), MarkIndependent); 176 return toV8(array.release(), args.Holder(), MarkIndependent);
177 } 177 }
178 178
179 template <class CPlusPlusArrayType, class JavaScriptWrapperArrayType> 179 template <class CPlusPlusArrayType, class JavaScriptWrapperArrayType>
180 v8::Handle<v8::Value> setWebGLArrayHelper(const v8::Arguments& args) 180 v8::Handle<v8::Value> setWebGLArrayHelper(const v8::Arguments& args)
181 { 181 {
182 if (args.Length() < 1) { 182 if (args.Length() < 1) {
183 V8Proxy::setDOMException(SYNTAX_ERR); 183 V8Proxy::setDOMException(SYNTAX_ERR);
184 return notHandledByInterceptor(); 184 return notHandledByInterceptor();
(...skipping 20 matching lines...) Expand all
205 offset = toUInt32(args[1]); 205 offset = toUInt32(args[1]);
206 uint32_t length = toUInt32(array->Get(v8::String::New("length"))); 206 uint32_t length = toUInt32(array->Get(v8::String::New("length")));
207 if (offset > impl->length() 207 if (offset > impl->length()
208 || offset + length > impl->length() 208 || offset + length > impl->length()
209 || offset + length < offset) 209 || offset + length < offset)
210 // Out of range offset or overflow 210 // Out of range offset or overflow
211 V8Proxy::setDOMException(INDEX_SIZE_ERR); 211 V8Proxy::setDOMException(INDEX_SIZE_ERR);
212 else { 212 else {
213 if (!fastSetInstalled(args.Holder())) { 213 if (!fastSetInstalled(args.Holder())) {
214 installFastSet(args.Holder()); 214 installFastSet(args.Holder());
215 copyElements(args.Holder(), array); 215 copyElements(args.Holder(), array, offset);
216 } else { 216 } else {
217 for (uint32_t i = 0; i < length; i++) 217 for (uint32_t i = 0; i < length; i++)
218 impl->set(offset + i, array->Get(i)->NumberValue()); 218 impl->set(offset + i, array->Get(i)->NumberValue());
219 } 219 }
220 } 220 }
221 return v8::Undefined(); 221 return v8::Undefined();
222 } 222 }
223 223
224 V8Proxy::setDOMException(SYNTAX_ERR); 224 V8Proxy::setDOMException(SYNTAX_ERR);
225 return notHandledByInterceptor(); 225 return notHandledByInterceptor();
226 } 226 }
227 227
228 } 228 }
229 229
230 #endif // V8ArrayBufferViewCustom_h 230 #endif // V8ArrayBufferViewCustom_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698