diff --git a/dom/media/platforms/apple/AppleUtils.h b/dom/media/platforms/apple/AppleUtils.h index 954365c5cf64..b9f51eb33da3 100644 --- a/dom/media/platforms/apple/AppleUtils.h +++ b/dom/media/platforms/apple/AppleUtils.h @@ -27,76 +27,6 @@ inline bool OSSupportsSVC() { namespace mozilla { -// Wrapper class to call CFRelease/CVBufferRelease on reference types -// when they go out of scope. -template -class AutoObjRefRelease { - public: - MOZ_IMPLICIT AutoObjRefRelease(T aRef) : mRef(aRef) {} - ~AutoObjRefRelease() { - if (mRef) { - relFunc(mRef); - } - } - // Return the wrapped ref so it can be used as an in parameter. - operator T() { return mRef; } - // Return a pointer to the wrapped ref for use as an out parameter. - T* receive() { return &mRef; } - - private: - // Copy operator isn't supported and is not implemented. - AutoObjRefRelease& operator=( - const AutoObjRefRelease&); - T mRef; -}; - -template -using AutoCFRelease = AutoObjRefRelease; -template -using AutoCVBufferRelease = - AutoObjRefRelease; - -// CFRefPtr: A CoreFoundation smart pointer. -template -class CFRefPtr { - public: - explicit CFRefPtr(T aRef) : mRef(aRef) { - if (mRef) { - CFRetain(mRef); - } - } - // Copy constructor. - CFRefPtr(const CFRefPtr& aCFRefPtr) : mRef(aCFRefPtr.mRef) { - if (mRef) { - CFRetain(mRef); - } - } - // Copy operator - CFRefPtr& operator=(const CFRefPtr& aCFRefPtr) { - if (mRef == aCFRefPtr.mRef) { - return; - } - if (mRef) { - CFRelease(mRef); - } - mRef = aCFRefPtr.mRef; - if (mRef) { - CFRetain(mRef); - } - return *this; - } - ~CFRefPtr() { - if (mRef) { - CFRelease(mRef); - } - } - // Return the wrapped ref so it can be used as an in parameter. - operator T() { return mRef; } - - private: - T mRef; -}; - template struct AutoTypeRefTraits; diff --git a/gfx/thebes/CoreTextFontList.cpp b/gfx/thebes/CoreTextFontList.cpp index c762b204eec1..4ed1476d3dbc 100644 --- a/gfx/thebes/CoreTextFontList.cpp +++ b/gfx/thebes/CoreTextFontList.cpp @@ -511,7 +511,7 @@ CGFontRef CTFontEntry::CreateOrCopyFontRef() { CrashReporter::Annotation::FontName, mName); // Create a new CGFont; caller will own the only reference to it. - AutoCFRelease psname = CreateCFStringForString(mName); + AutoCFTypeRef psname(CreateCFStringForString(mName)); if (!psname) { return nullptr; } @@ -549,7 +549,7 @@ class FontTableRec { hb_blob_t* CTFontEntry::GetFontTable(uint32_t aTag) { mLock.ReadLock(); - AutoCFRelease fontRef = CreateOrCopyFontRef(); + AutoCFTypeRef fontRef(CreateOrCopyFontRef()); mLock.ReadUnlock(); if (!fontRef) { return nullptr; @@ -582,11 +582,11 @@ bool CTFontEntry::HasFontTable(uint32_t aTableTag) { AutoWriteLock lock(mLock); if (mAvailableTables.Count() == 0) { - AutoCFRelease fontRef = CreateOrCopyFontRef(); + AutoCFTypeRef fontRef(CreateOrCopyFontRef()); if (!fontRef) { return false; } - AutoCFRelease tags = ::CGFontCopyTableTags(fontRef); + AutoCFTypeRef tags(::CGFontCopyTableTags(fontRef)); if (!tags) { return false; } @@ -679,10 +679,10 @@ bool CTFontEntry::SupportsOpenTypeFeature(Script aScript, CrashReporter::AutoRecordAnnotation autoFontName( CrashReporter::Annotation::FontName, FamilyName()); - AutoCFRelease ctFont = - CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr); + AutoCFTypeRef ctFont( + CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr)); if (ctFont) { - AutoCFRelease features = CTFontCopyFeatures(ctFont); + AutoCFTypeRef features(CTFontCopyFeatures(ctFont)); if (features) { mHasAATSmallCaps = CheckForAATSmallCaps(features); } @@ -700,14 +700,14 @@ void CTFontEntry::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf, static CTFontDescriptorRef CreateDescriptorForFamily( const nsACString& aFamilyName, bool aNormalized) { - AutoCFRelease family = CreateCFStringForString(aFamilyName); + AutoCFTypeRef family(CreateCFStringForString(aFamilyName)); const void* values[] = {family}; const void* keys[] = {kCTFontFamilyNameAttribute}; - AutoCFRelease attributes = CFDictionaryCreate( + AutoCFTypeRef attributes(CFDictionaryCreate( kCFAllocatorDefault, keys, values, 1, &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); + &kCFTypeDictionaryValueCallBacks)); - // Not AutoCFRelease, because we might return it. + // Not AutoCFTypeRef, because we might return it. CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes(attributes); @@ -724,12 +724,12 @@ static CTFontDescriptorRef CreateDescriptorForFamily( } void CTFontFamily::LocalizedName(nsACString& aLocalizedName) { - AutoCFRelease descriptor = - CreateDescriptorForFamily(mName, true); + AutoCFTypeRef descriptor( + CreateDescriptorForFamily(mName, true)); if (descriptor) { - AutoCFRelease name = + AutoCFTypeRef name( static_cast(CTFontDescriptorCopyLocalizedAttribute( - descriptor, kCTFontFamilyNameAttribute, nullptr)); + descriptor, kCTFontFamilyNameAttribute, nullptr))); if (name) { nsAutoString localized; GetStringForCFString(name, localized); @@ -824,15 +824,15 @@ static inline FontStretch CoreTextWidthToCSSStretch(CGFloat aCTWidth) { } void CTFontFamily::AddFace(CTFontDescriptorRef aFace) { - AutoCFRelease psname = - (CFStringRef)CTFontDescriptorCopyAttribute(aFace, kCTFontNameAttribute); - AutoCFRelease facename = + AutoCFTypeRef psname( + (CFStringRef)CTFontDescriptorCopyAttribute(aFace, kCTFontNameAttribute)); + AutoCFTypeRef facename( (CFStringRef)CTFontDescriptorCopyAttribute(aFace, - kCTFontStyleNameAttribute); + kCTFontStyleNameAttribute)); - AutoCFRelease traitsDict = + AutoCFTypeRef traitsDict( (CFDictionaryRef)CTFontDescriptorCopyAttribute(aFace, - kCTFontTraitsAttribute); + kCTFontTraitsAttribute)); CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(traitsDict, kCTFontWeightTrait); CFNumberRef width = @@ -921,7 +921,7 @@ void CTFontFamily::FindStyleVariationsLocked(FontInfoData* aFontInfoData) { MOZ_ASSERT(gfxPlatform::HasVariationFontSupport()); auto addToFamily = [&](CTFontRef aFont) MOZ_REQUIRES(mLock) { - AutoCFRelease psName = CTFontCopyPostScriptName(aFont); + AutoCFTypeRef psName(CTFontCopyPostScriptName(aFont)); nsAutoString nameUTF16; nsAutoCString nameUTF8; GetStringForCFString(psName, nameUTF16); @@ -944,8 +944,8 @@ void CTFontFamily::FindStyleVariationsLocked(FontInfoData* aFontInfoData) { addToFamily(mForSystemFont); // See if there is a corresponding italic face, and add it to the family. - AutoCFRelease italicFont = CTFontCreateCopyWithSymbolicTraits( - mForSystemFont, 0.0, nullptr, kCTFontTraitItalic, kCTFontTraitItalic); + AutoCFTypeRef italicFont(CTFontCreateCopyWithSymbolicTraits( + mForSystemFont, 0.0, nullptr, kCTFontTraitItalic, kCTFontTraitItalic)); if (italicFont != mForSystemFont) { addToFamily(italicFont); } @@ -979,10 +979,10 @@ void CTFontFamily::FindStyleVariationsLocked(FontInfoData* aFontInfoData) { MOZ_POP_THREAD_SAFETY; }; - AutoCFRelease descriptor = - CreateDescriptorForFamily(mName, false); - AutoCFRelease faces = - CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr); + AutoCFTypeRef descriptor( + CreateDescriptorForFamily(mName, false)); + AutoCFTypeRef faces( + CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr)); if (faces) { Context context{this}; @@ -1070,21 +1070,21 @@ void CoreTextFontList::AddFamily(CFStringRef aFamily) { /* static */ void CoreTextFontList::ActivateFontsFromDir( const nsACString& aDir, nsTHashSet* aLoadedFamilies) { - AutoCFRelease directory = CFURLCreateFromFileSystemRepresentation( + AutoCFTypeRef directory(CFURLCreateFromFileSystemRepresentation( kCFAllocatorDefault, (const UInt8*)nsPromiseFlatCString(aDir).get(), - aDir.Length(), true); + aDir.Length(), true)); if (!directory) { return; } - AutoCFRelease enumerator = + AutoCFTypeRef enumerator( CFURLEnumeratorCreateForDirectoryURL(kCFAllocatorDefault, directory, kCFURLEnumeratorDefaultBehavior, - nullptr); + nullptr)); if (!enumerator) { return; } - AutoCFRelease urls = - CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); + AutoCFTypeRef urls( + CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks)); if (!urls) { return; } @@ -1101,16 +1101,15 @@ void CoreTextFontList::ActivateFontsFromDir( if (!aLoadedFamilies) { continue; } - AutoCFRelease descriptors = - CTFontManagerCreateFontDescriptorsFromURL(url); + AutoCFTypeRef descriptors( + CTFontManagerCreateFontDescriptorsFromURL(url)); if (!descriptors || !CFArrayGetCount(descriptors)) { continue; } CTFontDescriptorRef desc = (CTFontDescriptorRef)CFArrayGetValueAtIndex(descriptors, 0); - AutoCFRelease name = - (CFStringRef)CTFontDescriptorCopyAttribute(desc, - kCTFontFamilyNameAttribute); + AutoCFTypeRef name((CFStringRef)CTFontDescriptorCopyAttribute( + desc, kCTFontFamilyNameAttribute)); nsAutoCString key; key.SetLength((CFStringGetLength(name) + 1) * 3); if (CFStringGetCString(name, key.BeginWriting(), key.Length(), @@ -1177,8 +1176,8 @@ nsresult CoreTextFontList::InitFontListForPlatform() { // We're not a content process, so get the available fonts directly // from Core Text. - AutoCFRelease familyNames = - CTFontManagerCopyAvailableFontFamilyNames(); + AutoCFTypeRef familyNames( + CTFontManagerCopyAvailableFontFamilyNames()); for (CFIndex i = 0; i < CFArrayGetCount(familyNames); i++) { CFStringRef familyName = (CFStringRef)CFArrayGetValueAtIndex(familyNames, i); @@ -1245,8 +1244,8 @@ void CoreTextFontList::InitSharedFontListForPlatform() { firstTime = false; } - AutoCFRelease familyNames = - CTFontManagerCopyAvailableFontFamilyNames(); + AutoCFTypeRef familyNames( + CTFontManagerCopyAvailableFontFamilyNames()); nsTArray families; families.SetCapacity(CFArrayGetCount(familyNames) #if USE_DEPRECATED_FONT_FAMILY_NAMES @@ -1347,11 +1346,11 @@ gfxFontEntry* CoreTextFontList::PlatformGlobalFontFallback( mDefaultFont = CTFontCreateWithName(CFSTR("LucidaGrande"), 12.f, NULL); } - AutoCFRelease fallback = - CTFontCreateForString(mDefaultFont, str, CFRangeMake(0, length)); + AutoCFTypeRef fallback( + CTFontCreateForString(mDefaultFont, str, CFRangeMake(0, length))); if (fallback) { - AutoCFRelease familyNameRef = CTFontCopyFamilyName(fallback); + AutoCFTypeRef familyNameRef(CTFontCopyFamilyName(fallback)); if (familyNameRef && CFStringCompare(familyNameRef, CFSTR("LastResort"), @@ -1432,13 +1431,13 @@ gfxFontEntry* CoreTextFontList::LookupLocalFont( CrashReporter::AutoRecordAnnotation autoFontName( CrashReporter::Annotation::FontName, aFontName); - AutoCFRelease faceName = CreateCFStringForString(aFontName); + AutoCFTypeRef faceName(CreateCFStringForString(aFontName)); if (!faceName) { return nullptr; } // lookup face based on postscript or full name - AutoCFRelease fontRef = CGFontCreateWithFontName(faceName); + AutoCFTypeRef fontRef(CGFontCreateWithFontName(faceName)); if (!fontRef) { return nullptr; } @@ -1449,12 +1448,12 @@ gfxFontEntry* CoreTextFontList::LookupLocalFont( // is allowed to be used. // CGFontRef doesn't offer a family-name API, so we go via a CTFontRef. - AutoCFRelease ctFont = - CTFontCreateWithGraphicsFont(fontRef, 0.0, nullptr, nullptr); + AutoCFTypeRef ctFont( + CTFontCreateWithGraphicsFont(fontRef, 0.0, nullptr, nullptr)); if (!ctFont) { return nullptr; } - AutoCFRelease name = CTFontCopyFamilyName(ctFont); + AutoCFTypeRef name(CTFontCopyFamilyName(ctFont)); // Convert the family name to a key suitable for font-list lookup (8-bit, // lowercased). nsAutoCString key; @@ -1510,9 +1509,9 @@ gfxFontEntry* CoreTextFontList::MakePlatformFont(const nsACString& aFontName, CrashReporter::AutoRecordAnnotation autoFontName( CrashReporter::Annotation::FontName, aFontName); - AutoCFRelease provider = - ::CGDataProviderCreateWithData(nullptr, aFontData, aLength, &ReleaseData); - AutoCFRelease fontRef = ::CGFontCreateWithDataProvider(provider); + AutoCFTypeRef provider(::CGDataProviderCreateWithData( + nullptr, aFontData, aLength, &ReleaseData)); + AutoCFTypeRef fontRef(::CGFontCreateWithDataProvider(provider)); if (!fontRef) { return nullptr; } @@ -1576,16 +1575,16 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) { RecursiveMutexAutoLock lock(mLock); // family name ==> CTFontDescriptor - AutoCFRelease family = CreateCFStringForString(aFamilyName); + AutoCFTypeRef family(CreateCFStringForString(aFamilyName)); - AutoCFRelease attr = + AutoCFTypeRef attr( CFDictionaryCreateMutable(NULL, 0, &kCFTypeDictionaryKeyCallBacks, - &kCFTypeDictionaryValueCallBacks); + &kCFTypeDictionaryValueCallBacks)); CFDictionaryAddValue(attr, kCTFontFamilyNameAttribute, family); - AutoCFRelease fd = - CTFontDescriptorCreateWithAttributes(attr); - AutoCFRelease matchingFonts = - CTFontDescriptorCreateMatchingFontDescriptors(fd, NULL); + AutoCFTypeRef fd( + CTFontDescriptorCreateWithAttributes(attr)); + AutoCFTypeRef matchingFonts( + CTFontDescriptorCreateMatchingFontDescriptors(fd, NULL)); if (!matchingFonts) { return; } @@ -1610,8 +1609,8 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) { } prevFace = faceDesc; - AutoCFRelease fontRef = - CTFontCreateWithFontDescriptor(faceDesc, 0.0, nullptr); + AutoCFTypeRef fontRef( + CTFontCreateWithFontDescriptor(faceDesc, 0.0, nullptr)); if (!fontRef) { NS_WARNING("failed to create a CTFontRef"); continue; @@ -1619,9 +1618,9 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) { if (mLoadCmaps) { // face name - AutoCFRelease faceName = + AutoCFTypeRef faceName( (CFStringRef)CTFontDescriptorCopyAttribute(faceDesc, - kCTFontNameAttribute); + kCTFontNameAttribute)); AutoTArray buffer; CFIndex len = CFStringGetLength(faceName); @@ -1633,8 +1632,8 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) { // load the cmap data FontFaceData fontData; - AutoCFRelease cmapTable = CTFontCopyTable( - fontRef, kCTFontTableCmap, kCTFontTableOptionNoOptions); + AutoCFTypeRef cmapTable(CTFontCopyTable( + fontRef, kCTFontTableCmap, kCTFontTableOptionNoOptions)); if (cmapTable) { const uint8_t* cmapData = (const uint8_t*)CFDataGetBytePtr(cmapTable); @@ -1655,8 +1654,8 @@ void CTFontInfo::LoadFontFamilyData(const nsACString& aFamilyName) { } if (mLoadOtherNames && hasOtherFamilyNames) { - AutoCFRelease nameTable = CTFontCopyTable( - fontRef, kCTFontTableName, kCTFontTableOptionNoOptions); + AutoCFTypeRef nameTable(CTFontCopyTable( + fontRef, kCTFontTableName, kCTFontTableOptionNoOptions)); if (nameTable) { const char* nameData = (const char*)CFDataGetBytePtr(nameTable); @@ -1702,15 +1701,14 @@ gfxFontEntry* CoreTextFontList::CreateFontEntry( void CoreTextFontList::AddFaceInitData( CTFontDescriptorRef aFontDesc, nsTArray& aFaces, bool aLoadCmaps) { - AutoCFRelease psname = + AutoCFTypeRef psname((CFStringRef)CTFontDescriptorCopyAttribute( + aFontDesc, kCTFontNameAttribute)); + AutoCFTypeRef facename( (CFStringRef)CTFontDescriptorCopyAttribute(aFontDesc, - kCTFontNameAttribute); - AutoCFRelease facename = - (CFStringRef)CTFontDescriptorCopyAttribute(aFontDesc, - kCTFontStyleNameAttribute); - AutoCFRelease traitsDict = + kCTFontStyleNameAttribute)); + AutoCFTypeRef traitsDict( (CFDictionaryRef)CTFontDescriptorCopyAttribute(aFontDesc, - kCTFontTraitsAttribute); + kCTFontTraitsAttribute)); CFNumberRef weight = (CFNumberRef)CFDictionaryGetValue(traitsDict, kCTFontWeightTrait); @@ -1752,11 +1750,11 @@ void CoreTextFontList::AddFaceInitData( RefPtr charmap; if (aLoadCmaps) { - AutoCFRelease font = - CGFontCreateWithFontName(CFStringRef(psname)); + AutoCFTypeRef font( + CGFontCreateWithFontName(CFStringRef(psname))); if (font) { uint32_t kCMAP = TRUETYPE_TAG('c', 'm', 'a', 'p'); - AutoCFRelease data = CGFontCopyTableForTag(font, kCMAP); + AutoCFTypeRef data(CGFontCopyTableForTag(font, kCMAP)); if (data) { uint32_t offset; charmap = new gfxCharacterMap(); @@ -1808,10 +1806,10 @@ void CoreTextFontList::GetFacesInitDataForFamily( context->mLoadCmaps); }; - AutoCFRelease descriptor = - CreateDescriptorForFamily(name, false); - AutoCFRelease faces = - CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr); + AutoCFTypeRef descriptor( + CreateDescriptorForFamily(name, false)); + AutoCFTypeRef faces( + CTFontDescriptorCreateMatchingFontDescriptors(descriptor, nullptr)); if (faces) { Context context{aFaces, aLoadCmaps}; @@ -1869,14 +1867,14 @@ void CoreTextFontList::ReadFaceNamesForFamily( } static CFStringRef CopyRealFamilyName(CTFontRef aFont) { - AutoCFRelease psName = CTFontCopyPostScriptName(aFont); - AutoCFRelease cgFont = - CGFontCreateWithFontName(CFStringRef(psName)); + AutoCFTypeRef psName(CTFontCopyPostScriptName(aFont)); + AutoCFTypeRef cgFont( + CGFontCreateWithFontName(CFStringRef(psName))); if (!cgFont) { return CTFontCopyFamilyName(aFont); } - AutoCFRelease ctFont = - CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr); + AutoCFTypeRef ctFont( + CTFontCreateWithGraphicsFont(cgFont, 0.0, nullptr, nullptr)); if (!ctFont) { return CTFontCopyFamilyName(aFont); } @@ -1885,9 +1883,9 @@ static CFStringRef CopyRealFamilyName(CTFontRef aFont) { void CoreTextFontList::InitSystemFontNames() { // text font family - AutoCFRelease font = CTFontCreateUIFontForLanguage( - kCTFontUIFontSystem, 0.0, nullptr); // TODO: language - AutoCFRelease name = CopyRealFamilyName(font); + AutoCFTypeRef font(CTFontCreateUIFontForLanguage( + kCTFontUIFontSystem, 0.0, nullptr)); // TODO: language + AutoCFTypeRef name(CopyRealFamilyName(font)); nsAutoString familyName; GetStringForCFString(name, familyName); @@ -1908,9 +1906,9 @@ void CoreTextFontList::InitSystemFontNames() { FontFamily CoreTextFontList::GetDefaultFontForPlatform( nsPresContext* aPresContext, const gfxFontStyle* aStyle, nsAtom* aLanguage) { - AutoCFRelease font = CTFontCreateUIFontForLanguage( - kCTFontUIFontUser, 0.0, nullptr); // TODO: language - AutoCFRelease name = CTFontCopyFamilyName(font); + AutoCFTypeRef font(CTFontCreateUIFontForLanguage( + kCTFontUIFontUser, 0.0, nullptr)); // TODO: language + AutoCFTypeRef name(CTFontCopyFamilyName(font)); nsAutoString familyName; GetStringForCFString(name, familyName); diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index c1aee3b80d28..746477d724a3 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -221,8 +221,8 @@ void gfxMacFont::InitMetrics() { // return the true value for OpenType/CFF fonts (it normalizes to 1000, // which then leads to metrics errors when we read the 'hmtx' table to // get glyph advances for HarfBuzz, see bug 580863) - AutoCFRelease headData = - ::CGFontCopyTableForTag(mCGFont, TRUETYPE_TAG('h', 'e', 'a', 'd')); + AutoCFTypeRef headData( + ::CGFontCopyTableForTag(mCGFont, TRUETYPE_TAG('h', 'e', 'a', 'd'))); if (headData) { if (size_t(::CFDataGetLength(headData)) >= sizeof(HeadTable)) { const HeadTable* head = @@ -278,8 +278,8 @@ void gfxMacFont::InitMetrics() { mMetrics.capHeight = ::CGFontGetCapHeight(mCGFont) * cgConvFactor; } - AutoCFRelease cmap = - ::CGFontCopyTableForTag(mCGFont, TRUETYPE_TAG('c', 'm', 'a', 'p')); + AutoCFTypeRef cmap( + ::CGFontCopyTableForTag(mCGFont, TRUETYPE_TAG('c', 'm', 'a', 'p'))); uint32_t glyphID; mMetrics.zeroWidth = GetCharWidth(cmap, '0', &glyphID, cgConvFactor); @@ -505,8 +505,8 @@ bool gfxMacFont::GetGlyphBounds(uint16_t aGID, gfxRect* aBounds, bool aTight) { // for sfnts, including ALL downloadable fonts, we prefer to use // InitMetricsFromSfntTables and avoid platform APIs. void gfxMacFont::InitMetricsFromPlatform() { - AutoCFRelease ctFont = - ::CTFontCreateWithGraphicsFont(mCGFont, mAdjustedSize, nullptr, nullptr); + AutoCFTypeRef ctFont( + ::CTFontCreateWithGraphicsFont(mCGFont, mAdjustedSize, nullptr, nullptr)); if (!ctFont) { return; } diff --git a/widget/cocoa/nsCocoaUtils.mm b/widget/cocoa/nsCocoaUtils.mm index 4c53a387d286..ff2676f39dca 100644 --- a/widget/cocoa/nsCocoaUtils.mm +++ b/widget/cocoa/nsCocoaUtils.mm @@ -1344,8 +1344,8 @@ nsresult nsCocoaUtils::GetScreenCapturePermissionState( // names if the calling application has been authorized to record the // screen. We use the window name, window level, and owning PID as // heuristics to determine if we have screen recording permission. - AutoCFRelease windowArray = - CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID); + AutoCFTypeRef windowArray( + CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID)); if (!windowArray) { LOG("GetScreenCapturePermissionState() ERROR: got NULL window info list"); return NS_ERROR_UNEXPECTED; @@ -1540,8 +1540,8 @@ void nsCocoaUtils::ResolveAudioCapturePromises(bool aGranted) { // nsresult nsCocoaUtils::MaybeRequestScreenCapturePermission() { LOG("MaybeRequestScreenCapturePermission()"); - AutoCFRelease image = - CGDisplayCreateImageForRect(kCGDirectMainDisplay, CGRectMake(0, 0, 1, 1)); + AutoCFTypeRef image(CGDisplayCreateImageForRect( + kCGDirectMainDisplay, CGRectMake(0, 0, 1, 1))); return NS_OK; } diff --git a/widget/cocoa/nsDeviceContextSpecX.mm b/widget/cocoa/nsDeviceContextSpecX.mm index b4ed7787a423..03fbf5289b11 100644 --- a/widget/cocoa/nsDeviceContextSpecX.mm +++ b/widget/cocoa/nsDeviceContextSpecX.mm @@ -121,12 +121,12 @@ NS_IMETHODIMP nsDeviceContextSpecX::Init(nsIPrintSettings* aPS, destination == kPMDestinationPreview) { mPrintViaSkPDF = true; } else if (destination == kPMDestinationFile) { - AutoCFRelease destURL(nullptr); + AutoCFTypeRef destURL(nullptr); status = ::PMSessionCopyDestinationLocation( - mPrintSession, mPMPrintSettings, destURL.receive()); + mPrintSession, mPMPrintSettings, destURL.Receive()); if (status == noErr) { - AutoCFRelease destPathRef = - CFURLCopyFileSystemPath(destURL, kCFURLPOSIXPathStyle); + AutoCFTypeRef destPathRef( + CFURLCopyFileSystemPath(destURL, kCFURLPOSIXPathStyle)); NSString* destPath = (NSString*)CFStringRef(destPathRef); NSString* destPathExt = [destPath pathExtension]; if ([destPathExt isEqualToString:@"pdf"]) { @@ -195,11 +195,11 @@ nsresult nsDeviceContextSpecX::DoEndDocument() { if (!tmpPDFFile) { return NS_ERROR_FAILURE; } - AutoCFRelease pdfURL(nullptr); + AutoCFTypeRef pdfURL(nullptr); // Note that the caller is responsible to release pdfURL according to // nsILocalFileMac.idl, even though we didn't follow the Core Foundation // naming conventions here (the method should've been called CopyCFURL). - nsresult rv = tmpPDFFile->GetCFURL(pdfURL.receive()); + nsresult rv = tmpPDFFile->GetCFURL(pdfURL.Receive()); NS_ENSURE_SUCCESS(rv, rv); PMDestinationType destination; @@ -220,24 +220,24 @@ nsresult nsDeviceContextSpecX::DoEndDocument() { } case kPMDestinationPreview: { // XXXjwatt Or should we use CocoaFileUtils::RevealFileInFinder(pdfURL); - AutoCFRelease pdfPath = - CFURLCopyFileSystemPath(pdfURL, kCFURLPOSIXPathStyle); + AutoCFTypeRef pdfPath( + CFURLCopyFileSystemPath(pdfURL, kCFURLPOSIXPathStyle)); NSString* path = (NSString*)CFStringRef(pdfPath); NSWorkspace* ws = [NSWorkspace sharedWorkspace]; [ws openFile:path]; break; } case kPMDestinationFile: { - AutoCFRelease destURL(nullptr); + AutoCFTypeRef destURL(nullptr); status = ::PMSessionCopyDestinationLocation( - mPrintSession, mPMPrintSettings, destURL.receive()); + mPrintSession, mPMPrintSettings, destURL.Receive()); if (status == noErr) { - AutoCFRelease sourcePathRef = - CFURLCopyFileSystemPath(pdfURL, kCFURLPOSIXPathStyle); + AutoCFTypeRef sourcePathRef( + CFURLCopyFileSystemPath(pdfURL, kCFURLPOSIXPathStyle)); NSString* sourcePath = (NSString*)CFStringRef(sourcePathRef); # ifdef DEBUG - AutoCFRelease destPathRef = - CFURLCopyFileSystemPath(destURL, kCFURLPOSIXPathStyle); + AutoCFTypeRef destPathRef( + CFURLCopyFileSystemPath(destURL, kCFURLPOSIXPathStyle)); NSString* destPath = (NSString*)CFStringRef(destPathRef); NSString* destPathExt = [destPath pathExtension]; MOZ_ASSERT([destPathExt isEqualToString:@"pdf"],