Chromium Code Reviews| Index: fpdfsdk/fpdfxfa/fpdfxfa_page.cpp |
| diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp |
| index 8179db5c11d2a5635239eb095b4c7e63f08a4291..539276bf0bd94ae025f27e0497b74fbcb7d7de33 100644 |
| --- a/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp |
| +++ b/fpdfsdk/fpdfxfa/fpdfxfa_page.cpp |
| @@ -16,22 +16,15 @@ |
| #include "xfa/fxfa/include/xfa_ffpageview.h" |
| CPDFXFA_Page::CPDFXFA_Page(CPDFXFA_Document* pDoc, int page_index) |
| - : m_pPDFPage(NULL), |
| - m_pXFAPageView(NULL), |
| - m_iPageIndex(page_index), |
| + : m_pXFAPageView(nullptr), |
| m_pDocument(pDoc), |
| + m_iPageIndex(page_index), |
| m_iRef(1) {} |
| -CPDFXFA_Page::~CPDFXFA_Page() { |
| - if (m_pPDFPage) |
| - delete m_pPDFPage; |
| - m_pPDFPage = NULL; |
| - m_pXFAPageView = NULL; |
| -} |
| +CPDFXFA_Page::~CPDFXFA_Page() {} |
| void CPDFXFA_Page::Release() { |
| - m_iRef--; |
| - if (m_iRef > 0) |
| + if (--m_iRef > 0) |
| return; |
| if (m_pDocument) |
| @@ -43,31 +36,27 @@ void CPDFXFA_Page::Release() { |
| FX_BOOL CPDFXFA_Page::LoadPDFPage() { |
| if (!m_pDocument) |
| return FALSE; |
| + |
| CPDF_Document* pPDFDoc = m_pDocument->GetPDFDoc(); |
| - if (pPDFDoc) { |
| - CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex); |
| - if (pDict == NULL) |
| - return FALSE; |
| - if (m_pPDFPage) { |
| - if (m_pPDFPage->m_pFormDict == pDict) |
| - return TRUE; |
| + if (!pPDFDoc) |
| + return FALSE; |
| - delete m_pPDFPage; |
| - m_pPDFPage = NULL; |
| - } |
| + CPDF_Dictionary* pDict = pPDFDoc->GetPage(m_iPageIndex); |
| + if (!pDict) |
| + return FALSE; |
| - m_pPDFPage = new CPDF_Page; |
| + if (!m_pPDFPage || m_pPDFPage->m_pFormDict != pDict) { |
| + m_pPDFPage.reset(new CPDF_Page); |
| m_pPDFPage->Load(pPDFDoc, pDict); |
| m_pPDFPage->ParseContent(nullptr); |
| - return TRUE; |
| } |
| - |
| - return FALSE; |
| + return TRUE; |
| } |
| FX_BOOL CPDFXFA_Page::LoadXFAPageView() { |
| if (!m_pDocument) |
| return FALSE; |
| + |
| CXFA_FFDoc* pXFADoc = m_pDocument->GetXFADoc(); |
| if (!pXFADoc) |
| return FALSE; |
| @@ -84,7 +73,7 @@ FX_BOOL CPDFXFA_Page::LoadXFAPageView() { |
| return TRUE; |
| m_pXFAPageView = pPageView; |
| - (void)m_pXFAPageView->LoadPageView(nullptr); |
| + m_pXFAPageView->LoadPageView(nullptr); |
|
Tom Sepez
2016/04/12 23:40:00
nit: I think this (void) was shorthand for // FIXM
Lei Zhang
2016/04/13 00:56:52
Not worth checking. See next patch set.
|
| return TRUE; |
| } |
| @@ -110,17 +99,13 @@ FX_BOOL CPDFXFA_Page::LoadPDFPage(CPDF_Dictionary* pageDict) { |
| if (!m_pDocument || m_iPageIndex < 0 || !pageDict) |
| return FALSE; |
| - if (m_pPDFPage) |
| - delete m_pPDFPage; |
| - |
| - m_pPDFPage = new CPDF_Page(); |
| + m_pPDFPage.reset(new CPDF_Page()); |
| m_pPDFPage->Load(m_pDocument->GetPDFDoc(), pageDict); |
| m_pPDFPage->ParseContent(nullptr); |
| - |
| return TRUE; |
| } |
| -FX_FLOAT CPDFXFA_Page::GetPageWidth() { |
| +FX_FLOAT CPDFXFA_Page::GetPageWidth() const { |
| if (!m_pPDFPage && !m_pXFAPageView) |
| return 0.0f; |
| @@ -145,7 +130,7 @@ FX_FLOAT CPDFXFA_Page::GetPageWidth() { |
| return 0.0f; |
| } |
| -FX_FLOAT CPDFXFA_Page::GetPageHeight() { |
| +FX_FLOAT CPDFXFA_Page::GetPageHeight() const { |
| if (!m_pPDFPage && !m_pXFAPageView) |
| return 0.0f; |