diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index ce272d5..0eaad73 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -376,10 +376,8 @@
   if (!pFormField->CountControls() ||
       m_nFormControlIndex >= pFormField->CountControls())
     return nullptr;
-
   if (m_nFormControlIndex < 0)
     return pFormField->GetControl(0);
-
   return pFormField->GetControl(m_nFormControlIndex);
 }
 
@@ -388,31 +386,31 @@
                           WideString* sError) {
   ASSERT(m_pFormFillEnv);
 
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
-      return false;
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+    return false;
 
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
 
-    switch (pFormControl->GetControlAlignment()) {
-      case 1:
-        vp->Set(L"center");
-        break;
-      case 0:
-        vp->Set(L"left");
-        break;
-      case 2:
-        vp->Set(L"right");
-        break;
-      default:
-        vp->Set(L"");
-    }
+  switch (pFormControl->GetControlAlignment()) {
+    case 1:
+      vp->Set(L"center");
+      break;
+    case 0:
+      vp->Set(L"left");
+      break;
+    case 2:
+      vp->Set(L"right");
+      break;
+    default:
+      vp->Set(L"");
+  }
 
   return true;
 }
@@ -421,24 +419,7 @@
                           const CJS_PropValue& vp,
                           WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_String(FP_ALIGNMENT, vp.ToByteString());
-  } else {
-    Field::SetAlignment(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                        vp.ToByteString());
-  }
-  return true;
-}
-
-void Field::SetAlignment(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                         const WideString& swFieldName,
-                         int nControlIndex,
-                         const ByteString& string) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_border_style(CJS_Runtime* pRuntime,
@@ -582,24 +563,7 @@
                                const CJS_PropValue& vp,
                                WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Int(FP_BUTTONALIGNX, vp.ToInt());
-  } else {
-    Field::SetButtonAlignX(m_pFormFillEnv.Get(), m_FieldName,
-                           m_nFormControlIndex, vp.ToInt());
-  }
-  return true;
-}
-
-void Field::SetButtonAlignX(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                            const WideString& swFieldName,
-                            int nControlIndex,
-                            int number) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_button_align_y(CJS_Runtime* pRuntime,
@@ -633,25 +597,7 @@
                                const CJS_PropValue& vp,
                                WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Int(FP_BUTTONALIGNY, vp.ToInt());
-  } else {
-    Field::SetButtonAlignY(m_pFormFillEnv.Get(), m_FieldName,
-                           m_nFormControlIndex, vp.ToInt());
-  }
-
-  return true;
-}
-
-void Field::SetButtonAlignY(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                            const WideString& swFieldName,
-                            int nControlIndex,
-                            int number) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_button_fit_bounds(CJS_Runtime* pRuntime,
@@ -659,44 +605,27 @@
                                   WideString* sError) {
   ASSERT(m_pFormFillEnv);
 
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
-      return false;
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+    return false;
 
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
 
-    vp->Set(pFormControl->GetIconFit().GetFittingBounds());
-    return true;
+  vp->Set(pFormControl->GetIconFit().GetFittingBounds());
+  return true;
 }
 
 bool Field::set_button_fit_bounds(CJS_Runtime* pRuntime,
                                   const CJS_PropValue& vp,
                                   WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Bool(FP_BUTTONFITBOUNDS, vp.ToBool());
-  } else {
-    Field::SetButtonFitBounds(m_pFormFillEnv.Get(), m_FieldName,
-                              m_nFormControlIndex, vp.ToBool());
-  }
-  return true;
-}
-
-void Field::SetButtonFitBounds(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                               const WideString& swFieldName,
-                               int nControlIndex,
-                               bool b) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_button_position(CJS_Runtime* pRuntime,
@@ -704,44 +633,27 @@
                                 WideString* sError) {
   ASSERT(m_pFormFillEnv);
 
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
-      return false;
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+    return false;
 
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
 
-    vp->Set(pFormControl->GetTextPosition());
-    return true;
+  vp->Set(pFormControl->GetTextPosition());
+  return true;
 }
 
 bool Field::set_button_position(CJS_Runtime* pRuntime,
                                 const CJS_PropValue& vp,
                                 WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Int(FP_BUTTONPOSITION, vp.ToInt());
-  } else {
-    Field::SetButtonPosition(m_pFormFillEnv.Get(), m_FieldName,
-                             m_nFormControlIndex, vp.ToInt());
-  }
-  return true;
-}
-
-void Field::SetButtonPosition(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                              const WideString& swFieldName,
-                              int nControlIndex,
-                              int number) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_button_scale_how(CJS_Runtime* pRuntime,
@@ -749,44 +661,27 @@
                                  WideString* sError) {
   ASSERT(m_pFormFillEnv);
 
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
-      return false;
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+    return false;
 
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
 
-    vp->Set(pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1);
-    return true;
+  vp->Set(pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1);
+  return true;
 }
 
 bool Field::set_button_scale_how(CJS_Runtime* pRuntime,
                                  const CJS_PropValue& vp,
                                  WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Int(FP_BUTTONSCALEHOW, vp.ToInt());
-  } else {
-    Field::SetButtonScaleHow(m_pFormFillEnv.Get(), m_FieldName,
-                             m_nFormControlIndex, vp.ToInt());
-  }
-  return true;
-}
-
-void Field::SetButtonScaleHow(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                              const WideString& swFieldName,
-                              int nControlIndex,
-                              int number) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_button_scale_when(CJS_Runtime* pRuntime,
@@ -794,59 +689,42 @@
                                   WideString* sError) {
   ASSERT(m_pFormFillEnv);
 
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
-      return false;
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+    return false;
 
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
 
-    CPDF_IconFit IconFit = pFormControl->GetIconFit();
-    int ScaleM = IconFit.GetScaleMethod();
-    switch (ScaleM) {
-      case CPDF_IconFit::Always:
-        vp->Set(static_cast<int32_t>(CPDF_IconFit::Always));
-        break;
-      case CPDF_IconFit::Bigger:
-        vp->Set(static_cast<int32_t>(CPDF_IconFit::Bigger));
-        break;
-      case CPDF_IconFit::Never:
-        vp->Set(static_cast<int32_t>(CPDF_IconFit::Never));
-        break;
-      case CPDF_IconFit::Smaller:
-        vp->Set(static_cast<int32_t>(CPDF_IconFit::Smaller));
-        break;
-    }
-    return true;
+  CPDF_IconFit IconFit = pFormControl->GetIconFit();
+  int ScaleM = IconFit.GetScaleMethod();
+  switch (ScaleM) {
+    case CPDF_IconFit::Always:
+      vp->Set(static_cast<int32_t>(CPDF_IconFit::Always));
+      break;
+    case CPDF_IconFit::Bigger:
+      vp->Set(static_cast<int32_t>(CPDF_IconFit::Bigger));
+      break;
+    case CPDF_IconFit::Never:
+      vp->Set(static_cast<int32_t>(CPDF_IconFit::Never));
+      break;
+    case CPDF_IconFit::Smaller:
+      vp->Set(static_cast<int32_t>(CPDF_IconFit::Smaller));
+      break;
+  }
+  return true;
 }
 
 bool Field::set_button_scale_when(CJS_Runtime* pRuntime,
                                   const CJS_PropValue& vp,
                                   WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Int(FP_BUTTONSCALEWHEN, vp.ToInt());
-  } else {
-    Field::SetButtonScaleWhen(m_pFormFillEnv.Get(), m_FieldName,
-                              m_nFormControlIndex, vp.ToInt());
-  }
-  return true;
-}
-
-void Field::SetButtonScaleWhen(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                               const WideString& swFieldName,
-                               int nControlIndex,
-                               int number) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_calc_order_index(CJS_Runtime* pRuntime,
@@ -854,45 +732,28 @@
                                  WideString* sError) {
   ASSERT(m_pFormFillEnv);
 
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
-        pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) {
-      return false;
-    }
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
+      pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD) {
+    return false;
+  }
 
-    CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
-    CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
-    vp->Set(static_cast<int32_t>(
-        pInterForm->FindFieldInCalculationOrder(pFormField)));
-    return true;
+  CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
+  CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
+  vp->Set(static_cast<int32_t>(
+      pInterForm->FindFieldInCalculationOrder(pFormField)));
+  return true;
 }
 
 bool Field::set_calc_order_index(CJS_Runtime* pRuntime,
                                  const CJS_PropValue& vp,
                                  WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Int(FP_CALCORDERINDEX, vp.ToInt());
-  } else {
-    Field::SetCalcOrderIndex(m_pFormFillEnv.Get(), m_FieldName,
-                             m_nFormControlIndex, vp.ToInt());
-  }
-  return true;
-}
-
-void Field::SetCalcOrderIndex(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                              const WideString& swFieldName,
-                              int nControlIndex,
-                              int number) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_char_limit(CJS_Runtime* pRuntime,
@@ -916,24 +777,7 @@
                            const CJS_PropValue& vp,
                            WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Int(FP_CHARLIMIT, vp.ToInt());
-  } else {
-    Field::SetCharLimit(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                        vp.ToInt());
-  }
-  return true;
-}
-
-void Field::SetCharLimit(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                         const WideString& swFieldName,
-                         int nControlIndex,
-                         int number) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_comb(CJS_Runtime* pRuntime,
@@ -957,25 +801,7 @@
                      const CJS_PropValue& vp,
                      WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Bool(FP_COMB, vp.ToBool());
-  } else {
-    Field::SetComb(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                   vp.ToBool());
-  }
-
-  return true;
-}
-
-void Field::SetComb(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                    const WideString& swFieldName,
-                    int nControlIndex,
-                    bool b) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_commit_on_sel_change(CJS_Runtime* pRuntime,
@@ -983,42 +809,25 @@
                                      WideString* sError) {
   ASSERT(m_pFormFillEnv);
 
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
-        pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
-      return false;
-    }
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX &&
+      pFormField->GetFieldType() != FIELDTYPE_LISTBOX) {
+    return false;
+  }
 
-    vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE));
-    return true;
+  vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE));
+  return true;
 }
 
 bool Field::set_commit_on_sel_change(CJS_Runtime* pRuntime,
                                      const CJS_PropValue& vp,
                                      WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Bool(FP_COMMITONSELCHANGE, vp.ToBool());
-  } else {
-    Field::SetCommitOnSelChange(m_pFormFillEnv.Get(), m_FieldName,
-                                m_nFormControlIndex, vp.ToBool());
-  }
-  return true;
-}
-
-void Field::SetCommitOnSelChange(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                                 const WideString& swFieldName,
-                                 int nControlIndex,
-                                 bool b) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_current_value_indices(CJS_Runtime* pRuntime,
@@ -1119,12 +928,6 @@
   return false;
 }
 
-void Field::SetDefaultStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                            const WideString& swFieldName,
-                            int nControlIndex) {
-  // Not supported.
-}
-
 bool Field::get_default_value(CJS_Runtime* pRuntime,
                               CJS_PropValue* vp,
                               WideString* sError) {
@@ -1148,24 +951,7 @@
                               const CJS_PropValue& vp,
                               WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_WideString(FP_DEFAULTVALUE, vp.ToWideString());
-  } else {
-    Field::SetDefaultValue(m_pFormFillEnv.Get(), m_FieldName,
-                           m_nFormControlIndex, vp.ToWideString());
-  }
-  return true;
-}
-
-void Field::SetDefaultValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                            const WideString& swFieldName,
-                            int nControlIndex,
-                            const WideString& string) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_do_not_scroll(CJS_Runtime* pRuntime,
@@ -1189,24 +975,7 @@
                               const CJS_PropValue& vp,
                               WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-    if (!m_bCanSet)
-      return false;
-
-    if (m_bDelay) {
-      AddDelay_Bool(FP_DONOTSCROLL, vp.ToBool());
-    } else {
-      Field::SetDoNotScroll(m_pFormFillEnv.Get(), m_FieldName,
-                            m_nFormControlIndex, vp.ToBool());
-    }
-  return true;
-}
-
-void Field::SetDoNotScroll(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                           const WideString& swFieldName,
-                           int nControlIndex,
-                           bool b) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_do_not_spell_check(CJS_Runtime* pRuntime,
@@ -1214,18 +983,18 @@
                                    WideString* sError) {
   ASSERT(m_pFormFillEnv);
 
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD &&
-        pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) {
-      return false;
-    }
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD &&
+      pFormField->GetFieldType() != FIELDTYPE_COMBOBOX) {
+    return false;
+  }
 
-    vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK));
-    return true;
+  vp->Set(!!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK));
+  return true;
 }
 
 bool Field::set_do_not_spell_check(CJS_Runtime* pRuntime,
@@ -1240,7 +1009,6 @@
 
   if (m_bDelay)
     return;
-
   if (m_pJSDoc)
     m_pJSDoc->DoFieldDelay(m_FieldName, m_nFormControlIndex);
 }
@@ -1512,32 +1280,13 @@
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
   if (FieldArray.empty())
     return false;
-
   if (!m_bCanSet)
     return false;
-
   if (!vp.GetJSValue()->IsArrayObject())
     return false;
-
-  CJS_Array crArray = vp.ToArray();
-  CFX_Color color;
-  color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
-  if (m_bDelay) {
-    AddDelay_Color(FP_FILLCOLOR, color);
-  } else {
-    Field::SetFillColor(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                        color);
-  }
   return true;
 }
 
-void Field::SetFillColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                         const WideString& swFieldName,
-                         int nControlIndex,
-                         const CFX_Color& color) {
-  // Not supported.
-}
-
 bool Field::get_hidden(CJS_Runtime* pRuntime,
                        CJS_PropValue* vp,
                        WideString* sError) {
@@ -1624,23 +1373,7 @@
                           const CJS_PropValue& vp,
                           WideString* sError) {
   ASSERT(m_pFormFillEnv);
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_String(FP_HIGHLIGHT, vp.ToByteString());
-  } else {
-    Field::SetHighlight(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                        vp.ToByteString());
-  }
-  return true;
-}
-
-void Field::SetHighlight(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                         const WideString& swFieldName,
-                         int nControlIndex,
-                         const ByteString& string) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_line_width(CJS_Runtime* pRuntime,
@@ -1744,24 +1477,7 @@
                           const CJS_PropValue& vp,
                           WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-    if (!m_bCanSet)
-      return false;
-
-    if (m_bDelay) {
-      AddDelay_Bool(FP_MULTILINE, vp.ToBool());
-    } else {
-      Field::SetMultiline(m_pFormFillEnv.Get(), m_FieldName,
-                          m_nFormControlIndex, vp.ToBool());
-    }
-    return true;
-}
-
-void Field::SetMultiline(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                         const WideString& swFieldName,
-                         int nControlIndex,
-                         bool b) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_multiple_selection(CJS_Runtime* pRuntime,
@@ -1784,24 +1500,7 @@
                                    const CJS_PropValue& vp,
                                    WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Bool(FP_MULTIPLESELECTION, vp.ToBool());
-  } else {
-    Field::SetMultipleSelection(m_pFormFillEnv.Get(), m_FieldName,
-                                m_nFormControlIndex, vp.ToBool());
-  }
-  return true;
-}
-
-void Field::SetMultipleSelection(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                                 const WideString& swFieldName,
-                                 int nControlIndex,
-                                 bool b) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_name(CJS_Runtime* pRuntime,
@@ -1912,42 +1611,25 @@
                          const CJS_PropValue& vp,
                          WideString* sError) {
   ASSERT(m_pFormFillEnv);
+  return m_bCanSet;
+}
 
-    if (!m_bCanSet)
-      return false;
+bool Field::get_print(CJS_Runtime* pRuntime,
+                      CJS_PropValue* vp,
+                      WideString* sError) {
+  CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    if (m_bDelay) {
-      AddDelay_Bool(FP_PASSWORD, vp.ToBool());
-    } else {
-      Field::SetPassword(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                         vp.ToBool());
-    }
-    return true;
-  }
+  CPDF_FormField* pFormField = FieldArray[0];
+  CPDFSDK_Widget* pWidget =
+      pInterForm->GetWidget(GetSmartFieldControl(pFormField));
+  if (!pWidget)
+    return false;
 
-  void Field::SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                          const WideString& swFieldName,
-                          int nControlIndex,
-                          bool b) {
-    // Not supported.
-  }
-
-  bool Field::get_print(CJS_Runtime* pRuntime,
-                        CJS_PropValue* vp,
-                        WideString* sError) {
-    CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    CPDFSDK_Widget* pWidget =
-        pInterForm->GetWidget(GetSmartFieldControl(pFormField));
-    if (!pWidget)
-      return false;
-
-    vp->Set(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT));
-    return true;
+  vp->Set(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT));
+  return true;
 }
 
 bool Field::set_print(CJS_Runtime* pRuntime,
@@ -2050,7 +1732,6 @@
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
   if (FieldArray.empty())
     return false;
-
   return m_bCanSet;
 }
 
@@ -2223,14 +1904,7 @@
                           const CJS_PropValue& vp,
                           WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay)
-    AddDelay_Bool(FP_RICHTEXT, vp.ToBool());
-
-  return true;
+  return m_bCanSet;
 }
 
 bool Field::get_rich_value(CJS_Runtime* pRuntime,
@@ -2266,24 +1940,8 @@
 bool Field::set_rotation(CJS_Runtime* pRuntime,
                          const CJS_PropValue& vp,
                          WideString* sError) {
-  if (!m_bCanSet)
-    return false;
-
   ASSERT(m_pFormFillEnv);
-  if (m_bDelay) {
-    AddDelay_Int(FP_ROTATION, vp.ToInt());
-  } else {
-    Field::SetRotation(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                       vp.ToInt());
-  }
-  return true;
-}
-
-void Field::SetRotation(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                        const WideString& swFieldName,
-                        int nControlIndex,
-                        int number) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_stroke_color(CJS_Runtime* pRuntime,
@@ -2331,29 +1989,11 @@
                              WideString* sError) {
   if (!m_bCanSet)
     return false;
-
   if (!vp.GetJSValue()->IsArrayObject())
     return false;
-
-  CJS_Array crArray = vp.ToArray();
-  CFX_Color color;
-  color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
-  if (m_bDelay) {
-    AddDelay_Color(FP_STROKECOLOR, color);
-  } else {
-    Field::SetStrokeColor(m_pFormFillEnv.Get(), m_FieldName,
-                          m_nFormControlIndex, color);
-  }
   return true;
 }
 
-void Field::SetStrokeColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                           const WideString& swFieldName,
-                           int nControlIndex,
-                           const CFX_Color& color) {
-  // Not supported.
-}
-
 bool Field::get_style(CJS_Runtime* pRuntime,
                       CJS_PropValue* vp,
                       WideString* sError) {
@@ -2404,24 +2044,7 @@
                       const CJS_PropValue& vp,
                       WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_String(FP_STYLE, vp.ToByteString());
-  } else {
-    Field::SetStyle(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                    vp.ToByteString());
-  }
-  return true;
-}
-
-void Field::SetStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                     const WideString& swFieldName,
-                     int nControlIndex,
-                     const ByteString& string) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_submit_name(CJS_Runtime* pRuntime,
@@ -2476,30 +2099,11 @@
                            WideString* sError) {
   if (!m_bCanSet)
     return false;
-
   if (!vp.GetJSValue()->IsArrayObject())
     return false;
-
-  CJS_Array crArray = vp.ToArray();
-  CFX_Color color;
-  color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
-
-  if (m_bDelay) {
-    AddDelay_Color(FP_TEXTCOLOR, color);
-  } else {
-    Field::SetTextColor(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                        color);
-  }
   return true;
 }
 
-void Field::SetTextColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                         const WideString& swFieldName,
-                         int nControlIndex,
-                         const CFX_Color& color) {
-  // Not supported.
-}
-
 bool Field::get_text_font(CJS_Runtime* pRuntime,
                           CJS_PropValue* vp,
                           WideString* sError) {
@@ -2533,27 +2137,11 @@
                           WideString* sError) {
   ASSERT(m_pFormFillEnv);
 
-    if (!m_bCanSet)
-      return false;
+  if (!m_bCanSet)
+    return false;
 
-    ByteString fontName = vp.ToByteString();
-    if (fontName.IsEmpty())
-      return false;
-
-    if (m_bDelay) {
-      AddDelay_String(FP_TEXTFONT, fontName);
-    } else {
-      Field::SetTextFont(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                         fontName);
-    }
-    return true;
-}
-
-void Field::SetTextFont(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                        const WideString& swFieldName,
-                        int nControlIndex,
-                        const ByteString& string) {
-  // Not supported.
+  ByteString fontName = vp.ToByteString();
+  return !fontName.IsEmpty();
 }
 
 bool Field::get_text_size(CJS_Runtime* pRuntime,
@@ -2582,24 +2170,7 @@
                           const CJS_PropValue& vp,
                           WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-  if (!m_bCanSet)
-    return false;
-
-  if (m_bDelay) {
-    AddDelay_Int(FP_TEXTSIZE, vp.ToInt());
-  } else {
-    Field::SetTextSize(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                       vp.ToInt());
-  }
-  return true;
-}
-
-void Field::SetTextSize(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                        const WideString& swFieldName,
-                        int nControlIndex,
-                        int number) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_type(CJS_Runtime* pRuntime,
@@ -2665,24 +2236,7 @@
                           const CJS_PropValue& vp,
                           WideString* sError) {
   ASSERT(m_pFormFillEnv);
-
-    if (!m_bCanSet)
-      return false;
-
-    if (m_bDelay) {
-      AddDelay_WideString(FP_USERNAME, vp.ToWideString());
-    } else {
-      Field::SetUserName(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
-                         vp.ToWideString());
-    }
-    return true;
-}
-
-void Field::SetUserName(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                        const WideString& swFieldName,
-                        int nControlIndex,
-                        const WideString& string) {
-  // Not supported.
+  return m_bCanSet;
 }
 
 bool Field::get_value(CJS_Runtime* pRuntime,
@@ -3161,9 +2715,8 @@
     return false;
 
   CPDF_FormField* pFormField = FieldArray[0];
-  if (nIndex < 0 || nIndex >= pFormField->CountControls()) {
+  if (nIndex < 0 || nIndex >= pFormField->CountControls())
     return false;
-  }
 
   vRet = CJS_Value(pRuntime,
                    ((pFormField->GetFieldType() == FIELDTYPE_CHECKBOX ||
@@ -3337,13 +2890,6 @@
   m_pJSDoc->AddDelayData(pNewData);
 }
 
-void Field::AddDelay_WideString(FIELD_PROP prop, const WideString& string) {
-  CJS_DelayData* pNewData =
-      new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName);
-  pNewData->widestring = string;
-  m_pJSDoc->AddDelayData(pNewData);
-}
-
 void Field::AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect) {
   CJS_DelayData* pNewData =
       new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName);
@@ -3351,13 +2897,6 @@
   m_pJSDoc->AddDelayData(pNewData);
 }
 
-void Field::AddDelay_Color(FIELD_PROP prop, const CFX_Color& color) {
-  CJS_DelayData* pNewData =
-      new CJS_DelayData(prop, m_nFormControlIndex, m_FieldName);
-  pNewData->color = color;
-  m_pJSDoc->AddDelayData(pNewData);
-}
-
 void Field::AddDelay_WordArray(FIELD_PROP prop,
                                const std::vector<uint32_t>& array) {
   CJS_DelayData* pNewData =
@@ -3378,146 +2917,35 @@
                     CJS_DelayData* pData) {
   ASSERT(pFormFillEnv);
   switch (pData->eProp) {
-    case FP_ALIGNMENT:
-      Field::SetAlignment(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                          pData->string);
-      break;
     case FP_BORDERSTYLE:
       Field::SetBorderStyle(pFormFillEnv, pData->sFieldName,
                             pData->nControlIndex, pData->string);
       break;
-    case FP_BUTTONALIGNX:
-      Field::SetButtonAlignX(pFormFillEnv, pData->sFieldName,
-                             pData->nControlIndex, pData->num);
-      break;
-    case FP_BUTTONALIGNY:
-      Field::SetButtonAlignY(pFormFillEnv, pData->sFieldName,
-                             pData->nControlIndex, pData->num);
-      break;
-    case FP_BUTTONFITBOUNDS:
-      Field::SetButtonFitBounds(pFormFillEnv, pData->sFieldName,
-                                pData->nControlIndex, pData->b);
-      break;
-    case FP_BUTTONPOSITION:
-      Field::SetButtonPosition(pFormFillEnv, pData->sFieldName,
-                               pData->nControlIndex, pData->num);
-      break;
-    case FP_BUTTONSCALEHOW:
-      Field::SetButtonScaleHow(pFormFillEnv, pData->sFieldName,
-                               pData->nControlIndex, pData->num);
-      break;
-    case FP_BUTTONSCALEWHEN:
-      Field::SetButtonScaleWhen(pFormFillEnv, pData->sFieldName,
-                                pData->nControlIndex, pData->num);
-      break;
-    case FP_CALCORDERINDEX:
-      Field::SetCalcOrderIndex(pFormFillEnv, pData->sFieldName,
-                               pData->nControlIndex, pData->num);
-      break;
-    case FP_CHARLIMIT:
-      Field::SetCharLimit(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                          pData->num);
-      break;
-    case FP_COMB:
-      Field::SetComb(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                     pData->b);
-      break;
-    case FP_COMMITONSELCHANGE:
-      Field::SetCommitOnSelChange(pFormFillEnv, pData->sFieldName,
-                                  pData->nControlIndex, pData->b);
-      break;
     case FP_CURRENTVALUEINDICES:
       Field::SetCurrentValueIndices(pFormFillEnv, pData->sFieldName,
                                     pData->nControlIndex, pData->wordarray);
       break;
-    case FP_DEFAULTVALUE:
-      Field::SetDefaultValue(pFormFillEnv, pData->sFieldName,
-                             pData->nControlIndex, pData->widestring);
-      break;
-    case FP_DONOTSCROLL:
-      Field::SetDoNotScroll(pFormFillEnv, pData->sFieldName,
-                            pData->nControlIndex, pData->b);
-      break;
     case FP_DISPLAY:
       Field::SetDisplay(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
                         pData->num);
       break;
-    case FP_FILLCOLOR:
-      Field::SetFillColor(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                          pData->color);
-      break;
     case FP_HIDDEN:
       Field::SetHidden(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
                        pData->b);
       break;
-    case FP_HIGHLIGHT:
-      Field::SetHighlight(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                          pData->string);
-      break;
     case FP_LINEWIDTH:
       Field::SetLineWidth(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
                           pData->num);
       break;
-    case FP_MULTILINE:
-      Field::SetMultiline(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                          pData->b);
-      break;
-    case FP_MULTIPLESELECTION:
-      Field::SetMultipleSelection(pFormFillEnv, pData->sFieldName,
-                                  pData->nControlIndex, pData->b);
-      break;
-    case FP_PASSWORD:
-      Field::SetPassword(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                         pData->b);
-      break;
     case FP_RECT:
       Field::SetRect(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
                      pData->rect);
       break;
-    case FP_RICHTEXT:
-      // Not supported.
-      break;
-    case FP_RICHVALUE:
-      break;
-    case FP_ROTATION:
-      Field::SetRotation(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                         pData->num);
-      break;
-    case FP_STROKECOLOR:
-      Field::SetStrokeColor(pFormFillEnv, pData->sFieldName,
-                            pData->nControlIndex, pData->color);
-      break;
-    case FP_STYLE:
-      Field::SetStyle(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                      pData->string);
-      break;
-    case FP_TEXTCOLOR:
-      Field::SetTextColor(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                          pData->color);
-      break;
-    case FP_TEXTFONT:
-      Field::SetTextFont(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                         pData->string);
-      break;
-    case FP_TEXTSIZE:
-      Field::SetTextSize(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                         pData->num);
-      break;
-    case FP_USERNAME:
-      Field::SetUserName(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
-                         pData->widestring);
-      break;
     case FP_VALUE:
       Field::SetValue(pFormFillEnv, pData->sFieldName, pData->nControlIndex,
                       pData->widestringarray);
       break;
+    default:
+      NOTREACHED();
   }
 }
-
-void Field::AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                     int nPageIndex,
-                     int nFieldType,
-                     const WideString& sName,
-                     const CFX_FloatRect& rcCoords) {
-  // Not supported.
-}
diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h
index 7284153..27e5cc3 100644
--- a/fpdfsdk/javascript/Field.h
+++ b/fpdfsdk/javascript/Field.h
@@ -19,39 +19,12 @@
 class Document;
 
 enum FIELD_PROP {
-  FP_ALIGNMENT,
   FP_BORDERSTYLE,
-  FP_BUTTONALIGNX,
-  FP_BUTTONALIGNY,
-  FP_BUTTONFITBOUNDS,
-  FP_BUTTONPOSITION,
-  FP_BUTTONSCALEHOW,
-  FP_BUTTONSCALEWHEN,
-  FP_CALCORDERINDEX,
-  FP_CHARLIMIT,
-  FP_COMB,
-  FP_COMMITONSELCHANGE,
   FP_CURRENTVALUEINDICES,
-  FP_DEFAULTVALUE,
-  FP_DONOTSCROLL,
   FP_DISPLAY,
-  FP_FILLCOLOR,
   FP_HIDDEN,
-  FP_HIGHLIGHT,
   FP_LINEWIDTH,
-  FP_MULTILINE,
-  FP_MULTIPLESELECTION,
-  FP_PASSWORD,
   FP_RECT,
-  FP_RICHTEXT,
-  FP_RICHVALUE,
-  FP_ROTATION,
-  FP_STROKECOLOR,
-  FP_STYLE,
-  FP_TEXTCOLOR,
-  FP_TEXTFONT,
-  FP_TEXTSIZE,
-  FP_USERNAME,
   FP_VALUE
 };
 
@@ -528,85 +501,22 @@
   bool AttachField(Document* pDocument, const WideString& csFieldName);
 
  private:
-  static void SetAlignment(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                           const WideString& swFieldName,
-                           int nControlIndex,
-                           const ByteString& string);
   static void SetBorderStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                              const WideString& swFieldName,
                              int nControlIndex,
                              const ByteString& string);
-  static void SetButtonAlignX(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                              const WideString& swFieldName,
-                              int nControlIndex,
-                              int number);
-  static void SetButtonAlignY(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                              const WideString& swFieldName,
-                              int nControlIndex,
-                              int number);
-  static void SetButtonFitBounds(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                                 const WideString& swFieldName,
-                                 int nControlIndex,
-                                 bool b);
-  static void SetButtonPosition(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                                const WideString& swFieldName,
-                                int nControlIndex,
-                                int number);
-  static void SetButtonScaleHow(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                                const WideString& swFieldName,
-                                int nControlIndex,
-                                int number);
-  static void SetButtonScaleWhen(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                                 const WideString& swFieldName,
-                                 int nControlIndex,
-                                 int number);
-  static void SetCalcOrderIndex(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                                const WideString& swFieldName,
-                                int nControlIndex,
-                                int number);
-  static void SetCharLimit(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                           const WideString& swFieldName,
-                           int nControlIndex,
-                           int number);
-  static void SetComb(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                      const WideString& swFieldName,
-                      int nControlIndex,
-                      bool b);
-  static void SetCommitOnSelChange(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                                   const WideString& swFieldName,
-                                   int nControlIndex,
-                                   bool b);
   static void SetCurrentValueIndices(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                                      const WideString& swFieldName,
                                      int nControlIndex,
                                      const std::vector<uint32_t>& array);
-  static void SetDefaultStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                              const WideString& swFieldName,
-                              int nControlIndex);
-  static void SetDefaultValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                              const WideString& swFieldName,
-                              int nControlIndex,
-                              const WideString& string);
-  static void SetDoNotScroll(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                             const WideString& swFieldName,
-                             int nControlIndex,
-                             bool b);
   static void SetDisplay(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                          const WideString& swFieldName,
                          int nControlIndex,
                          int number);
-  static void SetFillColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                           const WideString& swFieldName,
-                           int nControlIndex,
-                           const CFX_Color& color);
   static void SetHidden(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                         const WideString& swFieldName,
                         int nControlIndex,
                         bool b);
-  static void SetHighlight(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                           const WideString& swFieldName,
-                           int nControlIndex,
-                           const ByteString& string);
   static void SetLineWidth(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                            const WideString& swFieldName,
                            int nControlIndex,
@@ -615,57 +525,15 @@
                            const WideString& swFieldName,
                            int nControlIndex,
                            bool b);
-  static void SetMultipleSelection(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                                   const WideString& swFieldName,
-                                   int nControlIndex,
-                                   bool b);
-  static void SetPassword(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                          const WideString& swFieldName,
-                          int nControlIndex,
-                          bool b);
   static void SetRect(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                       const WideString& swFieldName,
                       int nControlIndex,
                       const CFX_FloatRect& rect);
-  static void SetRotation(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                          const WideString& swFieldName,
-                          int nControlIndex,
-                          int number);
-  static void SetStrokeColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                             const WideString& swFieldName,
-                             int nControlIndex,
-                             const CFX_Color& color);
-  static void SetStyle(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                       const WideString& swFieldName,
-                       int nControlIndex,
-                       const ByteString& string);
-  static void SetTextColor(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                           const WideString& swFieldName,
-                           int nControlIndex,
-                           const CFX_Color& color);
-  static void SetTextFont(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                          const WideString& swFieldName,
-                          int nControlIndex,
-                          const ByteString& string);
-  static void SetTextSize(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                          const WideString& swFieldName,
-                          int nControlIndex,
-                          int number);
-  static void SetUserName(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                          const WideString& swFieldName,
-                          int nControlIndex,
-                          const WideString& string);
   static void SetValue(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                        const WideString& swFieldName,
                        int nControlIndex,
                        const std::vector<WideString>& strArray);
 
-  static void AddField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                       int nPageIndex,
-                       int nFieldType,
-                       const WideString& sName,
-                       const CFX_FloatRect& rcCoords);
-
   static void UpdateFormField(CPDFSDK_FormFillEnvironment* pFormFillEnv,
                               CPDF_FormField* pFormField,
                               bool bChangeMark,
@@ -695,9 +563,7 @@
   void AddDelay_Int(FIELD_PROP prop, int32_t n);
   void AddDelay_Bool(FIELD_PROP prop, bool b);
   void AddDelay_String(FIELD_PROP prop, const ByteString& string);
-  void AddDelay_WideString(FIELD_PROP prop, const WideString& string);
   void AddDelay_Rect(FIELD_PROP prop, const CFX_FloatRect& rect);
-  void AddDelay_Color(FIELD_PROP prop, const CFX_Color& color);
   void AddDelay_WordArray(FIELD_PROP prop, const std::vector<uint32_t>& array);
   void AddDelay_WideStringArray(FIELD_PROP prop,
                                 const std::vector<WideString>& array);
