bug 1610296 - Rename TypedArray_base::ComputeLengthAndData to TypedArray_base::ComputeState; r=bzbarsky

Differential Revision: https://phabricator.services.mozilla.com/D60514

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Edgar Chen 2020-01-23 03:22:06 +00:00
Родитель 8512ab7c40
Коммит 9e846bd48a
41 изменённых файлов: 80 добавлений и 80 удалений

Просмотреть файл

@ -91,12 +91,12 @@ void ChromeUtils::Base64URLEncode(GlobalObject& aGlobal,
uint8_t* data = nullptr;
if (aSource.IsArrayBuffer()) {
const ArrayBuffer& buffer = aSource.GetAsArrayBuffer();
buffer.ComputeLengthAndData();
buffer.ComputeState();
length = buffer.Length();
data = buffer.Data();
} else if (aSource.IsArrayBufferView()) {
const ArrayBufferView& view = aSource.GetAsArrayBufferView();
view.ComputeLengthAndData();
view.ComputeState();
length = view.Length();
data = view.Data();
} else {

Просмотреть файл

@ -60,7 +60,7 @@ void Crypto::GetRandomValues(JSContext* aCx, const ArrayBufferView& aArray,
return;
}
aArray.ComputeLengthAndData();
aArray.ComputeState();
uint32_t dataLen = aArray.Length();
if (dataLen == 0) {
NS_WARNING("ArrayBufferView length is 0, cannot continue");

Просмотреть файл

@ -192,7 +192,7 @@ already_AddRefed<DOMMatrixReadOnly> DOMMatrixReadOnly::FromMatrix(
already_AddRefed<DOMMatrixReadOnly> DOMMatrixReadOnly::FromFloat32Array(
const GlobalObject& aGlobal, const Float32Array& aArray32,
ErrorResult& aRv) {
aArray32.ComputeLengthAndData();
aArray32.ComputeState();
const int length = aArray32.Length();
const bool is2D = length == 6;
@ -206,7 +206,7 @@ already_AddRefed<DOMMatrixReadOnly> DOMMatrixReadOnly::FromFloat32Array(
already_AddRefed<DOMMatrixReadOnly> DOMMatrixReadOnly::FromFloat64Array(
const GlobalObject& aGlobal, const Float64Array& aArray64,
ErrorResult& aRv) {
aArray64.ComputeLengthAndData();
aArray64.ComputeState();
const int length = aArray64.Length();
const bool is2D = length == 6;
@ -640,7 +640,7 @@ already_AddRefed<DOMMatrix> DOMMatrix::FromMatrix(
already_AddRefed<DOMMatrix> DOMMatrix::FromFloat32Array(
const GlobalObject& aGlobal, const Float32Array& aArray32,
ErrorResult& aRv) {
aArray32.ComputeLengthAndData();
aArray32.ComputeState();
const int length = aArray32.Length();
const bool is2D = length == 6;
@ -653,7 +653,7 @@ already_AddRefed<DOMMatrix> DOMMatrix::FromFloat32Array(
already_AddRefed<DOMMatrix> DOMMatrix::FromFloat64Array(
const GlobalObject& aGlobal, const Float64Array& aArray64,
ErrorResult& aRv) {
aArray64.ComputeLengthAndData();
aArray64.ComputeState();
const int length = aArray64.Length();
const bool is2D = length == 6;

Просмотреть файл

@ -119,7 +119,7 @@ already_AddRefed<Document> DOMParser::ParseFromSafeString(const nsAString& aStr,
already_AddRefed<Document> DOMParser::ParseFromBuffer(const Uint8Array& aBuf,
SupportedType aType,
ErrorResult& aRv) {
aBuf.ComputeLengthAndData();
aBuf.ComputeState();
return ParseFromBuffer(MakeSpan(aBuf.Data(), aBuf.Length()), aType, aRv);
}

Просмотреть файл

@ -199,7 +199,7 @@ void nsDOMDataChannel::Send(Blob& aData, ErrorResult& aRv) {
void nsDOMDataChannel::Send(const ArrayBuffer& aData, ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");
aData.ComputeLengthAndData();
aData.ComputeState();
static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");
@ -213,7 +213,7 @@ void nsDOMDataChannel::Send(const ArrayBuffer& aData, ErrorResult& aRv) {
void nsDOMDataChannel::Send(const ArrayBufferView& aData, ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread(), "Not running on main thread");
aData.ComputeLengthAndData();
aData.ComputeState();
static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");

Просмотреть файл

@ -119,7 +119,7 @@ struct TypedArray_base : public SpiderMonkeyInterfaceObjectStorage,
return mLength;
}
inline void ComputeLengthAndData() const {
inline void ComputeState() const {
MOZ_ASSERT(inited());
MOZ_ASSERT(!mComputed);
GetLengthAndDataAndSharedness(mImplObj, &mLength, &mShared, &mData);

Просмотреть файл

@ -5201,7 +5201,7 @@ nsresult CanvasRenderingContext2D::PutImageData_explicit(
return NS_OK;
}
aArray->ComputeLengthAndData();
aArray->ComputeState();
uint32_t dataLen = aArray->Length();

Просмотреть файл

@ -2616,7 +2616,7 @@ void ClientWebGLContext::BufferData(
if (!ValidateNonNull("src", maybeSrc)) return;
const auto& src = maybeSrc.Value();
src.ComputeLengthAndData();
src.ComputeState();
const auto view = RawBuffer<const uint8_t>(src.Length(), src.Data());
Run<RPROC(BufferData)>(target, view, usage);
@ -2644,7 +2644,7 @@ void ClientWebGLContext::BufferSubData(GLenum target,
WebGLsizeiptr dstByteOffset,
const dom::ArrayBuffer& src) {
const FuncScope funcScope(*this, "bufferSubData");
src.ComputeLengthAndData();
src.ComputeState();
Run<RPROC(BufferSubData)>(target, dstByteOffset,
RawBuffer<const uint8_t>(src.Length(), src.Data()));
}
@ -5076,7 +5076,7 @@ bool ClientWebGLContext::ValidateArrayBufferView(
const dom::ArrayBufferView& view, GLuint elemOffset,
GLuint elemCountOverride, const GLenum errorEnum, uint8_t** const out_bytes,
size_t* const out_byteLen) const {
view.ComputeLengthAndData();
view.ComputeState();
uint8_t* const bytes = view.Data();
const size_t byteLen = view.Length();

Просмотреть файл

@ -866,7 +866,7 @@ already_AddRefed<ImageBitmap> ImageBitmap::CreateInternal(
DebugOnly<bool> inited = array.Init(aImageData.GetDataObject());
MOZ_ASSERT(inited);
array.ComputeLengthAndData();
array.ComputeState();
const SurfaceFormat FORMAT = SurfaceFormat::R8G8B8A8;
// ImageData's underlying data is not alpha-premultiplied.
const auto alphaType = gfxAlphaType::NonPremult;

Просмотреть файл

@ -64,7 +64,7 @@ already_AddRefed<ImageData> ImageData::Constructor(
const GlobalObject& aGlobal, const Uint8ClampedArray& aData,
const uint32_t aWidth, const Optional<uint32_t>& aHeight,
ErrorResult& aRv) {
aData.ComputeLengthAndData();
aData.ComputeState();
uint32_t length = aData.Length();
if (length == 0 || length % 4) {

Просмотреть файл

@ -112,7 +112,7 @@ static UniquePtr<webgl::TexUnpackBlob> FromImageData(
DebugOnly<bool> inited = scopedArr->Init(imageData.GetDataObject());
MOZ_ASSERT(inited);
scopedArr->ComputeLengthAndData();
scopedArr->ComputeState();
const DebugOnly<size_t> dataSize = scopedArr->Length();
const void* const data = scopedArr->Data();

Просмотреть файл

@ -884,7 +884,7 @@ inline Range<T> MakeRange(RawBuffer<T>& from) {
template <typename T>
inline auto MakeRangeAbv(const T& abv)
-> Range<const typename T::element_type> {
abv.ComputeLengthAndData();
abv.ComputeState();
return {abv.Data(), abv.Length()};
}

Просмотреть файл

@ -39,12 +39,12 @@ uint8_t* CryptoBuffer::Assign(const nsTArray<uint8_t>& aData) {
}
uint8_t* CryptoBuffer::Assign(const ArrayBuffer& aData) {
aData.ComputeLengthAndData();
aData.ComputeState();
return Assign(aData.Data(), aData.Length());
}
uint8_t* CryptoBuffer::Assign(const ArrayBufferView& aData) {
aData.ComputeLengthAndData();
aData.ComputeState();
return Assign(aData.Data(), aData.Length());
}
@ -75,7 +75,7 @@ uint8_t* CryptoBuffer::Assign(const OwningArrayBufferViewOrArrayBuffer& aData) {
}
uint8_t* CryptoBuffer::Assign(const Uint8Array& aArray) {
aArray.ComputeLengthAndData();
aArray.ComputeState();
return Assign(aArray.Data(), aArray.Length());
}

Просмотреть файл

@ -35,7 +35,7 @@ struct RsaHashedKeyAlgorithmStorage {
aRsa.mModulusLength = mModulusLength;
aRsa.mHash.mName = mHash.mName;
aRsa.mPublicExponent.Init(exponent);
aRsa.mPublicExponent.ComputeLengthAndData();
aRsa.mPublicExponent.ComputeState();
return true;
}

Просмотреть файл

@ -107,12 +107,12 @@ void TextDecoder::Decode(const Optional<ArrayBufferViewOrArrayBuffer>& aBuffer,
uint8_t* data;
uint32_t length;
if (buf.IsArrayBufferView()) {
buf.GetAsArrayBufferView().ComputeLengthAndData();
buf.GetAsArrayBufferView().ComputeState();
data = buf.GetAsArrayBufferView().Data();
length = buf.GetAsArrayBufferView().Length();
} else {
MOZ_ASSERT(buf.IsArrayBuffer());
buf.GetAsArrayBuffer().ComputeLengthAndData();
buf.GetAsArrayBuffer().ComputeState();
data = buf.GetAsArrayBuffer().Data();
length = buf.GetAsArrayBuffer().Length();
}

Просмотреть файл

@ -30,7 +30,7 @@ void TextEncoder::EncodeInto(JSContext* aCx, JS::Handle<JSString*> aSrc,
const Uint8Array& aDst,
TextEncoderEncodeIntoResult& aResult,
OOMReporter& aError) {
aDst.ComputeLengthAndData();
aDst.ComputeState();
size_t read;
size_t written;
auto maybe = JS_EncodeStringToUTF8BufferPartial(

Просмотреть файл

@ -45,7 +45,7 @@ template <>
nsresult BodyExtractor<const ArrayBuffer>::GetAsStream(
nsIInputStream** aResult, uint64_t* aContentLength,
nsACString& aContentTypeWithCharset, nsACString& aCharset) const {
mBody->ComputeLengthAndData();
mBody->ComputeState();
return GetBufferDataAsStream(mBody->Data(), mBody->Length(), aResult,
aContentLength, aContentTypeWithCharset,
aCharset);
@ -55,7 +55,7 @@ template <>
nsresult BodyExtractor<const ArrayBufferView>::GetAsStream(
nsIInputStream** aResult, uint64_t* aContentLength,
nsACString& aContentTypeWithCharset, nsACString& aCharset) const {
mBody->ComputeLengthAndData();
mBody->ComputeState();
return GetBufferDataAsStream(mBody->Data(), mBody->Length(), aResult,
aContentLength, aContentTypeWithCharset,
aCharset);

Просмотреть файл

@ -261,7 +261,7 @@ void FetchStreamReader::ResolvedCallback(JSContext* aCx,
}
Uint8Array& array = value.mValue.Value();
array.ComputeLengthAndData();
array.ComputeState();
uint32_t len = array.Length();
if (len == 0) {

Просмотреть файл

@ -205,7 +205,7 @@ void MultipartBlobImpl::InitializeBlob(const Sequence<Blob::BlobPart>& aData,
else if (data.IsArrayBuffer()) {
const ArrayBuffer& buffer = data.GetAsArrayBuffer();
buffer.ComputeLengthAndData();
buffer.ComputeState();
aRv = blobSet.AppendVoidPtr(buffer.Data(), buffer.Length());
if (aRv.Failed()) {
return;
@ -214,7 +214,7 @@ void MultipartBlobImpl::InitializeBlob(const Sequence<Blob::BlobPart>& aData,
else if (data.IsArrayBufferView()) {
const ArrayBufferView& buffer = data.GetAsArrayBufferView();
buffer.ComputeLengthAndData();
buffer.ComputeState();
aRv = blobSet.AppendVoidPtr(buffer.Data(), buffer.Length());
if (aRv.Failed()) {
return;

Просмотреть файл

@ -185,7 +185,7 @@ void GamepadServiceTest::NewPoseMove(
GamepadCapabilityFlags::Cap_LinearAcceleration;
if (!aOrient.IsNull()) {
const Float32Array& value = aOrient.Value();
value.ComputeLengthAndData();
value.ComputeState();
MOZ_ASSERT(value.Length() == 4);
poseState.orientation[0] = value.Data()[0];
poseState.orientation[1] = value.Data()[1];
@ -195,7 +195,7 @@ void GamepadServiceTest::NewPoseMove(
}
if (!aPos.IsNull()) {
const Float32Array& value = aPos.Value();
value.ComputeLengthAndData();
value.ComputeState();
MOZ_ASSERT(value.Length() == 3);
poseState.position[0] = value.Data()[0];
poseState.position[1] = value.Data()[1];
@ -204,7 +204,7 @@ void GamepadServiceTest::NewPoseMove(
}
if (!aAngVelocity.IsNull()) {
const Float32Array& value = aAngVelocity.Value();
value.ComputeLengthAndData();
value.ComputeState();
MOZ_ASSERT(value.Length() == 3);
poseState.angularVelocity[0] = value.Data()[0];
poseState.angularVelocity[1] = value.Data()[1];
@ -212,7 +212,7 @@ void GamepadServiceTest::NewPoseMove(
}
if (!aAngAcceleration.IsNull()) {
const Float32Array& value = aAngAcceleration.Value();
value.ComputeLengthAndData();
value.ComputeState();
MOZ_ASSERT(value.Length() == 3);
poseState.angularAcceleration[0] = value.Data()[0];
poseState.angularAcceleration[1] = value.Data()[1];
@ -220,7 +220,7 @@ void GamepadServiceTest::NewPoseMove(
}
if (!aLinVelocity.IsNull()) {
const Float32Array& value = aLinVelocity.Value();
value.ComputeLengthAndData();
value.ComputeState();
MOZ_ASSERT(value.Length() == 3);
poseState.linearVelocity[0] = value.Data()[0];
poseState.linearVelocity[1] = value.Data()[1];
@ -228,7 +228,7 @@ void GamepadServiceTest::NewPoseMove(
}
if (!aLinAcceleration.IsNull()) {
const Float32Array& value = aLinAcceleration.Value();
value.ComputeLengthAndData();
value.ComputeState();
MOZ_ASSERT(value.Length() == 3);
poseState.linearAcceleration[0] = value.Data()[0];
poseState.linearAcceleration[1] = value.Data()[1];
@ -255,14 +255,14 @@ void GamepadServiceTest::NewTouch(uint32_t aIndex, uint32_t aTouchArrayIndex,
touchState.touchId = aTouchId;
touchState.surfaceId = aSurfaceId;
const Float32Array& value = aPos;
value.ComputeLengthAndData();
value.ComputeState();
MOZ_ASSERT(value.Length() == 2);
touchState.position[0] = value.Data()[0];
touchState.position[1] = value.Data()[1];
if (!aSurfDim.IsNull()) {
const Float32Array& value = aSurfDim.Value();
value.ComputeLengthAndData();
value.ComputeState();
MOZ_ASSERT(value.Length() == 2);
touchState.surfaceDimensions[0] = value.Data()[0];
touchState.surfaceDimensions[1] = value.Data()[1];

Просмотреть файл

@ -521,7 +521,7 @@ RefPtr<IDBFileRequest> IDBFileHandle::WriteOrAppend(const ArrayBuffer& aValue,
return nullptr;
}
aValue.ComputeLengthAndData();
aValue.ComputeState();
uint64_t dataLength = aValue.Length();
;
@ -555,7 +555,7 @@ RefPtr<IDBFileRequest> IDBFileHandle::WriteOrAppend(
return nullptr;
}
aValue.ComputeLengthAndData();
aValue.ComputeState();
uint64_t dataLength = aValue.Length();
;

Просмотреть файл

@ -25,12 +25,12 @@ ArrayData GetArrayBufferViewOrArrayBufferData(
aBufferOrView.IsArrayBufferView());
if (aBufferOrView.IsArrayBuffer()) {
const dom::ArrayBuffer& buffer = aBufferOrView.GetAsArrayBuffer();
buffer.ComputeLengthAndData();
buffer.ComputeState();
return ArrayData(buffer.Data(), buffer.Length());
} else if (aBufferOrView.IsArrayBufferView()) {
const dom::ArrayBufferView& bufferview =
aBufferOrView.GetAsArrayBufferView();
bufferview.ComputeLengthAndData();
bufferview.ComputeState();
return ArrayData(bufferview.Data(), bufferview.Length());
}
return ArrayData(nullptr, 0);

Просмотреть файл

@ -78,7 +78,7 @@ already_AddRefed<MediaEncryptedEvent> MediaEncryptedEvent::Constructor(
e->mInitDataType = aEventInitDict.mInitDataType;
if (!aEventInitDict.mInitData.IsNull()) {
const auto& a = aEventInitDict.mInitData.Value();
a.ComputeLengthAndData();
a.ComputeState();
e->mInitData = ArrayBuffer::Create(aGlobal.Context(), a.Length(), a.Data());
if (!e->mInitData) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);

Просмотреть файл

@ -76,7 +76,7 @@ already_AddRefed<MediaKeyMessageEvent> MediaKeyMessageEvent::Constructor(
RefPtr<MediaKeyMessageEvent> e = new MediaKeyMessageEvent(owner);
bool trusted = e->Init(owner);
e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
aEventInitDict.mMessage.ComputeLengthAndData();
aEventInitDict.mMessage.ComputeState();
e->mMessage =
ArrayBuffer::Create(aGlobal.Context(), aEventInitDict.mMessage.Length(),
aEventInitDict.mMessage.Data());

Просмотреть файл

@ -171,7 +171,7 @@ void SourceBuffer::SetAppendWindowEnd(double aAppendWindowEnd,
void SourceBuffer::AppendBuffer(const ArrayBuffer& aData, ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread());
MSE_API("AppendBuffer(ArrayBuffer)");
aData.ComputeLengthAndData();
aData.ComputeState();
DDLOG(DDLogCategory::API, "AppendBuffer", aData.Length());
AppendData(aData.Data(), aData.Length(), aRv);
}
@ -180,7 +180,7 @@ void SourceBuffer::AppendBuffer(const ArrayBufferView& aData,
ErrorResult& aRv) {
MOZ_ASSERT(NS_IsMainThread());
MSE_API("AppendBuffer(ArrayBufferView)");
aData.ComputeLengthAndData();
aData.ComputeState();
DDLOG(DDLogCategory::API, "AppendBuffer", aData.Length());
AppendData(aData.Data(), aData.Length(), aRv);
}
@ -190,7 +190,7 @@ already_AddRefed<Promise> SourceBuffer::AppendBufferAsync(
MOZ_ASSERT(NS_IsMainThread());
MSE_API("AppendBufferAsync(ArrayBuffer)");
aData.ComputeLengthAndData();
aData.ComputeState();
DDLOG(DDLogCategory::API, "AppendBufferAsync", aData.Length());
return AppendDataAsync(aData.Data(), aData.Length(), aRv);
@ -201,7 +201,7 @@ already_AddRefed<Promise> SourceBuffer::AppendBufferAsync(
MOZ_ASSERT(NS_IsMainThread());
MSE_API("AppendBufferAsync(ArrayBufferView)");
aData.ComputeLengthAndData();
aData.ComputeState();
DDLOG(DDLogCategory::API, "AppendBufferAsync", aData.Length());
return AppendDataAsync(aData.Data(), aData.Length(), aRv);

Просмотреть файл

@ -204,7 +204,7 @@ void AnalyserNode::GetFloatFrequencyData(const Float32Array& aArray) {
return;
}
aArray.ComputeLengthAndData();
aArray.ComputeState();
float* buffer = aArray.Data();
size_t length = std::min(size_t(aArray.Length()), mOutputBuffer.Length());
@ -223,7 +223,7 @@ void AnalyserNode::GetByteFrequencyData(const Uint8Array& aArray) {
const double rangeScaleFactor = 1.0 / (mMaxDecibels - mMinDecibels);
aArray.ComputeLengthAndData();
aArray.ComputeState();
unsigned char* buffer = aArray.Data();
size_t length = std::min(size_t(aArray.Length()), mOutputBuffer.Length());
@ -240,7 +240,7 @@ void AnalyserNode::GetByteFrequencyData(const Uint8Array& aArray) {
}
void AnalyserNode::GetFloatTimeDomainData(const Float32Array& aArray) {
aArray.ComputeLengthAndData();
aArray.ComputeState();
float* buffer = aArray.Data();
size_t length = std::min(aArray.Length(), FftSize());
@ -249,7 +249,7 @@ void AnalyserNode::GetFloatTimeDomainData(const Float32Array& aArray) {
}
void AnalyserNode::GetByteTimeDomainData(const Uint8Array& aArray) {
aArray.ComputeLengthAndData();
aArray.ComputeState();
size_t length = std::min(aArray.Length(), FftSize());

Просмотреть файл

@ -300,7 +300,7 @@ bool AudioBuffer::RestoreJSChannelData(JSContext* aJSContext) {
void AudioBuffer::CopyFromChannel(const Float32Array& aDestination,
uint32_t aChannelNumber,
uint32_t aStartInChannel, ErrorResult& aRv) {
aDestination.ComputeLengthAndData();
aDestination.ComputeState();
if (aChannelNumber >= NumberOfChannels() || aStartInChannel > Length()) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
@ -340,7 +340,7 @@ void AudioBuffer::CopyToChannel(JSContext* aJSContext,
const Float32Array& aSource,
uint32_t aChannelNumber,
uint32_t aStartInChannel, ErrorResult& aRv) {
aSource.ComputeLengthAndData();
aSource.ComputeState();
if (aChannelNumber >= NumberOfChannels() || aStartInChannel > Length()) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);

Просмотреть файл

@ -500,8 +500,8 @@ already_AddRefed<OscillatorNode> AudioContext::CreateOscillator(
already_AddRefed<PeriodicWave> AudioContext::CreatePeriodicWave(
const Float32Array& aRealData, const Float32Array& aImagData,
const PeriodicWaveConstraints& aConstraints, ErrorResult& aRv) {
aRealData.ComputeLengthAndData();
aImagData.ComputeLengthAndData();
aRealData.ComputeState();
aImagData.ComputeState();
if (aRealData.Length() != aImagData.Length() || aRealData.Length() == 0) {
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
@ -602,7 +602,7 @@ already_AddRefed<Promise> AudioContext::DecodeAudioData(
return nullptr;
}
aBuffer.ComputeLengthAndData();
aBuffer.ComputeState();
if (!aBuffer.Data()) {
// Throw if the buffer is detached

Просмотреть файл

@ -303,9 +303,9 @@ void BiquadFilterNode::GetFrequencyResponse(const Float32Array& aFrequencyHz,
const Float32Array& aMagResponse,
const Float32Array& aPhaseResponse,
ErrorResult& aRv) {
aFrequencyHz.ComputeLengthAndData();
aMagResponse.ComputeLengthAndData();
aPhaseResponse.ComputeLengthAndData();
aFrequencyHz.ComputeState();
aMagResponse.ComputeState();
aPhaseResponse.ComputeState();
if (!(aFrequencyHz.Length() == aMagResponse.Length() &&
aMagResponse.Length() == aPhaseResponse.Length())) {

Просмотреть файл

@ -212,9 +212,9 @@ JSObject* IIRFilterNode::WrapObject(JSContext* aCx,
void IIRFilterNode::GetFrequencyResponse(const Float32Array& aFrequencyHz,
const Float32Array& aMagResponse,
const Float32Array& aPhaseResponse) {
aFrequencyHz.ComputeLengthAndData();
aMagResponse.ComputeLengthAndData();
aPhaseResponse.ComputeLengthAndData();
aFrequencyHz.ComputeState();
aMagResponse.ComputeState();
aPhaseResponse.ComputeState();
uint32_t length =
std::min(std::min(aFrequencyHz.Length(), aMagResponse.Length()),

Просмотреть файл

@ -330,7 +330,7 @@ void WaveShaperNode::SetCurve(const Nullable<Float32Array>& aCurve,
}
const Float32Array& floats = aCurve.Value();
floats.ComputeLengthAndData();
floats.ComputeState();
nsTArray<float> curve;
uint32_t argLength = floats.Length();

Просмотреть файл

@ -76,7 +76,7 @@ already_AddRefed<MIDIMessageEvent> MIDIMessageEvent::Constructor(
// Set data for event. Timestamp will always be set to Now() (default for
// event) using this constructor.
const auto& a = aEventInitDict.mData.Value();
a.ComputeLengthAndData();
a.ComputeState();
e->mData = Uint8Array::Create(aGlobal.Context(), owner, a.Length(), a.Data());
if (NS_WARN_IF(!e->mData)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);

Просмотреть файл

@ -758,7 +758,7 @@ bool TCPSocket::Send(JSContext* aCx, const ArrayBuffer& aData,
nsCOMPtr<nsIArrayBufferInputStream> stream;
aData.ComputeLengthAndData();
aData.ComputeState();
uint32_t byteLength =
aByteLength.WasPassed() ? aByteLength.Value() : aData.Length();

Просмотреть файл

@ -345,12 +345,12 @@ bool UDPSocket::Send(const StringOrBlobOrArrayBufferOrArrayBufferView& aData,
aRv = strStream->SetData(data.BeginReading(), data.Length());
} else if (aData.IsArrayBuffer()) {
const ArrayBuffer& data = aData.GetAsArrayBuffer();
data.ComputeLengthAndData();
data.ComputeState();
aRv = strStream->SetData(reinterpret_cast<const char*>(data.Data()),
data.Length());
} else {
const ArrayBufferView& data = aData.GetAsArrayBufferView();
data.ComputeLengthAndData();
data.ComputeState();
aRv = strStream->SetData(reinterpret_cast<const char*>(data.Data()),
data.Length());
}

Просмотреть файл

@ -258,7 +258,7 @@ void PresentationConnection::Send(const ArrayBuffer& aData, ErrorResult& aRv) {
return;
}
aData.ComputeLengthAndData();
aData.ComputeState();
static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");
@ -292,7 +292,7 @@ void PresentationConnection::Send(const ArrayBufferView& aData,
return;
}
aData.ComputeLengthAndData();
aData.ComputeState();
static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");

Просмотреть файл

@ -198,8 +198,8 @@ TEST(PrioEncoder, VerifyFull)
prioEncodedData, rv);
ASSERT_FALSE(rv.Failed());
prioEncodedData.mA.Value().ComputeLengthAndData();
prioEncodedData.mB.Value().ComputeLengthAndData();
prioEncodedData.mA.Value().ComputeState();
prioEncodedData.mB.Value().ComputeState();
forServerA = prioEncodedData.mA.Value().Data();
forServerB = prioEncodedData.mB.Value().Data();

Просмотреть файл

@ -13,7 +13,7 @@ namespace dom {
bool PushUtil::CopyArrayBufferToArray(const ArrayBuffer& aBuffer,
nsTArray<uint8_t>& aArray) {
MOZ_ASSERT(aArray.IsEmpty());
aBuffer.ComputeLengthAndData();
aBuffer.ComputeState();
return aArray.SetCapacity(aBuffer.Length(), fallible) &&
aArray.InsertElementsAt(0, aBuffer.Data(), aBuffer.Length(), fallible);
}
@ -22,7 +22,7 @@ bool PushUtil::CopyArrayBufferToArray(const ArrayBuffer& aBuffer,
bool PushUtil::CopyArrayBufferViewToArray(const ArrayBufferView& aView,
nsTArray<uint8_t>& aArray) {
MOZ_ASSERT(aArray.IsEmpty());
aView.ComputeLengthAndData();
aView.ComputeState();
return aArray.SetCapacity(aView.Length(), fallible) &&
aArray.InsertElementsAt(0, aView.Data(), aView.Length(), fallible);
}

Просмотреть файл

@ -34,7 +34,7 @@ template <class T>
bool ReadFloat32Array(T& aDestination, const Float32Array& aSource,
ErrorResult& aRv) {
constexpr size_t length = std::extent<T>::value;
aSource.ComputeLengthAndData();
aSource.ComputeState();
if (aSource.Length() != length) {
aRv.Throw(NS_ERROR_INVALID_ARG);
// We don't want to MOZ_ASSERT here, as that would cause the

Просмотреть файл

@ -2247,7 +2247,7 @@ void WebSocket::Send(Blob& aData, ErrorResult& aRv) {
void WebSocket::Send(const ArrayBuffer& aData, ErrorResult& aRv) {
AssertIsOnTargetThread();
aData.ComputeLengthAndData();
aData.ComputeState();
static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");
@ -2261,7 +2261,7 @@ void WebSocket::Send(const ArrayBuffer& aData, ErrorResult& aRv) {
void WebSocket::Send(const ArrayBufferView& aData, ErrorResult& aRv) {
AssertIsOnTargetThread();
aData.ComputeLengthAndData();
aData.ComputeState();
static_assert(sizeof(*aData.Data()) == 1, "byte-sized data required");

Просмотреть файл

@ -54,7 +54,7 @@ template <typename T>
static void GetDataFrom(const T& aObject, uint8_t*& aBuffer,
uint32_t& aLength) {
MOZ_ASSERT(!aBuffer);
aObject.ComputeLengthAndData();
aObject.ComputeState();
// We use malloc here rather than a FallibleTArray or fallible
// operator new[] since the gfxUserFontEntry will be calling free
// on it.

Просмотреть файл

@ -132,7 +132,7 @@ bool StreamFilter::CheckAlive() {
template <typename T>
static inline bool ReadTypedArrayData(nsTArray<uint8_t>& aData, const T& aArray,
ErrorResult& aRv) {
aArray.ComputeLengthAndData();
aArray.ComputeState();
if (!aData.SetLength(aArray.Length(), fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return false;