Tue, 06 Jan 2015 21:39:09 +0100
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 GFX_MACFONT_H |
michael@0 | 7 | #define GFX_MACFONT_H |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/MemoryReporting.h" |
michael@0 | 10 | #include "gfxFont.h" |
michael@0 | 11 | #include "cairo.h" |
michael@0 | 12 | #include <ApplicationServices/ApplicationServices.h> |
michael@0 | 13 | |
michael@0 | 14 | class MacOSFontEntry; |
michael@0 | 15 | |
michael@0 | 16 | class gfxMacFont : public gfxFont |
michael@0 | 17 | { |
michael@0 | 18 | public: |
michael@0 | 19 | gfxMacFont(MacOSFontEntry *aFontEntry, const gfxFontStyle *aFontStyle, |
michael@0 | 20 | bool aNeedsBold); |
michael@0 | 21 | |
michael@0 | 22 | virtual ~gfxMacFont(); |
michael@0 | 23 | |
michael@0 | 24 | CGFontRef GetCGFontRef() const { return mCGFont; } |
michael@0 | 25 | |
michael@0 | 26 | /* overrides for the pure virtual methods in gfxFont */ |
michael@0 | 27 | virtual const gfxFont::Metrics& GetMetrics() { |
michael@0 | 28 | return mMetrics; |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | virtual uint32_t GetSpaceGlyph() { |
michael@0 | 32 | return mSpaceGlyph; |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | virtual bool SetupCairoFont(gfxContext *aContext); |
michael@0 | 36 | |
michael@0 | 37 | /* override Measure to add padding for antialiasing */ |
michael@0 | 38 | virtual RunMetrics Measure(gfxTextRun *aTextRun, |
michael@0 | 39 | uint32_t aStart, uint32_t aEnd, |
michael@0 | 40 | BoundingBoxType aBoundingBoxType, |
michael@0 | 41 | gfxContext *aContextForTightBoundingBox, |
michael@0 | 42 | Spacing *aSpacing); |
michael@0 | 43 | |
michael@0 | 44 | virtual mozilla::TemporaryRef<mozilla::gfx::ScaledFont> GetScaledFont(mozilla::gfx::DrawTarget *aTarget); |
michael@0 | 45 | |
michael@0 | 46 | virtual void AddSizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf, |
michael@0 | 47 | FontCacheSizes* aSizes) const; |
michael@0 | 48 | virtual void AddSizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf, |
michael@0 | 49 | FontCacheSizes* aSizes) const; |
michael@0 | 50 | |
michael@0 | 51 | virtual FontType GetType() const { return FONT_TYPE_MAC; } |
michael@0 | 52 | |
michael@0 | 53 | protected: |
michael@0 | 54 | virtual void CreatePlatformShaper(); |
michael@0 | 55 | |
michael@0 | 56 | // override to prefer CoreText shaping with fonts that depend on AAT |
michael@0 | 57 | virtual bool ShapeText(gfxContext *aContext, |
michael@0 | 58 | const char16_t *aText, |
michael@0 | 59 | uint32_t aOffset, |
michael@0 | 60 | uint32_t aLength, |
michael@0 | 61 | int32_t aScript, |
michael@0 | 62 | gfxShapedText *aShapedText, |
michael@0 | 63 | bool aPreferPlatformShaping = false); |
michael@0 | 64 | |
michael@0 | 65 | void InitMetrics(); |
michael@0 | 66 | void InitMetricsFromPlatform(); |
michael@0 | 67 | |
michael@0 | 68 | // Get width and glyph ID for a character; uses aConvFactor |
michael@0 | 69 | // to convert font units as returned by CG to actual dimensions |
michael@0 | 70 | gfxFloat GetCharWidth(CFDataRef aCmap, char16_t aUniChar, |
michael@0 | 71 | uint32_t *aGlyphID, gfxFloat aConvFactor); |
michael@0 | 72 | |
michael@0 | 73 | // a weak reference to the CoreGraphics font: this is owned by the |
michael@0 | 74 | // MacOSFontEntry, it is not retained or released by gfxMacFont |
michael@0 | 75 | CGFontRef mCGFont; |
michael@0 | 76 | |
michael@0 | 77 | cairo_font_face_t *mFontFace; |
michael@0 | 78 | |
michael@0 | 79 | Metrics mMetrics; |
michael@0 | 80 | uint32_t mSpaceGlyph; |
michael@0 | 81 | }; |
michael@0 | 82 | |
michael@0 | 83 | #endif /* GFX_MACFONT_H */ |