Bug 968520 - Add mozilla::fallible to more FallibleTArray calls. r=froydnj

This calls were already fallible due to their type (FallibleTArray). This
commit merely makes that fact visible at the call site.
This commit is contained in:
Birunthan Mohanathas 2015-06-10 14:30:41 -07:00
parent 85ccb70172
commit 94f1cfa658
10 changed files with 39 additions and 28 deletions

View File

@ -161,14 +161,15 @@ public:
int length = mEvent.mTechList.Length();
event.mTechList.Construct();
if (!event.mTechList.Value().SetCapacity(length)) {
if (!event.mTechList.Value().SetCapacity(length, fallible)) {
return NS_ERROR_FAILURE;
}
for (int i = 0; i < length; i++) {
NFCTechType tech = static_cast<NFCTechType>(mEvent.mTechList[i]);
MOZ_ASSERT(tech < NFCTechType::EndGuard_);
*event.mTechList.Value().AppendElement() = tech;
// FIXME: Make this infallible after bug 968520 is done.
*event.mTechList.Value().AppendElement(fallible) = tech;
}
}
@ -180,13 +181,15 @@ public:
if (mEvent.mRecords.Length() > 0) {
int length = mEvent.mRecords.Length();
event.mRecords.Construct();
if (!event.mRecords.Value().SetCapacity(length)) {
if (!event.mRecords.Value().SetCapacity(length, fallible)) {
return NS_ERROR_FAILURE;
}
for (int i = 0; i < length; i++) {
NDEFRecordStruct& recordStruct = mEvent.mRecords[i];
MozNDEFRecordOptions& record = *event.mRecords.Value().AppendElement();
// FIXME: Make this infallible after bug 968520 is done.
MozNDEFRecordOptions& record =
*event.mRecords.Value().AppendElement(fallible);
record.mTnf = recordStruct.mTnf;
MOZ_ASSERT(record.mTnf < TNF::EndGuard_);

View File

@ -137,7 +137,8 @@ FrameUniformityData::ToJS(JS::MutableHandleValue aOutValue, JSContext* aContext)
uintptr_t layerAddr = iter->first;
float uniformity = iter->second;
layers.AppendElement();
// FIXME: Make this infallible after bug 968520 is done.
MOZ_ALWAYS_TRUE(layers.AppendElement(fallible));
dom::FrameUniformity& entry = layers.LastElement();
entry.mLayerAddress.Construct() = layerAddr;

View File

@ -311,7 +311,7 @@ gfxDWriteFontFamily::LocalizedName(nsAString &aLocalizedName)
return;
}
if (!famName.SetLength(length + 1)) {
if (!famName.SetLength(length + 1, fallible)) {
// Eeep - running out of memory. Unlikely to end well.
return;
}
@ -403,7 +403,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag,
NativeEndian::swapToBigEndian(aTableTag), 0,
nullptr, 0);
if (tableSize != GDI_ERROR) {
if (aBuffer.SetLength(tableSize)) {
if (aBuffer.SetLength(tableSize, fallible)) {
::GetFontData(dc.GetDC(),
NativeEndian::swapToBigEndian(aTableTag), 0,
aBuffer.Elements(), aBuffer.Length());
@ -433,7 +433,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag,
return NS_ERROR_FAILURE;
}
if (aBuffer.SetLength(len)) {
if (aBuffer.SetLength(len, fallible)) {
memcpy(aBuffer.Elements(), tableData, len);
rv = NS_OK;
} else {
@ -1122,7 +1122,7 @@ gfxDWriteFontList::GetFontsFromCollection(IDWriteFontCollection* aCollection)
continue;
}
if (!enName.SetLength(length + 1)) {
if (!enName.SetLength(length + 1, fallible)) {
// Eeep - running out of memory. Unlikely to end well.
continue;
}
@ -1171,7 +1171,7 @@ gfxDWriteFontList::GetFontsFromCollection(IDWriteFontCollection* aCollection)
continue;
}
if (!localizedName.SetLength(nameLen + 1)) {
if (!localizedName.SetLength(nameLen + 1, fallible)) {
continue;
}
@ -1406,7 +1406,7 @@ static HRESULT GetFamilyName(IDWriteFont *aFont, nsString& aFamilyName)
return hr;
}
if (!name.SetLength(length + 1)) {
if (!name.SetLength(length + 1, fallible)) {
return E_FAIL;
}
hr = familyNames->GetString(index, name.Elements(), length + 1);
@ -1587,7 +1587,7 @@ DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
nsAutoTArray<wchar_t, 32> famName;
uint32_t len = aFamilyName.Length();
famName.SetLength(len + 1);
famName.SetLength(len + 1, fallible);
memcpy(famName.Elements(), aFamilyName.BeginReading(), len * sizeof(char16_t));
famName[len] = 0;

View File

@ -532,7 +532,7 @@ FT2FontEntry::CopyFontTable(uint32_t aTableTag,
return NS_ERROR_FAILURE;
}
if (!aBuffer.SetLength(len)) {
if (!aBuffer.SetLength(len, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
uint8_t *buf = aBuffer.Elements();

View File

@ -805,7 +805,7 @@ gfxFontconfigFontEntry::CopyFontTable(uint32_t aTableTag,
if (FT_Load_Sfnt_Table(mFTFace, aTableTag, 0, nullptr, &length) != 0) {
return NS_ERROR_NOT_AVAILABLE;
}
if (!aBuffer.SetLength(length)) {
if (!aBuffer.SetLength(length, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (FT_Load_Sfnt_Table(mFTFace, aTableTag, 0, aBuffer.Elements(), &length) != 0) {

View File

@ -184,9 +184,11 @@ public:
{
cairo_font_face_reference(mFontFace);
cairo_font_face_set_user_data(mFontFace, &sFontEntryKey, this, nullptr);
mPatterns.AppendElement();
// mPatterns is an nsAutoTArray with 1 space always available, so the
// AppendElement always succeeds.
// FIXME: Make this infallible after bug 968520 is done.
MOZ_ALWAYS_TRUE(mPatterns.AppendElement(fallible));
mPatterns[0] = aFontPattern;
FcChar8 *name;
@ -248,7 +250,7 @@ gfxSystemFcFontEntry::CopyFontTable(uint32_t aTableTag,
if (FT_Load_Sfnt_Table(mFTFace, aTableTag, 0, nullptr, &length) != 0) {
return NS_ERROR_NOT_AVAILABLE;
}
if (!aBuffer.SetLength(length)) {
if (!aBuffer.SetLength(length, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
if (FT_Load_Sfnt_Table(mFTFace, aTableTag, 0, aBuffer.Elements(), &length) != 0) {
@ -419,7 +421,7 @@ public:
const nsTArray< nsCountedRef<FcPattern> >& aPatterns)
: gfxUserFcFontEntry(aFontName, aWeight, aStretch, aItalic)
{
if (!mPatterns.SetCapacity(aPatterns.Length()))
if (!mPatterns.SetCapacity(aPatterns.Length(), fallible))
return; // OOM
for (uint32_t i = 0; i < aPatterns.Length(); ++i) {
@ -429,7 +431,8 @@ public:
AdjustPatternToCSS(pattern);
mPatterns.AppendElement();
// FIXME: Make this infallible after bug 968520 is done.
MOZ_ALWAYS_TRUE(mPatterns.AppendElement(fallible));
mPatterns[i].own(pattern);
}
mIsLocalUserFont = true;
@ -617,7 +620,8 @@ gfxDownloadedFcFontEntry::InitPattern()
AddDownloadedFontEntry(pattern, this);
// There is never more than one pattern
mPatterns.AppendElement();
// FIXME: Make this infallible after bug 968520 is done.
MOZ_ALWAYS_TRUE(mPatterns.AppendElement(fallible));
mPatterns[0].own(pattern);
}

View File

@ -245,7 +245,7 @@ GDIFontEntry::CopyFontTable(uint32_t aTableTag,
NativeEndian::swapToBigEndian(aTableTag),
0, nullptr, 0);
if (tableSize != GDI_ERROR) {
if (aBuffer.SetLength(tableSize)) {
if (aBuffer.SetLength(tableSize, fallible)) {
::GetFontData(dc.GetDC(),
NativeEndian::swapToBigEndian(aTableTag), 0,
aBuffer.Elements(), tableSize);
@ -976,7 +976,7 @@ int CALLBACK GDIFontInfo::EnumerateFontsForFamily(
nameSize = ::GetFontData(hdc, kNAME, 0, nullptr, 0);
if (nameSize != GDI_ERROR &&
nameSize > 0 &&
nameData.SetLength(nameSize)) {
nameData.SetLength(nameSize, fallible)) {
::GetFontData(hdc, kNAME, 0, nameData.Elements(), nameSize);
// face names
@ -1019,7 +1019,7 @@ int CALLBACK GDIFontInfo::EnumerateFontsForFamily(
cmapSize = ::GetFontData(hdc, kCMAP, 0, nullptr, 0);
if (cmapSize != GDI_ERROR &&
cmapSize > 0 &&
cmapData.SetLength(cmapSize)) {
cmapData.SetLength(cmapSize, fallible)) {
::GetFontData(hdc, kCMAP, 0, cmapData.Elements(), cmapSize);
bool cmapLoaded = false;
bool unicodeFont = false, symbolFont = false;

View File

@ -244,7 +244,7 @@ Index::Index(const nsTArray<Indice>& aIndex,
if (aIndex.IsEmpty()) {
mMoofParser = new MoofParser(aSource, aTrackId, aIsAudio, aMonitor);
} else {
if (!mIndex.SetCapacity(aIndex.Length())) {
if (!mIndex.SetCapacity(aIndex.Length(), fallible)) {
// OOM.
return;
}
@ -256,7 +256,8 @@ Index::Index(const nsTArray<Indice>& aIndex,
sample.mCompositionRange = Interval<Microseconds>(indice.start_composition,
indice.end_composition);
sample.mSync = indice.sync;
MOZ_ALWAYS_TRUE(mIndex.AppendElement(sample));
// FIXME: Make this infallible after bug 968520 is done.
MOZ_ALWAYS_TRUE(mIndex.AppendElement(sample, fallible));
}
}
}

View File

@ -71,7 +71,7 @@ ConvertIndex(FallibleTArray<Index::Indice>& aDest,
const stagefright::Vector<stagefright::MediaSource::Indice>& aIndex,
int64_t aMediaTime)
{
if (!aDest.SetCapacity(aIndex.size())) {
if (!aDest.SetCapacity(aIndex.size(), mozilla::fallible)) {
return false;
}
for (size_t i = 0; i < aIndex.size(); i++) {
@ -82,7 +82,8 @@ ConvertIndex(FallibleTArray<Index::Indice>& aDest,
indice.start_composition = s_indice.start_composition - aMediaTime;
indice.end_composition = s_indice.end_composition - aMediaTime;
indice.sync = s_indice.sync;
MOZ_ALWAYS_TRUE(aDest.AppendElement(indice));
// FIXME: Make this infallible after bug 968520 is done.
MOZ_ALWAYS_TRUE(aDest.AppendElement(indice, mozilla::fallible));
}
return true;
}

View File

@ -463,7 +463,7 @@ Moof::ParseTrun(Box& aBox, Tfhd& aTfhd, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, u
uint64_t decodeTime = *aDecodeTime;
nsTArray<Interval<Microseconds>> timeRanges;
if (!mIndex.SetCapacity(sampleCount)) {
if (!mIndex.SetCapacity(sampleCount, fallible)) {
LOG(Moof, "Out of Memory");
return false;
}
@ -497,7 +497,8 @@ Moof::ParseTrun(Box& aBox, Tfhd& aTfhd, Mvhd& aMvhd, Mdhd& aMdhd, Edts& aEdts, u
// because every audio sample is a keyframe.
sample.mSync = !(sampleFlags & 0x1010000) || aIsAudio;
MOZ_ALWAYS_TRUE(mIndex.AppendElement(sample));
// FIXME: Make this infallible after bug 968520 is done.
MOZ_ALWAYS_TRUE(mIndex.AppendElement(sample, fallible));
mMdatRange = mMdatRange.Extents(sample.mByteRange);
}