Pier Angelo Vendrame pushed to branch tor-browser-152.0a1-16.0-2 at The Tor Project / Applications / Tor Browser
Commits:
-
c6615d45
by Jonathan Kew at 2026-06-25T08:38:06+02:00
5 changed files:
- gfx/ipc/GPUProcessImpl.cpp
- gfx/thebes/CoreTextFontList.h
- gfx/thebes/gfxPlatformMac.cpp
- gfx/thebes/gfxPlatformMac.h
- security/sandbox/mac/SandboxPolicyGPU.h
Changes:
| ... | ... | @@ -11,6 +11,8 @@ |
| 11 | 11 | # include "mozilla/sandboxTarget.h"
|
| 12 | 12 | #elif defined(__OpenBSD__) && defined(MOZ_SANDBOX)
|
| 13 | 13 | # include "mozilla/SandboxSettings.h"
|
| 14 | +#elif defined(XP_MACOSX) && defined(MOZ_BUNDLED_FONTS)
|
|
| 15 | +# include "gfxPlatformMac.h"
|
|
| 14 | 16 | #endif
|
| 15 | 17 | |
| 16 | 18 | namespace mozilla {
|
| ... | ... | @@ -34,6 +36,35 @@ bool GPUProcessImpl::Init(int aArgc, char* aArgv[]) { |
| 34 | 36 | return false;
|
| 35 | 37 | }
|
| 36 | 38 | |
| 39 | +#if defined(XP_MACOSX) && defined(MOZ_BUNDLED_FONTS)
|
|
| 40 | + // On macOS, bundled fonts shipped with the application need to be activated
|
|
| 41 | + // in the GPU process, otherwise they will fail to render (and fall back to
|
|
| 42 | + // garbage glyphs from another font).
|
|
| 43 | + // The bundled fonts directory is a sibling of the appDir, so we use the
|
|
| 44 | + // sAppDir arg as a starting-point to locate it.
|
|
| 45 | + nsCOMPtr<nsIFile> appDirArg;
|
|
| 46 | + Maybe<const char*> appDir = geckoargs::sAppDir.Get(aArgc, aArgv);
|
|
| 47 | + if (appDir.isSome()) {
|
|
| 48 | + bool flag;
|
|
| 49 | + if (NS_FAILED(XRE_GetFileFromPath(*appDir, getter_AddRefs(appDirArg))) ||
|
|
| 50 | + NS_FAILED(appDirArg->Exists(&flag)) || !flag) {
|
|
| 51 | + NS_WARNING("Invalid application directory passed to GPU process.");
|
|
| 52 | + appDirArg = nullptr;
|
|
| 53 | + }
|
|
| 54 | + }
|
|
| 55 | + if (appDirArg) {
|
|
| 56 | + // appDirArg is the <app package>/Contents/Resources/browser directory.
|
|
| 57 | + // Get its parent (/Resources), and then append /fonts.
|
|
| 58 | + nsCOMPtr<nsIFile> fontsDir;
|
|
| 59 | + bool flag;
|
|
| 60 | + if (NS_SUCCEEDED(appDirArg->GetParent(getter_AddRefs(fontsDir))) &&
|
|
| 61 | + NS_SUCCEEDED(fontsDir->AppendRelativeNativePath("fonts"_ns)) &&
|
|
| 62 | + NS_SUCCEEDED(fontsDir->Exists(&flag)) && flag) {
|
|
| 63 | + gfxPlatformMac::ActivateFontsFromDir(fontsDir->NativePath());
|
|
| 64 | + }
|
|
| 65 | + }
|
|
| 66 | +#endif
|
|
| 67 | + |
|
| 37 | 68 | if (!ProcessChild::InitPrefs(aArgc, aArgv)) {
|
| 38 | 69 | return false;
|
| 39 | 70 | }
|
| ... | ... | @@ -193,6 +193,10 @@ class CoreTextFontList : public gfxPlatformFontList { |
| 193 | 193 | };
|
| 194 | 194 | void ReadSystemFontList(mozilla::dom::SystemFontList*);
|
| 195 | 195 | |
| 196 | + static void ActivateFontsFromDir(
|
|
| 197 | + const nsACString& aDir,
|
|
| 198 | + nsTHashSet<nsCStringHashKey>* aLoadedFamilies = nullptr);
|
|
| 199 | + |
|
| 196 | 200 | protected:
|
| 197 | 201 | CoreTextFontList();
|
| 198 | 202 | virtual ~CoreTextFontList();
|
| ... | ... | @@ -251,10 +255,6 @@ class CoreTextFontList : public gfxPlatformFontList { |
| 251 | 255 | void AddFamily(const nsACString& aFamilyName, FontVisibility aVisibility)
|
| 252 | 256 | MOZ_REQUIRES(mLock);
|
| 253 | 257 | |
| 254 | - static void ActivateFontsFromDir(
|
|
| 255 | - const nsACString& aDir,
|
|
| 256 | - nsTHashSet<nsCStringHashKey>* aLoadedFamilies = nullptr);
|
|
| 257 | - |
|
| 258 | 258 | gfxFontEntry* CreateFontEntry(
|
| 259 | 259 | mozilla::fontlist::Face* aFace,
|
| 260 | 260 | const mozilla::fontlist::Family* aFamily) override;
|
| ... | ... | @@ -1073,3 +1073,9 @@ nsTArray<uint8_t> gfxPlatformMac::GetPlatformCMSOutputProfileData() { |
| 1073 | 1073 | }
|
| 1074 | 1074 | |
| 1075 | 1075 | bool gfxPlatformMac::CheckVariationFontSupport() { return true; }
|
| 1076 | + |
|
| 1077 | +#ifdef MOZ_BUNDLED_FONTS
|
|
| 1078 | +void gfxPlatformMac::ActivateFontsFromDir(const nsACString& aPath) {
|
|
| 1079 | + CoreTextFontList::ActivateFontsFromDir(aPath);
|
|
| 1080 | +}
|
|
| 1081 | +#endif |
| ... | ... | @@ -80,6 +80,10 @@ class gfxPlatformMac : public gfxPlatform { |
| 80 | 80 | |
| 81 | 81 | static bool CheckVariationFontSupport();
|
| 82 | 82 | |
| 83 | +#ifdef MOZ_BUNDLED_FONTS
|
|
| 84 | + static void ActivateFontsFromDir(const nsACString& aPath);
|
|
| 85 | +#endif
|
|
| 86 | + |
|
| 83 | 87 | protected:
|
| 84 | 88 | bool AccelerateLayersByDefault() override;
|
| 85 | 89 |
| ... | ... | @@ -232,6 +232,7 @@ static const char SandboxPolicyGPU[] = R"SANDBOX_LITERAL( |
| 232 | 232 | (allow file-read*
|
| 233 | 233 | (subpath "/Library/Fonts")
|
| 234 | 234 | (subpath "/Library/Application Support/Apple/Fonts")
|
| 235 | + (subpath (string-append appPath "/Contents/Resources/fonts"))
|
|
| 235 | 236 | (home-subpath "/Library/Fonts")
|
| 236 | 237 | ; Allow read access to paths allowed via sandbox extensions.
|
| 237 | 238 | ; This is needed for fonts in non-standard locations normally
|