From 2aa4b2f3928ccd8393f60db8f7b740c75f4e8a8d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 25 May 2018 22:38:49 +0000 Subject: Make CPDF_Page retainable. Small step to reducing the differences between XFA and non-XFA. We still use the RetainPtr pretty much as if it were an unique_ptr, in that we're not yet caching pages and handing out multiple pointers to the same page in the non-XFA case. The one change is in page view cleanup, where we no longer need a boolean and can take (sufficient) page ownership with a RetainPtr. Tidy up some document.h -> page.h -> document.h circular inclusion while we're at it. NOTE: Wait for imminent branch to pass before landing. We'll want this to bake a while. Change-Id: I64a2f12ac3424ece1063d40583995b834117cf34 Reviewed-on: https://pdfium-review.googlesource.com/32790 Reviewed-by: dsinclair Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- fpdfsdk/fpdfxfa/cpdfxfa_page.cpp | 4 ++-- fpdfsdk/fpdfxfa/cpdfxfa_page.h | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'fpdfsdk/fpdfxfa') diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp index 170f17ea7a..4d7e3bc222 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.cpp @@ -35,7 +35,7 @@ bool CPDFXFA_Page::LoadPDFPage() { return false; if (!m_pPDFPage || m_pPDFPage->GetFormDict() != pDict) { - m_pPDFPage = pdfium::MakeUnique(pPDFDoc, pDict, true); + m_pPDFPage = pdfium::MakeRetain(pPDFDoc, pDict, true); m_pPDFPage->ParseContent(); } return true; @@ -81,7 +81,7 @@ bool CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) { return false; m_pPDFPage = - pdfium::MakeUnique(m_pContext->GetPDFDoc(), pageDict, true); + pdfium::MakeRetain(m_pContext->GetPDFDoc(), pageDict, true); m_pPDFPage->ParseContent(); return true; } diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_page.h b/fpdfsdk/fpdfxfa/cpdfxfa_page.h index 4f4d6b0a22..2573b9cebd 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_page.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_page.h @@ -29,11 +29,10 @@ class CPDFXFA_Page : public CPDF_Page::Extension { bool LoadPage(); bool LoadPDFPage(CPDF_Dictionary* pageDict); - // CPDF_Page::Extension: - CPDF_Document::Extension* GetDocumentExtension() const override; + CPDF_Document::Extension* GetDocumentExtension() const; int GetPageIndex() const { return m_iPageIndex; } - CPDF_Page* GetPDFPage() const { return m_pPDFPage.get(); } + CPDF_Page* GetPDFPage() const { return m_pPDFPage.Get(); } CXFA_FFPageView* GetXFAPageView() const { return m_pXFAPageView; } void SetXFAPageView(CXFA_FFPageView* pPageView) { @@ -61,7 +60,7 @@ class CPDFXFA_Page : public CPDF_Page::Extension { bool LoadXFAPageView(); private: - std::unique_ptr m_pPDFPage; + RetainPtr m_pPDFPage; CXFA_FFPageView* m_pXFAPageView; UnownedPtr const m_pContext; const int m_iPageIndex; -- cgit v1.2.3