diff options
author | Lei Zhang <thestig@chromium.org> | 2015-10-30 01:31:39 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-10-30 01:31:39 -0700 |
commit | 9dd9439d23d44d105db0950e33af0cc913a6cece (patch) | |
tree | ebcc15f9cb5b549e2d98270dae9f9eaf280596fc | |
parent | 23d576f0b498bd4f37ef2175916223a2e5ea0324 (diff) | |
download | pdfium-9dd9439d23d44d105db0950e33af0cc913a6cece.tar.xz |
Fix incorrect CPDFSDK_PageView::CountAnnots().
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.
BUG=536967
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1406183007 .
-rw-r--r-- | fpdfsdk/include/fsdk_mgr.h | 2 | ||||
-rw-r--r-- | fpdfsdk/src/fsdk_mgr.cpp | 16 |
2 files changed, 7 insertions, 11 deletions
diff --git a/fpdfsdk/include/fsdk_mgr.h b/fpdfsdk/include/fsdk_mgr.h index fa2860aa00..2c063ed5a8 100644 --- a/fpdfsdk/include/fsdk_mgr.h +++ b/fpdfsdk/include/fsdk_mgr.h @@ -308,7 +308,7 @@ class CPDFSDK_PageView final { CPDFSDK_Annot* AddAnnot(const FX_CHAR* lpSubType, CPDF_Dictionary* pDict); CPDFSDK_Annot* AddAnnot(CPDF_Annot* pPDFAnnot); FX_BOOL DeleteAnnot(CPDFSDK_Annot* pAnnot); - int CountAnnots() const; + size_t CountAnnots() const; CPDFSDK_Annot* GetAnnot(size_t nIndex); CPDFSDK_Annot* GetAnnotByDict(CPDF_Dictionary* pDict); CPDF_Page* GetPDFPage() { return m_page; } diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp index 53a774edcd..dfd39541fc 100644 --- a/fpdfsdk/src/fsdk_mgr.cpp +++ b/fpdfsdk/src/fsdk_mgr.cpp @@ -664,8 +664,7 @@ 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++) { + for (size_t i = 0; i < CountAnnots(); ++i) { CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); CFX_FloatRect annotRect; pAnnot->GetRect(annotRect); @@ -677,8 +676,7 @@ CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX, CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX, FX_FLOAT pageY) { - int nCount = CountAnnots(); - for (int i = 0; i < nCount; ++i) { + for (size_t i = 0; i < CountAnnots(); ++i) { CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i); if (pAnnot->GetSubType() == "Widget") { CFX_FloatRect annotRect; @@ -764,8 +762,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,9 +897,8 @@ void CPDFSDK_PageView::LoadFXAnnots() { CPDF_InterForm::EnableUpdateAP(FALSE); m_pAnnotList.reset(new CPDF_AnnotList(m_page)); CPDF_InterForm::EnableUpdateAP(enableAPUpdate); - int nCount = CountAnnots(); SetLock(TRUE); - for (int i = 0; i < nCount; ++i) { + for (size_t i = 0; i < CountAnnots(); ++i) { CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i); CPDF_Document* pDoc = GetPDFDocument(); @@ -952,8 +949,7 @@ FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const { if (!p) return FALSE; - int nCount = CountAnnots(); - for (int i = 0; i < nCount; ++i) { + for (size_t i = 0; i < CountAnnots(); ++i) { if (m_pAnnotList->GetAt(i) == p) return TRUE; } |