Nest XFA_SOM_MESSAGETYPE in CJX_Object

-- Make into a protected member.
-- Convert to an enum class.

Change-Id: I274e343cf5dc516d5ba74c09b8462dace3602b0a
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/84152
Auto-Submit: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp
index c0e813e..bf98ee0 100644
--- a/fxjs/xfa/cjx_field.cpp
+++ b/fxjs/xfa/cjx_field.cpp
@@ -324,7 +324,7 @@
                               v8::Local<v8::Value>* pValue,
                               bool bSetting,
                               XFA_Attribute eAttribute) {
-  ScriptSomMessage(pIsolate, pValue, bSetting, XFA_SOM_FormatMessage);
+  ScriptSomMessage(pIsolate, pValue, bSetting, SOMMessageType::kFormatMessage);
 }
 
 void CJX_Field::formattedValue(v8::Isolate* pIsolate,
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 177e656..7a47c1a 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -1181,7 +1181,7 @@
 void CJX_Object::ScriptSomMessage(v8::Isolate* pIsolate,
                                   v8::Local<v8::Value>* pValue,
                                   bool bSetting,
-                                  XFA_SOM_MESSAGETYPE iMessageType) {
+                                  SOMMessageType iMessageType) {
   bool bNew = false;
   CXFA_Validate* validate = ToNode(object_.Get())->GetValidateIfExists();
   if (!validate) {
@@ -1192,20 +1192,18 @@
   if (bSetting) {
     if (validate) {
       switch (iMessageType) {
-        case XFA_SOM_ValidationMessage:
+        case SOMMessageType::kValidationMessage:
           validate->SetScriptMessageText(
               fxv8::ReentrantToWideStringHelper(pIsolate, *pValue));
           break;
-        case XFA_SOM_FormatMessage:
+        case SOMMessageType::kFormatMessage:
           validate->SetFormatMessageText(
               fxv8::ReentrantToWideStringHelper(pIsolate, *pValue));
           break;
-        case XFA_SOM_MandatoryMessage:
+        case SOMMessageType::kMandatoryMessage:
           validate->SetNullMessageText(
               fxv8::ReentrantToWideStringHelper(pIsolate, *pValue));
           break;
-        default:
-          break;
       }
     }
 
@@ -1227,17 +1225,15 @@
 
   WideString wsMessage;
   switch (iMessageType) {
-    case XFA_SOM_ValidationMessage:
+    case SOMMessageType::kValidationMessage:
       wsMessage = validate->GetScriptMessageText();
       break;
-    case XFA_SOM_FormatMessage:
+    case SOMMessageType::kFormatMessage:
       wsMessage = validate->GetFormatMessageText();
       break;
-    case XFA_SOM_MandatoryMessage:
+    case SOMMessageType::kMandatoryMessage:
       wsMessage = validate->GetNullMessageText();
       break;
-    default:
-      break;
   }
   *pValue = fxv8::NewStringHelper(pIsolate, wsMessage.ToUTF8().AsStringView());
 }
@@ -1246,14 +1242,16 @@
                                             v8::Local<v8::Value>* pValue,
                                             bool bSetting,
                                             XFA_Attribute eAttribute) {
-  ScriptSomMessage(pIsolate, pValue, bSetting, XFA_SOM_ValidationMessage);
+  ScriptSomMessage(pIsolate, pValue, bSetting,
+                   SOMMessageType::kValidationMessage);
 }
 
 void CJX_Object::ScriptSomMandatoryMessage(v8::Isolate* pIsolate,
                                            v8::Local<v8::Value>* pValue,
                                            bool bSetting,
                                            XFA_Attribute eAttribute) {
-  ScriptSomMessage(pIsolate, pValue, bSetting, XFA_SOM_MandatoryMessage);
+  ScriptSomMessage(pIsolate, pValue, bSetting,
+                   SOMMessageType::kMandatoryMessage);
 }
 
 void CJX_Object::ScriptSomDefaultValue(v8::Isolate* pIsolate,
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index b23e87d..aec1d19 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -42,12 +42,6 @@
   CJX_MethodCall pMethodCall;
 };
 
-enum XFA_SOM_MESSAGETYPE {
-  XFA_SOM_ValidationMessage,
-  XFA_SOM_FormatMessage,
-  XFA_SOM_MandatoryMessage
-};
-
 class CJX_Object : public cppgc::GarbageCollected<CJX_Object>,
                    public CFXJSE_HostObject {
  public:
@@ -180,11 +174,6 @@
   JSE_PROP(ScriptSomInstanceIndex);
   JSE_PROP(ScriptSubmitFormatMode);
 
-  void ScriptSomMessage(v8::Isolate* pIsolate,
-                        v8::Local<v8::Value>* pValue,
-                        bool bSetting,
-                        XFA_SOM_MESSAGETYPE iMessageType);
-
   Optional<WideString> TryNamespace() const;
 
   int32_t GetInteger(XFA_Attribute eAttr) const;
@@ -226,8 +215,18 @@
   void ThrowTooManyOccurancesException(const WideString& obj) const;
 
  protected:
+  enum class SOMMessageType {
+    kValidationMessage,
+    kFormatMessage,
+    kMandatoryMessage
+  };
+
   explicit CJX_Object(CXFA_Object* obj);
 
+  void ScriptSomMessage(v8::Isolate* pIsolate,
+                        v8::Local<v8::Value>* pValue,
+                        bool bSetting,
+                        SOMMessageType iMessageType);
   void SetAttributeValueImpl(const WideString& wsValue,
                              const WideString& wsXMLValue,
                              bool bNotify,