Bug 1265452 - Remove use of nsAutoPtr from gfx/thebes. r=jrmuizel

This commit is contained in:
Jonathan Kew 2016-04-15 20:45:37 +01:00
Родитель c55f3816d1
Коммит 28a9e2cf14
35 изменённых файлов: 146 добавлений и 153 удалений

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

@ -8,7 +8,6 @@
#include "gfxTypes.h"
#include "nsSize.h"
#include "nsAutoPtr.h"
#include "gfxPoint.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"

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

@ -14,7 +14,6 @@
#include "gfxMatrix.h"
#include "gfxPattern.h"
#include "nsTArray.h"
#include "nsAutoPtr.h"
#include "mozilla/gfx/2D.h"

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

@ -10,7 +10,6 @@
#include "nscore.h"
#include "nsIServiceManager.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "cairo-features.h"
#include "gfxFontConstants.h"
#include "nsTArray.h"

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

@ -597,7 +597,7 @@ int32_t
gfxDWriteFont::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID)
{
if (!mGlyphWidths) {
mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(128);
mGlyphWidths = MakeUnique<nsDataHashtable<nsUint32HashKey,int32_t>>(128);
}
int32_t width = -1;

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

@ -7,6 +7,7 @@
#define GFX_WINDOWSDWRITEFONTS_H
#include "mozilla/MemoryReporting.h"
#include "mozilla/UniquePtr.h"
#include <dwrite.h>
#include "gfxFont.h"
@ -98,7 +99,7 @@ protected:
Metrics *mMetrics;
// cache of glyph widths in 16.16 fixed-point pixels
nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths;
mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey,int32_t>> mGlyphWidths;
uint32_t mSpaceGlyph;

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

@ -6,7 +6,6 @@
#ifndef GFX_DRAWABLE_H
#define GFX_DRAWABLE_H
#include "nsAutoPtr.h"
#include "gfxRect.h"
#include "gfxMatrix.h"
#include "mozilla/gfx/2D.h"

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

@ -1405,7 +1405,7 @@ PreloadAsUserFontFaces(nsStringHashKey::KeyType aKey,
crc);
#endif
fe->mUserFontData = new gfxUserFontData;
fe->mUserFontData = MakeUnique<gfxUserFontData>();
fe->mUserFontData->mRealName = fe->Name();
fe->mUserFontData->mCRC32 = crc;
fe->mUserFontData->mLength = buf.st_size;

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

@ -11,6 +11,7 @@
#include "gfxFT2FontBase.h"
#include "gfxPlatformFontList.h"
#include "mozilla/mozalloc.h"
#include "nsClassHashtable.h"
#include <fontconfig/fontconfig.h>
#include "ft2build.h"
@ -277,9 +278,8 @@ protected:
FcPattern*> mLocalNames;
// caching generic/lang ==> font family list
nsBaseHashtable<nsCStringHashKey,
nsAutoPtr<PrefFontList>,
PrefFontList*> mGenericMappings;
nsClassHashtable<nsCStringHashKey,
PrefFontList> mGenericMappings;
// Caching family lookups as found by FindAndAddFamilies after resolving
// substitutions. The gfxFontFamily objects cached here are owned by the

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

@ -700,7 +700,7 @@ gfxShapedText::AllocateDetailedGlyphs(uint32_t aIndex, uint32_t aCount)
NS_ASSERTION(aIndex < GetLength(), "Index out of range");
if (!mDetailedGlyphs) {
mDetailedGlyphs = new DetailedGlyphStore();
mDetailedGlyphs = MakeUnique<DetailedGlyphStore>();
}
return mDetailedGlyphs->Allocate(aIndex, aCount);
@ -858,7 +858,7 @@ gfxFont::~gfxFont()
{
uint32_t i, count = mGlyphExtentsArray.Length();
// We destroy the contents of mGlyphExtentsArray explicitly instead of
// using nsAutoPtr because VC++ can't deal with nsTArrays of nsAutoPtrs
// using UniquePtr because VC++ can't deal with nsTArrays of UniquePtrs
// of classes that lack a proper copy constructor
for (i = 0; i < count; ++i) {
delete mGlyphExtentsArray[i];
@ -888,7 +888,7 @@ gfxFont::GetGlyphHAdvance(DrawTarget* aDrawTarget, uint16_t aGID)
NS_ASSERTION(mFUnitsConvFactor >= 0.0f,
"missing font unit conversion factor");
if (!mHarfBuzzShaper) {
mHarfBuzzShaper = new gfxHarfBuzzShaper(this);
mHarfBuzzShaper = MakeUnique<gfxHarfBuzzShaper>(this);
}
gfxHarfBuzzShaper* shaper =
static_cast<gfxHarfBuzzShaper*>(mHarfBuzzShaper.get());
@ -1462,7 +1462,7 @@ gfxFont::SupportsSubSuperscript(uint32_t aSubSuperscript,
}
if (!mHarfBuzzShaper) {
mHarfBuzzShaper = new gfxHarfBuzzShaper(this);
mHarfBuzzShaper = MakeUnique<gfxHarfBuzzShaper>(this);
}
gfxHarfBuzzShaper* shaper =
static_cast<gfxHarfBuzzShaper*>(mHarfBuzzShaper.get());
@ -2050,16 +2050,16 @@ gfxFont::Draw(gfxTextRun *aTextRun, uint32_t aStart, uint32_t aEnd,
aRunParams.context->SetMatrix(mat);
}
nsAutoPtr<gfxTextContextPaint> contextPaint;
UniquePtr<gfxTextContextPaint> contextPaint;
if (fontParams.haveSVGGlyphs && !fontParams.contextPaint) {
// If no pattern is specified for fill, use the current pattern
NS_ASSERTION((int(aRunParams.drawMode) & int(DrawMode::GLYPH_STROKE)) == 0,
"no pattern supplied for stroking text");
RefPtr<gfxPattern> fillPattern = aRunParams.context->GetPattern();
contextPaint =
contextPaint.reset(
new SimpleTextContextPaint(fillPattern, nullptr,
aRunParams.context->CurrentMatrix());
fontParams.contextPaint = contextPaint;
aRunParams.context->CurrentMatrix()));
fontParams.contextPaint = contextPaint.get();
}
// Synthetic-bold strikes are each offset one device pixel in run direction.
@ -2274,7 +2274,7 @@ gfxFont::Measure(gfxTextRun *aTextRun,
if (aBoundingBoxType == TIGHT_HINTED_OUTLINE_EXTENTS &&
mAntialiasOption != kAntialiasNone) {
if (!mNonAAFont) {
mNonAAFont = CopyWithAntialiasOption(kAntialiasNone);
mNonAAFont.reset(CopyWithAntialiasOption(kAntialiasNone));
}
// if font subclass doesn't implement CopyWithAntialiasOption(),
// it will return null and we'll proceed to use the existing font
@ -2540,7 +2540,7 @@ gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
NS_WARNING("failed to create word cache entry - expect missing text");
return nullptr;
}
gfxShapedWord *sw = entry->mShapedWord;
gfxShapedWord* sw = entry->mShapedWord.get();
bool isContent = !mStyle.systemFont;
@ -2566,10 +2566,9 @@ gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
}
#endif
sw = entry->mShapedWord = gfxShapedWord::Create(aText, aLength,
aRunScript,
aAppUnitsPerDevUnit,
aFlags);
sw = gfxShapedWord::Create(aText, aLength, aRunScript, aAppUnitsPerDevUnit,
aFlags);
entry->mShapedWord.reset(sw);
if (!sw) {
NS_WARNING("failed to create gfxShapedWord - expect missing text");
return nullptr;
@ -2586,7 +2585,7 @@ gfxFont::GetShapedWord(DrawTarget *aDrawTarget,
bool
gfxFont::CacheHashEntry::KeyEquals(const KeyTypePointer aKey) const
{
const gfxShapedWord *sw = mShapedWord;
const gfxShapedWord* sw = mShapedWord.get();
if (!sw) {
return false;
}
@ -2655,7 +2654,7 @@ gfxFont::ShapeText(DrawTarget *aDrawTarget,
if (FontCanSupportGraphite() && !aVertical) {
if (gfxPlatform::GetPlatform()->UseGraphiteShaping()) {
if (!mGraphiteShaper) {
mGraphiteShaper = new gfxGraphiteShaper(this);
mGraphiteShaper = MakeUnique<gfxGraphiteShaper>(this);
}
ok = mGraphiteShaper->ShapeText(aDrawTarget, aText, aOffset, aLength,
aScript, aVertical, aShapedText);
@ -2664,7 +2663,7 @@ gfxFont::ShapeText(DrawTarget *aDrawTarget,
if (!ok) {
if (!mHarfBuzzShaper) {
mHarfBuzzShaper = new gfxHarfBuzzShaper(this);
mHarfBuzzShaper = MakeUnique<gfxHarfBuzzShaper>(this);
}
ok = mHarfBuzzShaper->ShapeText(aDrawTarget, aText, aOffset, aLength,
aScript, aVertical, aShapedText);
@ -3180,26 +3179,24 @@ gfxFont::InitFakeSmallCapsRun(DrawTarget *aDrawTarget,
aDrawTarget, nullptr, nullptr, nullptr, 0,
aTextRun->GetAppUnitsPerDevUnit()
};
nsAutoPtr<gfxTextRun> tempRun;
tempRun =
UniquePtr<gfxTextRun> tempRun(
gfxTextRun::Create(&params, convertedString.Length(),
aTextRun->GetFontGroup(), 0);
aTextRun->GetFontGroup(), 0));
tempRun->AddGlyphRun(f, aMatchType, 0, true, aOrientation);
if (!f->SplitAndInitTextRun(aDrawTarget, tempRun,
if (!f->SplitAndInitTextRun(aDrawTarget, tempRun.get(),
convertedString.BeginReading(),
0, convertedString.Length(),
aScript, vertical)) {
ok = false;
} else {
nsAutoPtr<gfxTextRun> mergedRun;
mergedRun =
UniquePtr<gfxTextRun> mergedRun(
gfxTextRun::Create(&params, runLength,
aTextRun->GetFontGroup(), 0);
MergeCharactersInTextRun(mergedRun, tempRun,
aTextRun->GetFontGroup(), 0));
MergeCharactersInTextRun(mergedRun.get(), tempRun.get(),
charsToMergeArray.Elements(),
deletedCharsArray.Elements());
gfxTextRun::Range runRange(0, runLength);
aTextRun->CopyGlyphDataFrom(mergedRun, runRange,
aTextRun->CopyGlyphDataFrom(mergedRun.get(), runRange,
aOffset + runStart);
}
} else {
@ -3801,7 +3798,8 @@ void
gfxFont::AddGlyphChangeObserver(GlyphChangeObserver *aObserver)
{
if (!mGlyphChangeObservers) {
mGlyphChangeObservers = new nsTHashtable<nsPtrHashKey<GlyphChangeObserver> >;
mGlyphChangeObservers.reset(
new nsTHashtable<nsPtrHashKey<GlyphChangeObserver>>);
}
mGlyphChangeObservers->PutEntry(aObserver);
}

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

@ -653,7 +653,7 @@ protected:
static void GetRoundOffsetsToPixels(DrawTarget* aDrawTarget,
bool* aRoundX, bool* aRoundY);
// the font this shaper is working with. The font owns a nsAutoPtr reference
// the font this shaper is working with. The font owns a UniquePtr reference
// to this object, and will destroy it before it dies. Thus, mFont will always
// be valid.
gfxFont* MOZ_NON_OWNING_REF mFont;
@ -1145,7 +1145,7 @@ protected:
nsTArray<DGRec>::index_type mLastUsed;
};
nsAutoPtr<DetailedGlyphStore> mDetailedGlyphs;
mozilla::UniquePtr<DetailedGlyphStore> mDetailedGlyphs;
// Number of char16_t characters and CompressedGlyph glyph records
uint32_t mLength;
@ -1534,7 +1534,7 @@ public:
return GetHorizontalMetrics();
}
if (!mVerticalMetrics) {
mVerticalMetrics = CreateVerticalMetrics();
mVerticalMetrics.reset(CreateVerticalMetrics());
}
return *mVerticalMetrics;
}
@ -1751,7 +1751,7 @@ public:
// any attempt to use GetShapedWord().
void InitWordCache() {
if (!mWordCache) {
mWordCache = new nsTHashtable<CacheHashEntry>;
mWordCache = mozilla::MakeUnique<nsTHashtable<CacheHashEntry>>();
}
}
@ -2065,10 +2065,10 @@ protected:
enum { ALLOW_MEMMOVE = true };
nsAutoPtr<gfxShapedWord> mShapedWord;
mozilla::UniquePtr<gfxShapedWord> mShapedWord;
};
nsAutoPtr<nsTHashtable<CacheHashEntry> > mWordCache;
mozilla::UniquePtr<nsTHashtable<CacheHashEntry> > mWordCache;
static const uint32_t kShapedWordCacheMaxAge = 3;
@ -2084,7 +2084,8 @@ protected:
nsExpirationState mExpirationState;
gfxFontStyle mStyle;
AutoTArray<gfxGlyphExtents*,1> mGlyphExtentsArray;
nsAutoPtr<nsTHashtable<nsPtrHashKey<GlyphChangeObserver> > > mGlyphChangeObservers;
mozilla::UniquePtr<nsTHashtable<nsPtrHashKey<GlyphChangeObserver>>>
mGlyphChangeObservers;
gfxFloat mAdjustedSize;
@ -2098,13 +2099,13 @@ protected:
// a copy of the font without antialiasing, if needed for separate
// measurement by mathml code
nsAutoPtr<gfxFont> mNonAAFont;
mozilla::UniquePtr<gfxFont> mNonAAFont;
// we create either or both of these shapers when needed, depending
// whether the font has graphite tables, and whether graphite shaping
// is actually enabled
nsAutoPtr<gfxFontShaper> mHarfBuzzShaper;
nsAutoPtr<gfxFontShaper> mGraphiteShaper;
mozilla::UniquePtr<gfxFontShaper> mHarfBuzzShaper;
mozilla::UniquePtr<gfxFontShaper> mGraphiteShaper;
// if a userfont with unicode-range specified, contains map of *possible*
// ranges supported by font
@ -2113,7 +2114,7 @@ protected:
RefPtr<mozilla::gfx::ScaledFont> mAzureScaledFont;
// For vertical metrics, created on demand.
nsAutoPtr<const Metrics> mVerticalMetrics;
mozilla::UniquePtr<const Metrics> mVerticalMetrics;
// Helper for subclasses that want to initialize standard metrics from the
// tables of sfnt (TrueType/OpenType) fonts.

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

@ -385,7 +385,7 @@ gfxFontEntry::TryGetSVGData(gfxFont* aFont)
// gfxSVGGlyphs will hb_blob_destroy() the table when it is finished
// with it.
mSVGGlyphs = new gfxSVGGlyphs(svgTable, this);
mSVGGlyphs = MakeUnique<gfxSVGGlyphs>(svgTable, this);
}
if (!mFontsUsingSVGGlyphs.Contains(aFont)) {
@ -430,9 +430,9 @@ gfxFontEntry::TryGetMathTable()
// gfxMathTable will hb_blob_destroy() the table when it is finished
// with it.
mMathTable = new gfxMathTable(mathTable);
mMathTable = MakeUnique<gfxMathTable>(mathTable);
if (!mMathTable->HasValidHeaders()) {
mMathTable = nullptr;
mMathTable.reset(nullptr);
return false;
}
}
@ -643,7 +643,7 @@ gfxFontEntry::GetExistingFontTable(uint32_t aTag, hb_blob_t **aBlob)
if (!mFontTableCache) {
// we do this here rather than on fontEntry construction
// because not all shapers will access the table cache at all
mFontTableCache = new nsTHashtable<FontTableHashEntry>(8);
mFontTableCache = MakeUnique<nsTHashtable<FontTableHashEntry>>(8);
}
FontTableHashEntry *entry = mFontTableCache->GetEntry(aTag);
@ -662,7 +662,7 @@ gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
if (MOZ_UNLIKELY(!mFontTableCache)) {
// we do this here rather than on fontEntry construction
// because not all shapers will access the table cache at all
mFontTableCache = new nsTHashtable<FontTableHashEntry>(8);
mFontTableCache = MakeUnique<nsTHashtable<FontTableHashEntry>>(8);
}
FontTableHashEntry *entry = mFontTableCache->PutEntry(aTag);
@ -676,7 +676,7 @@ gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
return nullptr;
}
return entry->ShareTableAndGetBlob(Move(*aBuffer), mFontTableCache);
return entry->ShareTableAndGetBlob(Move(*aBuffer), mFontTableCache.get());
}
static int
@ -893,7 +893,7 @@ bool
gfxFontEntry::SupportsOpenTypeFeature(int32_t aScript, uint32_t aFeatureTag)
{
if (!mSupportedFeatures) {
mSupportedFeatures = new nsDataHashtable<nsUint32HashKey,bool>();
mSupportedFeatures = MakeUnique<nsDataHashtable<nsUint32HashKey,bool>>();
}
// note: high-order three bytes *must* be unique for each feature
@ -971,7 +971,7 @@ const hb_set_t*
gfxFontEntry::InputsForOpenTypeFeature(int32_t aScript, uint32_t aFeatureTag)
{
if (!mFeatureInputs) {
mFeatureInputs = new nsDataHashtable<nsUint32HashKey,hb_set_t*>();
mFeatureInputs = MakeUnique<nsDataHashtable<nsUint32HashKey,hb_set_t*>>();
}
NS_ASSERTION(aFeatureTag == HB_TAG('s','u','p','s') ||
@ -1032,7 +1032,7 @@ bool
gfxFontEntry::SupportsGraphiteFeature(uint32_t aFeatureTag)
{
if (!mSupportedFeatures) {
mSupportedFeatures = new nsDataHashtable<nsUint32HashKey,bool>();
mSupportedFeatures = MakeUnique<nsDataHashtable<nsUint32HashKey,bool>>();
}
// note: high-order three bytes *must* be unique for each feature

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

@ -433,14 +433,14 @@ public:
RefPtr<gfxCharacterMap> mCharacterMap;
uint32_t mUVSOffset;
mozilla::UniquePtr<uint8_t[]> mUVSData;
nsAutoPtr<gfxUserFontData> mUserFontData;
nsAutoPtr<gfxSVGGlyphs> mSVGGlyphs;
mozilla::UniquePtr<gfxUserFontData> mUserFontData;
mozilla::UniquePtr<gfxSVGGlyphs> mSVGGlyphs;
// list of gfxFonts that are using SVG glyphs
nsTArray<gfxFont*> mFontsUsingSVGGlyphs;
nsAutoPtr<gfxMathTable> mMathTable;
mozilla::UniquePtr<gfxMathTable> mMathTable;
nsTArray<gfxFontFeature> mFeatureSettings;
nsAutoPtr<nsDataHashtable<nsUint32HashKey,bool>> mSupportedFeatures;
nsAutoPtr<nsDataHashtable<nsUint32HashKey,hb_set_t*>> mFeatureInputs;
mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey,bool>> mSupportedFeatures;
mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey,hb_set_t*>> mFeatureInputs;
uint32_t mLanguageOverride;
// Color Layer font support
@ -625,7 +625,7 @@ private:
hb_blob_t *mBlob;
};
nsAutoPtr<nsTHashtable<FontTableHashEntry> > mFontTableCache;
mozilla::UniquePtr<nsTHashtable<FontTableHashEntry> > mFontTableCache;
gfxFontEntry(const gfxFontEntry&);
gfxFontEntry& operator=(const gfxFontEntry&);

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

@ -6,7 +6,6 @@
#ifndef GFX_FONT_INFO_LOADER_H
#define GFX_FONT_INFO_LOADER_H
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
#include "nsIObserver.h"
#include "nsITimer.h"

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

@ -66,8 +66,10 @@ gfxSparseBitSet::Dump(const char* aPrefix, eGfxLog aWhichLog) const
uint32_t b, numBlocks = mBlocks.Length();
for (b = 0; b < numBlocks; b++) {
Block *block = mBlocks[b];
if (!block) continue;
Block *block = mBlocks[b].get();
if (!block) {
continue;
}
const int BUFSIZE = 256;
char outStr[BUFSIZE];
int index = 0;

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

@ -9,7 +9,6 @@
#include "gfxPlatform.h"
#include "nsComponentManagerUtils.h"
#include "nsTArray.h"
#include "nsAutoPtr.h"
#include "mozilla/Likely.h"
#include "mozilla/Endian.h"
#include "mozilla/MemoryReporting.h"
@ -44,9 +43,10 @@ public:
uint32_t len = aBitset.mBlocks.Length();
mBlocks.AppendElements(len);
for (uint32_t i = 0; i < len; ++i) {
Block *block = aBitset.mBlocks[i];
if (block)
mBlocks[i] = new Block(*block);
Block *block = aBitset.mBlocks[i].get();
if (block) {
mBlocks[i] = mozilla::MakeUnique<Block>(*block);
}
}
}
@ -56,8 +56,8 @@ public:
}
size_t n = mBlocks.Length();
for (size_t i = 0; i < n; ++i) {
const Block *b1 = mBlocks[i];
const Block *b2 = aOther->mBlocks[i];
const Block *b1 = mBlocks[i].get();
const Block *b2 = aOther->mBlocks[i].get();
if (!b1 != !b2) {
return false;
}
@ -74,11 +74,13 @@ public:
bool test(uint32_t aIndex) const {
NS_ASSERTION(mBlocks.DebugGetHeader(), "mHdr is null, this is bad");
uint32_t blockIndex = aIndex/BLOCK_SIZE_BITS;
if (blockIndex >= mBlocks.Length())
if (blockIndex >= mBlocks.Length()) {
return false;
Block *block = mBlocks[blockIndex];
if (!block)
}
const Block *block = mBlocks[blockIndex].get();
if (!block) {
return false;
}
return ((block->mBits[(aIndex>>3) & (BLOCK_SIZE - 1)]) & (1 << (aIndex & 0x7))) != 0;
}
@ -99,43 +101,54 @@ public:
endBlock = aEnd >> BLOCK_INDEX_SHIFT;
for (blockIndex = startBlock; blockIndex <= endBlock; blockIndex++) {
if (blockIndex < blockLen && mBlocks[blockIndex])
if (blockIndex < blockLen && mBlocks[blockIndex]) {
hasBlocksInRange = true;
}
}
if (!hasBlocksInRange) {
return false;
}
if (!hasBlocksInRange) return false;
Block *block;
uint32_t i, start, end;
// first block, check bits
if ((block = mBlocks[startBlock])) {
if ((block = mBlocks[startBlock].get())) {
start = aStart;
end = std::min(aEnd, ((startBlock+1) << BLOCK_INDEX_SHIFT) - 1);
for (i = start; i <= end; i++) {
if ((block->mBits[(i>>3) & (BLOCK_SIZE - 1)]) & (1 << (i & 0x7)))
if ((block->mBits[(i>>3) & (BLOCK_SIZE - 1)]) & (1 << (i & 0x7))) {
return true;
}
}
}
if (endBlock == startBlock) return false;
if (endBlock == startBlock) {
return false;
}
// [2..n-1] blocks check bytes
for (blockIndex = startBlock + 1; blockIndex < endBlock; blockIndex++) {
uint32_t index;
if (blockIndex >= blockLen || !(block = mBlocks[blockIndex])) continue;
if (blockIndex >= blockLen ||
!(block = mBlocks[blockIndex].get())) {
continue;
}
for (index = 0; index < BLOCK_SIZE; index++) {
if (block->mBits[index])
if (block->mBits[index]) {
return true;
}
}
}
// last block, check bits
if (endBlock < blockLen && (block = mBlocks[endBlock])) {
if (endBlock < blockLen && (block = mBlocks[endBlock].get())) {
start = endBlock << BLOCK_INDEX_SHIFT;
end = aEnd;
for (i = start; i <= end; i++) {
if ((block->mBits[(i>>3) & (BLOCK_SIZE - 1)]) & (1 << (i & 0x7)))
if ((block->mBits[(i>>3) & (BLOCK_SIZE - 1)]) & (1 << (i & 0x7))) {
return true;
}
}
}
@ -145,14 +158,12 @@ public:
void set(uint32_t aIndex) {
uint32_t blockIndex = aIndex/BLOCK_SIZE_BITS;
if (blockIndex >= mBlocks.Length()) {
nsAutoPtr<Block> *blocks = mBlocks.AppendElements(blockIndex + 1 - mBlocks.Length());
if (MOZ_UNLIKELY(!blocks)) // OOM
return;
mBlocks.AppendElements(blockIndex + 1 - mBlocks.Length());
}
Block *block = mBlocks[blockIndex];
Block *block = mBlocks[blockIndex].get();
if (!block) {
block = new Block;
mBlocks[blockIndex] = block;
mBlocks[blockIndex].reset(block);
}
block->mBits[(aIndex>>3) & (BLOCK_SIZE - 1)] |= 1 << (aIndex & 0x7);
}
@ -170,26 +181,24 @@ public:
if (endIndex >= mBlocks.Length()) {
uint32_t numNewBlocks = endIndex + 1 - mBlocks.Length();
nsAutoPtr<Block> *blocks = mBlocks.AppendElements(numNewBlocks);
if (MOZ_UNLIKELY(!blocks)) // OOM
return;
mBlocks.AppendElements(numNewBlocks);
}
for (uint32_t i = startIndex; i <= endIndex; ++i) {
const uint32_t blockFirstBit = i * BLOCK_SIZE_BITS;
const uint32_t blockLastBit = blockFirstBit + BLOCK_SIZE_BITS - 1;
Block *block = mBlocks[i];
Block *block = mBlocks[i].get();
if (!block) {
bool fullBlock = false;
if (aStart <= blockFirstBit && aEnd >= blockLastBit)
fullBlock = true;
bool fullBlock =
(aStart <= blockFirstBit && aEnd >= blockLastBit);
block = new Block(fullBlock ? 0xFF : 0);
mBlocks[i] = block;
mBlocks[i].reset(block);
if (fullBlock)
if (fullBlock) {
continue;
}
}
const uint32_t start = aStart > blockFirstBit ? aStart - blockFirstBit : 0;
@ -204,11 +213,9 @@ public:
void clear(uint32_t aIndex) {
uint32_t blockIndex = aIndex/BLOCK_SIZE_BITS;
if (blockIndex >= mBlocks.Length()) {
nsAutoPtr<Block> *blocks = mBlocks.AppendElements(blockIndex + 1 - mBlocks.Length());
if (MOZ_UNLIKELY(!blocks)) // OOM
return;
mBlocks.AppendElements(blockIndex + 1 - mBlocks.Length());
}
Block *block = mBlocks[blockIndex];
Block *block = mBlocks[blockIndex].get();
if (!block) {
return;
}
@ -221,15 +228,13 @@ public:
if (endIndex >= mBlocks.Length()) {
uint32_t numNewBlocks = endIndex + 1 - mBlocks.Length();
nsAutoPtr<Block> *blocks = mBlocks.AppendElements(numNewBlocks);
if (MOZ_UNLIKELY(!blocks)) // OOM
return;
mBlocks.AppendElements(numNewBlocks);
}
for (uint32_t i = startIndex; i <= endIndex; ++i) {
const uint32_t blockFirstBit = i * BLOCK_SIZE_BITS;
Block *block = mBlocks[i];
Block *block = mBlocks[i].get();
if (!block) {
// any nonexistent block is implicitly all clear,
// so there's no need to even create it
@ -249,7 +254,7 @@ public:
size_t total = mBlocks.ShallowSizeOfExcludingThis(aMallocSizeOf);
for (uint32_t i = 0; i < mBlocks.Length(); i++) {
if (mBlocks[i]) {
total += aMallocSizeOf(mBlocks[i]);
total += aMallocSizeOf(mBlocks[i].get());
}
}
return total;
@ -262,8 +267,9 @@ public:
// clear out all blocks in the array
void reset() {
uint32_t i;
for (i = 0; i < mBlocks.Length(); i++)
mBlocks[i] = nullptr;
for (i = 0; i < mBlocks.Length(); i++) {
mBlocks[i] = nullptr;
}
}
// set this bitset to the union of its current contents and another
@ -272,10 +278,7 @@ public:
uint32_t blockCount = aBitset.mBlocks.Length();
if (blockCount > mBlocks.Length()) {
uint32_t needed = blockCount - mBlocks.Length();
nsAutoPtr<Block> *blocks = mBlocks.AppendElements(needed);
if (MOZ_UNLIKELY(!blocks)) { // OOM
return;
}
mBlocks.AppendElements(needed);
}
// for each block that may be present in aBitset...
for (uint32_t i = 0; i < blockCount; ++i) {
@ -285,7 +288,7 @@ public:
}
// if the block is missing in this set, just copy the other
if (!mBlocks[i]) {
mBlocks[i] = new Block(*aBitset.mBlocks[i]);
mBlocks[i] = mozilla::MakeUnique<Block>(*aBitset.mBlocks[i]);
continue;
}
// else set existing block to the union of both
@ -306,7 +309,7 @@ public:
uint32_t check = adler32(0, Z_NULL, 0);
for (uint32_t i = 0; i < mBlocks.Length(); i++) {
if (mBlocks[i]) {
const Block *block = mBlocks[i];
const Block *block = mBlocks[i].get();
check = adler32(check, (uint8_t*) (&i), 4);
check = adler32(check, (uint8_t*) block, sizeof(Block));
}
@ -315,7 +318,7 @@ public:
}
private:
nsTArray< nsAutoPtr<Block> > mBlocks;
nsTArray<mozilla::UniquePtr<Block>> mBlocks;
};
#define TRUETYPE_TAG(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d))

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

@ -469,7 +469,7 @@ gfxGDIFont::GetGlyph(uint32_t aUnicode, uint32_t aVarSelector)
}
if (!mGlyphIDs) {
mGlyphIDs = new nsDataHashtable<nsUint32HashKey,uint32_t>(64);
mGlyphIDs = MakeUnique<nsDataHashtable<nsUint32HashKey,uint32_t>>(64);
}
uint32_t gid;
@ -506,7 +506,7 @@ int32_t
gfxGDIFont::GetGlyphWidth(DrawTarget& aDrawTarget, uint16_t aGID)
{
if (!mGlyphWidths) {
mGlyphWidths = new nsDataHashtable<nsUint32HashKey,int32_t>(128);
mGlyphWidths = MakeUnique<nsDataHashtable<nsUint32HashKey,int32_t>>(128);
}
int32_t width;

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

@ -106,11 +106,11 @@ protected:
bool mNeedsBold;
// cache of glyph IDs (used for non-sfnt fonts only)
nsAutoPtr<nsDataHashtable<nsUint32HashKey,uint32_t> > mGlyphIDs;
mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey,uint32_t> > mGlyphIDs;
SCRIPT_CACHE mScriptCache;
// cache of glyph widths in 16.16 fixed-point pixels
nsAutoPtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths;
mozilla::UniquePtr<nsDataHashtable<nsUint32HashKey,int32_t> > mGlyphWidths;
};
#endif /* GFX_GDIFONT_H */

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

@ -130,7 +130,7 @@ GDIFontEntry::GDIFontEntry(const nsAString& aFaceName,
mFamilyHasItalicFace(aFamilyHasItalicFace),
mCharset(), mUnicodeRanges()
{
mUserFontData = aUserFontData;
mUserFontData.reset(aUserFontData);
mStyle = aStyle;
mWeight = aWeight;
mStretch = aStretch;

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

@ -9,7 +9,6 @@
#include "mozilla/MemoryReporting.h"
#include "mozilla/RefPtr.h"
#include "gfxASurface.h"
#include "nsAutoPtr.h"
#include "nsSize.h"
// ARGB -- raw buffer.. wont be changed.. good for storing data.

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

@ -138,7 +138,7 @@ gfxMacFont::ShapeText(DrawTarget *aDrawTarget,
if (static_cast<MacOSFontEntry*>(GetFontEntry())->RequiresAATLayout() &&
!aVertical) {
if (!mCoreTextShaper) {
mCoreTextShaper = new gfxCoreTextShaper(this);
mCoreTextShaper = MakeUnique<gfxCoreTextShaper>(this);
}
if (mCoreTextShaper->ShapeText(aDrawTarget, aText, aOffset, aLength,
aScript, aVertical, aShapedText)) {

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

@ -93,7 +93,7 @@ protected:
cairo_font_face_t *mFontFace;
nsAutoPtr<gfxFontShaper> mCoreTextShaper;
mozilla::UniquePtr<gfxFontShaper> mCoreTextShaper;
Metrics mMetrics;
uint32_t mSpaceGlyph;

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

@ -1068,14 +1068,14 @@ gfxMacPlatformFontList::MakePlatformFont(const nsAString& aFontName,
return nullptr;
}
nsAutoPtr<MacOSFontEntry>
newFontEntry(new MacOSFontEntry(uniqueName, fontRef, aWeight,
aStretch, aStyle, true, false));
auto newFontEntry =
MakeUnique<MacOSFontEntry>(uniqueName, fontRef, aWeight, aStretch,
aStyle, true, false);
::CFRelease(fontRef);
// if succeeded and font cmap is good, return the new font
if (newFontEntry->mIsValid && NS_SUCCEEDED(newFontEntry->ReadCMAP())) {
return newFontEntry.forget();
return newFontEntry.release();
}
// if something is funky about this font, delete immediately

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

@ -13,7 +13,6 @@
#include "mozilla/gfx/2D.h"
#include "mozilla/gfx/PatternHelpers.h"
#include "nsISupportsImpl.h"
#include "nsAutoPtr.h"
#include "nsTArray.h"
typedef struct _cairo_pattern cairo_pattern_t;

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

@ -11,7 +11,6 @@
#include "nsTArray.h"
#include "nsString.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "gfxTypes.h"
#include "gfxFontFamilyList.h"

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

@ -184,7 +184,7 @@ gfxPlatformFontList::gfxPlatformFontList(bool aNeedFullnamePostscriptNames)
mOtherFamilyNamesInitialized = false;
if (aNeedFullnamePostscriptNames) {
mExtraNames = new ExtraNames();
mExtraNames = MakeUnique<ExtraNames>();
}
mFaceNameListsInitialized = false;
@ -381,7 +381,7 @@ gfxPlatformFontList::LookupInFaceNameLists(const nsAString& aFaceName)
// names not completely initialized, so keep track of lookup misses
if (!mFaceNameListsInitialized) {
if (!mFaceNamesMissed) {
mFaceNamesMissed = new nsTHashtable<nsStringHashKey>(2);
mFaceNamesMissed = MakeUnique<nsTHashtable<nsStringHashKey>>(2);
}
mFaceNamesMissed->PutEntry(aFaceName);
}
@ -673,7 +673,7 @@ gfxPlatformFontList::FindAndAddFamilies(const nsAString& aFamily,
// localized family names load timed out, add name to list of
// names to check after localized names are loaded
if (!mOtherNamesMissed) {
mOtherNamesMissed = new nsTHashtable<nsStringHashKey>(2);
mOtherNamesMissed = MakeUnique<nsTHashtable<nsStringHashKey>>(2);
}
mOtherNamesMissed->PutEntry(key);
}
@ -852,11 +852,12 @@ gfxPlatformFontList::GetPrefFontsLangGroup(mozilla::FontFamilyType aGenericType,
aGenericType = eFamily_monospace;
}
PrefFontList* prefFonts = mLangGroupPrefFonts[aPrefLang][aGenericType];
PrefFontList* prefFonts =
mLangGroupPrefFonts[aPrefLang][aGenericType].get();
if (MOZ_UNLIKELY(!prefFonts)) {
prefFonts = new PrefFontList;
ResolveGenericFontNames(aGenericType, aPrefLang, prefFonts);
mLangGroupPrefFonts[aPrefLang][aGenericType] = prefFonts;
mLangGroupPrefFonts[aPrefLang][aGenericType].reset(prefFonts);
}
return prefFonts;
}
@ -1570,7 +1571,7 @@ gfxPlatformFontList::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
auto& prefFontsLangGroup = mLangGroupPrefFonts[i];
for (uint32_t j = eFamily_generic_first;
j < eFamily_generic_first + eFamily_generic_count; j++) {
PrefFontList* pf = prefFontsLangGroup[j];
PrefFontList* pf = prefFontsLangGroup[j].get();
if (pf) {
aSizes->mFontListSize +=
pf->ShallowSizeOfExcludingThis(aMallocSizeOf);

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

@ -391,16 +391,16 @@ protected:
// Postscript name ==> font entry (unique, one name per font entry)
FontEntryTable mPostscriptNames;
};
nsAutoPtr<ExtraNames> mExtraNames;
mozilla::UniquePtr<ExtraNames> mExtraNames;
// face names missed when face name loading takes a long time
nsAutoPtr<nsTHashtable<nsStringHashKey> > mFaceNamesMissed;
mozilla::UniquePtr<nsTHashtable<nsStringHashKey> > mFaceNamesMissed;
// localized family names missed when face name loading takes a long time
nsAutoPtr<nsTHashtable<nsStringHashKey> > mOtherNamesMissed;
mozilla::UniquePtr<nsTHashtable<nsStringHashKey> > mOtherNamesMissed;
typedef nsTArray<RefPtr<gfxFontFamily>> PrefFontList;
typedef mozilla::RangedArray<nsAutoPtr<PrefFontList>,
typedef mozilla::RangedArray<mozilla::UniquePtr<PrefFontList>,
mozilla::eFamily_generic_first,
mozilla::eFamily_generic_count> PrefFontsForLangGroup;
mozilla::RangedArray<PrefFontsForLangGroup,

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

@ -7,7 +7,6 @@
#include "gfxImageSurface.h"
#include "nsISupportsImpl.h"
#include "nsAutoPtr.h"
/**

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

@ -8,7 +8,6 @@
#include "gfxFontUtils.h"
#include "mozilla/gfx/2D.h"
#include "nsString.h"
#include "nsAutoPtr.h"
#include "nsClassHashtable.h"
#include "nsBaseHashtable.h"
#include "nsHashKeys.h"

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

@ -4,7 +4,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "gfxTeeSurface.h"
#include "nsAutoPtr.h"
#include "nsTArray.h"
#include "cairo-tee.h"

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

@ -2061,7 +2061,7 @@ gfxFontGroup::GetHyphenWidth(gfxTextRun::PropertyProvider *aProvider)
if (mHyphenWidth < 0) {
RefPtr<DrawTarget> dt(aProvider->GetDrawTarget());
if (dt) {
nsAutoPtr<gfxTextRun>
UniquePtr<gfxTextRun>
hyphRun(MakeHyphenTextRun(dt,
aProvider->GetAppUnitsPerDevUnit()));
mHyphenWidth = hyphRun.get() ? hyphRun->GetAdvanceWidth() : 0;
@ -2548,7 +2548,7 @@ gfxFontGroup::GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, uint32_t aFlags,
if (mCachedEllipsisTextRun &&
(mCachedEllipsisTextRun->GetFlags() & TEXT_ORIENT_MASK) == aFlags &&
mCachedEllipsisTextRun->GetAppUnitsPerDevUnit() == aAppUnitsPerDevPixel) {
return mCachedEllipsisTextRun;
return mCachedEllipsisTextRun.get();
}
// Use a Unicode ellipsis if the font supports it,
@ -2570,7 +2570,7 @@ gfxFontGroup::GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, uint32_t aFlags,
if (!textRun) {
return nullptr;
}
mCachedEllipsisTextRun = textRun;
mCachedEllipsisTextRun.reset(textRun);
textRun->ReleaseFontGroup(); // don't let the presence of a cached ellipsis
// textrun prolong the fontgroup's life
return textRun;

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

@ -1076,7 +1076,7 @@ protected:
// Cache a textrun representing an ellipsis (useful for CSS text-overflow)
// at a specific appUnitsPerDevPixel size and orientation
nsAutoPtr<gfxTextRun> mCachedEllipsisTextRun;
mozilla::UniquePtr<gfxTextRun> mCachedEllipsisTextRun;
// cache the most recent pref font to avoid general pref font lookup
RefPtr<gfxFontFamily> mLastPrefFamily;

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

@ -270,9 +270,9 @@ gfxUserFontEntry::StoreUserFontData(gfxFontEntry* aFontEntry,
uint8_t aCompression)
{
if (!aFontEntry->mUserFontData) {
aFontEntry->mUserFontData = new gfxUserFontData;
aFontEntry->mUserFontData = MakeUnique<gfxUserFontData>();
}
gfxUserFontData* userFontData = aFontEntry->mUserFontData;
gfxUserFontData* userFontData = aFontEntry->mUserFontData.get();
userFontData->mSrcIndex = mSrcIndex;
const gfxFontFaceSrc& src = mSrcList[mSrcIndex];
switch (src.mSourceType) {
@ -1120,7 +1120,7 @@ gfxUserFontSet::UserFontCache::CacheFont(gfxFontEntry* aFontEntry,
return;
}
gfxUserFontData* data = aFontEntry->mUserFontData;
gfxUserFontData* data = aFontEntry->mUserFontData.get();
if (data->mIsBuffer) {
#ifdef DEBUG_USERFONT_CACHE
printf("userfontcache skipped fontentry with buffer source: %p\n",

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

@ -9,7 +9,6 @@
#include "gfxFont.h"
#include "gfxFontFamilyList.h"
#include "nsRefPtrHashtable.h"
#include "nsAutoPtr.h"
#include "nsCOMPtr.h"
#include "nsIURI.h"
#include "nsIPrincipal.h"

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

@ -12,7 +12,6 @@
#undef max // Xlibint.h defines this and it breaks std::max
#undef min // Xlibint.h defines this and it breaks std::min
#include "nsAutoPtr.h"
#include "nsTArray.h"
#include "nsAlgorithm.h"
#include "mozilla/Preferences.h"

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

@ -187,7 +187,7 @@ nsFontFace::GetMetadata(nsAString & aMetadata)
aMetadata.Truncate();
if (mFontEntry->IsUserFont() && !mFontEntry->IsLocalUserFont()) {
NS_ASSERTION(mFontEntry->mUserFontData, "missing userFontData");
const gfxUserFontData* userFontData = mFontEntry->mUserFontData;
const gfxUserFontData* userFontData = mFontEntry->mUserFontData.get();
if (userFontData->mMetadata.Length() && userFontData->mMetaOrigLen) {
nsAutoCString str;
str.SetLength(userFontData->mMetaOrigLen);