Chromium Code Reviews| Index: fpdfsdk/src/fsdk_mgr.cpp |
| diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp |
| index 53a774edcd11bdd5f76ec63ab5a72d04791b2d92..0b6770174bdafc9d6f7022fd328d0425d943e925 100644 |
| --- a/fpdfsdk/src/fsdk_mgr.cpp |
| +++ b/fpdfsdk/src/fsdk_mgr.cpp |
| @@ -664,8 +664,8 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice, |
| CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
| FX_FLOAT pageY) { |
| - int nCount = CountAnnots(); |
| - for (int i = 0; i < nCount; i++) { |
| + const int nCount = m_pAnnotList->Count(); |
|
Lei Zhang
2015/10/30 17:02:53
This is what went wrong in the previous try.
|
| + for (int i = 0; i < nCount; ++i) { |
| CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
| CFX_FloatRect annotRect; |
| pAnnot->GetRect(annotRect); |
| @@ -677,7 +677,7 @@ CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, |
| CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, |
| FX_FLOAT pageY) { |
| - int nCount = CountAnnots(); |
| + const int nCount = m_pAnnotList->Count(); |
| for (int i = 0; i < nCount; ++i) { |
| CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); |
| if (pAnnot->GetSubType() == "Widget") { |
| @@ -764,8 +764,8 @@ CPDF_Document* CPDFSDK_PageView::GetPDFDocument() { |
| return NULL; |
| } |
| -int CPDFSDK_PageView::CountAnnots() const { |
| - return m_pAnnotList->Count(); |
| +size_t CPDFSDK_PageView::CountAnnots() const { |
| + return m_fxAnnotArray.size(); |
| } |
| CPDFSDK_Annot* CPDFSDK_PageView::GetAnnot(size_t nIndex) { |
| @@ -899,7 +899,7 @@ void CPDFSDK_PageView::LoadFXAnnots() { |
| CPDF_InterForm::EnableUpdateAP(FALSE); |
| m_pAnnotList.reset(new CPDF_AnnotList(m_page)); |
| CPDF_InterForm::EnableUpdateAP(enableAPUpdate); |
| - int nCount = CountAnnots(); |
| + const int nCount = m_pAnnotList->Count(); |
| SetLock(TRUE); |
| for (int i = 0; i < nCount; ++i) { |
| CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); |
| @@ -908,16 +908,12 @@ void CPDFSDK_PageView::LoadFXAnnots() { |
| CheckUnSupportAnnot(pDoc, pPDFAnnot); |
| CPDFSDK_AnnotHandlerMgr* pAnnotHandlerMgr = pEnv->GetAnnotHandlerMgr(); |
| - ASSERT(pAnnotHandlerMgr != NULL); |
| - |
| - if (pAnnotHandlerMgr) { |
|
Lei Zhang
2015/10/30 17:02:53
Always true.
|
| - CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
| - if (!pAnnot) |
| - continue; |
| - m_fxAnnotArray.push_back(pAnnot); |
| + CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this); |
| + if (!pAnnot) |
| + continue; |
| + m_fxAnnotArray.push_back(pAnnot); |
| - pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| - } |
| + pAnnotHandlerMgr->Annot_OnLoad(pAnnot); |
| } |
| SetLock(FALSE); |
| } |
| @@ -952,7 +948,7 @@ FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const { |
| if (!p) |
| return FALSE; |
| - int nCount = CountAnnots(); |
| + const int nCount = m_pAnnotList->Count(); |
| for (int i = 0; i < nCount; ++i) { |
| if (m_pAnnotList->GetAt(i) == p) |
| return TRUE; |