From fc9b9880c79bd9e7864c009aad48c9b27bb352a0 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 7 Mar 2017 09:18:18 -0500 Subject: Cleanup text code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This Cl removes unused defines and methods. It also merges fx_arb into fx_arabic as the arb methods are only used in the arabic file and they are always included together. Change-Id: I1e6f75d5cb5f5bcc8db3b54cb2a14d284da5b7b1 Reviewed-on: https://pdfium-review.googlesource.com/2899 Commit-Queue: dsinclair Reviewed-by: Tom Sepez Reviewed-by: Nicolás Peña --- BUILD.gn | 1 - core/fxcrt/fx_arabic.cpp | 11 ---- core/fxcrt/fx_arabic.h | 117 +++++++++++++++++++------------------ core/fxcrt/fx_arb.h | 51 ---------------- core/fxcrt/fx_ucd.h | 79 ++++++++++++------------- core/fxcrt/fx_unicode.cpp | 7 --- xfa/fgas/layout/fgas_rtfbreak.cpp | 9 +-- xfa/fgas/layout/fgas_rtfbreak.h | 2 - xfa/fgas/layout/fgas_textbreak.cpp | 8 ++- 9 files changed, 109 insertions(+), 176 deletions(-) delete mode 100644 core/fxcrt/fx_arb.h diff --git a/BUILD.gn b/BUILD.gn index 66a18bbc0c..8656ee7fb5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -796,7 +796,6 @@ static_library("fxcrt") { sources += [ "core/fxcrt/fx_arabic.cpp", "core/fxcrt/fx_arabic.h", - "core/fxcrt/fx_arb.h", ] } } diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp index 108c6c19ac..29e6e437e8 100644 --- a/core/fxcrt/fx_arabic.cpp +++ b/core/fxcrt/fx_arabic.cpp @@ -286,17 +286,6 @@ FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda) { namespace pdfium { namespace arabic { -bool IsArabicChar(FX_WCHAR wch) { - uint32_t dwRet = - kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK; - return dwRet >= FX_CHARTYPE_ArabicAlef; -} - -bool IsArabicFormChar(FX_WCHAR wch) { - return (kTextLayoutCodeProperties[(uint16_t)wch] & FX_CHARTYPEBITSMASK) == - FX_CHARTYPE_ArabicForm; -} - 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]); diff --git a/core/fxcrt/fx_arabic.h b/core/fxcrt/fx_arabic.h index e7ba079f43..9f6ec50ef6 100644 --- a/core/fxcrt/fx_arabic.h +++ b/core/fxcrt/fx_arabic.h @@ -7,7 +7,10 @@ #ifndef CORE_FXCRT_FX_ARABIC_H_ #define CORE_FXCRT_FX_ARABIC_H_ -#include "core/fxcrt/fx_arb.h" +#include + +#include "core/fxcrt/fx_system.h" +#include "core/fxcrt/fx_ucd.h" #define FX_BIDIMAXLEVEL 61 #define FX_BidiDirection(a) (FX_IsOdd(a) ? FX_BIDICLASS_R : FX_BIDICLASS_L) @@ -17,9 +20,7 @@ namespace pdfium { namespace arabic { -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(FX_WCHAR wch, FX_WCHAR prev, FX_WCHAR next); FX_WCHAR GetFormChar(const CFX_Char* cur, const CFX_Char* prev, const CFX_Char* next); @@ -46,47 +47,27 @@ int32_t FX_BidiResolveExplicit(int32_t iBaseLevel, int32_t iNest = 0); enum FX_BIDIWEAKSTATE { - FX_BIDIWEAKSTATE_xa = 0, - FX_BIDIWEAKSTATE_xr, - FX_BIDIWEAKSTATE_xl, - FX_BIDIWEAKSTATE_ao, - FX_BIDIWEAKSTATE_ro, - FX_BIDIWEAKSTATE_lo, - FX_BIDIWEAKSTATE_rt, - FX_BIDIWEAKSTATE_lt, - FX_BIDIWEAKSTATE_cn, - FX_BIDIWEAKSTATE_ra, - FX_BIDIWEAKSTATE_re, - FX_BIDIWEAKSTATE_la, - FX_BIDIWEAKSTATE_le, - FX_BIDIWEAKSTATE_ac, - FX_BIDIWEAKSTATE_rc, - FX_BIDIWEAKSTATE_rs, - FX_BIDIWEAKSTATE_lc, - FX_BIDIWEAKSTATE_ls, - FX_BIDIWEAKSTATE_ret, - FX_BIDIWEAKSTATE_let, + FX_BWSxa = 0, + FX_BWSxr, + FX_BWSxl, + FX_BWSao, + FX_BWSro, + FX_BWSlo, + FX_BWSrt, + FX_BWSlt, + FX_BWScn, + FX_BWSra, + FX_BWSre, + FX_BWSla, + FX_BWSle, + FX_BWSac, + FX_BWSrc, + FX_BWSrs, + FX_BWSlc, + FX_BWSls, + FX_BWSret, + FX_BWSlet }; -#define FX_BWSxa FX_BIDIWEAKSTATE_xa -#define FX_BWSxr FX_BIDIWEAKSTATE_xr -#define FX_BWSxl FX_BIDIWEAKSTATE_xl -#define FX_BWSao FX_BIDIWEAKSTATE_ao -#define FX_BWSro FX_BIDIWEAKSTATE_ro -#define FX_BWSlo FX_BIDIWEAKSTATE_lo -#define FX_BWSrt FX_BIDIWEAKSTATE_rt -#define FX_BWSlt FX_BIDIWEAKSTATE_lt -#define FX_BWScn FX_BIDIWEAKSTATE_cn -#define FX_BWSra FX_BIDIWEAKSTATE_ra -#define FX_BWSre FX_BIDIWEAKSTATE_re -#define FX_BWSla FX_BIDIWEAKSTATE_la -#define FX_BWSle FX_BIDIWEAKSTATE_le -#define FX_BWSac FX_BIDIWEAKSTATE_ac -#define FX_BWSrc FX_BIDIWEAKSTATE_rc -#define FX_BWSrs FX_BIDIWEAKSTATE_rs -#define FX_BWSlc FX_BIDIWEAKSTATE_lc -#define FX_BWSls FX_BIDIWEAKSTATE_ls -#define FX_BWSret FX_BIDIWEAKSTATE_ret -#define FX_BWSlet FX_BIDIWEAKSTATE_let enum FX_BIDIWEAKACTION { FX_BIDIWEAKACTION_IX = 0x100, @@ -139,19 +120,14 @@ void FX_BidiResolveWeak(int32_t iBaseLevel, CFX_ArrayTemplate& classes, CFX_ArrayTemplate& levels); enum FX_BIDINEUTRALSTATE { - FX_BIDINEUTRALSTATE_r = 0, - FX_BIDINEUTRALSTATE_l, - FX_BIDINEUTRALSTATE_rn, - FX_BIDINEUTRALSTATE_ln, - FX_BIDINEUTRALSTATE_a, - FX_BIDINEUTRALSTATE_na, + FX_BNSr = 0, + FX_BNSl, + FX_BNSrn, + FX_BNSln, + FX_BNSa, + FX_BNSna }; -#define FX_BNSr FX_BIDINEUTRALSTATE_r -#define FX_BNSl FX_BIDINEUTRALSTATE_l -#define FX_BNSrn FX_BIDINEUTRALSTATE_rn -#define FX_BNSln FX_BIDINEUTRALSTATE_ln -#define FX_BNSa FX_BIDINEUTRALSTATE_a -#define FX_BNSna FX_BIDINEUTRALSTATE_na + enum FX_BIDINEUTRALACTION { FX_BIDINEUTRALACTION_nL = FX_BIDICLASS_L, FX_BIDINEUTRALACTION_En = (FX_BIDICLASS_AN << 4), @@ -166,6 +142,35 @@ enum FX_BIDINEUTRALACTION { #define FX_BNALn FX_BIDINEUTRALACTION_Ln #define FX_BNAIn FX_BIDINEUTRALACTION_In #define FX_BNALnL FX_BIDINEUTRALACTION_LnL + +struct FX_ARBFORMTABLE { + uint16_t wIsolated; + uint16_t wFinal; + uint16_t wInitial; + uint16_t wMedial; +}; + +struct FX_ARAALEF { + uint16_t wAlef; + uint16_t wIsolated; +}; + +struct FX_ARASHADDA { + uint16_t wShadda; + uint16_t wIsolated; +}; + +const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode); +FX_WCHAR FX_GetArabicFromAlefTable(FX_WCHAR alef); +FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda); + +void FX_BidiLine(std::vector& chars, + int32_t iCount, + int32_t iBaseLevel = 0); +void FX_BidiLine(std::vector& chars, + int32_t iCount, + int32_t iBaseLevel = 0); + int32_t FX_BidiGetDeferredNeutrals(int32_t iAction, int32_t iLevel); int32_t FX_BidiGetResolvedNeutrals(int32_t iAction); void FX_BidiResolveNeutrals(int32_t iBaseLevel, diff --git a/core/fxcrt/fx_arb.h b/core/fxcrt/fx_arb.h deleted file mode 100644 index d24197c7e5..0000000000 --- a/core/fxcrt/fx_arb.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef CORE_FXCRT_FX_ARB_H_ -#define CORE_FXCRT_FX_ARB_H_ - -#include - -#include "core/fxcrt/fx_system.h" -#include "core/fxcrt/fx_ucd.h" - -struct FX_ARBFORMTABLE { - uint16_t wIsolated; - uint16_t wFinal; - uint16_t wInitial; - uint16_t wMedial; -}; - -struct FX_ARAALEF { - uint16_t wAlef; - uint16_t wIsolated; -}; - -struct FX_ARASHADDA { - uint16_t wShadda; - uint16_t wIsolated; -}; - -const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode); -FX_WCHAR FX_GetArabicFromAlefTable(FX_WCHAR alef); -FX_WCHAR FX_GetArabicFromShaddaTable(FX_WCHAR shadda); - -enum FX_ARBPOSITION { - FX_ARBPOSITION_Isolated = 0, - FX_ARBPOSITION_Final, - FX_ARBPOSITION_Initial, - FX_ARBPOSITION_Medial, -}; - -void FX_BidiLine(CFX_WideString& wsText, int32_t iBaseLevel = 0); -void FX_BidiLine(std::vector& chars, - int32_t iCount, - int32_t iBaseLevel = 0); -void FX_BidiLine(std::vector& chars, - int32_t iCount, - int32_t iBaseLevel = 0); - -#endif // CORE_FXCRT_FX_ARB_H_ diff --git a/core/fxcrt/fx_ucd.h b/core/fxcrt/fx_ucd.h index eb4bad097e..b07b387ece 100644 --- a/core/fxcrt/fx_ucd.h +++ b/core/fxcrt/fx_ucd.h @@ -49,46 +49,48 @@ uint32_t FX_GetUnicodeProperties(FX_WCHAR wch); FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, bool bRTL, bool bVertical); #ifdef PDF_ENABLE_XFA + +// As defined in http://www.unicode.org/reports/tr14/ enum FX_CHARBREAKPROP { - FX_CBP_OP = 0, - FX_CBP_CL = 1, - FX_CBP_QU = 2, - FX_CBP_GL = 3, - FX_CBP_NS = 4, - FX_CBP_EX = 5, - FX_CBP_SY = 6, - FX_CBP_IS = 7, - FX_CBP_PR = 8, - FX_CBP_PO = 9, - FX_CBP_NU = 10, - FX_CBP_AL = 11, - FX_CBP_ID = 12, - FX_CBP_IN = 13, - FX_CBP_HY = 14, - FX_CBP_BA = 15, - FX_CBP_BB = 16, - FX_CBP_B2 = 17, - FX_CBP_ZW = 18, - FX_CBP_CM = 19, - FX_CBP_WJ = 20, - FX_CBP_H2 = 21, - FX_CBP_H3 = 22, - FX_CBP_JL = 23, - FX_CBP_JV = 24, - FX_CBP_JT = 25, - - FX_CBP_BK = 26, - FX_CBP_CR = 27, - FX_CBP_LF = 28, - FX_CBP_NL = 29, - FX_CBP_SA = 30, - FX_CBP_SG = 31, - FX_CBP_CB = 32, - FX_CBP_XX = 33, - FX_CBP_AI = 34, - FX_CBP_SP = 35, - FX_CBP_TB = 37, + FX_CBP_OP = 0, // Opening Punctuation + FX_CBP_CL = 1, // Closing Punctuation + FX_CBP_QU = 2, // Ambiguous Quotation + FX_CBP_GL = 3, // Non-breaking ("Glue") + FX_CBP_NS = 4, // Non Starter + FX_CBP_EX = 5, // Exclamation/Interrogation + FX_CBP_SY = 6, // Symbols Allowing Breaks + FX_CBP_IS = 7, // Infix Separator (Numeric) + FX_CBP_PR = 8, // Prefix (Numeric) + FX_CBP_PO = 9, // Postfix (Numeric) + FX_CBP_NU = 10, // Numeric + FX_CBP_AL = 11, // Ordinary Alphabetic and Symbol Characters + FX_CBP_ID = 12, // Ideographic + FX_CBP_IN = 13, // Inseparable + FX_CBP_HY = 14, // Hyphen + FX_CBP_BA = 15, // Break Opportunity After + FX_CBP_BB = 16, // Break Opportunity Before + FX_CBP_B2 = 17, // Break Opportunity Before and After + FX_CBP_ZW = 18, // Zero Width Space + FX_CBP_CM = 19, // Attached Characters and Combining Marks + FX_CBP_WJ = 20, // Word Joiner + FX_CBP_H2 = 21, // Hangul LV Syllable + FX_CBP_H3 = 22, // Hangul LVT Syllable + FX_CBP_JL = 23, // Hangul Leading Jamo + FX_CBP_JV = 24, // Hangul Vowel Jamo + FX_CBP_JT = 25, // Hangul Trailing Jamo + + FX_CBP_BK = 26, // Mandatory Break + FX_CBP_CR = 27, // Carriage Return + FX_CBP_LF = 28, // Line Feed + FX_CBP_NL = 29, // Next Line + FX_CBP_SA = 30, // Complex Context (South East Asian) + FX_CBP_SG = 31, // Surrogate + FX_CBP_CB = 32, // Contingent Break Opportunity + FX_CBP_XX = 33, // Unknown + FX_CBP_AI = 34, // Ambiguous (Alphabetic or Ideographic) + FX_CBP_SP = 35, // Space FX_CBP_NONE = 36, + FX_CBP_TB = 37, // ? }; #define FX_CHARTYPEBITS 11 @@ -112,7 +114,6 @@ inline FX_CHARTYPE GetCharTypeFromProp(uint32_t prop) { return static_cast(prop & FX_CHARTYPEBITSMASK); } -bool FX_IsCtrlCode(FX_WCHAR ch); FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, uint32_t dwProps, bool bRTL, diff --git a/core/fxcrt/fx_unicode.cpp b/core/fxcrt/fx_unicode.cpp index e6f423e2af..44fa8e743d 100644 --- a/core/fxcrt/fx_unicode.cpp +++ b/core/fxcrt/fx_unicode.cpp @@ -13,13 +13,6 @@ uint32_t FX_GetUnicodeProperties(FX_WCHAR wch) { return 0; } -#ifdef PDF_ENABLE_XFA -bool FX_IsCtrlCode(FX_WCHAR ch) { - uint32_t dwRet = (FX_GetUnicodeProperties(ch) & FX_CHARTYPEBITSMASK); - return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control; -} -#endif // PDF_ENABLE_XFA - FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, bool bRTL, bool bVertical) { uint32_t dwProps = FX_GetUnicodeProperties(wch); uint32_t dwTemp = (dwProps & 0xFF800000); diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index d9e5f7f80b..8f5895f24c 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -9,7 +9,6 @@ #include #include "core/fxcrt/fx_arabic.h" -#include "core/fxcrt/fx_arb.h" #include "third_party/base/stl_util.h" #include "xfa/fgas/font/cfgas_gefont.h" #include "xfa/fgas/layout/fgas_linebreak.h" @@ -470,7 +469,7 @@ bool CFX_RTFBreak::EndBreak_SplitLine(CFX_RTFLine* pNextLine, } } - if (!m_bPagination && m_pCurLine->m_iMBCSChars <= 0) { + if (!m_bPagination) { if (bAllChars && !bDone) { int32_t endPos = m_pCurLine->GetLineEnd(); GetBreakPos(m_pCurLine->m_LineChars, endPos, bAllChars, true); @@ -1013,11 +1012,7 @@ CFX_RTFPiece::~CFX_RTFPiece() { } CFX_RTFLine::CFX_RTFLine() - : m_LinePieces(16), - m_iStart(0), - m_iWidth(0), - m_iArabicChars(0), - m_iMBCSChars(0) {} + : m_LinePieces(16), m_iStart(0), m_iWidth(0), m_iArabicChars(0) {} CFX_RTFLine::~CFX_RTFLine() { RemoveAll(false); diff --git a/xfa/fgas/layout/fgas_rtfbreak.h b/xfa/fgas/layout/fgas_rtfbreak.h index 63ad67f6c0..8907871f74 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.h +++ b/xfa/fgas/layout/fgas_rtfbreak.h @@ -127,7 +127,6 @@ class CFX_RTFLine { m_LinePieces.RemoveAll(bLeaveMemory); m_iWidth = 0; m_iArabicChars = 0; - m_iMBCSChars = 0; } std::vector m_LineChars; @@ -135,7 +134,6 @@ class CFX_RTFLine { int32_t m_iStart; int32_t m_iWidth; int32_t m_iArabicChars; - int32_t m_iMBCSChars; }; class CFX_RTFBreak { diff --git a/xfa/fgas/layout/fgas_textbreak.cpp b/xfa/fgas/layout/fgas_textbreak.cpp index 8be72f2c7b..153d575139 100644 --- a/xfa/fgas/layout/fgas_textbreak.cpp +++ b/xfa/fgas/layout/fgas_textbreak.cpp @@ -9,7 +9,6 @@ #include #include "core/fxcrt/fx_arabic.h" -#include "core/fxcrt/fx_arb.h" #include "core/fxcrt/fx_memory.h" #include "third_party/base/ptr_util.h" #include "xfa/fgas/font/cfgas_gefont.h" @@ -31,6 +30,11 @@ const FX_TxtBreak_LPFAppendChar g_FX_TxtBreak_lpfAppendChar[16] = { &CFX_TxtBreak::AppendChar_Others, &CFX_TxtBreak::AppendChar_Others, }; +bool IsCtrlCode(FX_WCHAR ch) { + uint32_t dwRet = (FX_GetUnicodeProperties(ch) & FX_CHARTYPEBITSMASK); + return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control; +} + } // namespace CFX_TxtBreak::CFX_TxtBreak(uint32_t dwPolicies) @@ -1561,7 +1565,7 @@ std::vector CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, iCharSize = *pWidths++; } fCharSize = static_cast(iCharSize) / 20000.0f; - bool bRet = (!bSingleLine && FX_IsCtrlCode(wch)); + bool bRet = (!bSingleLine && IsCtrlCode(wch)); if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || (wLineBreakChar != 0xFEFF && wch == wLineBreakChar))) { bRet = false; -- cgit v1.2.3