Merge to XFA: Kill IFX_FontMapper

(cherry picked from commit 01fa1efb228acdcf5250804c670107133668e4b2)
Orignal Review URL: https://codereview.chromium.org/1259123005 .

conflicts:
  core/include/fxge/fx_font.h
  core/src/fxge/ge/fx_ge_fontmap.cpp

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/1262723006 .
diff --git a/core/include/fxge/fx_font.h b/core/include/fxge/fx_font.h
index 0f7c18e..c1e1357 100644
--- a/core/include/fxge/fx_font.h
+++ b/core/include/fxge/fx_font.h
@@ -18,7 +18,6 @@
 class CFX_PathData;
 class CFX_SubstFont;
 class CFX_FaceCache;
-class IFX_FontMapper;
 class CFX_FontMapper;
 class IFX_SystemFontInfo;
 class CFontFileFaceInfo;
@@ -255,22 +254,10 @@
 
     FX_BOOL			GetStandardFont(const uint8_t*& pFontData, FX_DWORD& size, int index);
     CFX_FontMapper*	m_pBuiltinMapper;
-    IFX_FontMapper*	m_pExtMapper;
     CFX_MapByteStringToPtr	m_FaceMap;
     FXFT_Library	m_FTLibrary;
     FoxitFonts m_ExternalFonts[16];
 };
-class IFX_FontMapper
-{
-public:
-
-    virtual ~IFX_FontMapper() {}
-
-    virtual FXFT_Face	FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
-                                      int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont) = 0;
-
-    CFX_FontMgr*		m_pFontMgr;
-};
 class IFX_FontEnumerator
 {
 public:
@@ -287,13 +274,15 @@
     virtual int  CountFiles() = 0;
     virtual IFX_FileStream* GetFontFile(int index) = 0;
 };
-class CFX_FontMapper : public IFX_FontMapper
+class CFX_FontMapper
 {
 public:
-    CFX_FontMapper();
-    virtual ~CFX_FontMapper();
-    void                        SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo);
-    IFX_SystemFontInfo*         GetSystemFontInfo()
+
+    CFX_FontMapper(CFX_FontMgr* mgr);
+    ~CFX_FontMapper();
+
+    void				SetSystemFontInfo(IFX_SystemFontInfo* pFontInfo);
+    IFX_SystemFontInfo*	GetSystemFontInfo()
     {
         return m_pFontInfo;
     }
@@ -308,14 +297,16 @@
     {
         return m_pFontEnumerator;
     }
-    virtual FXFT_Face           FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
-                                              int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont);
+
+    FXFT_Face FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType, FX_DWORD flags,
+                            int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont);
     FXFT_Face                   FindSubstFontByUnicode(FX_DWORD dwUnicode, FX_DWORD flags, int weight, int italic_angle);

     FX_BOOL                     IsBuiltinFace(const FXFT_Face face) const;
 
 private:
     static const size_t         MM_FACE_COUNT = 2;
     static const size_t         FOXIT_FACE_COUNT = 14;
+
     CFX_ByteString              GetPSNameFromTT(void* hFont);
     CFX_ByteString              MatchInstalledFonts(const CFX_ByteString& norm_name);
     FXFT_Face                   UseInternalSubst(CFX_SubstFont* pSubstFont, int iBaseFont, int italic_angle, int weight, int picthfamily);
@@ -328,6 +319,7 @@
     IFX_SystemFontInfo*         m_pFontInfo;
     FXFT_Face                   m_FoxitFaces[FOXIT_FACE_COUNT];
     IFX_FontEnumerator*         m_pFontEnumerator;
+    CFX_FontMgr* const m_pFontMgr;
 };
 class IFX_SystemFontInfo
 {
diff --git a/core/include/fxge/fx_ge.h b/core/include/fxge/fx_ge.h
index fd9c148..dd349ad 100644
--- a/core/include/fxge/fx_ge.h
+++ b/core/include/fxge/fx_ge.h
@@ -42,7 +42,6 @@
     }
     void					SetTextGamma(FX_FLOAT gammaValue);
     const uint8_t*				GetTextGammaTable();
-    void					SetExtFontMapper(IFX_FontMapper* pFontMapper);
 
     void					SetCodecModule(CCodec_ModuleMgr* pCodecModule)
     {
diff --git a/core/src/fxge/apple/apple_int.h b/core/src/fxge/apple/apple_int.h
index 715e48d..090ac09 100644
--- a/core/src/fxge/apple/apple_int.h
+++ b/core/src/fxge/apple/apple_int.h
@@ -65,16 +65,10 @@
 class CApplePlatform
 {
 public:
-    CApplePlatform()
-    {
-        m_pFontMapper = NULL;
-    }
-    ~CApplePlatform()
-    {
-        delete m_pFontMapper;
-    }
+    CApplePlatform() {}
+    ~CApplePlatform() {}
+
     CQuartz2D	_quartz2d;
-    IFX_FontMapper* m_pFontMapper;
 };
 class CFX_QuartzDeviceDriver : public IFX_RenderDeviceDriver
 {
diff --git a/core/src/fxge/ge/fx_ge.cpp b/core/src/fxge/ge/fx_ge.cpp
index 8c2a437..8167a91 100644
--- a/core/src/fxge/ge/fx_ge.cpp
+++ b/core/src/fxge/ge/fx_ge.cpp
@@ -66,8 +66,3 @@
 {
     return m_GammaValue;
 }
-void CFX_GEModule::SetExtFontMapper(IFX_FontMapper* pFontMapper)
-{
-    GetFontMgr()->m_pExtMapper = pFontMapper;
-    pFontMapper->m_pFontMgr = m_pFontMgr;
-}
diff --git a/core/src/fxge/ge/fx_ge_fontmap.cpp b/core/src/fxge/ge/fx_ge_fontmap.cpp
index 8b13429..8998818 100644
--- a/core/src/fxge/ge/fx_ge_fontmap.cpp
+++ b/core/src/fxge/ge/fx_ge_fontmap.cpp
@@ -61,15 +61,9 @@
     delete this;
     return 0;
 }
-CFX_FontMgr::CFX_FontMgr()
+CFX_FontMgr::CFX_FontMgr() : m_FTLibrary(nullptr)
 {
-    m_pBuiltinMapper = FX_NEW CFX_FontMapper;
-    if (!m_pBuiltinMapper) {
-        return;
-    }
-    m_pBuiltinMapper->m_pFontMgr = this;
-    m_pExtMapper = NULL;
-    m_FTLibrary = NULL;
+    m_pBuiltinMapper = new CFX_FontMapper(this);
     FXSYS_memset(m_ExternalFonts, 0, sizeof m_ExternalFonts);
 }
 CFX_FontMgr::~CFX_FontMgr()
@@ -104,18 +98,10 @@
 FXFT_Face CFX_FontMgr::FindSubstFont(const CFX_ByteString& face_name, FX_BOOL bTrueType,
                                      FX_DWORD flags, int weight, int italic_angle, int CharsetCP, CFX_SubstFont* pSubstFont)
 {
-    if (m_FTLibrary == NULL) {
+    if (!m_FTLibrary) {
         FXFT_Init_FreeType(&m_FTLibrary);
     }
-    if (m_pExtMapper) {
-        FXFT_Face face = m_pExtMapper->FindSubstFont(face_name, bTrueType, flags, weight, italic_angle,
-                         CharsetCP, pSubstFont);
-        if (face) {
-            return face;
-        }
-    }
-    return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight, italic_angle,
-                                           CharsetCP, pSubstFont);
+    return m_pBuiltinMapper->FindSubstFont(face_name, bTrueType, flags, weight, italic_angle, CharsetCP, pSubstFont);
 }
 FXFT_Face CFX_FontMgr::GetCachedFace(const CFX_ByteString& face_name,
                                      int weight, FX_BOOL bItalic, uint8_t*& pFontData)
@@ -471,13 +457,14 @@
     }
     return TRUE;
 }
-CFX_FontMapper::CFX_FontMapper()
+CFX_FontMapper::CFX_FontMapper(CFX_FontMgr* mgr)
+        : m_pFontInfo(nullptr),
+          m_bListLoaded(FALSE),
+          m_pFontEnumerator(nullptr),
+          m_pFontMgr(mgr)
 {
     FXSYS_memset(m_FoxitFaces, 0, sizeof m_FoxitFaces);
     m_MMFaces[0] = m_MMFaces[1] = NULL;
-    m_pFontInfo = NULL;
-    m_bListLoaded = FALSE;
-    m_pFontEnumerator = NULL;
 }
 CFX_FontMapper::~CFX_FontMapper()
 {