summaryrefslogtreecommitdiff
path: root/core/fpdfdoc/cpdf_formfield.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-07-18 04:52:18 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-07-18 04:52:18 +0000
commitbeb56d69a7a57317d521bab927a651fb260f5404 (patch)
treeb2f0ba0b35af67635ff3e72a57b802ca5b5cfa2b /core/fpdfdoc/cpdf_formfield.cpp
parent084c31d93439d5166c60dbfb0ccee6db1406d09c (diff)
downloadpdfium-beb56d69a7a57317d521bab927a651fb260f5404.tar.xz
Avoid writing const/non-const versions of the same function.
Use const_cast for the non-const version to call the const version. Change-Id: Ibdf5fe53255ee6e983555080336f5d63e683afd1 Reviewed-on: https://pdfium-review.googlesource.com/37490 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'core/fpdfdoc/cpdf_formfield.cpp')
-rw-r--r--core/fpdfdoc/cpdf_formfield.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index 2f05ad8732..c88513d50f 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -37,8 +37,6 @@ const int kFormTextPassword = 0x200;
const int kFormTextNoScroll = 0x400;
const int kFormTextComb = 0x800;
-constexpr int kGetFieldMaxRecursion = 32;
-
bool IsUnison(CPDF_FormField* pField) {
if (pField->GetType() == CPDF_FormField::CheckBox)
return true;
@@ -58,6 +56,7 @@ Optional<FormFieldType> IntToFormFieldType(int value) {
const CPDF_Object* FPDF_GetFieldAttr(const CPDF_Dictionary* pFieldDict,
const char* name,
int nLevel) {
+ static constexpr int kGetFieldMaxRecursion = 32;
if (!pFieldDict || nLevel > kGetFieldMaxRecursion)
return nullptr;
@@ -72,15 +71,8 @@ const CPDF_Object* FPDF_GetFieldAttr(const CPDF_Dictionary* pFieldDict,
CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict,
const char* name,
int nLevel) {
- if (!pFieldDict || nLevel > kGetFieldMaxRecursion)
- return nullptr;
-
- CPDF_Object* pAttr = pFieldDict->GetDirectObjectFor(name);
- if (pAttr)
- return pAttr;
-
- CPDF_Dictionary* pParent = pFieldDict->GetDictFor("Parent");
- return pParent ? FPDF_GetFieldAttr(pParent, name, nLevel + 1) : nullptr;
+ return const_cast<CPDF_Object*>(FPDF_GetFieldAttr(
+ static_cast<const CPDF_Dictionary*>(pFieldDict), name, nLevel));
}
WideString FPDF_GetFullName(CPDF_Dictionary* pFieldDict) {