summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app/xfa_fontmgr.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-25 11:23:43 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-25 11:23:43 -0700
commitb6853cfe4fd1ee089dfdd0cb09bbc4063532ef82 (patch)
tree1404031e845c8b4b09d5a68fd81f09a7d2865d59 /xfa/fxfa/app/xfa_fontmgr.cpp
parent2a8a20cde4c8e2294f6868bb097fe450960a709f (diff)
downloadpdfium-b6853cfe4fd1ee089dfdd0cb09bbc4063532ef82.tar.xz
Pass CFX_*StringCs to FX_HashCode_GETA and _GETW hash functions.
Too many calls were of the form fn(x.c_str(), x.GetLength()) which is an anti-pattern given the StringC classes which tie these together. There are a few places where explicit CFX_*StringCs are constructed, but this can be avoided by changing the args to these functions in the same manner. Removed String_ from name of functions since it added little value. Also removed default argument. Review URL: https://codereview.chromium.org/1919563002
Diffstat (limited to 'xfa/fxfa/app/xfa_fontmgr.cpp')
-rw-r--r--xfa/fxfa/app/xfa_fontmgr.cpp25
1 files changed, 5 insertions, 20 deletions
diff --git a/xfa/fxfa/app/xfa_fontmgr.cpp b/xfa/fxfa/app/xfa_fontmgr.cpp
index 72952a7bd9..02b44be789 100644
--- a/xfa/fxfa/app/xfa_fontmgr.cpp
+++ b/xfa/fxfa/app/xfa_fontmgr.cpp
@@ -1694,12 +1694,7 @@ static const XFA_FONTINFO g_XFAFontsMap[] = {
void XFA_LocalFontNameToEnglishName(const CFX_WideStringC& wsLocalName,
CFX_WideString& wsEnglishName) {
wsEnglishName = wsLocalName;
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_
- uint32_t dwLocalNameHash = FX_HashCode_String_GetW(
- wsLocalName.c_str(), wsLocalName.GetLength(), TRUE);
+ uint32_t dwLocalNameHash = FX_HashCode_GetW(wsLocalName, true);
int32_t iStart = 0;
int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1;
int32_t iMid = 0;
@@ -1715,18 +1710,13 @@ void XFA_LocalFontNameToEnglishName(const CFX_WideStringC& wsLocalName,
iEnd = iMid - 1;
}
} while (iEnd >= iStart);
-#endif
}
const XFA_FONTINFO* XFA_GetFontINFOByFontName(
const CFX_WideStringC& wsFontName) {
-#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ || \
- _FXM_PLATFORM_ == _FXM_PLATFORM_ANDROID_
CFX_WideString wsFontNameTemp = wsFontName;
wsFontNameTemp.Remove(L' ');
- uint32_t dwCurFontNameHash = FX_HashCode_String_GetW(
- wsFontNameTemp.c_str(), wsFontNameTemp.GetLength(), TRUE);
+ uint32_t dwCurFontNameHash =
+ FX_HashCode_GetW(wsFontNameTemp.AsStringC(), true);
int32_t iStart = 0;
int32_t iEnd = sizeof(g_XFAFontsMap) / sizeof(XFA_FONTINFO) - 1;
int32_t iMid = 0;
@@ -1744,9 +1734,6 @@ const XFA_FONTINFO* XFA_GetFontINFOByFontName(
}
} while (iEnd >= iStart);
return pFontInfo;
-#else
- return NULL;
-#endif
}
CXFA_DefFontMgr::~CXFA_DefFontMgr() {
@@ -1891,8 +1878,7 @@ IFX_Font* CXFA_PDFFontMgr::GetFont(const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
CPDF_Font** pPDFFont,
FX_BOOL bStrictMatch) {
- uint32_t dwHashCode =
- FX_HashCode_String_GetW(wsFontFamily.c_str(), wsFontFamily.GetLength());
+ uint32_t dwHashCode = FX_HashCode_GetW(wsFontFamily, false);
CFX_ByteString strKey;
strKey.Format("%u%u", dwHashCode, dwFontStyles);
auto it = m_FontMap.find(strKey);
@@ -2018,8 +2004,7 @@ IFX_Font* CXFA_FontMgr::GetFont(CXFA_FFDoc* hDoc,
const CFX_WideStringC& wsFontFamily,
uint32_t dwFontStyles,
uint16_t wCodePage) {
- uint32_t dwHash = FX_HashCode_String_GetW(wsFontFamily.c_str(),
- wsFontFamily.GetLength(), FALSE);
+ uint32_t dwHash = FX_HashCode_GetW(wsFontFamily, false);
CFX_ByteString bsKey;
bsKey.Format("%u%u%u", dwHash, dwFontStyles, wCodePage);
auto it = m_FontMap.find(bsKey);