mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Backed out 3 changesets (bug 1849037) for causing mochitests failures in test_gamepad_extensions.html.
Backed out changeset 27fd9f6f57ea (bug 1849037) Backed out changeset 89aa49de2473 (bug 1849037) Backed out changeset c336a8c78928 (bug 1849037)
This commit is contained in:
parent
388b8f06a2
commit
2685d35c49
@ -162,8 +162,10 @@ void ChromeUtils::Base64URLDecode(GlobalObject& aGlobal,
|
||||
}
|
||||
|
||||
JS::Rooted<JSObject*> buffer(
|
||||
aGlobal.Context(), ArrayBuffer::Create(aGlobal.Context(), data, aRv));
|
||||
if (aRv.Failed()) {
|
||||
aGlobal.Context(),
|
||||
ArrayBuffer::Create(aGlobal.Context(), data.Length(), data.Elements()));
|
||||
if (NS_WARN_IF(!buffer)) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
aRetval.set(buffer);
|
||||
|
@ -42,9 +42,9 @@ void Pose::SetFloat32Array(JSContext* aJSContext, nsWrapperCache* creator,
|
||||
}
|
||||
|
||||
if (!aObj) {
|
||||
aObj =
|
||||
Float32Array::Create(aJSContext, creator, Span(aVal, aValLength), aRv);
|
||||
if (aRv.Failed()) {
|
||||
aObj = Float32Array::Create(aJSContext, creator, aValLength, aVal);
|
||||
if (!aObj) {
|
||||
aRv.NoteJSContextException(aJSContext);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
@ -693,74 +693,58 @@ struct TypedArray : public TypedArray_base<ArrayT> {
|
||||
TypedArray(TypedArray&& aOther) = default;
|
||||
|
||||
static inline JSObject* Create(JSContext* cx, nsWrapperCache* creator,
|
||||
size_t length, ErrorResult& error) {
|
||||
return CreateCommon(cx, creator, length, error).asObject();
|
||||
}
|
||||
|
||||
static inline JSObject* Create(JSContext* cx, size_t length,
|
||||
ErrorResult& error) {
|
||||
return CreateCommon(cx, length, error).asObject();
|
||||
}
|
||||
|
||||
static inline JSObject* Create(JSContext* cx, nsWrapperCache* creator,
|
||||
Span<const element_type> data,
|
||||
ErrorResult& error) {
|
||||
ArrayT array = CreateCommon(cx, creator, data.Length(), error);
|
||||
if (!error.Failed()) {
|
||||
CopyFrom(cx, data, array);
|
||||
}
|
||||
return array.asObject();
|
||||
}
|
||||
|
||||
static inline JSObject* Create(JSContext* cx, Span<const element_type> data,
|
||||
ErrorResult& error) {
|
||||
ArrayT array = CreateCommon(cx, data.Length(), error);
|
||||
if (!error.Failed()) {
|
||||
CopyFrom(cx, data, array);
|
||||
}
|
||||
return array.asObject();
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename>
|
||||
friend class TypedArrayCreator;
|
||||
|
||||
static inline ArrayT CreateCommon(JSContext* cx, nsWrapperCache* creator,
|
||||
size_t length, ErrorResult& error) {
|
||||
uint32_t length,
|
||||
const element_type* data = nullptr) {
|
||||
JS::Rooted<JSObject*> creatorWrapper(cx);
|
||||
Maybe<JSAutoRealm> ar;
|
||||
if (creator && (creatorWrapper = creator->GetWrapperPreserveColor())) {
|
||||
ar.emplace(cx, creatorWrapper);
|
||||
}
|
||||
|
||||
return CreateCommon(cx, length, error);
|
||||
return CreateCommon(cx, length, data);
|
||||
}
|
||||
static inline ArrayT CreateCommon(JSContext* cx, size_t length,
|
||||
ErrorResult& error) {
|
||||
ArrayT array = CreateCommon(cx, length);
|
||||
|
||||
static inline JSObject* Create(JSContext* cx, uint32_t length,
|
||||
const element_type* data = nullptr) {
|
||||
return CreateCommon(cx, length, data);
|
||||
}
|
||||
|
||||
static inline JSObject* Create(JSContext* cx, nsWrapperCache* creator,
|
||||
Span<const element_type> data) {
|
||||
// Span<> uses size_t as a length, and we use uint32_t instead.
|
||||
if (MOZ_UNLIKELY(data.Length() > UINT32_MAX)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return nullptr;
|
||||
}
|
||||
return Create(cx, creator, data.Length(), data.Elements());
|
||||
}
|
||||
|
||||
static inline JSObject* Create(JSContext* cx, Span<const element_type> data) {
|
||||
// Span<> uses size_t as a length, and we use uint32_t instead.
|
||||
if (MOZ_UNLIKELY(data.Length() > UINT32_MAX)) {
|
||||
JS_ReportOutOfMemory(cx);
|
||||
return nullptr;
|
||||
}
|
||||
return CreateCommon(cx, data.Length(), data.Elements());
|
||||
}
|
||||
|
||||
private:
|
||||
static inline JSObject* CreateCommon(JSContext* cx, uint32_t length,
|
||||
const element_type* data) {
|
||||
auto array = ArrayT::create(cx, length);
|
||||
if (!array) {
|
||||
error.StealExceptionFromJSContext(cx);
|
||||
return nullptr;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
// NOTE: this leaves any exceptions on the JSContext, and the caller is
|
||||
// required to deal with them.
|
||||
static inline ArrayT CreateCommon(JSContext* cx, size_t length) {
|
||||
return ArrayT::create(cx, length);
|
||||
}
|
||||
static inline void CopyFrom(JSContext* cx,
|
||||
const Span<const element_type>& data,
|
||||
ArrayT& dest) {
|
||||
if (data) {
|
||||
JS::AutoCheckCannotGC nogc;
|
||||
size_t length;
|
||||
bool isShared;
|
||||
element_type* buf = dest.getLengthAndData(&length, &isShared, nogc);
|
||||
MOZ_ASSERT(length == data.Length(),
|
||||
"Didn't create a large enough typed array object?");
|
||||
element_type* buf = array.getData(&isShared, nogc);
|
||||
// Data will not be shared, until a construction protocol exists
|
||||
// for constructing shared data.
|
||||
MOZ_ASSERT(!isShared);
|
||||
memcpy(buf, data.Elements(), data.LengthBytes());
|
||||
memcpy(buf, data, length * sizeof(element_type));
|
||||
}
|
||||
return array.asObject();
|
||||
}
|
||||
|
||||
TypedArray(const TypedArray&) = delete;
|
||||
@ -815,20 +799,14 @@ using ArrayBuffer = TypedArray<JS::ArrayBuffer>;
|
||||
// So this is best used to pass from things that understand nsTArray to
|
||||
// things that understand TypedArray, as with ToJSValue.
|
||||
template <typename TypedArrayType>
|
||||
class MOZ_STACK_CLASS TypedArrayCreator {
|
||||
class TypedArrayCreator {
|
||||
typedef nsTArray<typename TypedArrayType::element_type> ArrayType;
|
||||
|
||||
public:
|
||||
explicit TypedArrayCreator(const ArrayType& aArray) : mArray(aArray) {}
|
||||
|
||||
// NOTE: this leaves any exceptions on the JSContext, and the caller is
|
||||
// required to deal with them.
|
||||
JSObject* Create(JSContext* aCx) const {
|
||||
auto array = TypedArrayType::CreateCommon(aCx, mArray.Length());
|
||||
if (array) {
|
||||
TypedArrayType::CopyFrom(aCx, mArray, array);
|
||||
}
|
||||
return array.asObject();
|
||||
return TypedArrayType::Create(aCx, mArray.Length(), mArray.Elements());
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -6231,9 +6231,10 @@ static already_AddRefed<ImageData> CreateImageData(
|
||||
}
|
||||
|
||||
// Create the fast typed array; it's initialized to 0 by default.
|
||||
JSObject* darray =
|
||||
Uint8ClampedArray::Create(aCx, aContext, len.value(), aError);
|
||||
if (aError.Failed()) {
|
||||
JSObject* darray = Uint8ClampedArray::Create(aCx, aContext, len.value());
|
||||
if (!darray) {
|
||||
// TODO: Should use OOMReporter.
|
||||
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1935,12 +1935,6 @@ bool ClientWebGLContext::IsEnabled(GLenum cap) const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
static JS::Value Create(JSContext* cx, nsWrapperCache* creator, const S& src,
|
||||
ErrorResult& rv) {
|
||||
return JS::ObjectOrNullValue(T::Create(cx, creator, src, rv));
|
||||
}
|
||||
|
||||
void ClientWebGLContext::GetInternalformatParameter(
|
||||
JSContext* cx, GLenum target, GLenum internalformat, GLenum pname,
|
||||
JS::MutableHandle<JS::Value> retval, ErrorResult& rv) {
|
||||
@ -1967,8 +1961,13 @@ void ClientWebGLContext::GetInternalformatParameter(
|
||||
if (!maybe) {
|
||||
return;
|
||||
}
|
||||
|
||||
retval.set(Create<dom::Int32Array>(cx, this, *maybe, rv));
|
||||
// zero-length array indicates out-of-memory
|
||||
JSObject* obj =
|
||||
dom::Int32Array::Create(cx, this, maybe->size(), maybe->data());
|
||||
if (!obj) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
retval.setObjectOrNull(obj);
|
||||
}
|
||||
|
||||
static JS::Value StringValue(JSContext* cx, const std::string& str,
|
||||
@ -1992,6 +1991,23 @@ bool ToJSValueOrNull(JSContext* const cx, const RefPtr<T>& ptr,
|
||||
return dom::ToJSValue(cx, ptr, retval);
|
||||
}
|
||||
|
||||
template <typename T, typename U, typename S>
|
||||
static JS::Value CreateAs(JSContext* cx, nsWrapperCache* creator, const S& src,
|
||||
ErrorResult& rv) {
|
||||
const auto obj =
|
||||
T::Create(cx, creator, src.size(), reinterpret_cast<U>(src.data()));
|
||||
if (!obj) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return JS::ObjectOrNullValue(obj);
|
||||
}
|
||||
|
||||
template <typename T, typename S>
|
||||
static JS::Value Create(JSContext* cx, nsWrapperCache* creator, const S& src,
|
||||
ErrorResult& rv) {
|
||||
return CreateAs<T, decltype(&src[0]), S>(cx, creator, src, rv);
|
||||
}
|
||||
|
||||
Maybe<double> ClientWebGLContext::GetNumber(const GLenum pname) {
|
||||
MOZ_ASSERT(!IsContextLost());
|
||||
|
||||
@ -2162,9 +2178,9 @@ void ClientWebGLContext::GetParameter(JSContext* cx, GLenum pname,
|
||||
|
||||
// 2 ints
|
||||
case LOCAL_GL_MAX_VIEWPORT_DIMS: {
|
||||
auto maxViewportDim = BitwiseCast<int32_t>(limits.maxViewportDim);
|
||||
const auto dims = std::array<int32_t, 2>{maxViewportDim, maxViewportDim};
|
||||
retval.set(Create<dom::Int32Array>(cx, this, dims, rv));
|
||||
const auto dims =
|
||||
std::array<uint32_t, 2>{limits.maxViewportDim, limits.maxViewportDim};
|
||||
retval.set(CreateAs<dom::Int32Array, const int32_t*>(cx, this, dims, rv));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2791,9 +2807,7 @@ void ClientWebGLContext::GetUniform(JSContext* const cx,
|
||||
case LOCAL_GL_FLOAT_MAT4x2:
|
||||
case LOCAL_GL_FLOAT_MAT4x3: {
|
||||
const auto ptr = reinterpret_cast<const float*>(res.data);
|
||||
IgnoredErrorResult error;
|
||||
JSObject* obj =
|
||||
dom::Float32Array::Create(cx, this, Span(ptr, elemCount), error);
|
||||
JSObject* obj = dom::Float32Array::Create(cx, this, elemCount, ptr);
|
||||
MOZ_ASSERT(obj);
|
||||
retval.set(JS::ObjectOrNullValue(obj));
|
||||
return;
|
||||
@ -2803,9 +2817,7 @@ void ClientWebGLContext::GetUniform(JSContext* const cx,
|
||||
case LOCAL_GL_INT_VEC3:
|
||||
case LOCAL_GL_INT_VEC4: {
|
||||
const auto ptr = reinterpret_cast<const int32_t*>(res.data);
|
||||
IgnoredErrorResult error;
|
||||
JSObject* obj =
|
||||
dom::Int32Array::Create(cx, this, Span(ptr, elemCount), error);
|
||||
JSObject* obj = dom::Int32Array::Create(cx, this, elemCount, ptr);
|
||||
MOZ_ASSERT(obj);
|
||||
retval.set(JS::ObjectOrNullValue(obj));
|
||||
return;
|
||||
@ -2815,9 +2827,7 @@ void ClientWebGLContext::GetUniform(JSContext* const cx,
|
||||
case LOCAL_GL_UNSIGNED_INT_VEC3:
|
||||
case LOCAL_GL_UNSIGNED_INT_VEC4: {
|
||||
const auto ptr = reinterpret_cast<const uint32_t*>(res.data);
|
||||
IgnoredErrorResult error;
|
||||
JSObject* obj =
|
||||
dom::Uint32Array::Create(cx, this, Span(ptr, elemCount), error);
|
||||
JSObject* obj = dom::Uint32Array::Create(cx, this, elemCount, ptr);
|
||||
MOZ_ASSERT(obj);
|
||||
retval.set(JS::ObjectOrNullValue(obj));
|
||||
return;
|
||||
@ -4742,31 +4752,33 @@ void ClientWebGLContext::GetVertexAttrib(JSContext* cx, GLuint index,
|
||||
|
||||
switch (pname) {
|
||||
case LOCAL_GL_CURRENT_VERTEX_ATTRIB: {
|
||||
JS::Rooted<JSObject*> obj(cx);
|
||||
|
||||
const auto& attrib = genericAttribs[index];
|
||||
switch (attrib.type) {
|
||||
case webgl::AttribBaseType::Float: {
|
||||
const auto ptr = reinterpret_cast<const float*>(attrib.data.data());
|
||||
retval.setObjectOrNull(
|
||||
dom::Float32Array::Create(cx, this, Span(ptr, 4), rv));
|
||||
case webgl::AttribBaseType::Float:
|
||||
obj = dom::Float32Array::Create(
|
||||
cx, this, 4, reinterpret_cast<const float*>(attrib.data.data()));
|
||||
break;
|
||||
}
|
||||
case webgl::AttribBaseType::Int: {
|
||||
const auto ptr = reinterpret_cast<const int32_t*>(attrib.data.data());
|
||||
retval.setObjectOrNull(
|
||||
dom::Int32Array::Create(cx, this, Span(ptr, 4), rv));
|
||||
case webgl::AttribBaseType::Int:
|
||||
obj = dom::Int32Array::Create(
|
||||
cx, this, 4,
|
||||
reinterpret_cast<const int32_t*>(attrib.data.data()));
|
||||
break;
|
||||
}
|
||||
case webgl::AttribBaseType::Uint: {
|
||||
const auto ptr =
|
||||
reinterpret_cast<const uint32_t*>(attrib.data.data());
|
||||
retval.setObjectOrNull(
|
||||
dom::Uint32Array::Create(cx, this, Span(ptr, 4), rv));
|
||||
case webgl::AttribBaseType::Uint:
|
||||
obj = dom::Uint32Array::Create(
|
||||
cx, this, 4,
|
||||
reinterpret_cast<const uint32_t*>(attrib.data.data()));
|
||||
break;
|
||||
}
|
||||
case webgl::AttribBaseType::Boolean:
|
||||
MOZ_CRASH("impossible");
|
||||
}
|
||||
|
||||
if (!obj) {
|
||||
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
retval.set(JS::ObjectValue(*obj));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -6100,7 +6112,13 @@ void ClientWebGLContext::GetActiveUniformBlockParameter(
|
||||
|
||||
case LOCAL_GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES: {
|
||||
const auto& indices = block.activeUniformIndices;
|
||||
return Create<dom::Uint32Array>(cx, this, indices, rv);
|
||||
JS::Rooted<JSObject*> obj(
|
||||
cx,
|
||||
dom::Uint32Array::Create(cx, this, indices.size(), indices.data()));
|
||||
if (!obj) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return JS::ObjectOrNullValue(obj);
|
||||
}
|
||||
|
||||
case LOCAL_GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
|
||||
|
@ -58,9 +58,9 @@ already_AddRefed<ImageData> ImageData::Constructor(const GlobalObject& aGlobal,
|
||||
return nullptr;
|
||||
}
|
||||
js::AssertSameCompartment(aGlobal.Context(), aGlobal.Get());
|
||||
JSObject* data =
|
||||
Uint8ClampedArray::Create(aGlobal.Context(), length.value(), aRv);
|
||||
if (aRv.Failed()) {
|
||||
JSObject* data = Uint8ClampedArray::Create(aGlobal.Context(), length.value());
|
||||
if (!data) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
}
|
||||
RefPtr<ImageData> imageData = new ImageData(aWidth, aHeight, *data);
|
||||
|
@ -122,14 +122,12 @@ bool CryptoBuffer::ToSECItem(PLArenaPool* aArena, SECItem* aItem) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
JSObject* CryptoBuffer::ToUint8Array(JSContext* aCx,
|
||||
ErrorResult& aError) const {
|
||||
return Uint8Array::Create(aCx, *this, aError);
|
||||
JSObject* CryptoBuffer::ToUint8Array(JSContext* aCx) const {
|
||||
return Uint8Array::Create(aCx, Length(), Elements());
|
||||
}
|
||||
|
||||
JSObject* CryptoBuffer::ToArrayBuffer(JSContext* aCx,
|
||||
ErrorResult& aError) const {
|
||||
return ArrayBuffer::Create(aCx, *this, aError);
|
||||
JSObject* CryptoBuffer::ToArrayBuffer(JSContext* aCx) const {
|
||||
return ArrayBuffer::Create(aCx, Length(), Elements());
|
||||
}
|
||||
|
||||
// "BigInt" comes from the WebCrypto spec
|
||||
|
@ -35,8 +35,8 @@ class CryptoBuffer : public FallibleTArray<uint8_t> {
|
||||
nsresult FromJwkBase64(const nsString& aBase64);
|
||||
nsresult ToJwkBase64(nsString& aBase64) const;
|
||||
bool ToSECItem(PLArenaPool* aArena, SECItem* aItem) const;
|
||||
JSObject* ToUint8Array(JSContext* aCx, ErrorResult& aError) const;
|
||||
JSObject* ToArrayBuffer(JSContext* aCx, ErrorResult& aError) const;
|
||||
JSObject* ToUint8Array(JSContext* aCx) const;
|
||||
JSObject* ToArrayBuffer(JSContext* aCx) const;
|
||||
|
||||
bool GetBigIntValue(unsigned long& aRetVal);
|
||||
|
||||
|
@ -200,7 +200,7 @@ void CryptoKey::GetAlgorithm(JSContext* cx,
|
||||
break;
|
||||
case KeyAlgorithmProxy::RSA: {
|
||||
RootedDictionary<RsaHashedKeyAlgorithm> rsa(cx);
|
||||
converted = mAlgorithm.mRsa.ToKeyAlgorithm(cx, rsa, aRv);
|
||||
converted = mAlgorithm.mRsa.ToKeyAlgorithm(cx, rsa);
|
||||
if (converted) {
|
||||
converted = ToJSValue(cx, rsa, &val);
|
||||
}
|
||||
|
@ -35,11 +35,9 @@ struct RsaHashedKeyAlgorithmStorage {
|
||||
uint16_t mModulusLength;
|
||||
CryptoBuffer mPublicExponent;
|
||||
|
||||
bool ToKeyAlgorithm(JSContext* aCx, RsaHashedKeyAlgorithm& aRsa,
|
||||
ErrorResult& aError) const {
|
||||
JS::Rooted<JSObject*> exponent(aCx,
|
||||
mPublicExponent.ToUint8Array(aCx, aError));
|
||||
if (aError.Failed()) {
|
||||
bool ToKeyAlgorithm(JSContext* aCx, RsaHashedKeyAlgorithm& aRsa) const {
|
||||
JS::Rooted<JSObject*> exponent(aCx, mPublicExponent.ToUint8Array(aCx));
|
||||
if (!exponent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,11 @@ namespace mozilla::dom {
|
||||
void TextEncoder::Encode(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
const nsACString& aUtf8String,
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aRv) {
|
||||
OOMReporter& aRv) {
|
||||
JSAutoRealm ar(aCx, aObj);
|
||||
JSObject* outView = Uint8Array::Create(aCx, aUtf8String, aRv);
|
||||
if (aRv.Failed()) {
|
||||
JSObject* outView = Uint8Array::Create(aCx, aUtf8String);
|
||||
if (!outView) {
|
||||
aRv.ReportOOM();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ class TextEncoder final : public NonRefcountedDOMObject {
|
||||
*/
|
||||
void Encode(JSContext* aCx, JS::Handle<JSObject*> aObj,
|
||||
const nsACString& aUtf8String,
|
||||
JS::MutableHandle<JSObject*> aRetval, ErrorResult& aRv);
|
||||
JS::MutableHandle<JSObject*> aRetval, OOMReporter& aRv);
|
||||
|
||||
void EncodeInto(JSContext* aCx, JS::Handle<JSString*> aSrc,
|
||||
const Uint8Array& aDst, TextEncoderEncodeIntoResult& aResult,
|
||||
|
@ -33,8 +33,9 @@ GamepadTouch::~GamepadTouch() { mozilla::DropJSObjects(this); }
|
||||
void GamepadTouch::GetPosition(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aRv) {
|
||||
mPosition = Float32Array::Create(aCx, this, mTouchState.position, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mPosition = Float32Array::Create(aCx, this, 2, mTouchState.position);
|
||||
if (!mPosition) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -44,16 +45,13 @@ void GamepadTouch::GetPosition(JSContext* aCx,
|
||||
void GamepadTouch::GetSurfaceDimensions(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aRv) {
|
||||
if (mTouchState.isSurfaceDimensionsValid) {
|
||||
mSurfaceDimensions = Uint32Array::Create(
|
||||
aCx, this, std::size(mTouchState.surfaceDimensions), aRv);
|
||||
mSurfaceDimensions = Uint32Array::Create(aCx, this, 2,
|
||||
mTouchState.isSurfaceDimensionsValid
|
||||
? mTouchState.surfaceDimensions
|
||||
: nullptr);
|
||||
|
||||
} else {
|
||||
mSurfaceDimensions =
|
||||
Uint32Array::Create(aCx, this, mTouchState.surfaceDimensions, aRv);
|
||||
}
|
||||
|
||||
if (aRv.Failed()) {
|
||||
if (!mSurfaceDimensions) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,10 @@ void MediaEncryptedEvent::GetInitData(JSContext* cx,
|
||||
JS::MutableHandle<JSObject*> aData,
|
||||
ErrorResult& aRv) {
|
||||
if (mRawInitData.Length()) {
|
||||
mInitData = ArrayBuffer::Create(cx, this, mRawInitData, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mInitData = ArrayBuffer::Create(cx, this, mRawInitData.Length(),
|
||||
mRawInitData.Elements());
|
||||
if (!mInitData) {
|
||||
aRv.NoteJSContextException(cx);
|
||||
return;
|
||||
}
|
||||
mRawInitData.Clear();
|
||||
|
@ -89,8 +89,10 @@ void MediaKeyMessageEvent::GetMessage(JSContext* cx,
|
||||
JS::MutableHandle<JSObject*> aMessage,
|
||||
ErrorResult& aRv) {
|
||||
if (!mMessage) {
|
||||
mMessage = ArrayBuffer::Create(cx, this, mRawMessage, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mMessage = ArrayBuffer::Create(cx, this, mRawMessage.Length(),
|
||||
mRawMessage.Elements());
|
||||
if (!mMessage) {
|
||||
aRv.NoteJSContextException(cx);
|
||||
return;
|
||||
}
|
||||
mRawMessage.Clear();
|
||||
|
@ -364,8 +364,7 @@ void WaveShaperNode::SendCurveToTrack() {
|
||||
}
|
||||
|
||||
void WaveShaperNode::GetCurve(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aError) {
|
||||
JS::MutableHandle<JSObject*> aRetval) {
|
||||
// Let's return a null value if the list is empty.
|
||||
if (mCurve.IsEmpty()) {
|
||||
aRetval.set(nullptr);
|
||||
@ -373,11 +372,8 @@ void WaveShaperNode::GetCurve(JSContext* aCx,
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mCurve.Length() >= 2);
|
||||
JSObject* curve = Float32Array::Create(aCx, this, mCurve, aError);
|
||||
if (aError.Failed()) {
|
||||
return;
|
||||
}
|
||||
aRetval.set(curve);
|
||||
aRetval.set(
|
||||
Float32Array::Create(aCx, this, mCurve.Length(), mCurve.Elements()));
|
||||
}
|
||||
|
||||
void WaveShaperNode::SetOversample(OverSampleType aType) {
|
||||
|
@ -35,8 +35,7 @@ class WaveShaperNode final : public AudioNode {
|
||||
JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
void GetCurve(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval,
|
||||
ErrorResult& aRv);
|
||||
void GetCurve(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval);
|
||||
void SetCurve(const Nullable<Float32Array>& aData, ErrorResult& aRv);
|
||||
|
||||
OverSampleType Oversample() const { return mType; }
|
||||
|
@ -83,8 +83,10 @@ void MIDIMessageEvent::GetData(JSContext* cx,
|
||||
JS::MutableHandle<JSObject*> aData,
|
||||
ErrorResult& aRv) {
|
||||
if (!mData) {
|
||||
mData = Uint8Array::Create(cx, this, mRawData, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mData =
|
||||
Uint8Array::Create(cx, this, mRawData.Length(), mRawData.Elements());
|
||||
if (!mData) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
mRawData.Clear();
|
||||
|
@ -578,11 +578,11 @@ nsresult UDPSocket::DispatchReceivedData(const nsACString& aRemoteAddress,
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
// Copy packet data to ArrayBuffer
|
||||
ErrorResult error;
|
||||
JS::Rooted<JSObject*> arrayBuf(cx, ArrayBuffer::Create(cx, aData, error));
|
||||
JS::Rooted<JSObject*> arrayBuf(
|
||||
cx, ArrayBuffer::Create(cx, aData.Length(), aData.Elements()));
|
||||
|
||||
if (NS_WARN_IF(error.Failed())) {
|
||||
return error.StealNSResult();
|
||||
if (NS_WARN_IF(!arrayBuf)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> jsData(cx, JS::ObjectValue(*arrayBuf));
|
||||
|
@ -26,8 +26,10 @@ void PushUtil::CopyArrayToArrayBuffer(JSContext* aCx,
|
||||
aValue.set(nullptr);
|
||||
return;
|
||||
}
|
||||
JS::Rooted<JSObject*> buffer(aCx, ArrayBuffer::Create(aCx, aArray, aRv));
|
||||
if (NS_WARN_IF(aRv.Failed())) {
|
||||
JS::Rooted<JSObject*> buffer(
|
||||
aCx, ArrayBuffer::Create(aCx, aArray.Length(), aArray.Elements()));
|
||||
if (NS_WARN_IF(!buffer)) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
aValue.set(buffer);
|
||||
|
@ -670,9 +670,11 @@ class PushEventOp final : public ExtendableEventOp {
|
||||
|
||||
if (args.data().type() != OptionalPushData::Tvoid_t) {
|
||||
auto& bytes = args.data().get_ArrayOfuint8_t();
|
||||
JSObject* data = Uint8Array::Create(aCx, bytes, result);
|
||||
JSObject* data =
|
||||
Uint8Array::Create(aCx, bytes.Length(), bytes.Elements());
|
||||
|
||||
if (result.Failed()) {
|
||||
if (!data) {
|
||||
result = ErrorResult(NS_ERROR_FAILURE);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -147,8 +147,9 @@ void VREyeParameters::GetOffset(JSContext* aCx,
|
||||
if (!mOffset) {
|
||||
// Lazily create the Float32Array
|
||||
mOffset =
|
||||
dom::Float32Array::Create(aCx, this, mEyeTranslation.components, aRv);
|
||||
if (aRv.Failed()) {
|
||||
dom::Float32Array::Create(aCx, this, 3, mEyeTranslation.components);
|
||||
if (!mOffset) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -200,8 +201,9 @@ void VRStageParameters::GetSittingToStandingTransform(
|
||||
if (!mSittingToStandingTransformArray) {
|
||||
// Lazily create the Float32Array
|
||||
mSittingToStandingTransformArray = dom::Float32Array::Create(
|
||||
aCx, this, mSittingToStandingTransform.components, aRv);
|
||||
if (aRv.Failed()) {
|
||||
aCx, this, 16, mSittingToStandingTransform.components);
|
||||
if (!mSittingToStandingTransformArray) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -58,9 +58,10 @@ JSObject* AuthenticatorAssertionResponse::WrapObject(
|
||||
void AuthenticatorAssertionResponse::GetAuthenticatorData(
|
||||
JSContext* aCx, JS::MutableHandle<JSObject*> aValue, ErrorResult& aRv) {
|
||||
if (!mAuthenticatorDataCachedObj) {
|
||||
mAuthenticatorDataCachedObj =
|
||||
ArrayBuffer::Create(aCx, mAuthenticatorData, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mAuthenticatorDataCachedObj = ArrayBuffer::Create(
|
||||
aCx, mAuthenticatorData.Length(), mAuthenticatorData.Elements());
|
||||
if (!mAuthenticatorDataCachedObj) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -75,8 +76,10 @@ void AuthenticatorAssertionResponse::SetAuthenticatorData(
|
||||
void AuthenticatorAssertionResponse::GetSignature(
|
||||
JSContext* aCx, JS::MutableHandle<JSObject*> aValue, ErrorResult& aRv) {
|
||||
if (!mSignatureCachedObj) {
|
||||
mSignatureCachedObj = ArrayBuffer::Create(aCx, mSignature, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mSignatureCachedObj =
|
||||
ArrayBuffer::Create(aCx, mSignature.Length(), mSignature.Elements());
|
||||
if (!mSignatureCachedObj) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -97,8 +100,10 @@ void AuthenticatorAssertionResponse::GetUserHandle(
|
||||
aValue.set(nullptr);
|
||||
} else {
|
||||
if (!mUserHandleCachedObj) {
|
||||
mUserHandleCachedObj = ArrayBuffer::Create(aCx, mUserHandle, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mUserHandleCachedObj = ArrayBuffer::Create(aCx, mUserHandle.Length(),
|
||||
mUserHandle.Elements());
|
||||
if (!mUserHandleCachedObj) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -54,9 +54,10 @@ JSObject* AuthenticatorAttestationResponse::WrapObject(
|
||||
void AuthenticatorAttestationResponse::GetAttestationObject(
|
||||
JSContext* aCx, JS::MutableHandle<JSObject*> aValue, ErrorResult& aRv) {
|
||||
if (!mAttestationObjectCachedObj) {
|
||||
mAttestationObjectCachedObj =
|
||||
ArrayBuffer::Create(aCx, mAttestationObject, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mAttestationObjectCachedObj = ArrayBuffer::Create(
|
||||
aCx, mAttestationObject.Length(), mAttestationObject.Elements());
|
||||
if (!mAttestationObjectCachedObj) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -105,8 +106,10 @@ void AuthenticatorAttestationResponse::GetAuthenticatorData(
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Heap<JSObject*> buffer(ArrayBuffer::Create(aCx, authenticatorData, aRv));
|
||||
if (aRv.Failed()) {
|
||||
JS::Heap<JSObject*> buffer(ArrayBuffer::Create(
|
||||
aCx, authenticatorData.Length(), authenticatorData.Elements()));
|
||||
if (!buffer) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
aValue.set(buffer);
|
||||
@ -142,8 +145,10 @@ void AuthenticatorAttestationResponse::GetPublicKey(
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Heap<JSObject*> buffer(ArrayBuffer::Create(aCx, publicKey, aRv));
|
||||
if (aRv.Failed()) {
|
||||
JS::Heap<JSObject*> buffer(
|
||||
ArrayBuffer::Create(aCx, publicKey.Length(), publicKey.Elements()));
|
||||
if (!buffer) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
aValue.set(buffer);
|
||||
|
@ -37,8 +37,9 @@ nsISupports* AuthenticatorResponse::GetParentObject() const { return mParent; }
|
||||
void AuthenticatorResponse::GetClientDataJSON(
|
||||
JSContext* aCx, JS::MutableHandle<JSObject*> aValue, ErrorResult& aRv) {
|
||||
if (!mClientDataJSONCachedObj) {
|
||||
mClientDataJSONCachedObj = ArrayBuffer::Create(aCx, mClientDataJSON, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mClientDataJSONCachedObj = ArrayBuffer::Create(aCx, mClientDataJSON);
|
||||
if (!mClientDataJSONCachedObj) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +65,10 @@ void PublicKeyCredential::GetRawId(JSContext* aCx,
|
||||
JS::MutableHandle<JSObject*> aValue,
|
||||
ErrorResult& aRv) {
|
||||
if (!mRawIdCachedObj) {
|
||||
mRawIdCachedObj = ArrayBuffer::Create(aCx, mRawId, aRv);
|
||||
if (aRv.Failed()) {
|
||||
mRawIdCachedObj =
|
||||
ArrayBuffer::Create(aCx, mRawId.Length(), mRawId.Elements());
|
||||
if (!mRawIdCachedObj) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ interface TextEncoder {
|
||||
* replacing lone surrogates with the REPLACEMENT CHARACTER, so the
|
||||
* observable behavior of USVString is matched.)
|
||||
*/
|
||||
[NewObject, Throws]
|
||||
[NewObject]
|
||||
Uint8Array encode(optional UTF8String input = "");
|
||||
|
||||
/*
|
||||
|
@ -28,7 +28,7 @@ interface WaveShaperNode : AudioNode {
|
||||
constructor(BaseAudioContext context,
|
||||
optional WaveShaperOptions options = {});
|
||||
|
||||
[Cached, Pure, Throws]
|
||||
[Cached, Pure, SetterThrows]
|
||||
attribute Float32Array? curve;
|
||||
attribute OverSampleType oversample;
|
||||
|
||||
|
@ -224,8 +224,10 @@ void IncomingDatagramStreamAlgorithms::ReturnDatagram(JSContext* aCx,
|
||||
UniquePtr<DatagramEntry> entry = mDatagrams->mIncomingDatagramsQueue.Pop();
|
||||
|
||||
// Pull Step 6: Let chunk be a new Uint8Array object representing bytes.
|
||||
JSObject* outView = Uint8Array::Create(aCx, entry->mBuffer, aRv);
|
||||
if (aRv.Failed()) {
|
||||
JSObject* outView = Uint8Array::Create(aCx, entry->mBuffer.Length(),
|
||||
entry->mBuffer.Elements());
|
||||
if (!outView) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
JS::Rooted<JSObject*> chunk(aCx, outView);
|
||||
|
@ -223,11 +223,8 @@ nsUDPMessage::GetOutputStream(nsIOutputStream** aOutputStream) {
|
||||
NS_IMETHODIMP
|
||||
nsUDPMessage::GetRawData(JSContext* cx, JS::MutableHandle<JS::Value> aRawData) {
|
||||
if (!mJsobj) {
|
||||
ErrorResult error;
|
||||
mJsobj = dom::Uint8Array::Create(cx, nullptr, mData, error);
|
||||
if (error.Failed()) {
|
||||
return error.StealNSResult();
|
||||
}
|
||||
mJsobj =
|
||||
dom::Uint8Array::Create(cx, nullptr, mData.Length(), mData.Elements());
|
||||
HoldJSObjects(this);
|
||||
}
|
||||
aRawData.setObject(*mJsobj);
|
||||
|
@ -201,11 +201,9 @@ void StreamFilter::FireDataEvent(const nsTArray<uint8_t>& aData) {
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
|
||||
ErrorResult error;
|
||||
auto buffer = ArrayBuffer::Create(cx, aData, error);
|
||||
if (error.Failed()) {
|
||||
auto buffer = ArrayBuffer::Create(cx, aData.Length(), aData.Elements());
|
||||
if (!buffer) {
|
||||
// TODO: There is no way to recover from this. This chunk of data is lost.
|
||||
error.SuppressException();
|
||||
FireErrorEvent(u"Out of memory"_ns);
|
||||
return;
|
||||
}
|
||||
|
@ -478,14 +478,14 @@ nsProfiler::GetProfileDataAsArrayBuffer(double aSinceTime, JSContext* aCx,
|
||||
}
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
ErrorResult error;
|
||||
JSObject* typedArray =
|
||||
dom::ArrayBuffer::Create(cx, aResult.mProfile, error);
|
||||
if (!error.Failed()) {
|
||||
JSObject* typedArray = dom::ArrayBuffer::Create(
|
||||
cx, aResult.mProfile.Length(),
|
||||
reinterpret_cast<const uint8_t*>(aResult.mProfile.Data()));
|
||||
if (typedArray) {
|
||||
JS::Rooted<JS::Value> val(cx, JS::ObjectValue(*typedArray));
|
||||
promise->MaybeResolve(val);
|
||||
} else {
|
||||
promise->MaybeReject(std::move(error));
|
||||
promise->MaybeReject(NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
},
|
||||
[promise](nsresult aRv) { promise->MaybeReject(aRv); });
|
||||
@ -582,10 +582,10 @@ nsProfiler::GetProfileDataAsGzippedArrayBuffer(double aSinceTime,
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
// Get the profile typedArray.
|
||||
ErrorResult error;
|
||||
JSObject* typedArray = dom::ArrayBuffer::Create(cx, outBuff, error);
|
||||
if (error.Failed()) {
|
||||
promise->MaybeReject(std::move(error));
|
||||
JSObject* typedArray = dom::ArrayBuffer::Create(
|
||||
cx, outBuff.Length(), outBuff.Elements());
|
||||
if (!typedArray) {
|
||||
promise->MaybeReject(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
JS::Rooted<JS::Value> typedArrayValue(cx,
|
||||
@ -705,33 +705,25 @@ nsProfiler::GetSymbolTable(const nsACString& aDebugPath,
|
||||
|
||||
JSContext* cx = jsapi.cx();
|
||||
|
||||
ErrorResult error;
|
||||
JS::Rooted<JSObject*> addrsArray(
|
||||
cx, dom::Uint32Array::Create(cx, aSymbolTable.mAddrs, error));
|
||||
if (error.Failed()) {
|
||||
promise->MaybeReject(std::move(error));
|
||||
return;
|
||||
}
|
||||
|
||||
cx, dom::Uint32Array::Create(cx, aSymbolTable.mAddrs.Length(),
|
||||
aSymbolTable.mAddrs.Elements()));
|
||||
JS::Rooted<JSObject*> indexArray(
|
||||
cx, dom::Uint32Array::Create(cx, aSymbolTable.mIndex, error));
|
||||
if (error.Failed()) {
|
||||
promise->MaybeReject(std::move(error));
|
||||
return;
|
||||
}
|
||||
|
||||
cx, dom::Uint32Array::Create(cx, aSymbolTable.mIndex.Length(),
|
||||
aSymbolTable.mIndex.Elements()));
|
||||
JS::Rooted<JSObject*> bufferArray(
|
||||
cx, dom::Uint8Array::Create(cx, aSymbolTable.mBuffer, error));
|
||||
if (error.Failed()) {
|
||||
promise->MaybeReject(std::move(error));
|
||||
return;
|
||||
}
|
||||
cx, dom::Uint8Array::Create(cx, aSymbolTable.mBuffer.Length(),
|
||||
aSymbolTable.mBuffer.Elements()));
|
||||
|
||||
if (addrsArray && indexArray && bufferArray) {
|
||||
JS::Rooted<JSObject*> tuple(cx, JS::NewArrayObject(cx, 3));
|
||||
JS_SetElement(cx, tuple, 0, addrsArray);
|
||||
JS_SetElement(cx, tuple, 1, indexArray);
|
||||
JS_SetElement(cx, tuple, 2, bufferArray);
|
||||
promise->MaybeResolve(tuple);
|
||||
} else {
|
||||
promise->MaybeReject(NS_ERROR_FAILURE);
|
||||
}
|
||||
},
|
||||
[promise](nsresult aRv) { promise->MaybeReject(aRv); });
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user