Chromium Code Reviews| Index: core/src/fpdfdoc/doc_form.cpp |
| diff --git a/core/src/fpdfdoc/doc_form.cpp b/core/src/fpdfdoc/doc_form.cpp |
| index a59f35eeac5139429d05897221f7078254981801..4ec23fdae84a83e037b3451d4f80605099bea5d7 100644 |
| --- a/core/src/fpdfdoc/doc_form.cpp |
| +++ b/core/src/fpdfdoc/doc_form.cpp |
| @@ -866,29 +866,36 @@ CPDF_FormControl* CPDF_InterForm::GetPageControl(CPDF_Page* pPage, |
| } |
| return NULL; |
| } |
| + |
| CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage, |
| FX_FLOAT pdf_x, |
| - FX_FLOAT pdf_y) const { |
| + FX_FLOAT pdf_y, |
| + int* z_order) const { |
| CPDF_Array* pAnnotList = pPage->m_pFormDict->GetArray("Annots"); |
| - if (pAnnotList == NULL) { |
| - return NULL; |
| - } |
| + if (!pAnnotList) |
| + return nullptr; |
| + |
| for (FX_DWORD i = pAnnotList->GetCount(); i > 0; i--) { |
|
Tom Sepez
2015/08/07 18:14:06
nit: --i.
Lei Zhang
2015/08/07 23:03:41
Done.
|
| - CPDF_Dictionary* pAnnot = pAnnotList->GetDict(i - 1); |
| - if (pAnnot == NULL) { |
| + FX_DWORD annot_index = i - 1; |
| + CPDF_Dictionary* pAnnot = pAnnotList->GetDict(annot_index); |
| + if (!pAnnot) |
| continue; |
| - } |
| + |
| CPDF_FormControl* pControl; |
| - if (!m_ControlMap.Lookup(pAnnot, (void*&)pControl)) { |
| + if (!m_ControlMap.Lookup(pAnnot, (void*&)pControl)) |
|
Tom Sepez
2015/08/07 18:14:06
Illegal cast. Needs to be &of an actual void*, an
Lei Zhang
2015/08/07 23:03:41
I converted m_ControlMap to a std::map.
|
| continue; |
| - } |
| + |
| CFX_FloatRect rect = pControl->GetRect(); |
| - if (rect.Contains(pdf_x, pdf_y)) { |
| - return pControl; |
| - } |
| + if (!rect.Contains(pdf_x, pdf_y)) |
| + continue; |
| + |
| + if (z_order) |
| + *z_order = annot_index; |
| + return pControl; |
| } |
| - return NULL; |
| + return nullptr; |
| } |
| + |
| CPDF_FormControl* CPDF_InterForm::GetControlByDict( |
| CPDF_Dictionary* pWidgetDict) const { |
| CPDF_FormControl* pControl = NULL; |