summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_interform.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2017-01-10 10:19:04 -0800
committerCommit bot <commit-bot@chromium.org>2017-01-10 10:19:04 -0800
commitd18b8674378b104a9b5bb1f015e3f92fc174673e (patch)
tree6216931229e3b311e6c64008846a33e5135366b7 /core/fpdfdoc/cpdf_interform.cpp
parent3128d1c45d8bc313abb8aae151f86bbe62c52e56 (diff)
downloadpdfium-d18b8674378b104a9b5bb1f015e3f92fc174673e.tar.xz
Remove some CFX_ArrayTemplate in fpdfapi and fpdfdoc
Also use unique_ptr in one spot while we're at it. Review-Url: https://codereview.chromium.org/2625483002
Diffstat (limited to 'core/fpdfdoc/cpdf_interform.cpp')
-rw-r--r--core/fpdfdoc/cpdf_interform.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index e574e28fe5..6cffea6222 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -669,9 +669,7 @@ CPDF_InterForm::CPDF_InterForm(CPDF_Document* pDocument)
}
CPDF_InterForm::~CPDF_InterForm() {
- for (auto it : m_ControlMap)
- delete it.second;
-
+ m_ControlMap.clear();
size_t nCount = m_pFieldTree->m_Root.CountFields();
for (size_t i = 0; i < nCount; ++i)
delete m_pFieldTree->m_Root.GetFieldAtIndex(i);
@@ -919,7 +917,7 @@ CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage,
if (it == m_ControlMap.end())
continue;
- CPDF_FormControl* pControl = it->second;
+ CPDF_FormControl* pControl = it->second.get();
CFX_FloatRect rect = pControl->GetRect();
if (!rect.Contains(pdf_x, pdf_y))
continue;
@@ -934,7 +932,7 @@ CPDF_FormControl* CPDF_InterForm::GetControlAtPoint(CPDF_Page* pPage,
CPDF_FormControl* CPDF_InterForm::GetControlByDict(
const CPDF_Dictionary* pWidgetDict) const {
const auto it = m_ControlMap.find(pWidgetDict);
- return it != m_ControlMap.end() ? it->second : nullptr;
+ return it != m_ControlMap.end() ? it->second.get() : nullptr;
}
bool CPDF_InterForm::NeedConstructAP() const {
@@ -1150,11 +1148,12 @@ CPDF_FormControl* CPDF_InterForm::AddControl(CPDF_FormField* pField,
CPDF_Dictionary* pWidgetDict) {
const auto it = m_ControlMap.find(pWidgetDict);
if (it != m_ControlMap.end())
- return it->second;
+ return it->second.get();
- CPDF_FormControl* pControl = new CPDF_FormControl(pField, pWidgetDict);
- m_ControlMap[pWidgetDict] = pControl;
- pField->m_ControlList.Add(pControl);
+ auto pNew = pdfium::MakeUnique<CPDF_FormControl>(pField, pWidgetDict);
+ CPDF_FormControl* pControl = pNew.get();
+ m_ControlMap[pWidgetDict] = std::move(pNew);
+ pField->m_ControlList.push_back(pControl);
return pControl;
}