From ac19439e28b67289b8ea60fea7d2806cbaa150c9 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 25 Apr 2018 14:29:32 +0000 Subject: Remove m_NodeStack from CFX_XMLParser 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 Commit-Queue: dsinclair --- core/fxcrt/xml/cfx_xmlparser.cpp | 11 +++-------- core/fxcrt/xml/cfx_xmlparser.h | 5 ----- 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'core') 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(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(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 m_NodeStack; std::stack m_XMLNodeTypeStack; std::stack m_SkipStack; std::vector m_Buffer; -- cgit v1.2.3