diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-05-16 14:11:30 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-16 21:51:53 +0000 |
commit | 9792f16f3ef27a1e0c7f0526cc69637a158e3010 (patch) | |
tree | 861baddf94e96d7de9bc2c2b27409872d56ebcee /fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | |
parent | cc205131b021ebded854958973f445ed121da1b8 (diff) | |
download | pdfium-9792f16f3ef27a1e0c7f0526cc69637a158e3010.tar.xz |
Properly ref-count CPDFXFA_Page
Change-Id: Ibd1ebe4191f61e20d815de7f1a1094d78b72e6a7
Reviewed-on: https://pdfium-review.googlesource.com/5391
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp')
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index 1a27d9b015..11b001fc7f 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -63,7 +63,7 @@ void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView, if (m_pContext->GetDocType() != XFA_DocType::Dynamic) return; - CPDFXFA_Page* pPage = m_pContext->GetXFAPage(pPageView); + CFX_RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(pPageView); if (!pPage) return; @@ -71,7 +71,7 @@ void CPDFXFA_DocEnvironment::InvalidateRect(CXFA_FFPageView* pPageView, if (!pFormFillEnv) return; - pFormFillEnv->Invalidate(static_cast<FPDF_PAGE>(pPage), + pFormFillEnv->Invalidate(static_cast<FPDF_PAGE>(pPage.Get()), CFX_FloatRect::FromCFXRectF(rt).ToFxRect()); } @@ -94,7 +94,7 @@ void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget, if (!pPageView) return; - CPDFXFA_Page* pPage = m_pContext->GetXFAPage(pPageView); + CFX_RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(pPageView); if (!pPage) return; @@ -103,8 +103,9 @@ void CPDFXFA_DocEnvironment::DisplayCaret(CXFA_FFWidget* hWidget, return; CFX_FloatRect rcCaret = CFX_FloatRect::FromCFXRectF(*pRtAnchor); - pFormFillEnv->DisplayCaret((FPDF_PAGE)pPage, bVisible, rcCaret.left, - rcCaret.top, rcCaret.right, rcCaret.bottom); + pFormFillEnv->DisplayCaret(static_cast<FPDF_PAGE>(pPage.Get()), bVisible, + rcCaret.left, rcCaret.top, rcCaret.right, + rcCaret.bottom); } bool CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget, @@ -119,22 +120,21 @@ bool CPDFXFA_DocEnvironment::GetPopupPos(CXFA_FFWidget* hWidget, if (!pXFAPageView) return false; - CPDFXFA_Page* pPage = m_pContext->GetXFAPage(pXFAPageView); + CFX_RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(pXFAPageView); if (!pPage) return false; - CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); - int nRotate = pWidgetAcc->GetRotate(); CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); if (!pFormFillEnv) return false; FS_RECTF pageViewRect = {0.0f, 0.0f, 0.0f, 0.0f}; - pFormFillEnv->GetPageViewRect(pPage, pageViewRect); + pFormFillEnv->GetPageViewRect(pPage.Get(), pageViewRect); int t1; int t2; CFX_FloatRect rcAnchor = CFX_FloatRect::FromCFXRectF(rtAnchor); + int nRotate = hWidget->GetDataAcc()->GetRotate(); switch (nRotate) { case 90: { t1 = (int)(pageViewRect.right - rcAnchor.right); @@ -232,7 +232,7 @@ bool CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget, if (!pXFAPageView) return false; - CPDFXFA_Page* pPage = m_pContext->GetXFAPage(pXFAPageView); + CFX_RetainPtr<CPDFXFA_Page> pPage = m_pContext->GetXFAPage(pXFAPageView); if (!pPage) return false; @@ -254,7 +254,7 @@ bool CPDFXFA_DocEnvironment::PopupMenu(CXFA_FFWidget* hWidget, if (hWidget->CanSelectAll()) menuFlag |= FXFA_MENU_SELECTALL; - return pFormFillEnv->PopupMenu(pPage, hWidget, menuFlag, ptPopup); + return pFormFillEnv->PopupMenu(pPage.Get(), hWidget, menuFlag, ptPopup); } void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, @@ -278,11 +278,12 @@ void CPDFXFA_DocEnvironment::PageViewEvent(CXFA_FFPageView* pPageView, for (int iPageIter = 0; iPageIter < m_pContext->GetOriginalPageCount(); iPageIter++) { - CPDFXFA_Page* pPage = (*m_pContext->GetXFAPageList())[iPageIter]; + CFX_RetainPtr<CPDFXFA_Page> pPage = + (*m_pContext->GetXFAPageList())[iPageIter]; if (!pPage) continue; - m_pContext->GetFormFillEnv()->RemovePageView(pPage); + m_pContext->GetFormFillEnv()->RemovePageView(pPage.Get()); pPage->SetXFAPageView(pXFADocView->GetPageView(iPageIter)); } @@ -303,11 +304,13 @@ void CPDFXFA_DocEnvironment::WidgetPostAdd(CXFA_FFWidget* hWidget, if (!pPageView) return; - CPDFXFA_Page* pXFAPage = m_pContext->GetXFAPage(pPageView); + CFX_RetainPtr<CPDFXFA_Page> pXFAPage = m_pContext->GetXFAPage(pPageView); if (!pXFAPage) return; - m_pContext->GetFormFillEnv()->GetPageView(pXFAPage, true)->AddAnnot(hWidget); + m_pContext->GetFormFillEnv() + ->GetPageView(pXFAPage.Get(), true) + ->AddAnnot(hWidget); } void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget, @@ -319,13 +322,14 @@ void CPDFXFA_DocEnvironment::WidgetPreRemove(CXFA_FFWidget* hWidget, if (!pPageView) return; - CPDFXFA_Page* pXFAPage = m_pContext->GetXFAPage(pPageView); + CFX_RetainPtr<CPDFXFA_Page> pXFAPage = m_pContext->GetXFAPage(pPageView); if (!pXFAPage) return; CPDFSDK_PageView* pSdkPageView = - m_pContext->GetFormFillEnv()->GetPageView(pXFAPage, true); - if (CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget)) + m_pContext->GetFormFillEnv()->GetPageView(pXFAPage.Get(), true); + CPDFSDK_Annot* pAnnot = pSdkPageView->GetAnnotByXFAWidget(hWidget); + if (pAnnot) pSdkPageView->DeleteAnnot(pAnnot); } |