Add constants for type-specific annotation form flags.

Remove duplicate copy in fpdfsdk/cpdfsdk_common.h. Fix the value for
RadiosInUnison flag.

BUG=pdfium:1049

Change-Id: I0a8c854383327cd4cca1055f61dfd0ca03356165
Reviewed-on: https://pdfium-review.googlesource.com/c/49693
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/constants/form_flags.h b/constants/form_flags.h
index a2220bd..148bb4c 100644
--- a/constants/form_flags.h
+++ b/constants/form_flags.h
@@ -14,6 +14,32 @@
 constexpr uint32_t kRequired = 1 << 1;
 constexpr uint32_t kNoExport = 1 << 2;
 
+// PDF 1.7 spec, table 8.75.
+// Field flags specific to button fields.
+constexpr uint32_t kButtonNoToggleToOff = 1 << 14;
+constexpr uint32_t kButtonRadio = 1 << 15;
+constexpr uint32_t kButtonPushbutton = 1 << 16;
+constexpr uint32_t kButtonRadiosInUnison = 1 << 25;
+
+// PDF 1.7 spec, table 8.77.
+// Field flags specific to text fields.
+constexpr uint32_t kTextMultiline = 1 << 12;
+constexpr uint32_t kTextPassword = 1 << 13;
+constexpr uint32_t kTextFileSelect = 1 << 20;
+constexpr uint32_t kTextDoNotSpellCheck = 1 << 22;
+constexpr uint32_t kTextDoNotScroll = 1 << 23;
+constexpr uint32_t kTextComb = 1 << 24;
+constexpr uint32_t kTextRichText = 1 << 25;
+
+// PDF 1.7 spec, table 8.79.
+// Field flags specific to choice fields.
+constexpr uint32_t kChoiceCombo = 1 << 17;
+constexpr uint32_t kChoiceEdit = 1 << 18;
+constexpr uint32_t kChoiceSort = 1 << 19;
+constexpr uint32_t kChoiceMultiSelect = 1 << 21;
+constexpr uint32_t kChoiceDoNotSpellCheck = 1 << 22;
+constexpr uint32_t kChoiceCommitOnSelChange = 1 << 26;
+
 }  // namespace form_flags
 }  // namespace pdfium
 
diff --git a/core/fpdfdoc/cpdf_annotlist.cpp b/core/fpdfdoc/cpdf_annotlist.cpp
index aba0496..482c79e 100644
--- a/core/fpdfdoc/cpdf_annotlist.cpp
+++ b/core/fpdfdoc/cpdf_annotlist.cpp
@@ -12,6 +12,7 @@
 
 #include "constants/annotation_common.h"
 #include "constants/annotation_flags.h"
+#include "constants/form_flags.h"
 #include "core/fpdfapi/page/cpdf_page.h"
 #include "core/fpdfapi/parser/cpdf_array.h"
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
@@ -139,15 +140,16 @@
   CPDF_Object* pFieldFlagsObj = FPDF_GetFieldAttr(pAnnotDict, "Ff");
   uint32_t flags = pFieldFlagsObj ? pFieldFlagsObj->GetInteger() : 0;
   if (field_type == "Ch") {
-    auto type = (flags & (1 << 17)) ? CPVT_GenerateAP::kComboBox
-                                    : CPVT_GenerateAP::kListBox;
+    auto type = (flags & pdfium::form_flags::kChoiceCombo)
+                    ? CPVT_GenerateAP::kComboBox
+                    : CPVT_GenerateAP::kListBox;
     CPVT_GenerateAP::GenerateFormAP(pDoc, pAnnotDict, type);
     return;
   }
 
   if (field_type != "Btn")
     return;
-  if (flags & (1 << 16))
+  if (flags & pdfium::form_flags::kButtonPushbutton)
     return;
   if (pAnnotDict->KeyExist(pdfium::annotation::kAS))
     return;
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
index e66b9e4..9d65a7f 100644
--- a/fpdfsdk/BUILD.gn
+++ b/fpdfsdk/BUILD.gn
@@ -26,7 +26,6 @@
     "cpdfsdk_baannot.h",
     "cpdfsdk_baannothandler.cpp",
     "cpdfsdk_baannothandler.h",
-    "cpdfsdk_common.h",
     "cpdfsdk_customaccess.cpp",
     "cpdfsdk_customaccess.h",
     "cpdfsdk_fieldaction.cpp",
diff --git a/fpdfsdk/cpdfsdk_annot.h b/fpdfsdk/cpdfsdk_annot.h
index 06cfb70..c2cdf11 100644
--- a/fpdfsdk/cpdfsdk_annot.h
+++ b/fpdfsdk/cpdfsdk_annot.h
@@ -13,7 +13,6 @@
 #include "core/fxcrt/observable.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "fpdfsdk/cfx_systemhandler.h"
-#include "fpdfsdk/cpdfsdk_common.h"
 #include "fpdfsdk/cpdfsdk_helpers.h"
 
 class CFX_Matrix;
diff --git a/fpdfsdk/cpdfsdk_common.h b/fpdfsdk/cpdfsdk_common.h
deleted file mode 100644
index a5fb58f..0000000
--- a/fpdfsdk/cpdfsdk_common.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef FPDFSDK_CPDFSDK_COMMON_H_
-#define FPDFSDK_CPDFSDK_COMMON_H_
-
-// for all fields
-#define FIELDFLAG_READONLY 1
-#define FIELDFLAG_REQUIRED 2
-// for text fields
-#define FIELDFLAG_MULTILINE (1 << 12)
-#define FIELDFLAG_PASSWORD (1 << 13)
-#define FIELDFLAG_FILESELECT (1 << 20)
-#define FIELDFLAG_DONOTSPELLCHECK (1 << 22)
-#define FIELDFLAG_DONOTSCROLL (1 << 23)
-#define FIELDFLAG_COMB (1 << 24)
-#define FIELDFLAG_RICHTEXT (1 << 25)
-// for button fileds
-#define FIELDFLAG_RADIOSINUNISON (1 << 27)
-// for choice fields
-#define FIELDFLAG_EDIT (1 << 18)
-#define FIELDFLAG_MULTISELECT (1 << 21)
-#define FIELDFLAG_COMMITONSELCHANGE (1 << 26)
-
-#endif  // FPDFSDK_CPDFSDK_COMMON_H_
diff --git a/fpdfsdk/cpdfsdk_widgethandler.cpp b/fpdfsdk/cpdfsdk_widgethandler.cpp
index 038890d..80f60cf 100644
--- a/fpdfsdk/cpdfsdk_widgethandler.cpp
+++ b/fpdfsdk/cpdfsdk_widgethandler.cpp
@@ -9,6 +9,7 @@
 #include <memory>
 #include <vector>
 
+#include "constants/form_flags.h"
 #include "core/fpdfapi/page/cpdf_page.h"
 #include "core/fpdfapi/parser/cpdf_document.h"
 #include "core/fpdfdoc/cpdf_interactiveform.h"
@@ -42,7 +43,7 @@
     return false;
 
   int nFieldFlags = pWidget->GetFieldFlags();
-  if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY)
+  if (nFieldFlags & pdfium::form_flags::kReadOnly)
     return false;
 
   if (pWidget->GetFieldType() == FormFieldType::kPushButton)
diff --git a/fpdfsdk/formfiller/BUILD.gn b/fpdfsdk/formfiller/BUILD.gn
index 89bd7de..45a2359 100644
--- a/fpdfsdk/formfiller/BUILD.gn
+++ b/fpdfsdk/formfiller/BUILD.gn
@@ -32,6 +32,7 @@
   deps = [
     ":fontmap",
     "../../:pdfium_public_headers",
+    "../../constants",
     "../../core/fpdfapi/page",
     "../../core/fpdfapi/parser",
     "../../core/fxcrt",
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index efde8ce..ce3cf7d 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -8,7 +8,7 @@
 
 #include <utility>
 
-#include "fpdfsdk/cpdfsdk_common.h"
+#include "constants/form_flags.h"
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_widget.h"
 #include "fpdfsdk/formfiller/cba_fontmap.h"
@@ -36,7 +36,7 @@
 
 CPWL_Wnd::CreateParams CFFL_ComboBox::GetCreateParam() {
   CPWL_Wnd::CreateParams cp = CFFL_TextObject::GetCreateParam();
-  if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
+  if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceEdit)
     cp.dwFlags |= PCBS_ALLOWCUSTOMTEXT;
 
   cp.pFontMap = MaybeCreateFontMap();
@@ -82,7 +82,7 @@
     return false;
 
   int32_t nCurSel = pWnd->GetSelect();
-  if (!(m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT))
+  if (!(m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceEdit))
     return nCurSel != m_pWidget->GetSelectedIndex(0);
 
   if (nCurSel >= 0)
@@ -100,7 +100,7 @@
   WideString swText = pWnd->GetText();
   int32_t nCurSel = pWnd->GetSelect();
   bool bSetValue = false;
-  if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
+  if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceEdit)
     bSetValue = (nCurSel < 0) || (swText != m_pWidget->GetOptionLabel(nCurSel));
 
   if (bSetValue) {
diff --git a/fpdfsdk/formfiller/cffl_formfiller.cpp b/fpdfsdk/formfiller/cffl_formfiller.cpp
index 02d1450..55d3304 100644
--- a/fpdfsdk/formfiller/cffl_formfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_formfiller.cpp
@@ -8,9 +8,9 @@
 
 #include <utility>
 
+#include "constants/form_flags.h"
 #include "core/fpdfapi/page/cpdf_page.h"
 #include "core/fxge/cfx_renderdevice.h"
-#include "fpdfsdk/cpdfsdk_common.h"
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_pageview.h"
 #include "fpdfsdk/cpdfsdk_widget.h"
@@ -333,7 +333,7 @@
 
   uint32_t dwCreateFlags = PWS_BORDER | PWS_BACKGROUND | PWS_VISIBLE;
   uint32_t dwFieldFlag = m_pWidget->GetFieldFlags();
-  if (dwFieldFlag & FIELDFLAG_READONLY)
+  if (dwFieldFlag & pdfium::form_flags::kReadOnly)
     dwCreateFlags |= PWS_READONLY;
 
   Optional<FX_COLORREF> color = m_pWidget->GetFillColor();
diff --git a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
index 4a33c71..bc95f4b 100644
--- a/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
+++ b/fpdfsdk/formfiller/cffl_interactiveformfiller.cpp
@@ -6,6 +6,7 @@
 
 #include "fpdfsdk/formfiller/cffl_interactiveformfiller.h"
 
+#include "constants/form_flags.h"
 #include "core/fpdfapi/page/cpdf_page.h"
 #include "core/fpdfapi/parser/cpdf_document.h"
 #include "core/fxcrt/autorestorer.h"
@@ -451,7 +452,7 @@
 
 bool CFFL_InteractiveFormFiller::IsReadOnly(CPDFSDK_Widget* pWidget) {
   int nFieldFlags = pWidget->GetFieldFlags();
-  return (nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY;
+  return !!(nFieldFlags & pdfium::form_flags::kReadOnly);
 }
 
 bool CFFL_InteractiveFormFiller::IsFillingAllowed(CPDFSDK_Widget* pWidget) {
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index d64fa7c..d521be6 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -8,7 +8,7 @@
 
 #include <utility>
 
-#include "fpdfsdk/cpdfsdk_common.h"
+#include "constants/form_flags.h"
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_widget.h"
 #include "fpdfsdk/formfiller/cba_fontmap.h"
@@ -27,7 +27,7 @@
 CPWL_Wnd::CreateParams CFFL_ListBox::GetCreateParam() {
   CPWL_Wnd::CreateParams cp = CFFL_TextObject::GetCreateParam();
   uint32_t dwFieldFlag = m_pWidget->GetFieldFlags();
-  if (dwFieldFlag & FIELDFLAG_MULTISELECT)
+  if (dwFieldFlag & pdfium::form_flags::kChoiceMultiSelect)
     cp.dwFlags |= PLBS_MULTIPLESEL;
 
   cp.dwFlags |= PWS_VSCROLL;
@@ -88,7 +88,7 @@
   if (!pListBox)
     return false;
 
-  if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
+  if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceMultiSelect) {
     size_t nSelCount = 0;
     for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; ++i) {
       if (pListBox->IsItemSelected(i)) {
@@ -112,7 +112,7 @@
 
   int32_t nNewTopIndex = pListBox->GetTopVisibleIndex();
   m_pWidget->ClearSelection(NotificationOption::kDoNotNotify);
-  if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
+  if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceMultiSelect) {
     for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) {
       if (pListBox->IsItemSelected(i)) {
         m_pWidget->SetOptionSelection(i, true,
@@ -145,7 +145,7 @@
                                  CPDFSDK_FieldAction& fa) {
   switch (type) {
     case CPDF_AAction::kValidate:
-      if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
+      if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceMultiSelect) {
         fa.sValue.clear();
       } else {
         auto* pListBox =
@@ -159,7 +159,7 @@
       break;
     case CPDF_AAction::kLoseFocus:
     case CPDF_AAction::kGetFocus:
-      if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
+      if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kChoiceMultiSelect) {
         fa.sValue.clear();
       } else {
         int32_t nCurSel = m_pWidget->GetSelectedIndex(0);
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index 5ebedc3..3d299de 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -8,7 +8,7 @@
 
 #include <utility>
 
-#include "fpdfsdk/cpdfsdk_common.h"
+#include "constants/form_flags.h"
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_widget.h"
 #include "fpdfsdk/formfiller/cba_fontmap.h"
@@ -32,23 +32,23 @@
 CPWL_Wnd::CreateParams CFFL_TextField::GetCreateParam() {
   CPWL_Wnd::CreateParams cp = CFFL_TextObject::GetCreateParam();
   int nFlags = m_pWidget->GetFieldFlags();
-  if (nFlags & FIELDFLAG_PASSWORD)
+  if (nFlags & pdfium::form_flags::kTextPassword)
     cp.dwFlags |= PES_PASSWORD;
 
-  if (nFlags & FIELDFLAG_MULTILINE) {
+  if (nFlags & pdfium::form_flags::kTextMultiline) {
     cp.dwFlags |= PES_MULTILINE | PES_AUTORETURN | PES_TOP;
-    if (!(nFlags & FIELDFLAG_DONOTSCROLL))
+    if (!(nFlags & pdfium::form_flags::kTextDoNotScroll))
       cp.dwFlags |= PWS_VSCROLL | PES_AUTOSCROLL;
   } else {
     cp.dwFlags |= PES_CENTER;
-    if (!(nFlags & FIELDFLAG_DONOTSCROLL))
+    if (!(nFlags & pdfium::form_flags::kTextDoNotScroll))
       cp.dwFlags |= PES_AUTOSCROLL;
   }
 
-  if (nFlags & FIELDFLAG_COMB)
+  if (nFlags & pdfium::form_flags::kTextComb)
     cp.dwFlags |= PES_CHARARRAY;
 
-  if (nFlags & FIELDFLAG_RICHTEXT)
+  if (nFlags & pdfium::form_flags::kTextRichText)
     cp.dwFlags |= PES_RICH;
 
   cp.dwFlags |= PES_UNDO;
@@ -97,7 +97,7 @@
                             uint32_t nFlags) {
   switch (nChar) {
     case FWL_VKEY_Return: {
-      if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTILINE)
+      if (m_pWidget->GetFieldFlags() & pdfium::form_flags::kTextMultiline)
         break;
 
       CPDFSDK_PageView* pPageView = GetCurPageView(true);
diff --git a/fpdfsdk/pwl/BUILD.gn b/fpdfsdk/pwl/BUILD.gn
index d37fe69..ccf7e1f 100644
--- a/fpdfsdk/pwl/BUILD.gn
+++ b/fpdfsdk/pwl/BUILD.gn
@@ -42,6 +42,7 @@
   configs += [ "../../:pdfium_core_config" ]
   deps = [
     "../../:pdfium_public_headers",
+    "../../constants",
     "../../core/fpdfapi/font",
     "../../core/fpdfapi/page",
     "../../core/fpdfapi/parser",
diff --git a/fpdfsdk/pwl/cpwl_appstream.cpp b/fpdfsdk/pwl/cpwl_appstream.cpp
index 137022a..4b68972 100644
--- a/fpdfsdk/pwl/cpwl_appstream.cpp
+++ b/fpdfsdk/pwl/cpwl_appstream.cpp
@@ -8,6 +8,7 @@
 
 #include <utility>
 
+#include "constants/form_flags.h"
 #include "core/fpdfapi/parser/cpdf_dictionary.h"
 #include "core/fpdfapi/parser/cpdf_document.h"
 #include "core/fpdfapi/parser/cpdf_name.h"
@@ -1757,7 +1758,7 @@
   pEdit->SetAlignmentH(pControl->GetControlAlignment(), true);
 
   uint32_t dwFieldFlags = pField->GetFieldFlags();
-  bool bMultiLine = (dwFieldFlags >> 12) & 1;
+  bool bMultiLine = dwFieldFlags & pdfium::form_flags::kTextMultiline;
   if (bMultiLine) {
     pEdit->SetMultiLine(true, true);
     pEdit->SetAutoReturn(true, true);
@@ -1766,13 +1767,13 @@
   }
 
   uint16_t subWord = 0;
-  if ((dwFieldFlags >> 13) & 1) {
+  if (dwFieldFlags & pdfium::form_flags::kTextPassword) {
     subWord = '*';
     pEdit->SetPasswordChar(subWord, true);
   }
 
   int nMaxLen = pField->GetMaxLen();
-  bool bCharArray = (dwFieldFlags >> 24) & 1;
+  bool bCharArray = dwFieldFlags & pdfium::form_flags::kTextComb;
   float fFontSize = widget_->GetFontSize();
 
 #ifdef PDF_ENABLE_XFA
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index b0f7969..753094b 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -11,6 +11,7 @@
 #include <utility>
 
 #include "constants/annotation_flags.h"
+#include "constants/form_flags.h"
 #include "core/fpdfapi/font/cpdf_font.h"
 #include "core/fpdfdoc/cpdf_formcontrol.h"
 #include "core/fpdfdoc/cpdf_formfield.h"
@@ -252,7 +253,7 @@
     uint32_t dwFieldFlags = pFormField->GetFieldFlags();
     pFormField->ClearSelection(NotificationOption::kNotify);
     for (size_t i = 0; i < array.size(); ++i) {
-      if (i != 0 && !(dwFieldFlags & (1 << 21)))
+      if (i != 0 && !(dwFieldFlags & pdfium::form_flags::kChoiceMultiSelect))
         break;
       if (array[i] < static_cast<uint32_t>(pFormField->CountOptions()) &&
           !pFormField->IsItemSelected(array[i])) {
@@ -956,8 +957,8 @@
   if (pFormField->GetFieldType() != FormFieldType::kTextField)
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
-  return CJS_Result::Success(
-      pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB)));
+  return CJS_Result::Success(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & pdfium::form_flags::kTextComb)));
 }
 
 CJS_Result CJS_Field::set_comb(CJS_Runtime* pRuntime, v8::Local<v8::Value> vp) {
@@ -977,8 +978,9 @@
   if (!IsComboBoxOrListBox(pFormField))
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
+  uint32_t dwFieldFlags = pFormField->GetFieldFlags();
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)));
+      !!(dwFieldFlags & pdfium::form_flags::kChoiceCommitOnSelChange)));
 }
 
 CJS_Result CJS_Field::set_commit_on_sel_change(CJS_Runtime* pRuntime,
@@ -1083,7 +1085,7 @@
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)));
+      !!(pFormField->GetFieldFlags() & pdfium::form_flags::kTextDoNotScroll)));
 }
 
 CJS_Result CJS_Field::set_do_not_scroll(CJS_Runtime* pRuntime,
@@ -1104,8 +1106,9 @@
   if (!IsComboBoxOrTextField(pFormField))
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
+  uint32_t dwFieldFlags = pFormField->GetFieldFlags();
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)));
+      !!(dwFieldFlags & pdfium::form_flags::kTextDoNotSpellCheck)));
 }
 
 CJS_Result CJS_Field::set_do_not_spell_check(CJS_Runtime* pRuntime,
@@ -1192,8 +1195,8 @@
   if (pFormField->GetFieldType() != FormFieldType::kComboBox)
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
-  return CJS_Result::Success(
-      pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT)));
+  return CJS_Result::Success(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & pdfium::form_flags::kChoiceEdit)));
 }
 
 CJS_Result CJS_Field::set_editable(CJS_Runtime* pRuntime,
@@ -1262,7 +1265,7 @@
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)));
+      !!(pFormField->GetFieldFlags() & pdfium::form_flags::kTextFileSelect)));
 }
 
 CJS_Result CJS_Field::set_file_select(CJS_Runtime* pRuntime,
@@ -1445,7 +1448,7 @@
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)));
+      !!(pFormField->GetFieldFlags() & pdfium::form_flags::kTextMultiline)));
 }
 
 CJS_Result CJS_Field::set_multiline(CJS_Runtime* pRuntime,
@@ -1465,8 +1468,9 @@
   if (pFormField->GetFieldType() != FormFieldType::kListBox)
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
+  uint32_t dwFieldFlags = pFormField->GetFieldFlags();
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)));
+      !!(dwFieldFlags & pdfium::form_flags::kChoiceMultiSelect)));
 }
 
 CJS_Result CJS_Field::set_multiple_selection(CJS_Runtime* pRuntime,
@@ -1549,7 +1553,7 @@
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)));
+      !!(pFormField->GetFieldFlags() & pdfium::form_flags::kTextPassword)));
 }
 
 CJS_Result CJS_Field::set_password(CJS_Runtime* pRuntime,
@@ -1641,8 +1645,9 @@
   if (pFormField->GetFieldType() != FormFieldType::kRadioButton)
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
+  uint32_t dwFieldFlags = pFormField->GetFieldFlags();
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)));
+      !!(dwFieldFlags & pdfium::form_flags::kButtonRadiosInUnison)));
 }
 
 CJS_Result CJS_Field::set_radios_in_unison(CJS_Runtime* pRuntime,
@@ -1661,7 +1666,7 @@
     return CJS_Result::Failure(JSMessage::kBadObjectError);
 
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_READONLY)));
+      !!(pFormField->GetFieldFlags() & pdfium::form_flags::kReadOnly)));
 }
 
 CJS_Result CJS_Field::set_readonly(CJS_Runtime* pRuntime,
@@ -1736,7 +1741,7 @@
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)));
+      !!(pFormField->GetFieldFlags() & pdfium::form_flags::kRequired)));
 }
 
 CJS_Result CJS_Field::set_required(CJS_Runtime* pRuntime,
@@ -1760,7 +1765,7 @@
     return CJS_Result::Failure(JSMessage::kObjectTypeError);
 
   return CJS_Result::Success(pRuntime->NewBoolean(
-      !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)));
+      !!(pFormField->GetFieldFlags() & pdfium::form_flags::kTextRichText)));
 }
 
 CJS_Result CJS_Field::set_rich_text(CJS_Runtime* pRuntime,
@@ -2170,7 +2175,8 @@
   }
 
   if (pFormField->GetFieldType() == FormFieldType::kRadioButton &&
-      !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) {
+      !(pFormField->GetFieldFlags() &
+        pdfium::form_flags::kButtonRadiosInUnison)) {
     for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
       if (pFormField->GetControl(i)->IsChecked()) {
         return CJS_Result::Success(pRuntime->NewString(
@@ -2200,7 +2206,7 @@
   if (!pFormField)
     return CJS_Result::Failure(JSMessage::kBadObjectError);
 
-  if ((pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT) &&
+  if ((pFormField->GetFieldFlags() & pdfium::form_flags::kTextFileSelect) &&
       (pFormField->GetFieldType() == FormFieldType::kTextField)) {
     WideString wsFileName = m_pFormFillEnv->JS_fieldBrowse();
     if (!wsFileName.IsEmpty()) {