summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_mgr.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-30 14:03:43 -0700
committerLei Zhang <thestig@chromium.org>2015-10-30 14:03:43 -0700
commit502185351be66bd6498b7aa1e1a37ed0826b7936 (patch)
treebaef7d5140e32b2bd6df1c0266ac8c52a8a183d9 /fpdfsdk/src/fsdk_mgr.cpp
parent961c04a7c30746a395347133d0507811b0dece05 (diff)
downloadpdfium-502185351be66bd6498b7aa1e1a37ed0826b7936.tar.xz
Merge to XFA: 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 TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1413973011 . (cherry picked from commit c91d5c276b6b986f645d34a0e583fbe4f73e74bc) Review URL: https://codereview.chromium.org/1422503012 .
Diffstat (limited to 'fpdfsdk/src/fsdk_mgr.cpp')
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 383acbd4a9..7954d2620c 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -725,8 +725,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);
@@ -738,7 +738,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") {
@@ -877,8 +877,8 @@ CPDF_Page* CPDFSDK_PageView::GetPDFPage() {
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) {
@@ -1094,12 +1094,10 @@ void CPDFSDK_PageView::LoadFXAnnots() {
m_pAnnotList.reset(new CPDF_AnnotList(pPage));
CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
- int nCount = m_pAnnotList->Count();
+ const int nCount = m_pAnnotList->Count();
for (int i = 0; i < nCount; i++) {
CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
- CPDF_Document* pDoc = GetPDFDocument();
-
- CheckUnSupportAnnot(pDoc, pPDFAnnot);
+ CheckUnSupportAnnot(GetPDFDocument(), pPDFAnnot);
CPDFSDK_Annot* pAnnot = pAnnotHandlerMgr->NewAnnot(pPDFAnnot, this);
if (!pAnnot)
@@ -1143,7 +1141,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;