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

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

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh 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
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];
11 IFX_BidiChar* IFX_BidiChar::Create() 11 IFX_BidiChar* IFX_BidiChar::Create() {
12 { 12 return new CFX_BidiChar;
13 return new CFX_BidiChar;
14 } 13 }
15 CFX_BidiChar::CFX_BidiChar() 14 CFX_BidiChar::CFX_BidiChar()
16 : m_bSeparateNeutral(TRUE) 15 : m_bSeparateNeutral(TRUE),
17 , m_iCurStart(0) 16 m_iCurStart(0),
18 , m_iCurCount(0) 17 m_iCurCount(0),
19 , m_iCurBidi(0) 18 m_iCurBidi(0),
20 , m_iLastBidi(0) 19 m_iLastBidi(0),
21 , m_iLastStart(0) 20 m_iLastStart(0),
22 , m_iLastCount(0) 21 m_iLastCount(0) {}
23 { 22 void CFX_BidiChar::SetPolicy(FX_BOOL bSeparateNeutral) {
24 } 23 m_bSeparateNeutral = bSeparateNeutral;
25 void CFX_BidiChar::SetPolicy(FX_BOOL bSeparateNeutral)
26 {
27 m_bSeparateNeutral = bSeparateNeutral;
28 } 24 }
29 25
30 FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) 26 FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) {
31 { 27 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch];
32 FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; 28 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS;
33 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; 29 int32_t iContext = 0;
34 int32_t iContext = 0; 30 switch (iBidiCls) {
35 switch (iBidiCls) { 31 case FX_BIDICLASS_L:
36 case FX_BIDICLASS_L: 32 case FX_BIDICLASS_AN:
37 case FX_BIDICLASS_AN: 33 case FX_BIDICLASS_EN:
38 case FX_BIDICLASS_EN: 34 iContext = 1;
39 iContext = 1; 35 break;
40 break; 36 case FX_BIDICLASS_R:
41 case FX_BIDICLASS_R: 37 case FX_BIDICLASS_AL:
42 case FX_BIDICLASS_AL: 38 iContext = 2;
43 iContext = 2; 39 break;
44 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 }
45 } 51 }
46 FX_BOOL bRet = FALSE; 52 if (bRet) {
47 if (iContext != m_iCurBidi) { 53 m_iLastBidi = m_iCurBidi;
48 if (m_bSeparateNeutral) { 54 m_iLastStart = m_iCurStart;
49 bRet = TRUE; 55 m_iCurStart = m_iCurCount;
50 } else { 56 m_iLastCount = m_iCurCount - m_iLastStart;
51 if (m_iCurBidi == 0) {
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 } 57 }
67 m_iCurCount ++; 58 if (m_bSeparateNeutral || iContext != 0) {
68 return bRet; 59 m_iCurBidi = iContext;
60 }
61 }
62 m_iCurCount++;
63 return bRet;
69 } 64 }
70 FX_BOOL CFX_BidiChar::EndChar() 65 FX_BOOL CFX_BidiChar::EndChar() {
71 { 66 m_iLastBidi = m_iCurBidi;
72 m_iLastBidi = m_iCurBidi; 67 m_iLastStart = m_iCurStart;
73 m_iLastStart = m_iCurStart; 68 m_iCurStart = m_iCurCount;
74 m_iCurStart = m_iCurCount; 69 m_iLastCount = m_iCurCount - m_iLastStart;
75 m_iLastCount = m_iCurCount - m_iLastStart; 70 return m_iLastCount > 0;
76 return m_iLastCount > 0;
77 } 71 }
78 int32_t CFX_BidiChar::GetBidiInfo(int32_t &iStart, int32_t &iCount) 72 int32_t CFX_BidiChar::GetBidiInfo(int32_t& iStart, int32_t& iCount) {
79 { 73 iStart = m_iLastStart;
80 iStart = m_iLastStart; 74 iCount = m_iLastCount;
81 iCount = m_iLastCount; 75 return m_iLastBidi;
82 return m_iLastBidi;
83 } 76 }
84 void CFX_BidiChar::Reset() 77 void CFX_BidiChar::Reset() {
85 { 78 m_iCurStart = 0;
86 m_iCurStart = 0; 79 m_iCurCount = 0;
87 m_iCurCount = 0; 80 m_iCurBidi = 0;
88 m_iCurBidi = 0; 81 m_iLastBidi = 0;
89 m_iLastBidi = 0; 82 m_iLastStart = 0;
90 m_iLastStart = 0; 83 m_iLastCount = 0;
91 m_iLastCount = 0;
92 } 84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698