gfx/thebes/gfxMacPlatformFontList.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef gfxMacPlatformFontList_H_
michael@0 7 #define gfxMacPlatformFontList_H_
michael@0 8
michael@0 9 #include <CoreFoundation/CoreFoundation.h>
michael@0 10
michael@0 11 #include "mozilla/MemoryReporting.h"
michael@0 12 #include "nsDataHashtable.h"
michael@0 13 #include "nsRefPtrHashtable.h"
michael@0 14
michael@0 15 #include "gfxPlatformFontList.h"
michael@0 16 #include "gfxPlatform.h"
michael@0 17 #include "gfxPlatformMac.h"
michael@0 18
michael@0 19 #include "nsUnicharUtils.h"
michael@0 20 #include "nsTArray.h"
michael@0 21
michael@0 22 class gfxMacPlatformFontList;
michael@0 23
michael@0 24 // a single member of a font family (i.e. a single face, such as Times Italic)
michael@0 25 class MacOSFontEntry : public gfxFontEntry
michael@0 26 {
michael@0 27 public:
michael@0 28 friend class gfxMacPlatformFontList;
michael@0 29
michael@0 30 MacOSFontEntry(const nsAString& aPostscriptName, int32_t aWeight,
michael@0 31 bool aIsStandardFace = false);
michael@0 32
michael@0 33 // for use with data fonts
michael@0 34 MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef,
michael@0 35 uint16_t aWeight, uint16_t aStretch, uint32_t aItalicStyle,
michael@0 36 bool aIsUserFont, bool aIsLocal);
michael@0 37
michael@0 38 virtual ~MacOSFontEntry() {
michael@0 39 ::CGFontRelease(mFontRef);
michael@0 40 }
michael@0 41
michael@0 42 virtual CGFontRef GetFontRef();
michael@0 43
michael@0 44 // override gfxFontEntry table access function to bypass table cache,
michael@0 45 // use CGFontRef API to get direct access to system font data
michael@0 46 virtual hb_blob_t *GetFontTable(uint32_t aTag) MOZ_OVERRIDE;
michael@0 47
michael@0 48 virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf,
michael@0 49 FontListSizes* aSizes) const;
michael@0 50
michael@0 51 nsresult ReadCMAP(FontInfoData *aFontInfoData = nullptr);
michael@0 52
michael@0 53 bool RequiresAATLayout() const { return mRequiresAAT; }
michael@0 54
michael@0 55 bool IsCFF();
michael@0 56
michael@0 57 protected:
michael@0 58 virtual gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold);
michael@0 59
michael@0 60 virtual bool HasFontTable(uint32_t aTableTag);
michael@0 61
michael@0 62 static void DestroyBlobFunc(void* aUserData);
michael@0 63
michael@0 64 CGFontRef mFontRef; // owning reference to the CGFont, released on destruction
michael@0 65
michael@0 66 bool mFontRefInitialized;
michael@0 67 bool mRequiresAAT;
michael@0 68 bool mIsCFF;
michael@0 69 bool mIsCFFInitialized;
michael@0 70 };
michael@0 71
michael@0 72 class gfxMacPlatformFontList : public gfxPlatformFontList {
michael@0 73 public:
michael@0 74 static gfxMacPlatformFontList* PlatformFontList() {
michael@0 75 return static_cast<gfxMacPlatformFontList*>(sPlatformFontList);
michael@0 76 }
michael@0 77
michael@0 78 static int32_t AppleWeightToCSSWeight(int32_t aAppleWeight);
michael@0 79
michael@0 80 virtual gfxFontFamily* GetDefaultFont(const gfxFontStyle* aStyle);
michael@0 81
michael@0 82 virtual bool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
michael@0 83
michael@0 84 virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
michael@0 85 const nsAString& aFontName);
michael@0 86
michael@0 87 virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
michael@0 88 const uint8_t *aFontData, uint32_t aLength);
michael@0 89
michael@0 90 void ClearPrefFonts() { mPrefFonts.Clear(); }
michael@0 91
michael@0 92 private:
michael@0 93 friend class gfxPlatformMac;
michael@0 94
michael@0 95 gfxMacPlatformFontList();
michael@0 96 virtual ~gfxMacPlatformFontList();
michael@0 97
michael@0 98 // initialize font lists
michael@0 99 virtual nsresult InitFontList();
michael@0 100
michael@0 101 // special case font faces treated as font families (set via prefs)
michael@0 102 void InitSingleFaceList();
michael@0 103
michael@0 104 static void RegisteredFontsChangedNotificationCallback(CFNotificationCenterRef center,
michael@0 105 void *observer,
michael@0 106 CFStringRef name,
michael@0 107 const void *object,
michael@0 108 CFDictionaryRef userInfo);
michael@0 109
michael@0 110 // search fonts system-wide for a given character, null otherwise
michael@0 111 virtual gfxFontEntry* GlobalFontFallback(const uint32_t aCh,
michael@0 112 int32_t aRunScript,
michael@0 113 const gfxFontStyle* aMatchStyle,
michael@0 114 uint32_t& aCmapCount,
michael@0 115 gfxFontFamily** aMatchedFamily);
michael@0 116
michael@0 117 virtual bool UsesSystemFallback() { return true; }
michael@0 118
michael@0 119 virtual already_AddRefed<FontInfoData> CreateFontInfoData();
michael@0 120
michael@0 121 enum {
michael@0 122 kATSGenerationInitial = -1
michael@0 123 };
michael@0 124
michael@0 125 // default font for use with system-wide font fallback
michael@0 126 CTFontRef mDefaultFont;
michael@0 127 };
michael@0 128
michael@0 129 #endif /* gfxMacPlatformFontList_H_ */

mercurial