summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_mgr.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-30 11:18:29 -0700
committerLei Zhang <thestig@chromium.org>2015-10-30 11:18:29 -0700
commitc91d5c276b6b986f645d34a0e583fbe4f73e74bc (patch)
tree3aa5e597124540674f929d527649c7f38e10657b /fpdfsdk/src/fsdk_mgr.cpp
parent9f4def68601ec75b85b92077c521b9423b4f7f00 (diff)
downloadpdfium-c91d5c276b6b986f645d34a0e583fbe4f73e74bc.tar.xz
Fix incorrect CPDFSDK_PageView::CountAnnots(). (try 2)
The original XFA version was correct, and the master version here is wrong. The two versions are now in sync, but incorrect. So we need to fix this here and then merge to XFA again. Also fix what are now incorrect uses of CountAnnots() and do some cleanups. BUG=543049 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1413973011 .
Diffstat (limited to 'fpdfsdk/src/fsdk_mgr.cpp')
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp28
1 files changed, 12 insertions, 16 deletions
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 53a774edcd..0b6770174b 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();
+ 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) {
- 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;