Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Unified Diff: core/fpdfdoc/cpdf_interform.cpp

Issue 2625483002: Remove some CFX_ArrayTemplate in fpdfapi and fpdfdoc (Closed)
Patch Set: coments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_interform.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpdf_interform.cpp
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index e574e28fe5a67e5129ac8cfa2866e32a0418eaba..6cffea62222a573244603f3aec164d1465f7c7ce 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;
}
« no previous file with comments | « core/fpdfdoc/cpdf_interform.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698