diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-04-25 14:29:32 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-25 14:29:32 +0000 |
commit | ac19439e28b67289b8ea60fea7d2806cbaa150c9 (patch) | |
tree | 066170b5797fb7e415e51ed694d057421f827d15 | |
parent | a1d344230925e94bbf43a62ddc814321056c68d5 (diff) | |
download | pdfium-ac19439e28b67289b8ea60fea7d2806cbaa150c9.tar.xz |
Remove m_NodeStack from CFX_XMLParserchromium/3408
This CL removes the m_NodeStack member from the CFX_XMLParser. Instead
of using the node stack we retrieve the parent by getting the current
childs parent.
Change-Id: I0c4c220d14e35c5b6edc5c9c6a3008368f2d550a
Reviewed-on: https://pdfium-review.googlesource.com/31290
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | core/fxcrt/xml/cfx_xmlparser.cpp | 11 | ||||
-rw-r--r-- | core/fxcrt/xml/cfx_xmlparser.h | 5 |
2 files changed, 3 insertions, 13 deletions
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp index 651ebb41eb..685655e815 100644 --- a/core/fxcrt/xml/cfx_xmlparser.cpp +++ b/core/fxcrt/xml/cfx_xmlparser.cpp @@ -72,8 +72,6 @@ CFX_XMLParser::CFX_XMLParser(CFX_XMLNode* pParent, } m_pStream = proxy; - m_NodeStack.push(m_pParent); - m_iXMLPlaneSize = std::min(m_iXMLPlaneSize, pdfium::base::checked_cast<size_t>(m_pStream->GetSize())); @@ -117,12 +115,10 @@ bool CFX_XMLParser::Parse() { return false; } - if (!m_NodeStack.empty()) - m_NodeStack.pop(); - if (m_NodeStack.empty()) + if (!m_pChild || !m_pChild->GetParent()) return false; - m_pParent = m_NodeStack.top(); + m_pParent = m_pChild->GetParent(); m_pChild = m_pParent; iCount++; break; @@ -142,7 +138,6 @@ bool CFX_XMLParser::Parse() { auto child = pdfium::MakeUnique<CFX_XMLElement>(GetTextData()); m_pChild = child.get(); m_pParent->AppendChild(std::move(child)); - m_NodeStack.push(m_pChild); m_pParent = m_pChild; break; } @@ -192,7 +187,7 @@ bool CFX_XMLParser::Parse() { break; } } - return m_NodeStack.size() != 1 ? false : GetStatus(); + return !m_pParent || m_pParent->GetParent() ? false : GetStatus(); } FX_XmlSyntaxResult CFX_XMLParser::DoSyntaxParse() { diff --git a/core/fxcrt/xml/cfx_xmlparser.h b/core/fxcrt/xml/cfx_xmlparser.h index 6db24e5040..e2a2d5b30f 100644 --- a/core/fxcrt/xml/cfx_xmlparser.h +++ b/core/fxcrt/xml/cfx_xmlparser.h @@ -61,14 +61,10 @@ class CFX_XMLParser { AttriEqualSign, AttriQuotation, AttriValue, - Entity, - EntityDecimal, - EntityHex, CloseInstruction, BreakElement, CloseElement, SkipDeclNode, - DeclCharData, SkipComment, SkipCommentOrDecl, SkipCData, @@ -86,7 +82,6 @@ class CFX_XMLParser { FX_FILESIZE m_End = 0; // End position in m_Buffer FX_XmlSyntaxResult m_syntaxParserResult = FX_XmlSyntaxResult::None; FDE_XmlSyntaxState m_syntaxParserState = FDE_XmlSyntaxState::Text; - std::stack<CFX_XMLNode*> m_NodeStack; std::stack<FX_XMLNODETYPE> m_XMLNodeTypeStack; std::stack<wchar_t> m_SkipStack; std::vector<wchar_t> m_Buffer; |