summaryrefslogtreecommitdiff
path: root/xfa/fgas/layout/fgas_textbreak.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-03-16 11:48:04 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-03-16 18:23:45 +0000
commitdb0cc520a3ea43e9a81f5e936616e27b0927ef2b (patch)
tree016cae3386e114a2446a6c1ce9cc03013f30b090 /xfa/fgas/layout/fgas_textbreak.cpp
parente533b93601c7e9eb328619681a78c188d1a89191 (diff)
downloadpdfium-db0cc520a3ea43e9a81f5e936616e27b0927ef2b.tar.xz
Simplify TxtBreak AppendChar
Remove the array of AppendChar methods and use a switch instead to clarify the code. Change-Id: I68809caf70919bf6d8dab16bfd3fa2e9ff2b7f90 Reviewed-on: https://pdfium-review.googlesource.com/3062 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fgas/layout/fgas_textbreak.cpp')
-rw-r--r--xfa/fgas/layout/fgas_textbreak.cpp52
1 files changed, 31 insertions, 21 deletions
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 6e36da1b68..8fc425f631 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -16,19 +16,6 @@
namespace {
-typedef CFX_BreakType (CFX_TxtBreak::*FX_TxtBreak_LPFAppendChar)(
- CFX_Char* pCurChar);
-const FX_TxtBreak_LPFAppendChar g_FX_TxtBreak_lpfAppendChar[16] = {
- &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Tab,
- &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Control,
- &CFX_TxtBreak::AppendChar_Combination, &CFX_TxtBreak::AppendChar_Others,
- &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Arabic,
- &CFX_TxtBreak::AppendChar_Arabic, &CFX_TxtBreak::AppendChar_Arabic,
- &CFX_TxtBreak::AppendChar_Arabic, &CFX_TxtBreak::AppendChar_Arabic,
- &CFX_TxtBreak::AppendChar_Arabic, &CFX_TxtBreak::AppendChar_Others,
- &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Others,
-};
-
bool IsCtrlCode(wchar_t ch) {
uint32_t dwRet = (FX_GetUnicodeProperties(ch) & FX_CHARTYPEBITSMASK);
return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control;
@@ -107,7 +94,7 @@ void CFX_TxtBreak::AppendChar_PageLoad(CFX_Char* pCurChar, uint32_t dwProps) {
pCurChar->m_dwCharStyles = m_dwContextCharStyles;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar) {
+void CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar) {
wchar_t wch = pCurChar->m_wCharCode;
wchar_t wForm;
int32_t iCharWidth = 0;
@@ -145,12 +132,10 @@ CFX_BreakType CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar) {
iCharWidth = iCharWidth * m_iHorizontalScale / 100;
}
pCurChar->m_iCharWidth = -iCharWidth;
- return CFX_BreakType::None;
}
-CFX_BreakType CFX_TxtBreak::AppendChar_Tab(CFX_Char* pCurChar) {
+void CFX_TxtBreak::AppendChar_Tab(CFX_Char* pCurChar) {
m_eCharType = FX_CHARTYPE_Tab;
- return CFX_BreakType::None;
}
CFX_BreakType CFX_TxtBreak::AppendChar_Control(CFX_Char* pCurChar) {
@@ -274,7 +259,7 @@ CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) {
pCurChar->m_dwCharStyles = 0;
pCurChar->m_iCharWidth = 0;
pCurChar->m_iHorizontalScale = m_iHorizontalScale;
- pCurChar->m_iVerticalScale = 100;
+ pCurChar->m_iVerticalScale = m_iVerticalScale;
pCurChar->m_dwStatus = CFX_BreakType::None;
pCurChar->m_iBidiClass = 0;
pCurChar->m_iBidiLevel = 0;
@@ -294,9 +279,34 @@ CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) {
pCurChar = &m_pCurLine->m_LineChars[iCount - 1];
}
- CFX_BreakType dwRet2 =
- (this->*g_FX_TxtBreak_lpfAppendChar[chartype >> FX_CHARTYPEBITS])(
- pCurChar);
+ CFX_BreakType dwRet2 = CFX_BreakType::None;
+ switch (chartype) {
+ case FX_CHARTYPE_Tab:
+ AppendChar_Tab(pCurChar);
+ break;
+ case FX_CHARTYPE_Control:
+ dwRet2 = AppendChar_Control(pCurChar);
+ break;
+ case FX_CHARTYPE_Combination:
+ AppendChar_Combination(pCurChar);
+ break;
+ case FX_CHARTYPE_ArabicAlef:
+ case FX_CHARTYPE_ArabicSpecial:
+ case FX_CHARTYPE_ArabicDistortion:
+ case FX_CHARTYPE_ArabicNormal:
+ case FX_CHARTYPE_ArabicForm:
+ case FX_CHARTYPE_Arabic:
+ dwRet2 = AppendChar_Arabic(pCurChar);
+ break;
+ case FX_CHARTYPE_Unknown:
+ case FX_CHARTYPE_Space:
+ case FX_CHARTYPE_Numeric:
+ case FX_CHARTYPE_Normal:
+ default:
+ dwRet2 = AppendChar_Others(pCurChar);
+ break;
+ }
+
return std::max(dwRet1, dwRet2);
}