From 2efb11c89ee200473f5675ba3d3a946d5606e813 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 12 Apr 2018 13:21:48 +0000 Subject: Retrieve the XML tree in the DocumentParser This CL changes the document parser to store the parsed XML tree. That way we no longer need to store the pointer to the CXFA_SimpleParser in the CXFA_DocumentParser. Change-Id: I9272150e73613411cb1bb59c3cf77c7af6cc799d Reviewed-on: https://pdfium-review.googlesource.com/30211 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_document_parser.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_document_parser.cpp') diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index 883f684768..52b5e333c0 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -18,17 +18,22 @@ CXFA_DocumentParser::~CXFA_DocumentParser() { m_pDocument->ReleaseXMLNodesIfNeeded(); } -int32_t CXFA_DocumentParser::Parse(const RetainPtr& pStream, - XFA_PacketType ePacketID) { +bool CXFA_DocumentParser::Parse(const RetainPtr& pStream, + XFA_PacketType ePacketID) { m_pDocument = pdfium::MakeUnique(GetNotify()); - m_nodeParser.SetFactory(m_pDocument.get()); - if (!m_nodeParser.Parse(pStream, ePacketID)) - return XFA_PARSESTATUS_StatusErr; + // Note, we don't pass the document into the constructor as currently that + // triggers different behaviour in the parser. + CXFA_SimpleParser parser; + parser.SetFactory(m_pDocument.get()); - ASSERT(m_pDocument); - m_pDocument->SetRoot(m_nodeParser.GetRootNode()); - return XFA_PARSESTATUS_Done; + if (!parser.Parse(pStream, ePacketID)) + return false; + + m_pXMLRoot = parser.GetXMLRoot(); + + m_pDocument->SetRoot(parser.GetRootNode()); + return true; } CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const { -- cgit v1.2.3