Chromium Code Reviews| Index: fpdfsdk/src/fsdk_mgr.cpp |
| diff --git a/fpdfsdk/src/fsdk_mgr.cpp b/fpdfsdk/src/fsdk_mgr.cpp |
| index 0b6770174bdafc9d6f7022fd328d0425d943e925..0709a4b551d9cbc31f7482b3b234d3079799740b 100644 |
| --- a/fpdfsdk/src/fsdk_mgr.cpp |
| +++ b/fpdfsdk/src/fsdk_mgr.cpp |
| @@ -662,11 +662,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)) |
| @@ -675,11 +673,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); |
| @@ -899,9 +895,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(); |
| @@ -944,13 +940,12 @@ int CPDFSDK_PageView::GetPageIndex() { |
| return -1; |
| } |
| -FX_BOOL CPDFSDK_PageView::IsValidAnnot(CPDF_Annot* p) const { |
| +FX_BOOL CPDFSDK_PageView::IsValidAnnot(const CPDF_Annot* p) const { |
| if (!p) |
| return FALSE; |
| - const int nCount = m_pAnnotList->Count(); |
| - for (int i = 0; i < nCount; ++i) { |
| - if (m_pAnnotList->GetAt(i) == p) |
| + for (const CPDF_Annot* pAnnot : m_pAnnotList->All()) { |
|
Tom Sepez
2015/10/30 20:26:07
Use std::find() rather than explicit iteration.
Lei Zhang
2015/10/30 22:17:50
Done.
|
| + if (pAnnot == p) |
| return TRUE; |
| } |
| return FALSE; |