summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fsdk_mgr.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-30 23:42:33 -0700
committerLei Zhang <thestig@chromium.org>2015-10-30 23:42:33 -0700
commitc88c42f317c0e94c4c7b98949bfe1a495aef07a9 (patch)
tree338bce5904097056be9afc47796ad1ba22f05c53 /fpdfsdk/src/fsdk_mgr.cpp
parent1630dffdc1d554d8f2319e83cdbd7b12f480362d (diff)
downloadpdfium-c88c42f317c0e94c4c7b98949bfe1a495aef07a9.tar.xz
Clean up CPDF_AnnotList.
- Remove dead code - Stop using CFX_PtrArray - Mark more things const - Fix style nits R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1425093003 .
Diffstat (limited to 'fpdfsdk/src/fsdk_mgr.cpp')
-rw-r--r--fpdfsdk/src/fsdk_mgr.cpp32
1 files changed, 12 insertions, 20 deletions
diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp
index 2797bc8f9a..ab6e3cf023 100644
--- a/fpdfsdk/src/fsdk_mgr.cpp
+++ b/fpdfsdk/src/fsdk_mgr.cpp
@@ -635,11 +635,9 @@ void CPDFSDK_PageView::PageView_OnDraw(CFX_RenderDevice* pDevice,
}
}
-CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX,
- FX_FLOAT pageY) {
- const int nCount = m_pAnnotList->Count();
- for (int i = 0; i < nCount; ++i) {
- CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
+const CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX,
+ FX_FLOAT pageY) {
+ for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) {
CFX_FloatRect annotRect;
pAnnot->GetRect(annotRect);
if (annotRect.Contains(pageX, pageY))
@@ -648,11 +646,9 @@ CPDF_Annot* CPDFSDK_PageView::GetPDFAnnotAtPoint(FX_FLOAT pageX,
return nullptr;
}
-CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX,
- FX_FLOAT pageY) {
- const int nCount = m_pAnnotList->Count();
- for (int i = 0; i < nCount; ++i) {
- CPDF_Annot* pAnnot = m_pAnnotList->GetAt(i);
+const CPDF_Annot* CPDFSDK_PageView::GetPDFWidgetAtPoint(FX_FLOAT pageX,
+ FX_FLOAT pageY) {
+ for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) {
if (pAnnot->GetSubType() == "Widget") {
CFX_FloatRect annotRect;
pAnnot->GetRect(annotRect);
@@ -869,9 +865,9 @@ void CPDFSDK_PageView::LoadFXAnnots() {
CPDF_InterForm::EnableUpdateAP(FALSE);
m_pAnnotList.reset(new CPDF_AnnotList(m_page));
CPDF_InterForm::EnableUpdateAP(enableAPUpdate);
- const int nCount = m_pAnnotList->Count();
+ const size_t nCount = m_pAnnotList->Count();
SetLock(TRUE);
- for (int i = 0; i < nCount; ++i) {
+ for (size_t i = 0; i < nCount; ++i) {
CPDF_Annot* pPDFAnnot = m_pAnnotList->GetAt(i);
CPDF_Document* pDoc = GetPDFDocument();
@@ -914,16 +910,12 @@ int CPDFSDK_PageView::GetPageIndex() {
return -1;
}
-FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const {
+bool CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const {
if (!p)
- return FALSE;
+ return false;
- const int nCount = m_pAnnotList->Count();
- for (int i = 0; i < nCount; ++i) {
- if (m_pAnnotList->GetAt(i) == p)
- return TRUE;
- }
- return FALSE;
+ const auto& annots = m_pAnnotList->All();
+ return std::find(annots.begin(), annots.end(), p) != annots.end();
}
CPDFSDK_Annot* CPDFSDK_PageView::GetFocusAnnot() {