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

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: address comments, similarity 20 Created 5 years, 4 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
« no previous file with comments | « core/src/fxcrt/fx_arabic.h ('k') | core/src/fxcrt/fx_bidi.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "../../include/fxcrt/fx_ucd.h"
8 #include "fx_arabic.h"
9
10 extern const FX_DWORD gs_FX_TextLayout_CodeProperties[65536];
11 IFX_BidiChar* IFX_BidiChar::Create() {
12 return new CFX_BidiChar;
13 }
14 CFX_BidiChar::CFX_BidiChar()
15 : m_bSeparateNeutral(TRUE),
16 m_iCurStart(0),
17 m_iCurCount(0),
18 m_iCurBidi(0),
19 m_iLastBidi(0),
20 m_iLastStart(0),
21 m_iLastCount(0) {}
22 void CFX_BidiChar::SetPolicy(FX_BOOL bSeparateNeutral) {
23 m_bSeparateNeutral = bSeparateNeutral;
24 }
25
26 FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) {
27 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch];
28 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS;
29 int32_t iContext = 0;
30 switch (iBidiCls) {
31 case FX_BIDICLASS_L:
32 case FX_BIDICLASS_AN:
33 case FX_BIDICLASS_EN:
34 iContext = 1;
35 break;
36 case FX_BIDICLASS_R:
37 case FX_BIDICLASS_AL:
38 iContext = 2;
39 break;
40 }
41 FX_BOOL bRet = FALSE;
42 if (iContext != m_iCurBidi) {
43 if (m_bSeparateNeutral) {
44 bRet = TRUE;
45 } else {
46 if (m_iCurBidi == 0) {
47 bRet = (m_iCurCount > 0);
48 } else {
49 bRet = (iContext != 0);
50 }
51 }
52 if (bRet) {
53 m_iLastBidi = m_iCurBidi;
54 m_iLastStart = m_iCurStart;
55 m_iCurStart = m_iCurCount;
56 m_iLastCount = m_iCurCount - m_iLastStart;
57 }
58 if (m_bSeparateNeutral || iContext != 0) {
59 m_iCurBidi = iContext;
60 }
61 }
62 m_iCurCount++;
63 return bRet;
64 }
65 FX_BOOL CFX_BidiChar::EndChar() {
66 m_iLastBidi = m_iCurBidi;
67 m_iLastStart = m_iCurStart;
68 m_iCurStart = m_iCurCount;
69 m_iLastCount = m_iCurCount - m_iLastStart;
70 return m_iLastCount > 0;
71 }
72 int32_t CFX_BidiChar::GetBidiInfo(int32_t& iStart, int32_t& iCount) {
73 iStart = m_iLastStart;
74 iCount = m_iLastCount;
75 return m_iLastBidi;
76 }
77 void CFX_BidiChar::Reset() {
78 m_iCurStart = 0;
79 m_iCurCount = 0;
80 m_iCurBidi = 0;
81 m_iLastBidi = 0;
82 m_iLastStart = 0;
83 m_iLastCount = 0;
84 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_arabic.h ('k') | core/src/fxcrt/fx_bidi.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698