summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_interactiveform.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-10-15 18:51:11 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-10-15 18:51:11 +0000
commite4f2f4a3f4fd3e9f372912f4151d7c7843f9556f (patch)
treed88a221b657d7e09bd0fd7460644fd5c048515fb /core/fpdfdoc/cpdf_interactiveform.cpp
parent98ac76ec09ce72526134ad75f1921a1691804dd1 (diff)
downloadpdfium-e4f2f4a3f4fd3e9f372912f4151d7c7843f9556f.tar.xz
Use more UnownedPtr in CPDF_FormControl.
To make this work, remove an UnownedPtr vector in CPDF_FormField and make CPDF_InteractiveForm manage it instead. Also simplify some code within CPDF_FormControl and CPDF_InteractiveForm. Change-Id: Ifc3a979dcdb992376a48db7a40840d2e76078500 Reviewed-on: https://pdfium-review.googlesource.com/c/43938 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_interactiveform.cpp')
-rw-r--r--core/fpdfdoc/cpdf_interactiveform.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/core/fpdfdoc/cpdf_interactiveform.cpp b/core/fpdfdoc/cpdf_interactiveform.cpp
index 347fd559e0..754737c454 100644
--- a/core/fpdfdoc/cpdf_interactiveform.cpp
+++ b/core/fpdfdoc/cpdf_interactiveform.cpp
@@ -390,10 +390,10 @@ class CFieldTree {
public:
class Node {
public:
- Node() : m_pField(nullptr), m_level(0) {}
+ Node() : m_level(0) {}
Node(const WideString& short_name, int level)
: m_ShortName(short_name), m_level(level) {}
- ~Node() {}
+ ~Node() = default;
void AddChildNode(std::unique_ptr<Node> pNode) {
m_Children.push_back(std::move(pNode));
@@ -466,9 +466,9 @@ class CFieldTree {
Node m_Root;
};
-CFieldTree::CFieldTree() {}
+CFieldTree::CFieldTree() = default;
-CFieldTree::~CFieldTree() {}
+CFieldTree::~CFieldTree() = default;
CFieldTree::Node* CFieldTree::AddChild(Node* pParent,
const WideString& short_name) {
@@ -717,7 +717,7 @@ CPDF_FormControl* CPDF_InteractiveForm::GetControlAtPoint(
for (size_t i = pAnnotList->size(); i > 0; --i) {
size_t annot_index = i - 1;
- CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(annot_index);
+ const CPDF_Dictionary* pAnnot = pAnnotList->GetDictAt(annot_index);
if (!pAnnot)
continue;
@@ -826,6 +826,13 @@ void CPDF_InteractiveForm::ResetForm(NotificationOption notify) {
m_pFormNotify->AfterFormReset(this);
}
+const std::vector<UnownedPtr<CPDF_FormControl>>&
+CPDF_InteractiveForm::GetControlsForField(const CPDF_FormField* pField) const {
+ const auto& it = m_ControlLists.find(pField);
+ ASSERT(it != m_ControlLists.end());
+ return it->second;
+}
+
void CPDF_InteractiveForm::LoadField(CPDF_Dictionary* pFieldDict, int nLevel) {
if (nLevel > nMaxRecursion)
return;
@@ -955,7 +962,7 @@ CPDF_FormControl* CPDF_InteractiveForm::AddControl(
auto pNew = pdfium::MakeUnique<CPDF_FormControl>(pField, pWidgetDict);
CPDF_FormControl* pControl = pNew.get();
m_ControlMap[pWidgetDict] = std::move(pNew);
- pField->AddFormControl(pControl);
+ m_ControlLists[pField].emplace_back(pControl);
return pControl;
}