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

Side by Side Diff: xfa/fde/css/fde_csssyntax.h

Issue 2467203003: Remove FX_BOOL from xfa. (Closed)
Patch Set: Created 4 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 | « xfa/fde/css/fde_cssstylesheet.cpp ('k') | xfa/fde/css/fde_csssyntax.cpp » ('j') | 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 #ifndef XFA_FDE_CSS_FDE_CSSSYNTAX_H_ 7 #ifndef XFA_FDE_CSS_FDE_CSSSYNTAX_H_
8 #define XFA_FDE_CSS_FDE_CSSSYNTAX_H_ 8 #define XFA_FDE_CSS_FDE_CSSSYNTAX_H_
9 9
10 #include "xfa/fde/css/fde_css.h" 10 #include "xfa/fde/css/fde_css.h"
11 #include "xfa/fgas/crt/fgas_memory.h" 11 #include "xfa/fgas/crt/fgas_memory.h"
12 #include "xfa/fgas/crt/fgas_stream.h" 12 #include "xfa/fgas/crt/fgas_stream.h"
13 13
14 class CFDE_CSSTextBuf : public CFX_Target { 14 class CFDE_CSSTextBuf : public CFX_Target {
15 public: 15 public:
16 CFDE_CSSTextBuf(); 16 CFDE_CSSTextBuf();
17 ~CFDE_CSSTextBuf() override; 17 ~CFDE_CSSTextBuf() override;
18 18
19 FX_BOOL AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen); 19 bool AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen);
20 FX_BOOL EstimateSize(int32_t iAllocSize); 20 bool EstimateSize(int32_t iAllocSize);
21 int32_t LoadFromStream(IFX_Stream* pTxtStream, 21 int32_t LoadFromStream(IFX_Stream* pTxtStream,
22 int32_t iStreamOffset, 22 int32_t iStreamOffset,
23 int32_t iMaxChars, 23 int32_t iMaxChars,
24 FX_BOOL& bEOS); 24 bool& bEOS);
25 bool AppendChar(FX_WCHAR wch) { 25 bool AppendChar(FX_WCHAR wch) {
26 if (m_iDatLen >= m_iBufLen && !ExpandBuf(m_iBufLen * 2)) 26 if (m_iDatLen >= m_iBufLen && !ExpandBuf(m_iBufLen * 2))
27 return false; 27 return false;
28 m_pBuffer[m_iDatLen++] = wch; 28 m_pBuffer[m_iDatLen++] = wch;
29 return true; 29 return true;
30 } 30 }
31 void Clear() { m_iDatPos = m_iDatLen = 0; } 31 void Clear() { m_iDatPos = m_iDatLen = 0; }
32 void Reset(); 32 void Reset();
33 int32_t TrimEnd() { 33 int32_t TrimEnd() {
34 while (m_iDatLen > 0 && m_pBuffer[m_iDatLen - 1] <= ' ') { 34 while (m_iDatLen > 0 && m_pBuffer[m_iDatLen - 1] <= ' ') {
35 --m_iDatLen; 35 --m_iDatLen;
36 } 36 }
37 AppendChar(0); 37 AppendChar(0);
38 return --m_iDatLen; 38 return --m_iDatLen;
39 } 39 }
40 void Subtract(int32_t iStart, int32_t iLength); 40 void Subtract(int32_t iStart, int32_t iLength);
41 FX_BOOL IsEOF() const { return m_iDatPos >= m_iDatLen; } 41 bool IsEOF() const { return m_iDatPos >= m_iDatLen; }
42 FX_WCHAR GetAt(int32_t index) const { return m_pBuffer[index]; } 42 FX_WCHAR GetAt(int32_t index) const { return m_pBuffer[index]; }
43 FX_WCHAR GetChar() const { return m_pBuffer[m_iDatPos]; } 43 FX_WCHAR GetChar() const { return m_pBuffer[m_iDatPos]; }
44 FX_WCHAR GetNextChar() const { 44 FX_WCHAR GetNextChar() const {
45 return (m_iDatPos + 1 >= m_iDatLen) ? 0 : m_pBuffer[m_iDatPos + 1]; 45 return (m_iDatPos + 1 >= m_iDatLen) ? 0 : m_pBuffer[m_iDatPos + 1];
46 } 46 }
47 void MoveNext() { m_iDatPos++; } 47 void MoveNext() { m_iDatPos++; }
48 int32_t GetLength() const { return m_iDatLen; } 48 int32_t GetLength() const { return m_iDatLen; }
49 const FX_WCHAR* GetBuffer() const { return m_pBuffer; } 49 const FX_WCHAR* GetBuffer() const { return m_pBuffer; }
50 50
51 protected: 51 protected:
52 FX_BOOL ExpandBuf(int32_t iDesiredSize); 52 bool ExpandBuf(int32_t iDesiredSize);
53 FX_BOOL m_bExtBuf; 53 bool m_bExtBuf;
54 FX_WCHAR* m_pBuffer; 54 FX_WCHAR* m_pBuffer;
55 int32_t m_iBufLen; 55 int32_t m_iBufLen;
56 int32_t m_iDatLen; 56 int32_t m_iDatLen;
57 int32_t m_iDatPos; 57 int32_t m_iDatPos;
58 }; 58 };
59 59
60 #define FDE_CSSSYNTAXCHECK_AllowCharset 1 60 #define FDE_CSSSYNTAXCHECK_AllowCharset 1
61 #define FDE_CSSSYNTAXCHECK_AllowImport 2 61 #define FDE_CSSSYNTAXCHECK_AllowImport 2
62 62
63 enum FDE_CSSSYNTAXMODE { 63 enum FDE_CSSSYNTAXMODE {
64 FDE_CSSSYNTAXMODE_RuleSet, 64 FDE_CSSSYNTAXMODE_RuleSet,
65 FDE_CSSSYNTAXMODE_Comment, 65 FDE_CSSSYNTAXMODE_Comment,
66 FDE_CSSSYNTAXMODE_AtRule, 66 FDE_CSSSYNTAXMODE_AtRule,
67 FDE_CSSSYNTAXMODE_UnknownRule, 67 FDE_CSSSYNTAXMODE_UnknownRule,
68 FDE_CSSSYNTAXMODE_Charset, 68 FDE_CSSSYNTAXMODE_Charset,
69 FDE_CSSSYNTAXMODE_Import, 69 FDE_CSSSYNTAXMODE_Import,
70 FDE_CSSSYNTAXMODE_MediaRule, 70 FDE_CSSSYNTAXMODE_MediaRule,
71 FDE_CSSSYNTAXMODE_URI, 71 FDE_CSSSYNTAXMODE_URI,
72 FDE_CSSSYNTAXMODE_MediaType, 72 FDE_CSSSYNTAXMODE_MediaType,
73 FDE_CSSSYNTAXMODE_Selector, 73 FDE_CSSSYNTAXMODE_Selector,
74 FDE_CSSSYNTAXMODE_PropertyName, 74 FDE_CSSSYNTAXMODE_PropertyName,
75 FDE_CSSSYNTAXMODE_PropertyValue, 75 FDE_CSSSYNTAXMODE_PropertyValue,
76 }; 76 };
77 77
78 class CFDE_CSSSyntaxParser : public CFX_Target { 78 class CFDE_CSSSyntaxParser : public CFX_Target {
79 public: 79 public:
80 CFDE_CSSSyntaxParser(); 80 CFDE_CSSSyntaxParser();
81 ~CFDE_CSSSyntaxParser() override; 81 ~CFDE_CSSSyntaxParser() override;
82 82
83 FX_BOOL Init(IFX_Stream* pStream, 83 bool Init(IFX_Stream* pStream,
84 int32_t iCSSPlaneSize, 84 int32_t iCSSPlaneSize,
85 int32_t iTextDataSize = 32, 85 int32_t iTextDataSize = 32,
86 FX_BOOL bOnlyDeclaration = FALSE); 86 bool bOnlyDeclaration = false);
87 FX_BOOL Init(const FX_WCHAR* pBuffer, 87 bool Init(const FX_WCHAR* pBuffer,
88 int32_t iBufferSize, 88 int32_t iBufferSize,
89 int32_t iTextDatSize = 32, 89 int32_t iTextDatSize = 32,
90 FX_BOOL bOnlyDeclaration = FALSE); 90 bool bOnlyDeclaration = false);
91 FDE_CSSSYNTAXSTATUS DoSyntaxParse(); 91 FDE_CSSSYNTAXSTATUS DoSyntaxParse();
92 const FX_WCHAR* GetCurrentString(int32_t& iLength) const; 92 const FX_WCHAR* GetCurrentString(int32_t& iLength) const;
93 93
94 protected: 94 protected:
95 void Reset(FX_BOOL bOnlyDeclaration); 95 void Reset(bool bOnlyDeclaration);
96 void SwitchMode(FDE_CSSSYNTAXMODE eMode); 96 void SwitchMode(FDE_CSSSYNTAXMODE eMode);
97 int32_t SwitchToComment(); 97 int32_t SwitchToComment();
98 98
99 FX_BOOL RestoreMode(); 99 bool RestoreMode();
100 FX_BOOL AppendChar(FX_WCHAR wch); 100 bool AppendChar(FX_WCHAR wch);
101 int32_t SaveTextData(); 101 int32_t SaveTextData();
102 FX_BOOL IsCharsetEnabled() const { 102 bool IsCharsetEnabled() const {
103 return (m_dwCheck & FDE_CSSSYNTAXCHECK_AllowCharset) != 0; 103 return (m_dwCheck & FDE_CSSSYNTAXCHECK_AllowCharset) != 0;
104 } 104 }
105 void DisableCharset() { m_dwCheck = FDE_CSSSYNTAXCHECK_AllowImport; } 105 void DisableCharset() { m_dwCheck = FDE_CSSSYNTAXCHECK_AllowImport; }
106 FX_BOOL IsImportEnabled() const; 106 bool IsImportEnabled() const;
107 void DisableImport() { m_dwCheck = 0; } 107 void DisableImport() { m_dwCheck = 0; }
108 108
109 IFX_Stream* m_pStream; 109 IFX_Stream* m_pStream;
110 int32_t m_iStreamPos; 110 int32_t m_iStreamPos;
111 int32_t m_iPlaneSize; 111 int32_t m_iPlaneSize;
112 CFDE_CSSTextBuf m_TextData; 112 CFDE_CSSTextBuf m_TextData;
113 CFDE_CSSTextBuf m_TextPlane; 113 CFDE_CSSTextBuf m_TextPlane;
114 int32_t m_iTextDatLen; 114 int32_t m_iTextDatLen;
115 uint32_t m_dwCheck; 115 uint32_t m_dwCheck;
116 FDE_CSSSYNTAXMODE m_eMode; 116 FDE_CSSSYNTAXMODE m_eMode;
117 FDE_CSSSYNTAXSTATUS m_eStatus; 117 FDE_CSSSYNTAXSTATUS m_eStatus;
118 CFX_StackTemplate<FDE_CSSSYNTAXMODE> m_ModeStack; 118 CFX_StackTemplate<FDE_CSSSYNTAXMODE> m_ModeStack;
119 }; 119 };
120 120
121 #endif // XFA_FDE_CSS_FDE_CSSSYNTAX_H_ 121 #endif // XFA_FDE_CSS_FDE_CSSSYNTAX_H_
OLDNEW
« no previous file with comments | « xfa/fde/css/fde_cssstylesheet.cpp ('k') | xfa/fde/css/fde_csssyntax.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698