Skip to content

Commit

Permalink
Bug 1235261 - Part 2: Switch some uses of AutoFallibleTArray to AutoT…
Browse files Browse the repository at this point in the history
…Array. 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`.
  • Loading branch information
poiru committed Feb 2, 2016
1 parent d557eac commit 1810d8b
Show file tree
Hide file tree
Showing 16 changed files with 57 additions and 64 deletions.
2 changes: 1 addition & 1 deletion dom/base/nsLineBreaker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand Down
54 changes: 25 additions & 29 deletions dom/indexedDB/ActorsParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -963,7 +961,7 @@ ReadCompressedIndexDataValuesFromSource(
nsresult
ReadCompressedIndexDataValues(mozIStorageStatement* aStatement,
uint32_t aColumnIndex,
FallibleTArray<IndexDataValue>& aIndexValues)
nsTArray<IndexDataValue>& aIndexValues)
{
return ReadCompressedIndexDataValuesFromSource(aStatement,
aColumnIndex,
Expand All @@ -973,7 +971,7 @@ ReadCompressedIndexDataValues(mozIStorageStatement* aStatement,
nsresult
ReadCompressedIndexDataValues(mozIStorageValueArray* aValues,
uint32_t aColumnIndex,
FallibleTArray<IndexDataValue>& aIndexValues)
nsTArray<IndexDataValue>& aIndexValues)
{
return ReadCompressedIndexDataValuesFromSource(aValues,
aColumnIndex,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3866,7 +3864,7 @@ class UpgradeIndexDataValuesFunction final
nsresult
ReadOldCompressedIDVFromBlob(const uint8_t* aBlobData,
uint32_t aBlobDataLength,
FallibleTArray<IndexDataValue>& aIndexValues);
nsTArray<IndexDataValue>& aIndexValues);

NS_IMETHOD
OnFunctionCall(mozIStorageValueArray* aArguments,
Expand All @@ -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());
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -5862,10 +5860,9 @@ class DatabaseOperationBase
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,
Expand Down Expand Up @@ -7912,7 +7909,7 @@ class DeleteIndexOp final
nsresult
RemoveReferencesToIndex(DatabaseConnection* aConnection,
const Key& aObjectDataKey,
FallibleTArray<IndexDataValue>& aIndexValues);
nsTArray<IndexDataValue>& aIndexValues);

virtual nsresult
DoDatabaseWork(DatabaseConnection* aConnection) override;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -18723,7 +18720,7 @@ DatabaseOperationBase::DeleteObjectStoreDataTableRowsWithIndexes(
}

DatabaseConnection::CachedStatement deleteStmt;
AutoFallibleTArray<IndexDataValue, 32> indexValues;
AutoTArray<IndexDataValue, 32> indexValues;

DebugOnly<uint32_t> resultCountDEBUG = 0;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -24111,7 +24107,7 @@ ObjectStoreAddOrPutRequestOp::RemoveOldIndexDataValues(
}

if (hasResult) {
AutoFallibleTArray<IndexDataValue, 32> existingIndexValues;
AutoTArray<IndexDataValue, 32> existingIndexValues;
rv = ReadCompressedIndexDataValues(indexValuesStmt,
0,
existingIndexValues);
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions gfx/thebes/gfxDWriteFontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ UsingArabicOrHebrewScriptSystemLocale()

nsresult
gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t> &aBuffer)
nsTArray<uint8_t> &aBuffer)
{
gfxDWriteFontList *pFontList = gfxDWriteFontList::PlatformFontList();

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion gfx/thebes/gfxDWriteFontList.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class gfxDWriteFontEntry : public gfxFontEntry
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);
Expand Down
5 changes: 2 additions & 3 deletions gfx/thebes/gfxFT2FontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion gfx/thebes/gfxFT2FontList.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class FT2FontEntry : public gfxFontEntry
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
Expand Down
2 changes: 1 addition & 1 deletion gfx/thebes/gfxFcPlatformFontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion gfx/thebes/gfxFcPlatformFontList.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class gfxFontconfigFontEntry : public gfxFontEntry {
// 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();
Expand Down
22 changes: 11 additions & 11 deletions gfx/thebes/gfxFontEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -570,8 +570,8 @@ class gfxFontEntry::FontTableBlobData {
}

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.
Expand All @@ -584,12 +584,12 @@ class gfxFontEntry::FontTableBlobData {

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,
Expand Down Expand Up @@ -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
Expand All @@ -675,7 +675,7 @@ gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
return nullptr;
}

return entry->ShareTableAndGetBlob(*aBuffer, mFontTableCache);
return entry->ShareTableAndGetBlob(Move(*aBuffer), mFontTableCache);
}

static int
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions gfx/thebes/gfxFontEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class gfxFontEntry {
// 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,
Expand Down Expand Up @@ -469,7 +469,7 @@ class gfxFontEntry {
// 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;
}
Expand Down Expand Up @@ -605,7 +605,7 @@ class gfxFontEntry {
// 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.
Expand Down
4 changes: 2 additions & 2 deletions gfx/thebes/gfxFontconfigFonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class gfxSystemFcFontEntry : public gfxFcFontEntry {

protected:
virtual nsresult
CopyFontTable(uint32_t aTableTag, FallibleTArray<uint8_t>& aBuffer) override;
CopyFontTable(uint32_t aTableTag, nsTArray<uint8_t>& aBuffer) override;

void MaybeReleaseFTFace();

Expand All @@ -228,7 +228,7 @@ class gfxSystemFcFontEntry : public gfxFcFontEntry {

nsresult
gfxSystemFcFontEntry::CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t>& aBuffer)
nsTArray<uint8_t>& aBuffer)
{
if (!mFTFaceInitialized) {
mFTFaceInitialized = true;
Expand Down
5 changes: 2 additions & 3 deletions gfx/thebes/gfxGDIFontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gfx/thebes/gfxGDIFontList.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class GDIFontEntry : public gfxFontEntry
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;
};
Expand Down
Loading

0 comments on commit 1810d8b

Please sign in to comment.