Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: core/src/fxcrt/fx_arabic.cpp

Issue 1197643002: Cleanup IFX_BidiChar (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« core/src/fxcrt/fx_arabic.h ('K') | « core/src/fxcrt/fx_arabic.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "../../include/fxcrt/fx_ucd.h" 7 #include "../../include/fxcrt/fx_ucd.h"
8 #include "fx_arabic.h" 8 #include "fx_arabic.h"
9 9
10 extern const FX_DWORD gs_FX_TextLayout_CodeProperties[65536]; 10 extern const FX_DWORD gs_FX_TextLayout_CodeProperties[65536];
Tom Sepez 2015/06/19 20:30:32 nit: This needs to be in a .h file. Does it have t
Tom Sepez 2015/06/19 21:36:10 Answer is that its a DWORD. I was counting the bi
Lei Zhang 2015/08/17 17:41:35 Done.
11
11 IFX_BidiChar* IFX_BidiChar::Create() 12 IFX_BidiChar* IFX_BidiChar::Create()
12 { 13 {
13 return new CFX_BidiChar; 14 return new CFX_BidiChar;
14 } 15 }
16
15 CFX_BidiChar::CFX_BidiChar() 17 CFX_BidiChar::CFX_BidiChar()
16 : m_bSeparateNeutral(TRUE) 18 : m_iCurStart(0),
17 , m_iCurStart(0) 19 m_iCurCount(0),
18 , m_iCurCount(0) 20 m_CurBidi(NEUTRAL),
19 , m_iCurBidi(0) 21 m_iLastStart(0),
20 , m_iLastBidi(0) 22 m_iLastCount(0),
21 , m_iLastStart(0) 23 m_LastBidi(NEUTRAL)
22 , m_iLastCount(0)
23 { 24 {
24 } 25 }
25 void CFX_BidiChar::SetPolicy(FX_BOOL bSeparateNeutral) 26
27 CFX_BidiChar::~CFX_BidiChar()
26 { 28 {
27 m_bSeparateNeutral = bSeparateNeutral;
28 } 29 }
29 30
30 FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) 31 bool CFX_BidiChar::AppendChar(FX_WCHAR wch)
31 { 32 {
32 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; 33 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch];
33 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; 34 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS;
34 int32_t iContext = 0; 35 Direction bidi = NEUTRAL;
35 switch (iBidiCls) { 36 switch (iBidiCls) {
36 case FX_BIDICLASS_L: 37 case FX_BIDICLASS_L:
37 case FX_BIDICLASS_AN: 38 case FX_BIDICLASS_AN:
38 case FX_BIDICLASS_EN: 39 case FX_BIDICLASS_EN:
39 iContext = 1; 40 bidi = LEFT;
40 break; 41 break;
41 case FX_BIDICLASS_R: 42 case FX_BIDICLASS_R:
42 case FX_BIDICLASS_AL: 43 case FX_BIDICLASS_AL:
43 iContext = 2; 44 bidi = RIGHT;
44 break; 45 break;
45 } 46 }
46 FX_BOOL bRet = FALSE; 47
47 if (iContext != m_iCurBidi) { 48 bool bRet = (bidi != m_CurBidi);
48 if (m_bSeparateNeutral) { 49 if (bRet) {
49 bRet = TRUE; 50 SaveCurrentStateToLastState();
50 } else { 51 m_iCurStart = m_iCurCount;
51 if (m_iCurBidi == 0) { 52 m_CurBidi = bidi;
52 bRet = (m_iCurCount > 0);
53 } else {
54 bRet = (iContext != 0);
55 }
56 }
57 if (bRet) {
58 m_iLastBidi = m_iCurBidi;
59 m_iLastStart = m_iCurStart;
60 m_iCurStart = m_iCurCount;
61 m_iLastCount = m_iCurCount - m_iLastStart;
62 }
63 if (m_bSeparateNeutral || iContext != 0) {
64 m_iCurBidi = iContext;
65 }
66 } 53 }
67 m_iCurCount ++; 54 m_iCurCount++;
68 return bRet; 55 return bRet;
69 } 56 }
70 FX_BOOL CFX_BidiChar::EndChar() 57
58 bool CFX_BidiChar::EndChar()
71 { 59 {
72 m_iLastBidi = m_iCurBidi; 60 SaveCurrentStateToLastState();
73 m_iLastStart = m_iCurStart;
74 m_iCurStart = m_iCurCount;
Tom Sepez 2015/06/19 20:30:32 Did we lose this assignment?
Lei Zhang 2015/08/17 17:41:35 Yep, don't remember why I did that.
75 m_iLastCount = m_iCurCount - m_iLastStart;
76 return m_iLastCount > 0; 61 return m_iLastCount > 0;
77 } 62 }
78 int32_t CFX_BidiChar::GetBidiInfo(int32_t &iStart, int32_t &iCount) 63
64 IFX_BidiChar::Direction CFX_BidiChar::GetBidiInfo(int32_t* iStart,
65 int32_t* iCount)
79 { 66 {
80 iStart = m_iLastStart; 67 if (iStart)
81 iCount = m_iLastCount; 68 *iStart = m_iLastStart;
82 return m_iLastBidi; 69 if (iCount)
70 *iCount = m_iLastCount;
71 return m_LastBidi;
83 } 72 }
84 void CFX_BidiChar::Reset() 73
74 void CFX_BidiChar::SaveCurrentStateToLastState()
85 { 75 {
86 m_iCurStart = 0; 76 m_iLastStart = m_iCurStart;
87 m_iCurCount = 0; 77 m_iLastCount = m_iCurCount - m_iLastStart;
88 m_iCurBidi = 0; 78 m_LastBidi = m_CurBidi;
89 m_iLastBidi = 0;
90 m_iLastStart = 0;
91 m_iLastCount = 0;
92 } 79 }
OLDNEW
« core/src/fxcrt/fx_arabic.h ('K') | « core/src/fxcrt/fx_arabic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698