summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-12-04 06:04:35 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-04 06:04:35 +0000
commit56b08b1f2bb8a4eb9330963bff3a626603499730 (patch)
tree406c3453ad65a08c56aa3c15b6f70d7b149b84a7 /xfa/fxfa
parentb8d86800487df4021860f08407c323ed82243c79 (diff)
downloadpdfium-56b08b1f2bb8a4eb9330963bff3a626603499730.tar.xz
Make CXFA_SimpleParser members const or Unowned.
Fix ownership issues, and simplify CXFA_SimpleParser ctors. Change-Id: Ie083080297c5c2586ae3e6a8355839fcb86ee9ea Reviewed-on: https://pdfium-review.googlesource.com/20130 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/parser/cxfa_dataimporter.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.h4
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp14
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.h17
5 files changed, 20 insertions, 19 deletions
diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp
index 28d0a8ce2a..2967c30304 100644
--- a/xfa/fxfa/parser/cxfa_dataimporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp
@@ -27,7 +27,7 @@ CXFA_DataImporter::~CXFA_DataImporter() {}
bool CXFA_DataImporter::ImportData(
const RetainPtr<IFX_SeekableStream>& pDataDocument) {
auto pDataDocumentParser =
- pdfium::MakeUnique<CXFA_SimpleParser>(m_pDocument.Get(), false);
+ pdfium::MakeUnique<CXFA_SimpleParser>(m_pDocument.Get());
if (pDataDocumentParser->StartParse(
pDataDocument, XFA_PacketType::Datasets) != XFA_PARSESTATUS_Ready) {
return false;
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index 0cc03b94d0..df7d789781 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -12,7 +12,7 @@
#include "xfa/fxfa/parser/cxfa_document.h"
CXFA_DocumentParser::CXFA_DocumentParser(CXFA_FFNotify* pNotify)
- : m_nodeParser(nullptr, true), m_pNotify(pNotify) {}
+ : m_pNotify(pNotify) {}
CXFA_DocumentParser::~CXFA_DocumentParser() {
}
diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h
index a3c2365b7b..6629101457 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.h
+++ b/xfa/fxfa/parser/cxfa_document_parser.h
@@ -31,9 +31,9 @@ class CXFA_DocumentParser {
CXFA_Document* GetDocument() const;
private:
- CXFA_SimpleParser m_nodeParser;
- CXFA_FFNotify* m_pNotify;
+ CXFA_FFNotify* const m_pNotify;
std::unique_ptr<CXFA_Document> m_pDocument;
+ CXFA_SimpleParser m_nodeParser;
};
#endif // XFA_FXFA_PARSER_CXFA_DOCUMENT_PARSER_H_
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 22b02ccdc8..b3965ed6a2 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -299,18 +299,15 @@ bool XFA_RecognizeRichText(CFX_XMLElement* pRichTextXMLNode) {
L"http://www.w3.org/1999/xhtml";
}
-CXFA_SimpleParser::CXFA_SimpleParser(CXFA_Document* pFactory,
- bool bDocumentParser)
- : m_pXMLParser(nullptr),
- m_pFactory(pFactory),
- m_pRootNode(nullptr),
- m_ePacketID(XFA_PacketType::User),
- m_bParseStarted(false),
- m_bDocumentParser(bDocumentParser) {}
+CXFA_SimpleParser::CXFA_SimpleParser() : m_bDocumentParser(true) {}
+
+CXFA_SimpleParser::CXFA_SimpleParser(CXFA_Document* pFactory)
+ : m_pFactory(pFactory), m_bDocumentParser(false) {}
CXFA_SimpleParser::~CXFA_SimpleParser() {}
void CXFA_SimpleParser::SetFactory(CXFA_Document* pFactory) {
+ ASSERT(m_bDocumentParser);
m_pFactory = pFactory;
}
@@ -348,6 +345,7 @@ 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();
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h
index 2ccb2c3b1a..52bb60fac5 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.h
+++ b/xfa/fxfa/parser/cxfa_simple_parser.h
@@ -22,7 +22,8 @@ class CFX_SeekableStreamProxy;
class CXFA_SimpleParser {
public:
- CXFA_SimpleParser(CXFA_Document* pFactory, bool bDocumentParser);
+ CXFA_SimpleParser();
+ explicit CXFA_SimpleParser(CXFA_Document* pFactory);
~CXFA_SimpleParser();
int32_t StartParse(const RetainPtr<IFX_SeekableStream>& pStream,
@@ -34,6 +35,7 @@ class CXFA_SimpleParser {
CFX_XMLDoc* GetXMLDoc() const;
void CloseParser();
+ // Called later for the ctor with no parameters.
void SetFactory(CXFA_Document* pFactory);
private:
@@ -71,15 +73,16 @@ class CXFA_SimpleParser {
CFX_XMLInstruction* pXMLInstruction,
XFA_PacketType ePacketID);
- CFX_XMLParser* m_pXMLParser;
+ UnownedPtr<CFX_XMLParser> m_pXMLParser; // Owned by |m_pXMLDoc|
std::unique_ptr<CFX_XMLDoc> m_pXMLDoc;
RetainPtr<CFX_SeekableStreamProxy> m_pStream;
RetainPtr<IFX_SeekableStream> m_pFileRead;
- CXFA_Document* m_pFactory;
- CXFA_Node* m_pRootNode;
- XFA_PacketType m_ePacketID;
- bool m_bParseStarted;
- bool m_bDocumentParser;
+ UnownedPtr<CXFA_Document> m_pFactory;
+ // TODO(dsinclair): Figure out who owns this.
+ CXFA_Node* m_pRootNode = nullptr;
+ XFA_PacketType m_ePacketID = XFA_PacketType::User;
+ bool m_bParseStarted = false;
+ const bool m_bDocumentParser;
};
#endif // XFA_FXFA_PARSER_CXFA_SIMPLE_PARSER_H_