diff options
author | Lei Zhang <thestig@chromium.org> | 2017-06-26 15:28:15 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-06-30 18:51:27 +0000 |
commit | f3024c3b1fbbfe442f93da3459ea79e817d5b8fe (patch) | |
tree | 86652e7b9fc74c60bb966883d02ea14ca0d2995b /xfa/fde/css/cfde_csssyntaxparser.cpp | |
parent | d24236a926deeb8b9589c330c27dbd300b7f8c9d (diff) | |
download | pdfium-f3024c3b1fbbfe442f93da3459ea79e817d5b8fe.tar.xz |
Split CFDE_CSSTextBuf in two.
For the external buffer use case, use a CFDE_CSSExtTextBuf instead. With
the split, both text buffer implementations are simpler now. As a
result, it becomes obvious where it never fails. Adjust callers
accordingly.
Change-Id: I7b53d36593172487b8c939e6a55af2437ea4ee5a
Reviewed-on: https://pdfium-review.googlesource.com/6932
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa/fde/css/cfde_csssyntaxparser.cpp')
-rw-r--r-- | xfa/fde/css/cfde_csssyntaxparser.cpp | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/xfa/fde/css/cfde_csssyntaxparser.cpp b/xfa/fde/css/cfde_csssyntaxparser.cpp index b896eb79b8..51d99f1992 100644 --- a/xfa/fde/css/cfde_csssyntaxparser.cpp +++ b/xfa/fde/css/cfde_csssyntaxparser.cpp @@ -22,39 +22,26 @@ bool IsSelectorStart(wchar_t wch) { } // namespace -CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser() +CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser(const wchar_t* pBuffer, + int32_t iBufferSize) + : CFDE_CSSSyntaxParser(pBuffer, iBufferSize, 32, false) {} + +CFDE_CSSSyntaxParser::CFDE_CSSSyntaxParser(const wchar_t* pBuffer, + int32_t iBufferSize, + int32_t iTextDatSize, + bool bOnlyDeclaration) : m_iTextDataLen(0), m_dwCheck(0xFFFFFFFF), - m_eMode(FDE_CSSSyntaxMode::RuleSet), - m_eStatus(FDE_CSSSyntaxStatus::None) {} - -CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() { - m_TextData.Reset(); - m_TextPlane.Reset(); -} - -bool CFDE_CSSSyntaxParser::Init(const wchar_t* pBuffer, - int32_t iBufferSize, - int32_t iTextDatSize, - bool bOnlyDeclaration) { + m_eStatus(FDE_CSSSyntaxStatus::None) { ASSERT(pBuffer && iBufferSize > 0 && iTextDatSize > 0); - Reset(bOnlyDeclaration); - if (!m_TextData.EstimateSize(iTextDatSize)) - return false; - m_TextPlane.AttachBuffer(pBuffer, iBufferSize); - return true; -} - -void CFDE_CSSSyntaxParser::Reset(bool bOnlyDeclaration) { - m_TextPlane.Reset(); - m_TextData.Reset(); - m_iTextDataLen = 0; - m_dwCheck = 0xFFFFFFFF; - m_eStatus = FDE_CSSSyntaxStatus::None; m_eMode = bOnlyDeclaration ? FDE_CSSSyntaxMode::PropertyName : FDE_CSSSyntaxMode::RuleSet; + m_TextData.InitWithSize(iTextDatSize); + m_TextPlane.AttachBuffer(pBuffer, iBufferSize); } +CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() {} + FDE_CSSSyntaxStatus CFDE_CSSSyntaxParser::DoSyntaxParse() { while (m_eStatus >= FDE_CSSSyntaxStatus::None) { if (m_TextPlane.IsEOF()) { @@ -171,7 +158,7 @@ FDE_CSSSyntaxStatus CFDE_CSSSyntaxParser::DoSyntaxParse() { break; case FDE_CSSSyntaxMode::Comment: if (wch == '/' && m_TextData.GetLength() > 0 && - m_TextData.GetAt(m_TextData.GetLength() - 1) == '*') { + m_TextData.GetBuffer()[m_TextData.GetLength() - 1] == '*') { RestoreMode(); } else { m_TextData.AppendChar(wch); |