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

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

Issue 1423103002: XFA: Manual merge of Clean up IFX_BidiChar (Closed) Base URL: https://pdfium.googlesource.com/pdfium@xfa
Patch Set: address comments Created 5 years, 1 month 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.cpp ('k') | core/src/fxcrt/fx_bidi_unittest.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_bidi.h"
8 #include "../../include/fxcrt/fx_ucd.h"
9
10 CFX_BidiChar::CFX_BidiChar()
11 : m_iCurStart(0),
12 m_iCurCount(0),
13 m_CurBidi(NEUTRAL),
14 m_iLastStart(0),
15 m_iLastCount(0),
16 m_LastBidi(NEUTRAL) {
17 }
18
19 CFX_BidiChar::~CFX_BidiChar() {
20 }
21
22 bool CFX_BidiChar::AppendChar(FX_WCHAR wch) {
23 FX_DWORD dwProps = FX_GetUnicodeProperties(wch);
24 int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS;
25 Direction bidi = NEUTRAL;
26 switch (iBidiCls) {
27 case FX_BIDICLASS_L:
28 case FX_BIDICLASS_AN:
29 case FX_BIDICLASS_EN:
30 bidi = LEFT;
31 break;
32 case FX_BIDICLASS_R:
33 case FX_BIDICLASS_AL:
34 bidi = RIGHT;
35 break;
36 }
37
38 bool bRet = (bidi != m_CurBidi);
39 if (bRet) {
40 SaveCurrentStateToLastState();
41 m_CurBidi = bidi;
42 }
43 m_iCurCount++;
44 return bRet;
45 }
46
47 bool CFX_BidiChar::EndChar() {
48 SaveCurrentStateToLastState();
49 return m_iLastCount > 0;
50 }
51
52 CFX_BidiChar::Direction CFX_BidiChar::GetBidiInfo(int32_t* iStart,
53 int32_t* iCount) const {
54 if (iStart)
55 *iStart = m_iLastStart;
56 if (iCount)
57 *iCount = m_iLastCount;
58 return m_LastBidi;
59 }
60
61 void CFX_BidiChar::SaveCurrentStateToLastState() {
62 m_LastBidi = m_CurBidi;
63 m_iLastStart = m_iCurStart;
64 m_iCurStart = m_iCurCount;
65 m_iLastCount = m_iCurCount - m_iLastStart;
66 }
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_arabic.cpp ('k') | core/src/fxcrt/fx_bidi_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698