Bug 1235261 - Part 2: Switch some uses of AutoFallibleTArray to AutoTArray. r=froydnj

This changes some function signatures to take a nsTArray<T>& instead of a
FallibleTArray<T>& because AutoTArray does not inherit from FallibleTArray.

This is effectively a no-op because the affected array operations already use
`mozilla::fallible`.
This commit is contained in:
Birunthan Mohanathas 2016-01-31 17:12:12 +02:00
parent 373593275e
commit 53bb27f2a4
16 changed files with 57 additions and 64 deletions

View File

@ -313,7 +313,7 @@ nsLineBreaker::FindHyphenationPoints(nsHyphenator *aHyphenator,
uint8_t *aBreakState)
{
nsDependentSubstring string(aTextStart, aTextLimit);
AutoFallibleTArray<bool,200> hyphens;
AutoTArray<bool,200> hyphens;
if (NS_SUCCEEDED(aHyphenator->Hyphenate(string, hyphens))) {
for (uint32_t i = 0; i + 1 < string.Length(); ++i) {
if (hyphens[i]) {

View File

@ -838,10 +838,9 @@ MakeCompressedIndexDataValues(
}
nsresult
ReadCompressedIndexDataValuesFromBlob(
const uint8_t* aBlobData,
uint32_t aBlobDataLength,
FallibleTArray<IndexDataValue>& aIndexValues)
ReadCompressedIndexDataValuesFromBlob(const uint8_t* aBlobData,
uint32_t aBlobDataLength,
nsTArray<IndexDataValue>& aIndexValues)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!IsOnBackgroundThread());
@ -916,10 +915,9 @@ ReadCompressedIndexDataValuesFromBlob(
// static
template <typename T>
nsresult
ReadCompressedIndexDataValuesFromSource(
T* aSource,
uint32_t aColumnIndex,
FallibleTArray<IndexDataValue>& aIndexValues)
ReadCompressedIndexDataValuesFromSource(T* aSource,
uint32_t aColumnIndex,
nsTArray<IndexDataValue>& aIndexValues)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!IsOnBackgroundThread());
@ -963,7 +961,7 @@ ReadCompressedIndexDataValuesFromSource(
nsresult
ReadCompressedIndexDataValues(mozIStorageStatement* aStatement,
uint32_t aColumnIndex,
FallibleTArray<IndexDataValue>& aIndexValues)
nsTArray<IndexDataValue>& aIndexValues)
{
return ReadCompressedIndexDataValuesFromSource(aStatement,
aColumnIndex,
@ -973,7 +971,7 @@ ReadCompressedIndexDataValues(mozIStorageStatement* aStatement,
nsresult
ReadCompressedIndexDataValues(mozIStorageValueArray* aValues,
uint32_t aColumnIndex,
FallibleTArray<IndexDataValue>& aIndexValues)
nsTArray<IndexDataValue>& aIndexValues)
{
return ReadCompressedIndexDataValuesFromSource(aValues,
aColumnIndex,
@ -2768,7 +2766,7 @@ InsertIndexDataValuesFunction::OnFunctionCall(mozIStorageValueArray* aValues,
// Read out the previous value. It may be NULL, in which case we'll just end
// up with an empty array.
AutoFallibleTArray<IndexDataValue, 32> indexValues;
AutoTArray<IndexDataValue, 32> indexValues;
nsresult rv = ReadCompressedIndexDataValues(aValues, 0, indexValues);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -3866,7 +3864,7 @@ private:
nsresult
ReadOldCompressedIDVFromBlob(const uint8_t* aBlobData,
uint32_t aBlobDataLength,
FallibleTArray<IndexDataValue>& aIndexValues);
nsTArray<IndexDataValue>& aIndexValues);
NS_IMETHOD
OnFunctionCall(mozIStorageValueArray* aArguments,
@ -3879,7 +3877,7 @@ nsresult
UpgradeIndexDataValuesFunction::ReadOldCompressedIDVFromBlob(
const uint8_t* aBlobData,
uint32_t aBlobDataLength,
FallibleTArray<IndexDataValue>& aIndexValues)
nsTArray<IndexDataValue>& aIndexValues)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!IsOnBackgroundThread());
@ -3991,7 +3989,7 @@ UpgradeIndexDataValuesFunction::OnFunctionCall(mozIStorageValueArray* aArguments
return rv;
}
AutoFallibleTArray<IndexDataValue, 32> oldIdv;
AutoTArray<IndexDataValue, 32> oldIdv;
rv = ReadOldCompressedIDVFromBlob(oldBlob, oldBlobLength, oldIdv);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -5862,10 +5860,9 @@ protected:
Maybe<UniqueIndexTable>& aMaybeUniqueIndexTable);
static nsresult
IndexDataValuesFromUpdateInfos(
const nsTArray<IndexUpdateInfo>& aUpdateInfos,
const UniqueIndexTable& aUniqueIndexTable,
FallibleTArray<IndexDataValue>& aIndexValues);
IndexDataValuesFromUpdateInfos(const nsTArray<IndexUpdateInfo>& aUpdateInfos,
const UniqueIndexTable& aUniqueIndexTable,
nsTArray<IndexDataValue>& aIndexValues);
static nsresult
InsertIndexTableRows(DatabaseConnection* aConnection,
@ -7912,7 +7909,7 @@ private:
nsresult
RemoveReferencesToIndex(DatabaseConnection* aConnection,
const Key& aObjectDataKey,
FallibleTArray<IndexDataValue>& aIndexValues);
nsTArray<IndexDataValue>& aIndexValues);
virtual nsresult
DoDatabaseWork(DatabaseConnection* aConnection) override;
@ -18403,7 +18400,7 @@ nsresult
DatabaseOperationBase::IndexDataValuesFromUpdateInfos(
const nsTArray<IndexUpdateInfo>& aUpdateInfos,
const UniqueIndexTable& aUniqueIndexTable,
FallibleTArray<IndexDataValue>& aIndexValues)
nsTArray<IndexDataValue>& aIndexValues)
{
MOZ_ASSERT(aIndexValues.IsEmpty());
MOZ_ASSERT_IF(!aUpdateInfos.IsEmpty(), aUniqueIndexTable.Count());
@ -18723,7 +18720,7 @@ DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
}
DatabaseConnection::CachedStatement deleteStmt;
AutoFallibleTArray<IndexDataValue, 32> indexValues;
AutoTArray<IndexDataValue, 32> indexValues;
DebugOnly<uint32_t> resultCountDEBUG = 0;
@ -23410,7 +23407,7 @@ UpdateIndexDataValuesFunction::OnFunctionCall(mozIStorageValueArray* aValues,
return rv;
}
AutoFallibleTArray<IndexDataValue, 32> indexValues;
AutoTArray<IndexDataValue, 32> indexValues;
rv = ReadCompressedIndexDataValues(aValues, 1, indexValues);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
@ -23509,10 +23506,9 @@ DeleteIndexOp::DeleteIndexOp(VersionChangeTransaction* aTransaction,
}
nsresult
DeleteIndexOp::RemoveReferencesToIndex(
DatabaseConnection* aConnection,
const Key& aObjectStoreKey,
FallibleTArray<IndexDataValue>& aIndexValues)
DeleteIndexOp::RemoveReferencesToIndex(DatabaseConnection* aConnection,
const Key& aObjectStoreKey,
nsTArray<IndexDataValue>& aIndexValues)
{
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(!IsOnBackgroundThread());
@ -23767,7 +23763,7 @@ DeleteIndexOp::DoDatabaseWork(DatabaseConnection* aConnection)
DatabaseConnection::CachedStatement nullIndexDataValuesStmt;
Key lastObjectStoreKey;
AutoFallibleTArray<IndexDataValue, 32> lastIndexValues;
AutoTArray<IndexDataValue, 32> lastIndexValues;
bool hasResult;
while (NS_SUCCEEDED(rv = selectStmt->ExecuteStep(&hasResult)) && hasResult) {
@ -24111,7 +24107,7 @@ ObjectStoreAddOrPutRequestOp::RemoveOldIndexDataValues(
}
if (hasResult) {
AutoFallibleTArray<IndexDataValue, 32> existingIndexValues;
AutoTArray<IndexDataValue, 32> existingIndexValues;
rv = ReadCompressedIndexDataValues(indexValuesStmt,
0,
existingIndexValues);
@ -24639,7 +24635,7 @@ ObjectStoreAddOrPutRequestOp::DoDatabaseWork(DatabaseConnection* aConnection)
MOZ_ASSERT(mUniqueIndexTable.isSome());
// Write the index_data_values column.
AutoFallibleTArray<IndexDataValue, 32> indexValues;
AutoTArray<IndexDataValue, 32> indexValues;
rv = IndexDataValuesFromUpdateInfos(mParams.indexUpdateInfos(),
mUniqueIndexTable.ref(),
indexValues);

View File

@ -398,7 +398,7 @@ UsingArabicOrHebrewScriptSystemLocale()
nsresult
gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t> &aBuffer)
nsTArray<uint8_t> &aBuffer)
{
gfxDWriteFontList *pFontList = gfxDWriteFontList::PlatformFontList();
@ -679,7 +679,7 @@ gfxDWriteFontEntry::IsCJKFont()
mIsCJK = false;
const uint32_t kOS2Tag = TRUETYPE_TAG('O','S','/','2');
AutoFallibleTArray<uint8_t,128> buffer;
AutoTArray<uint8_t, 128> buffer;
if (CopyFontTable(kOS2Tag, buffer) != NS_OK) {
return mIsCJK;
}

View File

@ -175,7 +175,7 @@ protected:
friend class gfxDWriteFontList;
virtual nsresult CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer) override;
nsTArray<uint8_t>& aBuffer) override;
virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle,
bool aNeedsBold);

View File

@ -457,7 +457,7 @@ FT2FontEntry::ReadCMAP(FontInfoData *aFontInfoData)
RefPtr<gfxCharacterMap> charmap = new gfxCharacterMap();
AutoFallibleTArray<uint8_t,16384> buffer;
AutoTArray<uint8_t, 16384> buffer;
nsresult rv = CopyFontTable(TTAG_cmap, buffer);
if (NS_SUCCEEDED(rv)) {
@ -511,8 +511,7 @@ FT2FontEntry::ReadCMAP(FontInfoData *aFontInfoData)
}
nsresult
FT2FontEntry::CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer)
FT2FontEntry::CopyFontTable(uint32_t aTableTag, nsTArray<uint8_t>& aBuffer)
{
AutoFTFace face(this);
if (!face) {

View File

@ -78,7 +78,7 @@ public:
virtual hb_blob_t* GetFontTable(uint32_t aTableTag) override;
virtual nsresult CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer) override;
nsTArray<uint8_t>& aBuffer) override;
// Check for various kinds of brokenness, and set flags on the entry
// accordingly so that we avoid using bad font tables

View File

@ -744,7 +744,7 @@ gfxFontconfigFontEntry::CreateFontInstance(const gfxFontStyle *aFontStyle,
nsresult
gfxFontconfigFontEntry::CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer)
nsTArray<uint8_t>& aBuffer)
{
NS_ASSERTION(!mIsDataUserFont,
"data fonts should be reading tables directly from memory");

View File

@ -137,7 +137,7 @@ protected:
// override to pull data from FTFace
virtual nsresult
CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer) override;
nsTArray<uint8_t>& aBuffer) override;
// if HB or GR faces are gone, close down the FT_Face
void MaybeReleaseFTFace();

View File

@ -523,12 +523,12 @@ gfxFontEntry::TryGetColorGlyphs()
class gfxFontEntry::FontTableBlobData {
public:
// Adopts the content of aBuffer.
explicit FontTableBlobData(FallibleTArray<uint8_t>& aBuffer)
: mHashtable(nullptr), mHashKey(0)
explicit FontTableBlobData(nsTArray<uint8_t>&& aBuffer)
: mTableData(Move(aBuffer))
, mHashtable(nullptr)
, mHashKey(0)
{
MOZ_COUNT_CTOR(FontTableBlobData);
mTableData.SwapElements(aBuffer);
}
~FontTableBlobData() {
@ -570,8 +570,8 @@ public:
}
private:
// The font table data block, owned (via adoption)
FallibleTArray<uint8_t> mTableData;
// The font table data block
nsTArray<uint8_t> mTableData;
// The blob destroy function needs to know the owning hashtable
// and the hashtable key, so that it can remove the entry.
@ -584,12 +584,12 @@ private:
hb_blob_t *
gfxFontEntry::FontTableHashEntry::
ShareTableAndGetBlob(FallibleTArray<uint8_t>& aTable,
ShareTableAndGetBlob(nsTArray<uint8_t>&& aTable,
nsTHashtable<FontTableHashEntry> *aHashtable)
{
Clear();
// adopts elements of aTable
mSharedBlobData = new FontTableBlobData(aTable);
mSharedBlobData = new FontTableBlobData(Move(aTable));
mBlob = hb_blob_create(mSharedBlobData->GetTable(),
mSharedBlobData->GetTableLength(),
HB_MEMORY_MODE_READONLY,
@ -656,7 +656,7 @@ gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t **aBlob)
hb_blob_t *
gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
FallibleTArray<uint8_t>* aBuffer)
nsTArray<uint8_t>* aBuffer)
{
if (MOZ_UNLIKELY(!mFontTableCache)) {
// we do this here rather than on fontEntry construction
@ -675,7 +675,7 @@ gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
return nullptr;
}
return entry->ShareTableAndGetBlob(*aBuffer, mFontTableCache);
return entry->ShareTableAndGetBlob(Move(*aBuffer), mFontTableCache);
}
static int
@ -725,7 +725,7 @@ gfxFontEntry::GetFontTable(uint32_t aTag)
return blob;
}
FallibleTArray<uint8_t> buffer;
nsTArray<uint8_t> buffer;
bool haveTable = NS_SUCCEEDED(CopyFontTable(aTag, buffer));
return ShareFontTableAndGetBlob(aTag, haveTable ? &buffer : nullptr);

View File

@ -337,7 +337,7 @@ public:
// Pass nullptr for aBuffer to indicate that the table is not present and
// nullptr will be returned. Also returns nullptr on OOM.
hb_blob_t *ShareFontTableAndGetBlob(uint32_t aTag,
FallibleTArray<uint8_t>* aTable);
nsTArray<uint8_t>* aTable);
// Get the font's unitsPerEm from the 'head' table, in the case of an
// sfnt resource. Will return kInvalidUPEM for non-sfnt fonts,
@ -469,7 +469,7 @@ protected:
// Copy a font table into aBuffer.
// The caller will be responsible for ownership of the data.
virtual nsresult CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer) {
nsTArray<uint8_t>& aBuffer) {
NS_NOTREACHED("forgot to override either GetFontTable or CopyFontTable?");
return NS_ERROR_FAILURE;
}
@ -605,7 +605,7 @@ private:
// recorded in the hashtable entry so that others may use the same
// table.
hb_blob_t *
ShareTableAndGetBlob(FallibleTArray<uint8_t>& aTable,
ShareTableAndGetBlob(nsTArray<uint8_t>&& aTable,
nsTHashtable<FontTableHashEntry> *aHashtable);
// Return a strong reference to the blob.

View File

@ -216,7 +216,7 @@ public:
protected:
virtual nsresult
CopyFontTable(uint32_t aTableTag, FallibleTArray<uint8_t>& aBuffer) override;
CopyFontTable(uint32_t aTableTag, nsTArray<uint8_t>& aBuffer) override;
void MaybeReleaseFTFace();
@ -228,7 +228,7 @@ private:
nsresult
gfxSystemFcFontEntry::CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer)
nsTArray<uint8_t>& aBuffer)
{
if (!mFTFaceInitialized) {
mFTFaceInitialized = true;

View File

@ -173,7 +173,7 @@ GDIFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
} else {
uint32_t kCMAP = TRUETYPE_TAG('c','m','a','p');
charmap = new gfxCharacterMap();
AutoFallibleTArray<uint8_t,16384> cmap;
AutoTArray<uint8_t, 16384> cmap;
rv = CopyFontTable(kCMAP, cmap);
if (NS_SUCCEEDED(rv)) {
@ -234,8 +234,7 @@ GDIFontEntry::CreateFontInstance(const gfxFontStyle* aFontStyle, bool aNeedsBold
}
nsresult
GDIFontEntry::CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer)
GDIFontEntry::CopyFontTable(uint32_t aTableTag, nsTArray<uint8_t>& aBuffer)
{
if (!IsTrueType()) {
return NS_ERROR_FAILURE;

View File

@ -274,7 +274,7 @@ protected:
virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold);
virtual nsresult CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer) override;
nsTArray<uint8_t>& aBuffer) override;
LOGFONTW mLogFont;
};

View File

@ -43,8 +43,7 @@ nsHyphenator::IsValid()
}
nsresult
nsHyphenator::Hyphenate(const nsAString& aString,
FallibleTArray<bool>& aHyphens)
nsHyphenator::Hyphenate(const nsAString& aString, nsTArray<bool>& aHyphens)
{
if (!aHyphens.SetLength(aString.Length(), mozilla::fallible)) {
return NS_ERROR_OUT_OF_MEMORY;

View File

@ -21,7 +21,7 @@ public:
bool IsValid();
nsresult Hyphenate(const nsAString& aText, FallibleTArray<bool>& aHyphens);
nsresult Hyphenate(const nsAString& aText, nsTArray<bool>& aHyphens);
private:
~nsHyphenator();

View File

@ -1472,7 +1472,7 @@ nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, gfxTextContextPaint *aContextPaint)
static bool
GetStrokeDashData(nsIFrame* aFrame,
FallibleTArray<gfxFloat>& aDashes,
nsTArray<gfxFloat>& aDashes,
gfxFloat* aDashOffset,
gfxTextContextPaint *aContextPaint)
{
@ -1576,7 +1576,7 @@ nsSVGUtils::SetupCairoStrokeGeometry(nsIFrame* aFrame,
break;
}
AutoFallibleTArray<gfxFloat, 10> dashes;
AutoTArray<gfxFloat, 10> dashes;
gfxFloat dashOffset;
if (GetStrokeDashData(aFrame, dashes, &dashOffset, aContextPaint)) {
aContext->SetDash(dashes.Elements(), dashes.Length(), dashOffset);