CFX_ArabicChar contains only static methods, no need to instantiate.

Review-Url: https://codereview.chromium.org/1954593004
diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp
index 191350e..01a1a2a 100644
--- a/core/fxcrt/fx_arabic.cpp
+++ b/core/fxcrt/fx_arabic.cpp
@@ -114,6 +114,23 @@
     {0x064F, 0xFC61}, {0x0650, 0xFC62},
 };
 
+const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC,
+                                 FX_WCHAR& wChar,
+                                 FX_CHARTYPE& eType) {
+  if (!pTC) {
+    eType = FX_CHARTYPE_Unknown;
+    wChar = 0xFEFF;
+    return nullptr;
+  }
+  eType = (FX_CHARTYPE)pTC->GetCharType();
+  wChar = (FX_WCHAR)pTC->m_wCharCode;
+  const FX_ARBFORMTABLE* pFT = FX_GetArabicFormTable(wChar);
+  if (!pFT || eType >= FX_CHARTYPE_ArabicNormal)
+    eType = FX_CHARTYPE_Unknown;
+
+  return pFT;
+}
+
 }  // namespace
 
 const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode) {
@@ -145,26 +162,30 @@
   return shadda;
 }
 
-FX_BOOL CFX_ArabicChar::IsArabicChar(FX_WCHAR wch) const {
+namespace pdfium {
+namespace arabic {
+
+bool IsArabicChar(FX_WCHAR wch) {
   uint32_t dwRet =
       kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK;
   return dwRet >= FX_CHARTYPE_ArabicAlef;
 }
-FX_BOOL CFX_ArabicChar::IsArabicFormChar(FX_WCHAR wch) const {
+
+bool IsArabicFormChar(FX_WCHAR wch) {
   return (kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK) ==
          FX_CHARTYPE_ArabicForm;
 }
-FX_WCHAR CFX_ArabicChar::GetFormChar(FX_WCHAR wch,
-                                     FX_WCHAR prev,
-                                     FX_WCHAR next) const {
+
+FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev, FX_WCHAR next) {
   CFX_Char c(wch, kTextLayoutCodeProperties[(uint16_t)wch]);
   CFX_Char p(prev, kTextLayoutCodeProperties[(uint16_t)prev]);
   CFX_Char n(next, kTextLayoutCodeProperties[(uint16_t)next]);
   return GetFormChar(&c, &p, &n);
 }
-FX_WCHAR CFX_ArabicChar::GetFormChar(const CFX_Char* cur,
-                                     const CFX_Char* prev,
-                                     const CFX_Char* next) const {
+
+FX_WCHAR GetFormChar(const CFX_Char* cur,
+                     const CFX_Char* prev,
+                     const CFX_Char* next) {
   FX_CHARTYPE eCur;
   FX_WCHAR wCur;
   const FX_ARBFORMTABLE* ft = ParseChar(cur, wCur, eCur);
@@ -184,37 +205,22 @@
   if (ePrev < FX_CHARTYPE_ArabicAlef) {
     if (bAlef) {
       return FX_GetArabicFromAlefTable(wNext);
-    } else {
-      return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
     }
-  } else {
-    if (bAlef) {
-      wCur = FX_GetArabicFromAlefTable(wNext);
-      return (ePrev != FX_CHARTYPE_ArabicDistortion) ? wCur : ++wCur;
-    } else if (ePrev == FX_CHARTYPE_ArabicAlef ||
-               ePrev == FX_CHARTYPE_ArabicSpecial) {
-      return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
-    } else {
-      return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wFinal : ft->wMedial;
-    }
+    return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
   }
+  if (bAlef) {
+    wCur = FX_GetArabicFromAlefTable(wNext);
+    return (ePrev != FX_CHARTYPE_ArabicDistortion) ? wCur : ++wCur;
+  }
+  if (ePrev == FX_CHARTYPE_ArabicAlef || ePrev == FX_CHARTYPE_ArabicSpecial) {
+    return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wIsolated : ft->wInitial;
+  }
+  return (eNext < FX_CHARTYPE_ArabicAlef) ? ft->wFinal : ft->wMedial;
 }
-const FX_ARBFORMTABLE* CFX_ArabicChar::ParseChar(const CFX_Char* pTC,
-                                                 FX_WCHAR& wChar,
-                                                 FX_CHARTYPE& eType) const {
-  if (pTC == NULL) {
-    eType = FX_CHARTYPE_Unknown;
-    wChar = 0xFEFF;
-    return NULL;
-  }
-  eType = (FX_CHARTYPE)pTC->GetCharType();
-  wChar = (FX_WCHAR)pTC->m_wCharCode;
-  const FX_ARBFORMTABLE* pFT = FX_GetArabicFormTable(wChar);
-  if (pFT == NULL || eType >= FX_CHARTYPE_ArabicNormal) {
-    eType = FX_CHARTYPE_Unknown;
-  }
-  return pFT;
-}
+
+}  // namespace arabic
+}  // namespace pdfium
+
 void FX_BidiReverseString(CFX_WideString& wsText,
                           int32_t iStart,
                           int32_t iCount) {
diff --git a/core/fxcrt/include/fx_arabic.h b/core/fxcrt/include/fx_arabic.h
index 96fa795..2617d189 100644
--- a/core/fxcrt/include/fx_arabic.h
+++ b/core/fxcrt/include/fx_arabic.h
@@ -14,25 +14,18 @@
 #define FX_BidiGetDeferredType(a) (((a) >> 4) & 0x0F)
 #define FX_BidiGetResolvedType(a) ((a)&0x0F)
 
-class CFX_ArabicChar {
- public:
-  void Release() { delete this; }
+namespace pdfium {
+namespace arabic {
 
-  FX_BOOL IsArabicChar(FX_WCHAR wch) const;
-  FX_BOOL IsArabicFormChar(FX_WCHAR wch) const;
+bool IsArabicChar(FX_WCHAR wch);
+bool IsArabicFormChar(FX_WCHAR wch);
+FX_WCHAR GetFormChar(FX_WCHAR wch, FX_WCHAR prev = 0, FX_WCHAR next = 0);
+FX_WCHAR GetFormChar(const CFX_Char* cur,
+                     const CFX_Char* prev,
+                     const CFX_Char* next);
 
-  FX_WCHAR GetFormChar(FX_WCHAR wch,
-                       FX_WCHAR prev = 0,
-                       FX_WCHAR next = 0) const;
-  FX_WCHAR GetFormChar(const CFX_Char* cur,
-                       const CFX_Char* prev,
-                       const CFX_Char* next) const;
-
- protected:
-  const FX_ARBFORMTABLE* ParseChar(const CFX_Char* pTC,
-                                   FX_WCHAR& wChar,
-                                   FX_CHARTYPE& eType) const;
-};
+}  // namespace arabic
+}  // namespace pdfium
 
 void FX_BidiReverseString(CFX_WideString& wsText,
                           int32_t iStart,
diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp
index b44af96..aaef7ae 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.cpp
+++ b/xfa/fgas/layout/fgas_rtfbreak.cpp
@@ -15,7 +15,6 @@
 
 CFX_RTFBreak::CFX_RTFBreak(uint32_t dwPolicies)
     : m_dwPolicies(dwPolicies),
-      m_pArabicChar(NULL),
       m_iBoundaryStart(0),
       m_iBoundaryEnd(2000000),
       m_dwLayoutStyles(0),
@@ -50,13 +49,11 @@
       m_pCurLine(NULL),
       m_iReady(0),
       m_iTolerance(0) {
-  m_pArabicChar = new CFX_ArabicChar;
   m_pCurLine = &m_RTFLine1;
 }
 CFX_RTFBreak::~CFX_RTFBreak() {
   Reset();
   m_PositionedTabs.RemoveAll();
-  m_pArabicChar->Release();
   if (m_pUserData != NULL) {
     m_pUserData->Release();
   }
@@ -343,7 +340,7 @@
     &CFX_RTFBreak::AppendChar_Others,      &CFX_RTFBreak::AppendChar_Others,
 };
 uint32_t CFX_RTFBreak::AppendChar(FX_WCHAR wch) {
-  ASSERT(m_pFont != NULL && m_pCurLine != NULL && m_pArabicChar != NULL);
+  ASSERT(m_pFont && m_pCurLine);
   if (m_bCharCode) {
     return AppendChar_CharCode(wch);
   }
@@ -520,7 +517,7 @@
     if (pLastChar != NULL) {
       iLineWidth -= pLastChar->m_iCharWidth;
       CFX_RTFChar* pPrevChar = GetLastChar(2);
-      wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar);
+      wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar);
       bAlef = (wForm == 0xFEFF &&
                pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef);
       int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation;
@@ -544,8 +541,8 @@
       iCharWidth = 0;
     }
   }
-  wForm =
-      m_pArabicChar->GetFormChar(pCurChar, (bAlef ? NULL : pLastChar), NULL);
+  wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? nullptr : pLastChar,
+                                      nullptr);
   if (m_bVertical != FX_IsOdd(iRotation)) {
     iCharWidth = 1000;
   } else if (!m_pFont->GetCharWidth(wForm, iCharWidth, m_bCharCode) &&
@@ -1268,7 +1265,7 @@
             } else {
               wNext = 0xFEFF;
             }
-            wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext);
+            wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext);
           } else if (bRTLPiece || bVerticalChar) {
             wForm = FX_GetMirrorChar(wch, dwProps, bRTLPiece, bVerticalChar);
           } else if (dwCharType == FX_CHARTYPE_Numeric && bArabicNumber) {
diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h
index 95de85b..d595ad3 100644
--- a/xfa/fgas/layout/fgas_rtfbreak.h
+++ b/xfa/fgas/layout/fgas_rtfbreak.h
@@ -14,7 +14,6 @@
 #include "xfa/fgas/layout/fgas_textbreak.h"
 #include "xfa/fgas/layout/fgas_unicode.h"
 
-class CFX_ArabicChar;
 class IFX_Unknown;
 class IFX_Font;
 
@@ -293,7 +292,6 @@
 
  protected:
   uint32_t m_dwPolicies;
-  CFX_ArabicChar* m_pArabicChar;
   int32_t m_iBoundaryStart;
   int32_t m_iBoundaryEnd;
   uint32_t m_dwLayoutStyles;
diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp
index 86fecbe..4b4ef1f 100644
--- a/xfa/fgas/layout/fgas_textbreak.cpp
+++ b/xfa/fgas/layout/fgas_textbreak.cpp
@@ -16,7 +16,6 @@
 
 CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies)
     : m_dwPolicies(dwPolicies),
-      m_pArabicChar(NULL),
       m_iLineWidth(2000000),
       m_dwLayoutStyles(0),
       m_bVertical(FALSE),
@@ -51,7 +50,6 @@
       m_iVerScale(100),
       m_iCharSpace(0) {
   m_bPagination = (m_dwPolicies & FX_TXTBREAKPOLICY_Pagination) != 0;
-  m_pArabicChar = new CFX_ArabicChar;
   if (m_bPagination) {
     m_pTxtLine1 = new CFX_TxtLine(sizeof(CFX_Char));
     m_pTxtLine2 = new CFX_TxtLine(sizeof(CFX_Char));
@@ -66,7 +64,6 @@
   Reset();
   delete m_pTxtLine1;
   delete m_pTxtLine2;
-  m_pArabicChar->Release();
 }
 void CFX_TxtBreak::SetLineWidth(FX_FLOAT fLineWidth) {
   m_iLineWidth = FXSYS_round(fLineWidth * 20000.0f);
@@ -465,7 +462,7 @@
         iLineWidth -= iCharWidth;
       }
       CFX_Char* pPrevChar = GetLastChar(2);
-      wForm = m_pArabicChar->GetFormChar(pLastChar, pPrevChar, pCurChar);
+      wForm = pdfium::arabic::GetFormChar(pLastChar, pPrevChar, pCurChar);
       bAlef = (wForm == 0xFEFF &&
                pLastChar->GetCharType() == FX_CHARTYPE_ArabicAlef);
       int32_t iLastRotation = pLastChar->m_nRotation + m_iLineRotation;
@@ -488,7 +485,7 @@
     }
   }
   m_dwCharType = dwType;
-  wForm = m_pArabicChar->GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL);
+  wForm = pdfium::arabic::GetFormChar(pCurChar, bAlef ? NULL : pLastChar, NULL);
   if (m_bCombText) {
     iCharWidth = m_iCombWidth;
   } else {
@@ -1268,7 +1265,7 @@
       } else {
         wNext = 0xFEFF;
       }
-      wForm = m_pArabicChar->GetFormChar(wch, wPrev, wNext);
+      wForm = pdfium::arabic::GetFormChar(wch, wPrev, wNext);
       bLam = (wPrev == 0x0644 && wch == 0x0644 && wNext == 0x0647);
     } else if (dwCharType == FX_CHARTYPE_Combination) {
       wForm = wch;
diff --git a/xfa/fgas/layout/fgas_textbreak.h b/xfa/fgas/layout/fgas_textbreak.h
index 41bd8f4..6d961f2 100644
--- a/xfa/fgas/layout/fgas_textbreak.h
+++ b/xfa/fgas/layout/fgas_textbreak.h
@@ -12,7 +12,6 @@
 #include "xfa/fgas/crt/fgas_utils.h"
 #include "xfa/fgas/layout/fgas_unicode.h"
 
-class CFX_ArabicChar;
 class CFX_Char;
 class CFX_TxtChar;
 class CFX_TxtPiece;
@@ -270,7 +269,6 @@
  protected:
   uint32_t m_dwPolicies;
   FX_BOOL m_bPagination;
-  CFX_ArabicChar* m_pArabicChar;
   int32_t m_iLineWidth;
   uint32_t m_dwLayoutStyles;
   FX_BOOL m_bVertical;