summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-04-09 17:27:55 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-09 17:27:55 +0000
commitd936d2931d86eb029feadd8aefbd3c7e51264a64 (patch)
tree6325dcc800614ef8c69e07b7ba90ccc83a836c0b /xfa/fxfa/parser
parent6f26db4dcbc64cc3602ffe22d1178a1abca83c96 (diff)
downloadpdfium-d936d2931d86eb029feadd8aefbd3c7e51264a64.tar.xz
Move the CFX_XMLParser out of CXFA_SimpleParser
This CL removes the CFX_XMLParser from CXFA_SimpleParser and constructs it in the CFX_XMLDoc. Change-Id: Id69b396f091892170a4c4654ac1d0fd65d1efbb6 Reviewed-on: https://pdfium-review.googlesource.com/29970 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp28
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.h2
2 files changed, 10 insertions, 20 deletions
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index f30ab6b631..de9f74f291 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -350,12 +350,8 @@ int32_t CXFA_SimpleParser::StartParse(
wCodePage != FX_CODEPAGE_UTF8) {
m_pStream->SetCodePage(FX_CODEPAGE_UTF8);
}
- m_pXMLDoc = pdfium::MakeUnique<CFX_XMLDoc>();
- auto pNewParser =
- pdfium::MakeUnique<CFX_XMLParser>(m_pXMLDoc->GetRoot(), m_pStream);
- m_pXMLParser = pNewParser.get();
- if (!m_pXMLDoc->LoadXML(std::move(pNewParser)))
- return XFA_PARSESTATUS_StatusErr;
+
+ m_pXMLDoc = pdfium::MakeUnique<CFX_XMLDoc>(m_pStream);
m_bParseStarted = true;
m_ePacketID = ePacketID;
@@ -373,7 +369,6 @@ int32_t CXFA_SimpleParser::DoParse() {
return iRet / 2;
m_pRootNode = ParseAsXDPPacket(GetDocumentNode(m_pXMLDoc.get()), m_ePacketID);
- m_pXMLParser.Release();
m_pXMLDoc->CloseXML();
m_pStream.Reset();
@@ -385,15 +380,11 @@ int32_t CXFA_SimpleParser::DoParse() {
CFX_XMLNode* CXFA_SimpleParser::ParseXMLData(const ByteString& wsXML) {
CloseParser();
- m_pXMLDoc = pdfium::MakeUnique<CFX_XMLDoc>();
auto pStream = pdfium::MakeRetain<CFX_SeekableStreamProxy>(
const_cast<uint8_t*>(wsXML.raw_str()), wsXML.GetLength());
- auto pParser =
- pdfium::MakeUnique<CFX_XMLParser>(m_pXMLDoc->GetRoot(), pStream);
- pParser->m_dwCheckStatus = 0x03;
- if (!m_pXMLDoc->LoadXML(std::move(pParser)))
- return nullptr;
+ m_pXMLDoc = pdfium::MakeUnique<CFX_XMLDoc>(pStream);
+ m_pXMLDoc->GetParser()->m_dwCheckStatus = 0x03;
int32_t iRet = m_pXMLDoc->DoLoad();
if (iRet < 0 || iRet >= 100)
@@ -662,16 +653,17 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Form(
CFX_XMLElement* pXMLDocumentElement =
static_cast<CFX_XMLElement*>(pXMLDocumentNode);
WideString wsChecksum = pXMLDocumentElement->GetString(L"checksum");
- if (wsChecksum.GetLength() != 28 || m_pXMLParser->m_dwCheckStatus != 0x03) {
+ if (wsChecksum.GetLength() != 28 ||
+ m_pXMLDoc->GetParser()->m_dwCheckStatus != 0x03) {
return nullptr;
}
auto pChecksum = pdfium::MakeUnique<CFX_ChecksumContext>();
pChecksum->StartChecksum();
- pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[0],
- m_pXMLParser->m_nSize[0]);
- pChecksum->UpdateChecksum(m_pFileRead, m_pXMLParser->m_nStart[1],
- m_pXMLParser->m_nSize[1]);
+ pChecksum->UpdateChecksum(m_pFileRead, m_pXMLDoc->GetParser()->m_nStart[0],
+ m_pXMLDoc->GetParser()->m_nSize[0]);
+ pChecksum->UpdateChecksum(m_pFileRead, m_pXMLDoc->GetParser()->m_nStart[1],
+ m_pXMLDoc->GetParser()->m_nSize[1]);
pChecksum->FinishChecksum();
ByteString bsCheck = pChecksum->GetChecksum();
if (bsCheck != wsChecksum.UTF8Encode())
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h
index c1015469c9..1300a8c4f2 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.h
+++ b/xfa/fxfa/parser/cxfa_simple_parser.h
@@ -16,7 +16,6 @@ class CXFA_Node;
class CFX_XMLDoc;
class CFX_XMLInstruction;
class CFX_XMLNode;
-class CFX_XMLParser;
class IFX_SeekableStream;
class CFX_SeekableStreamProxy;
@@ -73,7 +72,6 @@ class CXFA_SimpleParser {
XFA_PacketType ePacketID);
std::unique_ptr<CFX_XMLDoc> m_pXMLDoc;
- UnownedPtr<CFX_XMLParser> m_pXMLParser; // Owned by |m_pXMLDoc|
RetainPtr<CFX_SeekableStreamProxy> m_pStream;
RetainPtr<IFX_SeekableStream> m_pFileRead;
UnownedPtr<CXFA_Document> m_pFactory;