Ticket #23970: 0001-Bug-23970-Printing-to-a-file-is-broken-with-Linux-co.patch

File 0001-Bug-23970-Printing-to-a-file-is-broken-with-Linux-co.patch, 8.4 KB (added by pospeselr, 17 months ago)
  • gfx/2d/2D.h

    From 835c50bdd1013b3463e9ffd85fcc2709d5907172 Mon Sep 17 00:00:00 2001
    From: Richard Pospesel <richard@torproject.org>
    Date: Mon, 27 Nov 2017 13:57:32 -0800
    Subject: [PATCH 1/5] Bug 23970: Printing to a file is broken with Linux
     content  sandboxing enabled
    
    Ported over firefox patch 5c25a123203a (Bug 1309205 Part 1)
    ---
     gfx/2d/2D.h                     | 12 ++++++++++++
     gfx/2d/Factory.cpp              | 25 +++++++++++++++++++++++++
     gfx/thebes/gfxAndroidPlatform.h |  4 +---
     gfx/thebes/gfxFT2FontList.cpp   | 10 +++++-----
     gfx/thebes/gfxFontconfigFonts.h |  5 ++---
     gfx/thebes/gfxPlatform.cpp      |  4 ++++
     gfx/thebes/gfxPlatform.h        |  5 +++++
     gfx/thebes/gfxPlatformGtk.cpp   | 10 ++++++++++
     gfx/thebes/gfxPlatformGtk.h     |  2 ++
     9 files changed, 66 insertions(+), 11 deletions(-)
    
    diff --git a/gfx/2d/2D.h b/gfx/2d/2D.h
    index c1fba3463a8f..3d5fb52ad925 100644
    a b typedef _cairo_scaled_font cairo_scaled_font_t; 
    4141struct _FcPattern;
    4242typedef _FcPattern FcPattern;
    4343
     44struct FT_LibraryRec_;
     45typedef FT_LibraryRec_* FT_Library;
     46
    4447struct ID3D11Texture2D;
    4548struct ID3D11Device;
    4649struct ID2D1Device;
    public: 
    14831486    CreateCGGlyphRenderingOptions(const Color &aFontSmoothingBackgroundColor);
    14841487#endif
    14851488
     1489#ifdef MOZ_ENABLE_FREETYPE
     1490  static void SetFTLibrary(FT_Library aFTLibrary);
     1491  static FT_Library GetFTLibrary();
     1492
     1493private:
     1494  static FT_Library mFTLibrary;
     1495public:
     1496#endif
     1497
    14861498#ifdef WIN32
    14871499  static already_AddRefed<DrawTarget> CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat);
    14881500
  • gfx/2d/Factory.cpp

    diff --git a/gfx/2d/Factory.cpp b/gfx/2d/Factory.cpp
    index 5cd5d14eaba1..ceebce690afb 100644
    a b namespace gfx { 
    156156// In Gecko, this value is managed by gfx.logging.level in gfxPrefs.
    157157int32_t LoggingPrefs::sGfxLogLevel = LOG_DEFAULT;
    158158
     159#ifdef MOZ_ENABLE_FREETYPE
     160FT_Library Factory::mFTLibrary = nullptr;
     161#endif
     162
    159163#ifdef WIN32
    160164ID3D11Device *Factory::mD3D11Device = nullptr;
    161165ID2D1Device *Factory::mD2D1Device = nullptr;
    Factory::ShutDown() 
    192196    delete sConfig;
    193197    sConfig = nullptr;
    194198  }
     199
     200#ifdef MOZ_ENABLE_FREETYPE
     201  if (mFTLibrary) {
     202    mFTLibrary = nullptr;
     203  }
     204#endif
    195205}
    196206
    197207bool
    Factory::CreateDualDrawTarget(DrawTarget *targetA, DrawTarget *targetB) 
    579589}
    580590
    581591
     592#ifdef MOZ_ENABLE_FREETYPE
     593void
     594Factory::SetFTLibrary(FT_Library aFTLibrary)
     595{
     596  mFTLibrary = aFTLibrary;
     597}
     598
     599FT_Library
     600Factory::GetFTLibrary()
     601{
     602  MOZ_ASSERT(mFTLibrary);
     603  return mFTLibrary;
     604}
     605#endif
     606
    582607#ifdef WIN32
    583608already_AddRefed<DrawTarget>
    584609Factory::CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat)
  • gfx/thebes/gfxAndroidPlatform.h

    diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h
    index 30e7c89babeb..889928da86a7 100644
    a b namespace mozilla { 
    1919};
    2020using mozilla::dom::FontListEntry;
    2121
    22 typedef struct FT_LibraryRec_ *FT_Library;
    23 
    2422class gfxAndroidPlatform : public gfxPlatform {
    2523public:
    2624    gfxAndroidPlatform();
    public: 
    6058    virtual bool FontHintingEnabled() override;
    6159    virtual bool RequiresLinearZoom() override;
    6260
    63     FT_Library GetFTLibrary();
     61    FT_Library GetFTLibrary() override;
    6462
    6563    virtual bool CanRenderContentToDataSurface() const override {
    6664      return true;
  • gfx/thebes/gfxFT2FontList.cpp

    diff --git a/gfx/thebes/gfxFT2FontList.cpp b/gfx/thebes/gfxFT2FontList.cpp
    index 8a652df0dd34..2d9e09efe1c0 100644
    a b  
    1313#include "mozilla/UniquePtr.h"
    1414#include "mozilla/UniquePtrExtensions.h"
    1515#include "nsIInputStream.h"
    16 #define gfxToolkitPlatform gfxAndroidPlatform
    1716
    1817#include "nsXULAppAPI.h"
    1918#include <dirent.h>
    public: 
    8584
    8685        NS_ASSERTION(!aFontEntry->mFilename.IsEmpty(),
    8786                     "can't use AutoFTFace for fonts without a filename");
    88         FT_Library ft = gfxToolkitPlatform::GetPlatform()->GetFTLibrary();
     87        FT_Library ft = gfxPlatform::GetPlatform()->GetFTLibrary();
     88        MOZ_ASSERT(ft);
    8989
    9090        // A relative path (no initial "/") means this is a resource in
    9191        // omnijar, not an installed font on the device.
    FT2FontEntry::CreateFontEntry(const nsAString& aFontName, 
    256256    // eventually deleted.
    257257    FT_Face face;
    258258    FT_Error error =
    259         FT_New_Memory_Face(gfxToolkitPlatform::GetPlatform()->GetFTLibrary(),
     259        FT_New_Memory_Face(gfxPlatform::GetPlatform()->GetFTLibrary(),
    260260                           aFontData, aLength, 0, &face);
    261261    if (error != FT_Err_Ok) {
    262262        free((void*)aFontData);
    gfxFT2FontList::AppendFacesFromFontFile(const nsCString& aFileName, 
    974974        return;
    975975    }
    976976
    977     FT_Library ftLibrary = gfxAndroidPlatform::GetPlatform()->GetFTLibrary();
     977    FT_Library ftLibrary = gfxPlatform::GetPlatform()->GetFTLibrary();
    978978    FT_Face dummy;
    979979    if (FT_Err_Ok == FT_New_Face(ftLibrary, aFileName.get(), -1, &dummy)) {
    980980        LOG(("reading font info via FreeType for %s", aFileName.get()));
    gfxFT2FontList::AppendFacesFromOmnijarEntry(nsZipArchive* aArchive, 
    11261126        return;
    11271127    }
    11281128
    1129     FT_Library ftLibrary = gfxAndroidPlatform::GetPlatform()->GetFTLibrary();
     1129    FT_Library ftLibrary = gfxPlatform::GetPlatform()->GetFTLibrary();
    11301130
    11311131    FT_Face dummy;
    11321132    if (FT_Err_Ok != FT_New_Memory_Face(ftLibrary, buf.get(), bufSize, 0, &dummy)) {
  • gfx/thebes/gfxFontconfigFonts.h

    diff --git a/gfx/thebes/gfxFontconfigFonts.h b/gfx/thebes/gfxFontconfigFonts.h
    index cea9d0dbfaf2..cd59cfc68c62 100644
    a b public: 
    5555                                      const uint8_t* aFontData,
    5656                                      uint32_t aLength);
    5757
     58    static FT_Library GetFTLibrary();
     59
    5860private:
    5961
    6062    virtual gfxFont *GetFontAt(int32_t i, uint32_t aCh = 0x20);
    private: 
    116118                               nsIAtom *aLanguage,
    117119                               nsTArray<nsString>& aGenericFamilies);
    118120
    119 
    120     friend class gfxSystemFcFontEntry;
    121     static FT_Library GetFTLibrary();
    122121};
    123122
    124123#endif /* GFX_FONTCONFIG_FONTS_H */
  • gfx/thebes/gfxPlatform.cpp

    diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp
    index 2e4ec990f8b3..4843554d655b 100644
    a b gfxPlatform::Init() 
    752752        NS_RUNTIMEABORT("Could not initialize gfxFontCache");
    753753    }
    754754
     755#ifdef MOZ_ENABLE_FREETYPE
     756    Factory::SetFTLibrary(gPlatform->GetFTLibrary());
     757#endif
     758
    755759    /* Create and register our CMS Override observer. */
    756760    gPlatform->mSRGBOverrideObserver = new SRGBOverrideObserver();
    757761    Preferences::AddWeakObserver(gPlatform->mSRGBOverrideObserver, GFX_PREF_CMS_FORCE_SRGB);
  • gfx/thebes/gfxPlatform.h

    diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h
    index 68bb99ea44e9..5ef792b67a40 100644
    a b class nsIAtom; 
    3939class nsIObserver;
    4040class SRGBOverrideObserver;
    4141class gfxTextPerfMetrics;
     42typedef struct FT_LibraryRec_ *FT_Library;
    4243
    4344namespace mozilla {
    4445namespace gl {
    public: 
    681682     */
    682683    virtual void ImportGPUDeviceData(const mozilla::gfx::GPUDeviceData& aData);
    683684
     685    virtual FT_Library GetFTLibrary() {
     686      return nullptr;
     687    }
     688
    684689protected:
    685690    gfxPlatform();
    686691    virtual ~gfxPlatform();
  • gfx/thebes/gfxPlatformGtk.cpp

    diff --git a/gfx/thebes/gfxPlatformGtk.cpp b/gfx/thebes/gfxPlatformGtk.cpp
    index 9d7f512f27a7..c8661a433111 100644
    a b gfxPlatformGtk::MakePlatformFont(const nsAString& aFontName, 
    348348                                           aFontData, aLength);
    349349}
    350350
     351FT_Library
     352gfxPlatformGtk::GetFTLibrary()
     353{
     354    if (sUseFcFontList) {
     355        return gfxFcPlatformFontList::GetFTLibrary();
     356    }
     357
     358    return gfxPangoFontGroup::GetFTLibrary();
     359}
     360
    351361bool
    352362gfxPlatformGtk::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags)
    353363{
  • gfx/thebes/gfxPlatformGtk.h

    diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h
    index 982390d1867b..d0c6079bd943 100644
    a b public: 
    9595     */
    9696    virtual void FlushContentDrawing() override;
    9797
     98    FT_Library GetFTLibrary() override;
     99
    98100#if (MOZ_WIDGET_GTK == 2)
    99101    static void SetGdkDrawable(cairo_surface_t *target,
    100102                               GdkDrawable *drawable);