Make CFGAS_DefaultFontManager a class with only static methods.
It has no member variables.
Change-Id: I25b333e201d76e90d25e3f526cf23bccd2b4687a
Reviewed-on: https://pdfium-review.googlesource.com/c/43315
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.cpp b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
index fcaf6fd..4380c4e 100644
--- a/xfa/fgas/font/cfgas_defaultfontmanager.cpp
+++ b/xfa/fgas/font/cfgas_defaultfontmanager.cpp
@@ -9,10 +9,7 @@
#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fgas/font/fgas_fontutils.h"
-CFGAS_DefaultFontManager::CFGAS_DefaultFontManager() {}
-
-CFGAS_DefaultFontManager::~CFGAS_DefaultFontManager() {}
-
+// static
RetainPtr<CFGAS_GEFont> CFGAS_DefaultFontManager::GetFont(
CFGAS_FontMgr* pFontMgr,
const WideStringView& wsFontFamily,
@@ -55,6 +52,7 @@
return pFont;
}
+// static
RetainPtr<CFGAS_GEFont> CFGAS_DefaultFontManager::GetDefaultFont(
CFGAS_FontMgr* pFontMgr,
const WideStringView& wsFontFamily,
diff --git a/xfa/fgas/font/cfgas_defaultfontmanager.h b/xfa/fgas/font/cfgas_defaultfontmanager.h
index 3d723d5..e1b36be 100644
--- a/xfa/fgas/font/cfgas_defaultfontmanager.h
+++ b/xfa/fgas/font/cfgas_defaultfontmanager.h
@@ -15,15 +15,17 @@
class CFGAS_DefaultFontManager {
public:
- CFGAS_DefaultFontManager();
- ~CFGAS_DefaultFontManager();
-
- RetainPtr<CFGAS_GEFont> GetFont(CFGAS_FontMgr* pFontMgr,
- const WideStringView& wsFontFamily,
- uint32_t dwFontStyles);
- RetainPtr<CFGAS_GEFont> GetDefaultFont(CFGAS_FontMgr* pFontMgr,
+ static RetainPtr<CFGAS_GEFont> GetFont(CFGAS_FontMgr* pFontMgr,
const WideStringView& wsFontFamily,
uint32_t dwFontStyles);
+ static RetainPtr<CFGAS_GEFont> GetDefaultFont(
+ CFGAS_FontMgr* pFontMgr,
+ const WideStringView& wsFontFamily,
+ uint32_t dwFontStyles);
+
+ CFGAS_DefaultFontManager() = delete;
+ CFGAS_DefaultFontManager(const CFGAS_DefaultFontManager&) = delete;
+ CFGAS_DefaultFontManager& operator=(const CFGAS_DefaultFontManager&) = delete;
};
#endif // XFA_FGAS_FONT_CFGAS_DEFAULTFONTMANAGER_H_
diff --git a/xfa/fxfa/cxfa_ffapp.h b/xfa/fxfa/cxfa_ffapp.h
index a729560..4a93780 100644
--- a/xfa/fxfa/cxfa_ffapp.h
+++ b/xfa/fxfa/cxfa_ffapp.h
@@ -17,7 +17,6 @@
#include "xfa/fxfa/cxfa_fontmgr.h"
#include "xfa/fxfa/fxfa.h"
-class CFGAS_DefaultFontManager;
class CFGAS_FontMgr;
class CFWL_WidgetMgr;
class CPDF_Document;
@@ -33,8 +32,6 @@
explicit CXFA_FFApp(IXFA_AppProvider* pProvider);
~CXFA_FFApp();
- void SetDefaultFontMgr(std::unique_ptr<CFGAS_DefaultFontManager> pFontMgr);
-
CXFA_FWLAdapterWidgetMgr* GetFWLAdapterWidgetMgr();
CFWL_WidgetMgr* GetFWLWidgetMgr() const { return m_pFWLApp->GetWidgetMgr(); }
diff --git a/xfa/fxfa/cxfa_fontmgr.cpp b/xfa/fxfa/cxfa_fontmgr.cpp
index 7abf720..92fe77a 100644
--- a/xfa/fxfa/cxfa_fontmgr.cpp
+++ b/xfa/fxfa/cxfa_fontmgr.cpp
@@ -16,6 +16,7 @@
#include "core/fxge/cfx_fontmgr.h"
#include "core/fxge/cfx_gemodule.h"
#include "third_party/base/ptr_util.h"
+#include "xfa/fgas/font/cfgas_defaultfontmanager.h"
#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fgas/font/fgas_fontutils.h"
#include "xfa/fxfa/cxfa_ffapp.h"
@@ -44,9 +45,10 @@
if (pFont)
return pFont;
}
- if (!pFont)
- pFont = m_pDefFontMgr.GetFont(hDoc->GetApp()->GetFDEFontMgr(), wsFontFamily,
- dwFontStyles);
+ if (!pFont) {
+ pFont = CFGAS_DefaultFontManager::GetFont(hDoc->GetApp()->GetFDEFontMgr(),
+ wsFontFamily, dwFontStyles);
+ }
if (!pFont && pMgr) {
pFont = pMgr->GetFont(wsEnglishName.AsStringView(), dwFontStyles, false);
@@ -55,8 +57,8 @@
}
if (!pFont) {
- pFont = m_pDefFontMgr.GetDefaultFont(hDoc->GetApp()->GetFDEFontMgr(),
- wsFontFamily, dwFontStyles);
+ pFont = CFGAS_DefaultFontManager::GetDefaultFont(
+ hDoc->GetApp()->GetFDEFontMgr(), wsFontFamily, dwFontStyles);
}
if (!pFont) {
diff --git a/xfa/fxfa/cxfa_fontmgr.h b/xfa/fxfa/cxfa_fontmgr.h
index c009598..082c064 100644
--- a/xfa/fxfa/cxfa_fontmgr.h
+++ b/xfa/fxfa/cxfa_fontmgr.h
@@ -10,7 +10,6 @@
#include <map>
#include "core/fxcrt/fx_string.h"
-#include "xfa/fgas/font/cfgas_defaultfontmanager.h"
class CFGAS_GEFont;
class CXFA_FFDoc;
@@ -25,7 +24,6 @@
uint32_t dwFontStyles);
private:
- CFGAS_DefaultFontManager m_pDefFontMgr;
std::map<ByteString, RetainPtr<CFGAS_GEFont>> m_FontMap;
};