summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-07-27 13:13:41 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-07-27 20:44:44 +0000
commit4191b03e29ef54f37deeadf652ee11cbfb81f9df (patch)
tree14b5078ac26746acd5c1f2103e6b1692a45e394d /core/fxcrt
parentdb1e8a500588abb98026bafac376b953f61813d2 (diff)
downloadpdfium-4191b03e29ef54f37deeadf652ee11cbfb81f9df.tar.xz
Simplify CFX_BidiLine code.
The base level is always 0 in much of the code. Change-Id: I70b8342e0f6cf1dc366ff9f1d5d734d6f55ead0e Reviewed-on: https://pdfium-review.googlesource.com/9254 Reviewed-by: (OOO Jul 28 - Aug 8) dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/fx_arabic.cpp64
1 files changed, 24 insertions, 40 deletions
diff --git a/core/fxcrt/fx_arabic.cpp b/core/fxcrt/fx_arabic.cpp
index f197af5e13..79d6be2346 100644
--- a/core/fxcrt/fx_arabic.cpp
+++ b/core/fxcrt/fx_arabic.cpp
@@ -356,21 +356,19 @@ wchar_t GetArabicFromAlefTable(wchar_t alef) {
class CFX_BidiLine {
public:
- void BidiLine(std::vector<CFX_Char>* chars,
- int32_t iCount,
- int32_t iBaseLevel) {
+ void BidiLine(std::vector<CFX_Char>* chars, int32_t iCount) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(*chars));
if (iCount < 2)
return;
Classify(chars, iCount, false);
- ResolveExplicit(chars, iCount, iBaseLevel);
- ResolveWeak(chars, iCount, iBaseLevel);
- ResolveNeutrals(chars, iCount, iBaseLevel);
+ ResolveExplicit(chars, iCount);
+ ResolveWeak(chars, iCount);
+ ResolveNeutrals(chars, iCount);
ResolveImplicit(chars, iCount);
Classify(chars, iCount, true);
- ResolveWhitespace(chars, iCount, iBaseLevel);
- Reorder(chars, iCount, iBaseLevel);
+ ResolveWhitespace(chars, iCount);
+ Reorder(chars, iCount);
Position(chars, iCount);
}
@@ -441,25 +439,20 @@ class CFX_BidiLine {
}
}
- void ResolveExplicit(std::vector<CFX_Char>* chars,
- int32_t iCount,
- int32_t iBaseLevel) {
+ void ResolveExplicit(std::vector<CFX_Char>* chars, int32_t iCount) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(*chars));
- ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
for (int32_t i = 0; i < iCount; i++)
- (*chars)[i].m_iBidiLevel = static_cast<int16_t>(iBaseLevel);
+ (*chars)[i].m_iBidiLevel = 0;
}
- void ResolveWeak(std::vector<CFX_Char>* chars,
- int32_t iCount,
- int32_t iBaseLevel) {
+ void ResolveWeak(std::vector<CFX_Char>* chars, int32_t iCount) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(*chars));
iCount--;
if (iCount < 1)
return;
- int32_t iLevelCur = iBaseLevel;
- int32_t iState = FX_IsOdd(iBaseLevel) ? FX_BWSxr : FX_BWSxl;
+ int32_t iLevelCur = 0;
+ int32_t iState = FX_BWSxl;
int32_t i = 0;
int32_t iNum = 0;
int32_t iClsCur;
@@ -471,7 +464,7 @@ class CFX_BidiLine {
iClsCur = pTC->m_iBidiClass;
if (iClsCur == FX_BIDICLASS_BN) {
pTC->m_iBidiLevel = (int16_t)iLevelCur;
- if (i == iCount && iLevelCur != iBaseLevel) {
+ if (i == iCount && iLevelCur != 0) {
iClsCur = Direction(iLevelCur);
pTC->m_iBidiClass = (int16_t)iClsCur;
} else if (i < iCount) {
@@ -513,25 +506,22 @@ class CFX_BidiLine {
iState = gc_FX_BidiWeakStates[iState][iClsCur];
}
if (iNum > 0) {
- iClsCur = Direction(iBaseLevel);
+ iClsCur = Direction(0);
iClsRun = GetDeferredType(gc_FX_BidiWeakActions[iState][iClsCur]);
if (iClsRun != FX_BWAXX)
SetDeferredRun(chars, true, i, iNum, iClsRun);
}
}
- void ResolveNeutrals(std::vector<CFX_Char>* chars,
- int32_t iCount,
- int32_t iBaseLevel) {
+ void ResolveNeutrals(std::vector<CFX_Char>* chars, int32_t iCount) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(*chars));
- ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
iCount--;
if (iCount < 1)
return;
CFX_Char* pTC;
- int32_t iLevel = iBaseLevel;
- int32_t iState = FX_IsOdd(iBaseLevel) ? FX_BNSr : FX_BNSl;
+ int32_t iLevel = 0;
+ int32_t iState = FX_BNSl;
int32_t i = 0;
int32_t iNum = 0;
int32_t iClsCur;
@@ -587,16 +577,13 @@ class CFX_BidiLine {
}
}
- void ResolveWhitespace(std::vector<CFX_Char>* chars,
- int32_t iCount,
- int32_t iBaseLevel) {
+ void ResolveWhitespace(std::vector<CFX_Char>* chars, int32_t iCount) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(*chars));
- ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
if (iCount < 1)
return;
iCount--;
- int32_t iLevel = iBaseLevel;
+ int32_t iLevel = 0;
int32_t i = 0;
int32_t iNum = 0;
for (; i <= iCount; i++) {
@@ -616,9 +603,9 @@ class CFX_BidiLine {
case FX_BIDICLASS_S:
case FX_BIDICLASS_B:
if (iNum > 0)
- SetDeferredRun(chars, false, i, iNum, iBaseLevel);
+ SetDeferredRun(chars, false, i, iNum, 0);
- (*chars)[i].m_iBidiLevel = static_cast<int16_t>(iBaseLevel);
+ (*chars)[i].m_iBidiLevel = 0;
iNum = 0;
break;
default:
@@ -628,7 +615,7 @@ class CFX_BidiLine {
iLevel = (*chars)[i].m_iBidiLevel;
}
if (iNum > 0)
- SetDeferredRun(chars, false, i, iNum, iBaseLevel);
+ SetDeferredRun(chars, false, i, iNum, 0);
}
int32_t ReorderLevel(std::vector<CFX_Char>* chars,
@@ -660,14 +647,11 @@ class CFX_BidiLine {
return iNum;
}
- void Reorder(std::vector<CFX_Char>* chars,
- int32_t iCount,
- int32_t iBaseLevel) {
+ void Reorder(std::vector<CFX_Char>* chars, int32_t iCount) {
ASSERT(iCount >= 0 && iCount <= pdfium::CollectionSize<int32_t>(*chars));
- ASSERT(iBaseLevel >= 0 && iBaseLevel <= FX_BIDIMAXLEVEL);
int32_t i = 0;
while (i < iCount)
- i += ReorderLevel(chars, iCount, iBaseLevel, i, false);
+ i += ReorderLevel(chars, iCount, 0, i, false);
}
void Position(std::vector<CFX_Char>* chars, int32_t iCount) {
@@ -739,5 +723,5 @@ wchar_t FX_GetArabicFromShaddaTable(wchar_t shadda) {
void FX_BidiLine(std::vector<CFX_Char>* chars, int32_t iCount) {
CFX_BidiLine blt;
- blt.BidiLine(chars, iCount, 0);
+ blt.BidiLine(chars, iCount);
}