summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-12-04 06:13:55 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-04 06:13:55 +0000
commit8509d3eaec1b2fac27a24de7bc586ad12b7bb178 (patch)
tree820b680b9b313b3788165a3de7e4c08901f2f6e4
parent56b08b1f2bb8a4eb9330963bff3a626603499730 (diff)
downloadpdfium-8509d3eaec1b2fac27a24de7bc586ad12b7bb178.tar.xz
Make a CXFA_DocumentParser member Unowned.
Fix/cleanup ctors/dtors in related classes. Change-Id: Ia05ec9b6892fd7d19d0a417fc1226a407e3ac260 Reviewed-on: https://pdfium-review.googlesource.com/20216 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.cpp9
-rw-r--r--fpdfsdk/fpdfxfa/cpdfxfa_context.h6
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp8
-rw-r--r--xfa/fxfa/cxfa_ffdoc.h4
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.h2
6 files changed, 11 insertions, 20 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
index 4b67d0cf3f..d05e2f6b34 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp
@@ -36,14 +36,9 @@ extern int GetLastError();
#endif
CPDFXFA_Context::CPDFXFA_Context(std::unique_ptr<CPDF_Document> pPDFDoc)
- : m_FormType(FormType::kNone),
- m_pPDFDoc(std::move(pPDFDoc)),
- m_pFormFillEnv(nullptr),
- m_pXFADocView(nullptr),
- m_nLoadStatus(FXFA_LOADSTATUS_PRELOAD),
- m_nPageCount(0),
+ : m_pPDFDoc(std::move(pPDFDoc)),
+ m_pXFAApp(pdfium::MakeUnique<CXFA_FFApp>(this)),
m_DocEnv(this) {
- m_pXFAApp = pdfium::MakeUnique<CXFA_FFApp>(this);
m_pXFAApp->SetDefaultFontMgr(pdfium::MakeUnique<CFGAS_DefaultFontManager>());
}
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
index f5b62f53da..acef8f2aa8 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
@@ -105,7 +105,7 @@ class CPDFXFA_Context : public IXFA_AppProvider {
private:
void CloseXFADoc();
- FormType m_FormType;
+ FormType m_FormType = FormType::kNone;
std::unique_ptr<CPDF_Document> m_pPDFDoc;
std::unique_ptr<CXFA_FFDoc> m_pXFADoc;
Observable<CPDFSDK_FormFillEnvironment>::ObservedPtr m_pFormFillEnv;
@@ -113,8 +113,8 @@ class CPDFXFA_Context : public IXFA_AppProvider {
std::unique_ptr<CXFA_FFApp> m_pXFAApp;
std::unique_ptr<CJS_Runtime> m_pRuntime;
std::vector<RetainPtr<CPDFXFA_Page>> m_XFAPageList;
- LoadStatus m_nLoadStatus;
- int m_nPageCount;
+ LoadStatus m_nLoadStatus = FXFA_LOADSTATUS_PRELOAD;
+ int m_nPageCount = 0;
// Must be destroyed before |m_pFormFillEnv|.
CPDFXFA_DocEnvironment m_DocEnv;
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index bf8168d4cc..8ca1e95d87 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -155,12 +155,7 @@ int32_t Base64DecodeW(const wchar_t* pSrc, int32_t iSrcLen, uint8_t* pDst) {
} // namespace
CXFA_FFDoc::CXFA_FFDoc(CXFA_FFApp* pApp, IXFA_DocEnvironment* pDocEnvironment)
- : m_pDocEnvironment(pDocEnvironment),
- m_pDocumentParser(nullptr),
- m_pApp(pApp),
- m_pNotify(nullptr),
- m_pPDFDoc(nullptr),
- m_FormType(FormType::kXFAForeground) {}
+ : m_pDocEnvironment(pDocEnvironment), m_pApp(pApp) {}
CXFA_FFDoc::~CXFA_FFDoc() {
CloseDoc();
@@ -328,6 +323,7 @@ void CXFA_FFDoc::CloseDoc() {
if (doc)
doc->ClearLayoutData();
+ m_pDocumentParser.reset();
m_pNotify.reset();
m_pPDFFontMgr.reset();
m_HashToDibDpiMap.clear();
diff --git a/xfa/fxfa/cxfa_ffdoc.h b/xfa/fxfa/cxfa_ffdoc.h
index 10ffa36275..475ead3035 100644
--- a/xfa/fxfa/cxfa_ffdoc.h
+++ b/xfa/fxfa/cxfa_ffdoc.h
@@ -85,13 +85,13 @@ class CXFA_FFDoc {
UnownedPtr<IXFA_DocEnvironment> const m_pDocEnvironment;
std::unique_ptr<CXFA_DocumentParser> m_pDocumentParser;
RetainPtr<IFX_SeekableStream> m_pStream;
- UnownedPtr<CXFA_FFApp> m_pApp;
+ UnownedPtr<CXFA_FFApp> const m_pApp;
std::unique_ptr<CXFA_FFNotify> m_pNotify;
UnownedPtr<CPDF_Document> m_pPDFDoc;
std::map<uint32_t, FX_IMAGEDIB_AND_DPI> m_HashToDibDpiMap;
std::unique_ptr<CXFA_FFDocView> m_DocView;
std::unique_ptr<CFGAS_PDFFontMgr> m_pPDFFontMgr;
- FormType m_FormType;
+ FormType m_FormType = FormType::kXFAForeground;
};
#endif // XFA_FXFA_CXFA_FFDOC_H_
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index df7d789781..6446ea31ce 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -45,7 +45,7 @@ CFX_XMLDoc* CXFA_DocumentParser::GetXMLDoc() const {
}
CXFA_FFNotify* CXFA_DocumentParser::GetNotify() const {
- return m_pNotify;
+ return m_pNotify.Get();
}
CXFA_Document* CXFA_DocumentParser::GetDocument() const {
diff --git a/xfa/fxfa/parser/cxfa_document_parser.h b/xfa/fxfa/parser/cxfa_document_parser.h
index 6629101457..35d71603cb 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.h
+++ b/xfa/fxfa/parser/cxfa_document_parser.h
@@ -31,7 +31,7 @@ class CXFA_DocumentParser {
CXFA_Document* GetDocument() const;
private:
- CXFA_FFNotify* const m_pNotify;
+ UnownedPtr<CXFA_FFNotify> const m_pNotify;
std::unique_ptr<CXFA_Document> m_pDocument;
CXFA_SimpleParser m_nodeParser;
};