Chromium Code Reviews| Index: xfa/fxfa/parser/xfa_parser_imp.cpp |
| diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp |
| index 5e17df8d3a4c1882c3cf1d892c6571991f001f1d..84717f40ee1fafd53491e29e6a2fafdd5512d7af 100644 |
| --- a/xfa/fxfa/parser/xfa_parser_imp.cpp |
| +++ b/xfa/fxfa/parser/xfa_parser_imp.cpp |
| @@ -16,14 +16,9 @@ |
| #include "xfa/fxfa/parser/xfa_document.h" |
| #include "xfa/fxfa/parser/xfa_localemgr.h" |
| #include "xfa/fxfa/parser/xfa_object.h" |
| -#include "xfa/fxfa/parser/xfa_parser.h" |
| #include "xfa/fxfa/parser/xfa_script.h" |
| #include "xfa/fxfa/parser/xfa_utils.h" |
| -IXFA_Parser* IXFA_Parser::Create(CXFA_Document* pFactory, |
| - FX_BOOL bDocumentParser) { |
| - return new CXFA_SimpleParser(pFactory, bDocumentParser); |
| -} |
| CXFA_SimpleParser::CXFA_SimpleParser(CXFA_Document* pFactory, |
| FX_BOOL bDocumentParser) |
| : m_pXMLParser(nullptr), |
| @@ -34,15 +29,15 @@ CXFA_SimpleParser::CXFA_SimpleParser(CXFA_Document* pFactory, |
| m_pRootNode(nullptr), |
| m_ePacketID(XFA_XDPPACKET_UNKNOWN), |
| m_bDocumentParser(bDocumentParser) {} |
| + |
| CXFA_SimpleParser::~CXFA_SimpleParser() { |
| CloseParser(); |
| } |
| -void CXFA_SimpleParser::Release() { |
| - delete this; |
| -} |
| + |
| void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) { |
| m_pFactory = pFactory; |
| } |
| + |
| static CFDE_XMLNode* XFA_FDEExtension_GetDocumentNode( |
| CFDE_XMLDoc* pXMLDoc, |
| FX_BOOL bVerifyWellFormness = FALSE) { |
| @@ -194,10 +189,6 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode, |
| } |
| } |
| -CXFA_Document* CXFA_SimpleParser::GetFactory() const { |
| - return m_pFactory; |
| -} |
| - |
| CXFA_Node* CXFA_SimpleParser::GetRootNode() const { |
| return m_pRootNode; |
| } |
| @@ -1355,23 +1346,21 @@ void CXFA_SimpleParser::CloseParser() { |
| CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify) |
| : m_nodeParser(nullptr, TRUE), m_pNotify(pNotify), m_pDocument(nullptr) {} |
| + |
| CXFA_DocumentParser::~CXFA_DocumentParser() { |
| - CloseParser(); |
|
Lei Zhang
2016/07/06 23:02:24
No longer needed?
dsinclair
2016/07/07 13:54:44
I thought it wasn't, but looking again it needs to
|
| } |
| -void CXFA_DocumentParser::Release() { |
| - delete this; |
| -} |
| int32_t CXFA_DocumentParser::StartParse(IFX_FileRead* pStream, |
| XFA_XDPPACKET ePacketID) { |
| CloseParser(); |
| int32_t nRetStatus = m_nodeParser.StartParse(pStream, ePacketID); |
| if (nRetStatus == XFA_PARSESTATUS_Ready) { |
| - m_pDocument = new CXFA_Document(this); |
| - m_nodeParser.SetFactory(m_pDocument); |
| + m_pDocument.reset(new CXFA_Document(this)); |
| + m_nodeParser.SetFactory(m_pDocument.get()); |
| } |
| return nRetStatus; |
| } |
| + |
| int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { |
| int32_t nRetStatus = m_nodeParser.DoParse(pPause); |
| if (nRetStatus >= XFA_PARSESTATUS_Done) { |
| @@ -1380,36 +1369,6 @@ int32_t CXFA_DocumentParser::DoParse(IFX_Pause* pPause) { |
| } |
| return nRetStatus; |
| } |
| -int32_t CXFA_DocumentParser::ParseXMLData(const CFX_WideString& wsXML, |
| - CFDE_XMLNode*& pXMLNode, |
| - IFX_Pause* pPause) { |
| - CloseParser(); |
| - int32_t nRetStatus = m_nodeParser.ParseXMLData(wsXML, pXMLNode, nullptr); |
| - if (nRetStatus == XFA_PARSESTATUS_Done && pXMLNode) { |
| - m_pDocument = new CXFA_Document(this); |
| - m_nodeParser.SetFactory(m_pDocument); |
| - } |
| - return nRetStatus; |
| -} |
| -void CXFA_DocumentParser::ConstructXFANode(CXFA_Node* pXFANode, |
| - CFDE_XMLNode* pXMLNode) { |
| - if (!pXFANode || !pXMLNode) { |
| - return; |
| - } |
| - m_nodeParser.ConstructXFANode(pXFANode, pXMLNode); |
| - CXFA_Node* pRootNode = m_nodeParser.GetRootNode(); |
| - if (m_pDocument && pRootNode) { |
| - m_pDocument->SetRoot(pRootNode); |
| - } |
| -} |
| - |
| -CXFA_Document* CXFA_DocumentParser::GetFactory() const { |
| - return m_nodeParser.GetFactory(); |
| -} |
| - |
| -CXFA_Node* CXFA_DocumentParser::GetRootNode() const { |
| - return m_nodeParser.GetRootNode(); |
| -} |
| CFDE_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const { |
| return m_nodeParser.GetXMLDoc(); |
| @@ -1420,12 +1379,11 @@ CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const { |
| } |
| CXFA_Document* CXFA_DocumentParser::GetDocument() const { |
| - return m_pDocument; |
| + return m_pDocument.get(); |
| } |
| void CXFA_DocumentParser::CloseParser() { |
| - delete m_pDocument; |
| - m_pDocument = nullptr; |
| + m_pDocument.reset(nullptr); |
|
Lei Zhang
2016/07/06 23:02:24
Just reset()
dsinclair
2016/07/07 13:54:44
Done.
|
| m_nodeParser.CloseParser(); |
| } |