OLD | NEW |
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 "xfa/fde/css/fde_csssyntax.h" | 7 #include "xfa/fde/css/fde_csssyntax.h" |
8 | 8 |
9 #include "xfa/fde/css/fde_cssdatatable.h" | 9 #include "xfa/fde/css/fde_cssdatatable.h" |
10 #include "xfa/fgas/crt/fgas_codepage.h" | 10 #include "xfa/fgas/crt/fgas_codepage.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 bool FDE_IsSelectorStart(FX_WCHAR wch) { | 14 bool FDE_IsSelectorStart(FX_WCHAR wch) { |
15 return wch == '.' || wch == '#' || wch == '*' || (wch >= 'a' && wch <= 'z') || | 15 return wch == '.' || wch == '#' || wch == '*' || (wch >= 'a' && wch <= 'z') || |
16 (wch >= 'A' && wch <= 'Z'); | 16 (wch >= 'A' && wch <= 'Z'); |
17 } | 17 } |
18 | 18 |
19 } // namespace | 19 } // namespace |
20 | 20 |
21 CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser() | 21 CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser() |
22 : m_pStream(nullptr), | 22 : m_pStream(nullptr), |
23 m_iStreamPos(0), | 23 m_iStreamPos(0), |
24 m_iPlaneSize(0), | 24 m_iPlaneSize(0), |
25 m_iTextDatLen(0), | 25 m_iTextDatLen(0), |
26 m_dwCheck((uint32_t)-1), | 26 m_dwCheck((uint32_t)-1), |
27 m_eMode(FDE_CSSSYNTAXMODE_RuleSet), | 27 m_eMode(FDE_CSSSYNTAXMODE_RuleSet), |
28 m_eStatus(FDE_CSSSYNTAXSTATUS_None) {} | 28 m_eStatus(FDE_CSSSYNTAXSTATUS_None), |
| 29 m_ModeStack(100) {} |
| 30 |
29 CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() { | 31 CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() { |
30 m_TextData.Reset(); | 32 m_TextData.Reset(); |
31 m_TextPlane.Reset(); | 33 m_TextPlane.Reset(); |
32 } | 34 } |
| 35 |
33 FX_BOOL CFDE_CSSSyntaxParser::Init(IFX_Stream* pStream, | 36 FX_BOOL CFDE_CSSSyntaxParser::Init(IFX_Stream* pStream, |
34 int32_t iCSSPlaneSize, | 37 int32_t iCSSPlaneSize, |
35 int32_t iTextDataSize, | 38 int32_t iTextDataSize, |
36 FX_BOOL bOnlyDeclaration) { | 39 FX_BOOL bOnlyDeclaration) { |
37 ASSERT(pStream && iCSSPlaneSize > 0 && iTextDataSize > 0); | 40 ASSERT(pStream && iCSSPlaneSize > 0 && iTextDataSize > 0); |
38 Reset(bOnlyDeclaration); | 41 Reset(bOnlyDeclaration); |
39 if (!m_TextData.EstimateSize(iTextDataSize)) { | 42 if (!m_TextData.EstimateSize(iTextDataSize)) { |
40 return FALSE; | 43 return FALSE; |
41 } | 44 } |
42 uint8_t bom[4]; | 45 uint8_t bom[4]; |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 if (iLength > m_iDatLen - iStart) { | 474 if (iLength > m_iDatLen - iStart) { |
472 iLength = m_iDatLen - iStart; | 475 iLength = m_iDatLen - iStart; |
473 } | 476 } |
474 if (iLength < 0) { | 477 if (iLength < 0) { |
475 iLength = 0; | 478 iLength = 0; |
476 } else { | 479 } else { |
477 FXSYS_memmove(m_pBuffer, m_pBuffer + iStart, iLength * sizeof(FX_WCHAR)); | 480 FXSYS_memmove(m_pBuffer, m_pBuffer + iStart, iLength * sizeof(FX_WCHAR)); |
478 } | 481 } |
479 m_iDatLen = iLength; | 482 m_iDatLen = iLength; |
480 } | 483 } |
OLD | NEW |