Bug 993889 part 5. Remove the "creator" argument of the version of TypedArray::Create that takes a JSObject* creator. r=bholley

This commit is contained in:
Boris Zbarsky 2014-04-10 00:58:42 -04:00
parent adc450e8a7
commit e233bf14f8
3 changed files with 8 additions and 14 deletions

View File

@ -52,8 +52,8 @@ ImageData::Constructor(const GlobalObject& aGlobal,
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
return nullptr;
}
JS::Rooted<JSObject*> obj(aGlobal.GetContext(), aGlobal.Get());
JSObject* data = Uint8ClampedArray::Create(aGlobal.GetContext(), obj,
js::AssertSameCompartment(aGlobal.GetContext(), aGlobal.Get());
JSObject* data = Uint8ClampedArray::Create(aGlobal.GetContext(),
length.value());
if (!data) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);

View File

@ -132,24 +132,17 @@ struct TypedArray : public TypedArray_base<T,UnboxArray> {
ac.construct(cx, creatorWrapper);
}
return CreateCommon(cx, creatorWrapper, length, data);
return CreateCommon(cx, length, data);
}
static inline JSObject*
Create(JSContext* cx, JS::Handle<JSObject*> creator, uint32_t length,
const T* data = nullptr) {
Maybe<JSAutoCompartment> ac;
if (creator) {
ac.construct(cx, creator);
}
return CreateCommon(cx, creator, length, data);
Create(JSContext* cx, uint32_t length, const T* data = nullptr) {
return CreateCommon(cx, length, data);
}
private:
static inline JSObject*
CreateCommon(JSContext* cx, JS::Handle<JSObject*> creator, uint32_t length,
const T* data) {
CreateCommon(JSContext* cx, uint32_t length, const T* data) {
JSObject* obj = CreateNew(cx, length);
if (!obj) {
return nullptr;

View File

@ -75,7 +75,8 @@ TextEncoder::Encode(JSContext* aCx,
JSObject* outView = nullptr;
if (NS_SUCCEEDED(rv)) {
buf[dstLen] = '\0';
outView = Uint8Array::Create(aCx, aObj, dstLen,
JSAutoCompartment ac(aCx, aObj);
outView = Uint8Array::Create(aCx, dstLen,
reinterpret_cast<uint8_t*>(buf.get()));
if (!outView) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);