Replace optional bool bNotify with enum type.

Adds clarity to the call sites.

Change-Id: Id4deed9adda2ad79f0847d618792429044d4f7d6
Reviewed-on: https://pdfium-review.googlesource.com/40351
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_formfield.cpp b/core/fpdfdoc/cpdf_formfield.cpp
index 678a66a..e99c745 100644
--- a/core/fpdfdoc/cpdf_formfield.cpp
+++ b/core/fpdfdoc/cpdf_formfield.cpp
@@ -171,34 +171,34 @@
   return FPDF_GetFullName(m_pDict.Get());
 }
 
-bool CPDF_FormField::ResetField(bool bNotify) {
+bool CPDF_FormField::ResetField(NotificationOption notify) {
   switch (m_Type) {
     case CPDF_FormField::CheckBox:
     case CPDF_FormField::RadioButton: {
       int iCount = CountControls();
-      if (iCount) {
-        // TODO(weili): Check whether anything special needs to be done for
-        // unison field. (When IsUnison(this) returns true/false.)
-        for (int i = 0; i < iCount; i++)
-          CheckControl(i, GetControl(i)->IsDefaultChecked(), false);
+      // TODO(weili): Check whether anything special needs to be done for
+      // unison field. (When IsUnison(this) returns true/false.)
+      for (int i = 0; i < iCount; i++) {
+        CheckControl(i, GetControl(i)->IsDefaultChecked(),
+                     NotificationOption::kDoNotNotify);
       }
-      if (bNotify && m_pForm->GetFormNotify())
+      if (notify == NotificationOption::kNotify && m_pForm->GetFormNotify())
         m_pForm->GetFormNotify()->AfterCheckedStatusChange(this);
       break;
     }
     case CPDF_FormField::ComboBox:
     case CPDF_FormField::ListBox: {
+      ClearSelection(NotificationOption::kDoNotNotify);
       WideString csValue;
-      ClearSelection();
       int iIndex = GetDefaultSelectedItem();
       if (iIndex >= 0)
         csValue = GetOptionLabel(iIndex);
-
-      if (bNotify && !NotifyListOrComboBoxBeforeChange(csValue))
+      if (notify == NotificationOption::kNotify &&
+          !NotifyListOrComboBoxBeforeChange(csValue)) {
         return false;
-
-      SetItemSelection(iIndex, true);
-      if (bNotify)
+      }
+      SetItemSelection(iIndex, true, NotificationOption::kDoNotNotify);
+      if (notify == NotificationOption::kNotify)
         NotifyListOrComboBoxAfterChange();
       break;
     }
@@ -220,9 +220,10 @@
       if (!pRV && (csDValue == csValue))
         return false;
 
-      if (bNotify && !NotifyBeforeValueChange(csDValue))
+      if (notify == NotificationOption::kNotify &&
+          !NotifyBeforeValueChange(csDValue)) {
         return false;
-
+      }
       if (pDV) {
         std::unique_ptr<CPDF_Object> pClone = pDV->Clone();
         if (!pClone)
@@ -235,7 +236,7 @@
         m_pDict->RemoveFor("V");
         m_pDict->RemoveFor("RV");
       }
-      if (bNotify)
+      if (notify == NotificationOption::kNotify)
         NotifyAfterValueChange();
       break;
     }
@@ -341,11 +342,11 @@
 
 bool CPDF_FormField::SetValue(const WideString& value,
                               bool bDefault,
-                              bool bNotify) {
+                              NotificationOption notify) {
   switch (m_Type) {
     case CheckBox:
     case RadioButton: {
-      SetCheckValue(value, bDefault, bNotify);
+      SetCheckValue(value, bDefault, notify);
       return true;
     }
     case File:
@@ -353,9 +354,10 @@
     case Text:
     case ComboBox: {
       WideString csValue = value;
-      if (bNotify && !NotifyBeforeValueChange(csValue))
+      if (notify == NotificationOption::kNotify &&
+          !NotifyBeforeValueChange(csValue)) {
         return false;
-
+      }
       ByteString key(bDefault ? "DV" : "V");
       int iIndex = FindOptionValue(csValue);
       if (iIndex < 0) {
@@ -367,11 +369,11 @@
       } else {
         m_pDict->SetNewFor<CPDF_String>(key, PDF_EncodeText(csValue), false);
         if (!bDefault) {
-          ClearSelection();
-          SetItemSelection(iIndex, true);
+          ClearSelection(NotificationOption::kDoNotNotify);
+          SetItemSelection(iIndex, true, NotificationOption::kDoNotNotify);
         }
       }
-      if (bNotify)
+      if (notify == NotificationOption::kNotify)
         NotifyAfterValueChange();
       break;
     }
@@ -383,14 +385,15 @@
       if (bDefault && iIndex == GetDefaultSelectedItem())
         return false;
 
-      if (bNotify && !NotifyBeforeSelectionChange(value))
+      if (notify == NotificationOption::kNotify &&
+          !NotifyBeforeSelectionChange(value)) {
         return false;
-
-      if (!bDefault) {
-        ClearSelection();
-        SetItemSelection(iIndex, true);
       }
-      if (bNotify)
+      if (!bDefault) {
+        ClearSelection(NotificationOption::kDoNotNotify);
+        SetItemSelection(iIndex, true, NotificationOption::kDoNotNotify);
+      }
+      if (notify == NotificationOption::kNotify)
         NotifyAfterSelectionChange();
       break;
     }
@@ -400,8 +403,9 @@
   return true;
 }
 
-bool CPDF_FormField::SetValue(const WideString& value, bool bNotify) {
-  return SetValue(value, false, bNotify);
+bool CPDF_FormField::SetValue(const WideString& value,
+                              NotificationOption notify) {
+  return SetValue(value, false, notify);
 }
 
 int CPDF_FormField::GetMaxLen() const {
@@ -468,19 +472,18 @@
   return -1;
 }
 
-bool CPDF_FormField::ClearSelection(bool bNotify) {
-  if (bNotify && m_pForm->GetFormNotify()) {
+bool CPDF_FormField::ClearSelection(NotificationOption notify) {
+  if (notify == NotificationOption::kNotify && m_pForm->GetFormNotify()) {
     WideString csValue;
     int iIndex = GetSelectedIndex(0);
     if (iIndex >= 0)
       csValue = GetOptionLabel(iIndex);
-
     if (!NotifyListOrComboBoxBeforeChange(csValue))
       return false;
   }
   m_pDict->RemoveFor("V");
   m_pDict->RemoveFor("I");
-  if (bNotify)
+  if (notify == NotificationOption::kNotify)
     NotifyListOrComboBoxAfterChange();
   return true;
 }
@@ -528,18 +531,21 @@
   return false;
 }
 
-bool CPDF_FormField::SetItemSelection(int index, bool bSelected, bool bNotify) {
+bool CPDF_FormField::SetItemSelection(int index,
+                                      bool bSelected,
+                                      NotificationOption notify) {
   ASSERT(GetType() == ComboBox || GetType() == ListBox);
   if (index < 0 || index >= CountOptions())
     return false;
 
   WideString opt_value = GetOptionValue(index);
-  if (bNotify && !NotifyListOrComboBoxBeforeChange(opt_value))
+  if (notify == NotificationOption::kNotify &&
+      !NotifyListOrComboBoxBeforeChange(opt_value)) {
     return false;
-
+  }
   if (bSelected) {
     if (GetType() == ListBox) {
-      SelectOption(index, true);
+      SelectOption(index, true, NotificationOption::kDoNotNotify);
       if (!(m_Flags & kFormListMultiSelect)) {
         m_pDict->SetNewFor<CPDF_String>("V", PDF_EncodeText(opt_value), false);
       } else {
@@ -560,7 +566,7 @@
     const CPDF_Object* pValue = FPDF_GetFieldAttr(m_pDict.Get(), "V");
     if (pValue) {
       if (GetType() == ListBox) {
-        SelectOption(index, false);
+        SelectOption(index, false, NotificationOption::kDoNotNotify);
         if (pValue->IsString()) {
           if (pValue->GetUnicodeText() == opt_value)
             m_pDict->RemoveFor("V");
@@ -581,7 +587,7 @@
       }
     }
   }
-  if (bNotify)
+  if (notify == NotificationOption::kNotify)
     NotifyListOrComboBoxAfterChange();
   return true;
 }
@@ -655,7 +661,7 @@
 
 bool CPDF_FormField::CheckControl(int iControlIndex,
                                   bool bChecked,
-                                  bool bNotify) {
+                                  NotificationOption notify) {
   ASSERT(GetType() == CheckBox || GetType() == RadioButton);
   CPDF_FormControl* pControl = GetControl(iControlIndex);
   if (!pControl)
@@ -702,7 +708,7 @@
   } else if (bChecked) {
     m_pDict->SetNewFor<CPDF_Name>("V", ByteString::Format("%d", iControlIndex));
   }
-  if (bNotify && m_pForm->GetFormNotify())
+  if (notify == NotificationOption::kNotify && m_pForm->GetFormNotify())
     m_pForm->GetFormNotify()->AfterCheckedStatusChange(this);
   return true;
 }
@@ -725,19 +731,21 @@
 
 bool CPDF_FormField::SetCheckValue(const WideString& value,
                                    bool bDefault,
-                                   bool bNotify) {
+                                   NotificationOption notify) {
   ASSERT(GetType() == CheckBox || GetType() == RadioButton);
   int iCount = CountControls();
   for (int i = 0; i < iCount; i++) {
     CPDF_FormControl* pControl = GetControl(i);
     WideString csExport = pControl->GetExportValue();
     bool val = csExport == value;
-    if (!bDefault)
-      CheckControl(GetControlIndex(pControl), val);
+    if (!bDefault) {
+      CheckControl(GetControlIndex(pControl), val,
+                   NotificationOption::kDoNotNotify);
+    }
     if (val)
       break;
   }
-  if (bNotify && m_pForm->GetFormNotify())
+  if (notify == NotificationOption::kNotify && m_pForm->GetFormNotify())
     m_pForm->GetFormNotify()->AfterCheckedStatusChange(this);
   return true;
 }
@@ -775,7 +783,9 @@
   return false;
 }
 
-bool CPDF_FormField::SelectOption(int iOptIndex, bool bSelected, bool bNotify) {
+bool CPDF_FormField::SelectOption(int iOptIndex,
+                                  bool bSelected,
+                                  NotificationOption notify) {
   CPDF_Array* pArray = m_pDict->GetArrayFor("I");
   if (!pArray) {
     if (!bSelected)
@@ -791,7 +801,7 @@
       if (bSelected)
         return true;
 
-      if (bNotify && m_pForm->GetFormNotify()) {
+      if (notify == NotificationOption::kNotify && m_pForm->GetFormNotify()) {
         WideString csValue = GetOptionLabel(iOptIndex);
         if (!NotifyListOrComboBoxBeforeChange(csValue))
           return false;
@@ -805,7 +815,7 @@
       if (!bSelected)
         continue;
 
-      if (bNotify && m_pForm->GetFormNotify()) {
+      if (notify == NotificationOption::kNotify && m_pForm->GetFormNotify()) {
         WideString csValue = GetOptionLabel(iOptIndex);
         if (!NotifyListOrComboBoxBeforeChange(csValue))
           return false;
@@ -818,30 +828,27 @@
   if (!bReturn) {
     if (bSelected)
       pArray->AddNew<CPDF_Number>(iOptIndex);
-
     if (pArray->IsEmpty())
       m_pDict->RemoveFor("I");
   }
-  if (bNotify)
+  if (notify == NotificationOption::kNotify)
     NotifyListOrComboBoxAfterChange();
 
   return true;
 }
 
-bool CPDF_FormField::ClearSelectedOptions(bool bNotify) {
-  if (bNotify && m_pForm->GetFormNotify()) {
+bool CPDF_FormField::ClearSelectedOptions(NotificationOption notify) {
+  if (notify == NotificationOption::kNotify && m_pForm->GetFormNotify()) {
     WideString csValue;
     int iIndex = GetSelectedIndex(0);
     if (iIndex >= 0)
       csValue = GetOptionLabel(iIndex);
-
     if (!NotifyListOrComboBoxBeforeChange(csValue))
       return false;
   }
   m_pDict->RemoveFor("I");
-  if (bNotify)
+  if (notify == NotificationOption::kNotify)
     NotifyListOrComboBoxAfterChange();
-
   return true;
 }
 
diff --git a/core/fpdfdoc/cpdf_formfield.h b/core/fpdfdoc/cpdf_formfield.h
index 6f00065..7dc95e5 100644
--- a/core/fpdfdoc/cpdf_formfield.h
+++ b/core/fpdfdoc/cpdf_formfield.h
@@ -12,12 +12,13 @@
 #include <vector>
 
 #include "core/fpdfdoc/cpdf_aaction.h"
-#include "core/fpdfdoc/cpdf_formfield.h"
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/unowned_ptr.h"
 #include "third_party/base/stl_util.h"
 
+enum class NotificationOption { kDoNotNotify = 0, kNotify };
+
 enum class FormFieldType : uint8_t {
   kUnknown = 0,
   kPushButton = 1,
@@ -111,7 +112,7 @@
   CPDF_Dictionary* GetFieldDict() const { return m_pDict.Get(); }
   void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; }
 
-  bool ResetField(bool bNotify);
+  bool ResetField(NotificationOption notify);
 
   int CountControls() const {
     return pdfium::CollectionSize<int>(m_ControlList);
@@ -133,15 +134,15 @@
 
   WideString GetValue() const;
   WideString GetDefaultValue() const;
-  bool SetValue(const WideString& value, bool bNotify = false);
+  bool SetValue(const WideString& value, NotificationOption notify);
 
   int GetMaxLen() const;
   int CountSelectedItems() const;
   int GetSelectedIndex(int index) const;
 
-  bool ClearSelection(bool bNotify = false);
+  bool ClearSelection(NotificationOption notify);
   bool IsItemSelected(int index) const;
-  bool SetItemSelection(int index, bool bSelected, bool bNotify = false);
+  bool SetItemSelection(int index, bool bSelected, NotificationOption notify);
 
   bool IsItemDefaultSelected(int index) const;
 
@@ -154,15 +155,17 @@
   int FindOption(WideString csOptLabel) const;
   int FindOptionValue(const WideString& csOptValue) const;
 
-  bool CheckControl(int iControlIndex, bool bChecked, bool bNotify = false);
+  bool CheckControl(int iControlIndex,
+                    bool bChecked,
+                    NotificationOption notify);
 
   int GetTopVisibleIndex() const;
   int CountSelectedOptions() const;
 
   int GetSelectedOptionIndex(int index) const;
   bool IsOptionSelected(int iOptIndex) const;
-  bool SelectOption(int iOptIndex, bool bSelected, bool bNotify = false);
-  bool ClearSelectedOptions(bool bNotify);
+  bool SelectOption(int iOptIndex, bool bSelected, NotificationOption notify);
+  bool ClearSelectedOptions(NotificationOption notify);
 
   float GetFontSize() const { return m_FontSize; }
   CPDF_Font* GetFont() const { return m_pFont.Get(); }
@@ -182,21 +185,20 @@
 
  private:
   WideString GetValue(bool bDefault) const;
-  bool SetValue(const WideString& value, bool bDefault, bool bNotify);
-
+  bool SetValue(const WideString& value,
+                bool bDefault,
+                NotificationOption notify);
   void SyncFieldFlags();
   int FindListSel(CPDF_String* str);
   WideString GetOptionText(int index, int sub_index) const;
-
   void LoadDA();
-  bool SetCheckValue(const WideString& value, bool bDefault, bool bNotify);
-
+  bool SetCheckValue(const WideString& value,
+                     bool bDefault,
+                     NotificationOption notify);
   bool NotifyBeforeSelectionChange(const WideString& value);
   void NotifyAfterSelectionChange();
-
   bool NotifyBeforeValueChange(const WideString& value);
   void NotifyAfterValueChange();
-
   bool NotifyListOrComboBoxBeforeChange(const WideString& value);
   void NotifyListOrComboBoxAfterChange();
 
diff --git a/core/fpdfdoc/cpdf_interform.cpp b/core/fpdfdoc/cpdf_interform.cpp
index 953c962..97d22a2 100644
--- a/core/fpdfdoc/cpdf_interform.cpp
+++ b/core/fpdfdoc/cpdf_interform.cpp
@@ -815,7 +815,7 @@
 
 void CPDF_InterForm::ResetForm(const std::vector<CPDF_FormField*>& fields,
                                bool bIncludeOrExclude,
-                               bool bNotify) {
+                               NotificationOption notify) {
   size_t nCount = m_pFieldTree->m_Root.CountFields();
   for (size_t i = 0; i < nCount; ++i) {
     CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(i);
@@ -823,22 +823,22 @@
       continue;
 
     if (bIncludeOrExclude == pdfium::ContainsValue(fields, pField))
-      pField->ResetField(bNotify);
+      pField->ResetField(notify);
   }
-  if (bNotify && m_pFormNotify)
+  if (notify == NotificationOption::kNotify && m_pFormNotify)
     m_pFormNotify->AfterFormReset(this);
 }
 
-void CPDF_InterForm::ResetForm(bool bNotify) {
+void CPDF_InterForm::ResetForm(NotificationOption notify) {
   size_t nCount = m_pFieldTree->m_Root.CountFields();
   for (size_t i = 0; i < nCount; ++i) {
     CPDF_FormField* pField = m_pFieldTree->m_Root.GetFieldAtIndex(i);
     if (!pField)
       continue;
 
-    pField->ResetField(bNotify);
+    pField->ResetField(notify);
   }
-  if (bNotify && m_pFormNotify)
+  if (notify == NotificationOption::kNotify && m_pFormNotify)
     m_pFormNotify->AfterFormReset(this);
 }
 
diff --git a/core/fpdfdoc/cpdf_interform.h b/core/fpdfdoc/cpdf_interform.h
index 12c840f..c5da15d 100644
--- a/core/fpdfdoc/cpdf_interform.h
+++ b/core/fpdfdoc/cpdf_interform.h
@@ -13,6 +13,7 @@
 
 #include "core/fpdfapi/parser/fpdf_parser_decode.h"
 #include "core/fpdfdoc/cpdf_defaultappearance.h"
+#include "core/fpdfdoc/cpdf_formfield.h"
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/fx_system.h"
 #include "core/fxcrt/unowned_ptr.h"
@@ -23,7 +24,6 @@
 class CPDF_Dictionary;
 class CPDF_Font;
 class CPDF_FormControl;
-class CPDF_FormField;
 class CPDF_Object;
 class CPDF_Page;
 class IPDF_FormNotify;
@@ -80,10 +80,12 @@
       bool bIncludeOrExclude,
       bool bSimpleFileSpec) const;
 
+  void ResetForm(NotificationOption notify);
+
+  // TODO(tsepez): Use a span.
   void ResetForm(const std::vector<CPDF_FormField*>& fields,
                  bool bIncludeOrExclude,
-                 bool bNotify);
-  void ResetForm(bool bNotify);
+                 NotificationOption notify);
 
   void SetFormNotify(IPDF_FormNotify* pNotify);
   bool HasXFAForm() const;
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index b9256aa..0e44268 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -327,7 +327,7 @@
 
     Optional<IJS_Runtime::JS_Error> err = pContext->RunScript(csJS);
     if (!err && bRC && sValue.Compare(sOldValue) != 0)
-      pField->SetValue(sValue, true);
+      pField->SetValue(sValue, NotificationOption::kNotify);
   }
 }
 
@@ -557,19 +557,17 @@
 
 void CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) {
   ASSERT(action.GetDict());
-
   const CPDF_Dictionary* pActionDict = action.GetDict();
   if (!pActionDict->KeyExist("Fields")) {
-    m_pInterForm->ResetForm(true);
+    m_pInterForm->ResetForm(NotificationOption::kNotify);
     return;
   }
-
   CPDF_ActionFields af(&action);
   uint32_t dwFlags = action.GetFlags();
-
   std::vector<const CPDF_Object*> fieldObjects = af.GetAllFields();
   std::vector<CPDF_FormField*> fields = GetFieldFromObjects(fieldObjects);
-  m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), true);
+  m_pInterForm->ResetForm(fields, !(dwFlags & 0x01),
+                          NotificationOption::kNotify);
 }
 
 std::vector<CPDF_FormField*> CPDFSDK_InterForm::GetFieldFromObjects(
diff --git a/fpdfsdk/cpdfsdk_widget.cpp b/fpdfsdk/cpdfsdk_widget.cpp
index f9fdef8..8bd1f10 100644
--- a/fpdfsdk/cpdfsdk_widget.cpp
+++ b/fpdfsdk/cpdfsdk_widget.cpp
@@ -526,44 +526,45 @@
   return pFormField->GetMaxLen();
 }
 
-void CPDFSDK_Widget::SetCheck(bool bChecked, bool bNotify) {
+void CPDFSDK_Widget::SetCheck(bool bChecked, NotificationOption notify) {
   CPDF_FormControl* pFormCtrl = GetFormControl();
   CPDF_FormField* pFormField = pFormCtrl->GetField();
   pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecked,
-                           bNotify);
+                           notify);
 #ifdef PDF_ENABLE_XFA
   if (!IsWidgetAppearanceValid(CPDF_Annot::Normal))
     ResetAppearance(true);
-  if (!bNotify)
+  if (notify == NotificationOption::kDoNotNotify)
     Synchronize(true);
 #endif  // PDF_ENABLE_XFA
 }
 
-void CPDFSDK_Widget::SetValue(const WideString& sValue, bool bNotify) {
+void CPDFSDK_Widget::SetValue(const WideString& sValue,
+                              NotificationOption notify) {
   CPDF_FormField* pFormField = GetFormField();
-  pFormField->SetValue(sValue, bNotify);
+  pFormField->SetValue(sValue, notify);
 #ifdef PDF_ENABLE_XFA
-  if (!bNotify)
+  if (notify == NotificationOption::kDoNotNotify)
     Synchronize(true);
 #endif  // PDF_ENABLE_XFA
 }
 
 void CPDFSDK_Widget::SetOptionSelection(int index,
                                         bool bSelected,
-                                        bool bNotify) {
+                                        NotificationOption notify) {
   CPDF_FormField* pFormField = GetFormField();
-  pFormField->SetItemSelection(index, bSelected, bNotify);
+  pFormField->SetItemSelection(index, bSelected, notify);
 #ifdef PDF_ENABLE_XFA
-  if (!bNotify)
+  if (notify == NotificationOption::kDoNotNotify)
     Synchronize(true);
 #endif  // PDF_ENABLE_XFA
 }
 
-void CPDFSDK_Widget::ClearSelection(bool bNotify) {
+void CPDFSDK_Widget::ClearSelection(NotificationOption notify) {
   CPDF_FormField* pFormField = GetFormField();
-  pFormField->ClearSelection(bNotify);
+  pFormField->ClearSelection(notify);
 #ifdef PDF_ENABLE_XFA
-  if (!bNotify)
+  if (notify == NotificationOption::kDoNotNotify)
     Synchronize(true);
 #endif  // PDF_ENABLE_XFA
 }
diff --git a/fpdfsdk/cpdfsdk_widget.h b/fpdfsdk/cpdfsdk_widget.h
index 1349981..f3bdc54 100644
--- a/fpdfsdk/cpdfsdk_widget.h
+++ b/fpdfsdk/cpdfsdk_widget.h
@@ -81,10 +81,10 @@
   int GetMaxLen() const;
   WideString GetAlternateName() const;
 
-  void SetCheck(bool bChecked, bool bNotify);
-  void SetValue(const WideString& sValue, bool bNotify);
-  void SetOptionSelection(int index, bool bSelected, bool bNotify);
-  void ClearSelection(bool bNotify);
+  void SetCheck(bool bChecked, NotificationOption notify);
+  void SetValue(const WideString& sValue, NotificationOption notify);
+  void SetOptionSelection(int index, bool bSelected, NotificationOption notify);
+  void ClearSelection(NotificationOption notify);
   void SetTopVisibleIndex(int index);
 
 #ifdef PDF_ENABLE_XFA
diff --git a/fpdfsdk/formfiller/cffl_checkbox.cpp b/fpdfsdk/formfiller/cffl_checkbox.cpp
index 57119c5..4308c1a 100644
--- a/fpdfsdk/formfiller/cffl_checkbox.cpp
+++ b/fpdfsdk/formfiller/cffl_checkbox.cpp
@@ -113,13 +113,14 @@
   }
   CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get());
   CFFL_CheckBox::ObservedPtr observed_this(this);
-
-  m_pWidget->SetCheck(bNewChecked, false);
+  m_pWidget->SetCheck(bNewChecked, NotificationOption::kDoNotNotify);
   if (!observed_widget)
     return;
+
   m_pWidget->UpdateField();
   if (!observed_widget || !observed_this)
     return;
+
   SetChangeMark();
 }
 
diff --git a/fpdfsdk/formfiller/cffl_combobox.cpp b/fpdfsdk/formfiller/cffl_combobox.cpp
index 8aa656b..e0f0f3f 100644
--- a/fpdfsdk/formfiller/cffl_combobox.cpp
+++ b/fpdfsdk/formfiller/cffl_combobox.cpp
@@ -96,27 +96,27 @@
 
   WideString swText = pWnd->GetText();
   int32_t nCurSel = pWnd->GetSelect();
-
   bool bSetValue = false;
-
   if (m_pWidget->GetFieldFlags() & FIELDFLAG_EDIT)
     bSetValue = (nCurSel < 0) || (swText != m_pWidget->GetOptionLabel(nCurSel));
 
   if (bSetValue) {
-    m_pWidget->SetValue(swText, false);
+    m_pWidget->SetValue(swText, NotificationOption::kDoNotNotify);
   } else {
     m_pWidget->GetSelectedIndex(0);
-    m_pWidget->SetOptionSelection(nCurSel, true, false);
+    m_pWidget->SetOptionSelection(nCurSel, true,
+                                  NotificationOption::kDoNotNotify);
   }
   CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get());
   CFFL_ComboBox::ObservedPtr observed_this(this);
-
   m_pWidget->ResetFieldAppearance(true);
   if (!observed_widget)
     return;
+
   m_pWidget->UpdateField();
   if (!observed_widget || !observed_this)
     return;
+
   SetChangeMark();
   m_pWidget->GetPDFPage();
 }
diff --git a/fpdfsdk/formfiller/cffl_listbox.cpp b/fpdfsdk/formfiller/cffl_listbox.cpp
index bf24e11..c05400d 100644
--- a/fpdfsdk/formfiller/cffl_listbox.cpp
+++ b/fpdfsdk/formfiller/cffl_listbox.cpp
@@ -108,27 +108,32 @@
     return;
 
   int32_t nNewTopIndex = pListBox->GetTopVisibleIndex();
-  m_pWidget->ClearSelection(false);
+  m_pWidget->ClearSelection(NotificationOption::kDoNotNotify);
   if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) {
     for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; i++) {
-      if (pListBox->IsItemSelected(i))
-        m_pWidget->SetOptionSelection(i, true, false);
+      if (pListBox->IsItemSelected(i)) {
+        m_pWidget->SetOptionSelection(i, true,
+                                      NotificationOption::kDoNotNotify);
+      }
     }
   } else {
-    m_pWidget->SetOptionSelection(pListBox->GetCurSel(), true, false);
+    m_pWidget->SetOptionSelection(pListBox->GetCurSel(), true,
+                                  NotificationOption::kDoNotNotify);
   }
   CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get());
   CFFL_ListBox::ObservedPtr observed_this(this);
-
   m_pWidget->SetTopVisibleIndex(nNewTopIndex);
   if (!observed_widget)
     return;
+
   m_pWidget->ResetFieldAppearance(true);
   if (!observed_widget)
     return;
+
   m_pWidget->UpdateField();
   if (!observed_widget || !observed_this)
     return;
+
   SetChangeMark();
 }
 
diff --git a/fpdfsdk/formfiller/cffl_radiobutton.cpp b/fpdfsdk/formfiller/cffl_radiobutton.cpp
index 73ac44d..8105b0c 100644
--- a/fpdfsdk/formfiller/cffl_radiobutton.cpp
+++ b/fpdfsdk/formfiller/cffl_radiobutton.cpp
@@ -91,26 +91,25 @@
     return;
 
   bool bNewChecked = pWnd->IsChecked();
-
   if (bNewChecked) {
     CPDF_FormField* pField = m_pWidget->GetFormField();
     for (int32_t i = 0, sz = pField->CountControls(); i < sz; i++) {
       if (CPDF_FormControl* pCtrl = pField->GetControl(i)) {
-        if (pCtrl->IsChecked()) {
+        if (pCtrl->IsChecked())
           break;
-        }
       }
     }
   }
   CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get());
   CFFL_RadioButton::ObservedPtr observed_this(this);
-
-  m_pWidget->SetCheck(bNewChecked, false);
+  m_pWidget->SetCheck(bNewChecked, NotificationOption::kDoNotNotify);
   if (!observed_widget)
     return;
+
   m_pWidget->UpdateField();
   if (!observed_widget || !observed_this)
     return;
+
   SetChangeMark();
 }
 
diff --git a/fpdfsdk/formfiller/cffl_textfield.cpp b/fpdfsdk/formfiller/cffl_textfield.cpp
index da011e4..7293d42 100644
--- a/fpdfsdk/formfiller/cffl_textfield.cpp
+++ b/fpdfsdk/formfiller/cffl_textfield.cpp
@@ -138,19 +138,20 @@
 
   WideString sOldValue = m_pWidget->GetValue();
   WideString sNewValue = pWnd->GetText();
-
   CPDFSDK_Widget::ObservedPtr observed_widget(m_pWidget.Get());
   CFFL_TextField::ObservedPtr observed_this(this);
-
-  m_pWidget->SetValue(sNewValue, false);
+  m_pWidget->SetValue(sNewValue, NotificationOption::kDoNotNotify);
   if (!observed_widget)
     return;
+
   m_pWidget->ResetFieldAppearance(true);
   if (!observed_widget)
     return;
+
   m_pWidget->UpdateField();
   if (!observed_widget || !observed_this)
     return;
+
   SetChangeMark();
 }
 
diff --git a/fxjs/cjs_document.cpp b/fxjs/cjs_document.cpp
index 7e89e40..a6d68c8 100644
--- a/fxjs/cjs_document.cpp
+++ b/fxjs/cjs_document.cpp
@@ -465,7 +465,7 @@
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
   CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
   if (params.empty()) {
-    pPDFForm->ResetForm(true);
+    pPDFForm->ResetForm(NotificationOption::kNotify);
     m_pFormFillEnv->SetChangeMark();
     return CJS_Return();
   }
@@ -487,7 +487,7 @@
   }
 
   if (!aFields.empty()) {
-    pPDFForm->ResetForm(aFields, true, true);
+    pPDFForm->ResetForm(aFields, true, NotificationOption::kNotify);
     m_pFormFillEnv->SetChangeMark();
   }
 
diff --git a/fxjs/cjs_field.cpp b/fxjs/cjs_field.cpp
index 45715e2..a14e168 100644
--- a/fxjs/cjs_field.cpp
+++ b/fxjs/cjs_field.cpp
@@ -254,13 +254,14 @@
       continue;
 
     uint32_t dwFieldFlags = pFormField->GetFieldFlags();
-    pFormField->ClearSelection(true);
+    pFormField->ClearSelection(NotificationOption::kNotify);
     for (size_t i = 0; i < array.size(); ++i) {
       if (i != 0 && !(dwFieldFlags & (1 << 21)))
         break;
       if (array[i] < static_cast<uint32_t>(pFormField->CountOptions()) &&
           !pFormField->IsItemSelected(array[i])) {
-        pFormField->SetItemSelection(array[i], true);
+        pFormField->SetItemSelection(array[i], true,
+                                     NotificationOption::kDoNotNotify);
       }
     }
     UpdateFormField(pFormFillEnv, pFormField, true, true, true);
@@ -427,14 +428,14 @@
       case FormFieldType::kTextField:
       case FormFieldType::kComboBox:
         if (pFormField->GetValue() != strArray[0]) {
-          pFormField->SetValue(strArray[0], true);
+          pFormField->SetValue(strArray[0], NotificationOption::kNotify);
           UpdateFormField(pFormFillEnv, pFormField, true, false, true);
         }
         break;
       case FormFieldType::kCheckBox:
       case FormFieldType::kRadioButton:
         if (pFormField->GetValue() != strArray[0]) {
-          pFormField->SetValue(strArray[0], true);
+          pFormField->SetValue(strArray[0], NotificationOption::kNotify);
           UpdateFormField(pFormFillEnv, pFormField, true, false, true);
         }
         break;
@@ -447,11 +448,12 @@
           }
         }
         if (bModified) {
-          pFormField->ClearSelection(true);
+          pFormField->ClearSelection(NotificationOption::kNotify);
           for (const auto& str : strArray) {
             int index = pFormField->FindOption(str);
             if (!pFormField->IsItemSelected(index))
-              pFormField->SetItemSelection(index, true, true);
+              pFormField->SetItemSelection(index, true,
+                                           NotificationOption::kNotify);
           }
           UpdateFormField(pFormFillEnv, pFormField, true, false, true);
         }
@@ -2212,7 +2214,7 @@
       (pFormField->GetFieldType() == FormFieldType::kTextField)) {
     WideString wsFileName = m_pFormFillEnv->JS_fieldBrowse();
     if (!wsFileName.IsEmpty()) {
-      pFormField->SetValue(wsFileName);
+      pFormField->SetValue(wsFileName, NotificationOption::kDoNotNotify);
       UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true);
     }
     return CJS_Return();
@@ -2323,13 +2325,13 @@
 
   if (!IsCheckBoxOrRadioButton(pFormField))
     return CJS_Return(JSMessage::kObjectTypeError);
+
   if (nWidget < 0 || nWidget >= pFormField->CountControls())
     return CJS_Return(JSMessage::kValueError);
 
   // TODO(weili): Check whether anything special needed for radio button.
   // (When pFormField->GetFieldType() == FormFieldType::kRadioButton.)
-  pFormField->CheckControl(nWidget, bCheckit, true);
-
+  pFormField->CheckControl(nWidget, bCheckit, NotificationOption::kNotify);
   UpdateFormField(m_pFormFillEnv.Get(), pFormField, true, true, true);
   return CJS_Return();
 }