Disambiguate CJX_Object methods.

Rename some overloaded method names, so they are easier to tell apart.
Fold one method, that is effectively private to CJX_Object, into its
only caller.

Change-Id: Idfc910967622a08fb2068ec5c96055e9ce348143
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/74052
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_nodehelper.cpp b/fxjs/xfa/cfxjse_nodehelper.cpp
index a0f0d68..3063a45 100644
--- a/fxjs/xfa/cfxjse_nodehelper.cpp
+++ b/fxjs/xfa/cfxjse_nodehelper.cpp
@@ -104,8 +104,8 @@
     for (size_t i = 0; i < m_iCreateCount; ++i) {
       CXFA_Node* pNewNode = m_pCreateParent->CreateSamePacketNode(eClassType);
       if (pNewNode) {
-        pNewNode->JSObject()->SetAttribute(XFA_Attribute::Name, wsNameView,
-                                           false);
+        pNewNode->JSObject()->SetAttributeByEnum(XFA_Attribute::Name,
+                                                 wsNameView, false);
         pNewNode->CreateXMLMappingNode();
         m_pCreateParent->InsertChildAndNotify(pNewNode, nullptr);
         if (i == m_iCreateCount - 1) {
diff --git a/fxjs/xfa/cjx_form.cpp b/fxjs/xfa/cjx_form.cpp
index 0963874..4417530 100644
--- a/fxjs/xfa/cjx_form.cpp
+++ b/fxjs/xfa/cjx_form.cpp
@@ -134,8 +134,8 @@
                          bool bSetting,
                          XFA_Attribute eAttribute) {
   if (bSetting) {
-    SetAttribute(XFA_Attribute::Checksum, pValue->ToWideString().AsStringView(),
-                 false);
+    SetAttributeByEnum(XFA_Attribute::Checksum,
+                       pValue->ToWideString().AsStringView(), false);
     return;
   }
 
diff --git a/fxjs/xfa/cjx_model.cpp b/fxjs/xfa/cjx_model.cpp
index ae40531..4fb2dcc 100644
--- a/fxjs/xfa/cjx_model.cpp
+++ b/fxjs/xfa/cjx_model.cpp
@@ -60,8 +60,8 @@
     if (!pNewNode->HasAttribute(XFA_Attribute::Name))
       return CJS_Result::Failure(JSMessage::kParamError);
 
-    pNewNode->JSObject()->SetAttribute(XFA_Attribute::Name, name.AsStringView(),
-                                       true);
+    pNewNode->JSObject()->SetAttributeByEnum(XFA_Attribute::Name,
+                                             name.AsStringView(), true);
     if (pNewNode->GetPacketType() == XFA_PacketType::Datasets)
       pNewNode->CreateXMLMappingNode();
   }
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index ba7145f..63ed675 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -195,7 +195,7 @@
 
   WideString expression = runtime->ToWideString(params[0]);
   return CJS_Result::Success(runtime->NewString(
-      GetAttribute(expression.AsStringView()).ToUTF8().AsStringView()));
+      GetAttributeByString(expression.AsStringView()).ToUTF8().AsStringView()));
 }
 
 CJS_Result CJX_Node::getElement(
@@ -434,7 +434,8 @@
   WideString attribute = runtime->ToWideString(params[1]);
 
   // Pass them to our method, however, in the more usual manner.
-  SetAttribute(attribute.AsStringView(), attributeValue.AsStringView(), true);
+  SetAttributeByString(attribute.AsStringView(), attributeValue.AsStringView(),
+                       true);
   return CJS_Result::Success();
 }
 
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 7abc68c..a4a7f5c 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -229,9 +229,9 @@
   return HasMapModuleKey(pKey);
 }
 
-void CJX_Object::SetAttribute(XFA_Attribute eAttr,
-                              WideStringView wsValue,
-                              bool bNotify) {
+void CJX_Object::SetAttributeByEnum(XFA_Attribute eAttr,
+                                    WideStringView wsValue,
+                                    bool bNotify) {
   switch (GetXFANode()->GetAttributeType(eAttr)) {
     case XFA_AttributeType::Enum: {
       Optional<XFA_AttributeValue> item = XFA_GetAttributeValueByName(wsValue);
@@ -264,23 +264,29 @@
                      wsValue.GetLength() * sizeof(wchar_t), nullptr);
 }
 
-void CJX_Object::SetAttribute(WideStringView wsAttr,
-                              WideStringView wsValue,
-                              bool bNotify) {
+void CJX_Object::SetAttributeByString(WideStringView wsAttr,
+                                      WideStringView wsValue,
+                                      bool bNotify) {
   Optional<XFA_ATTRIBUTEINFO> attr = XFA_GetAttributeByName(wsAttr);
   if (attr.has_value()) {
-    SetAttribute(attr.value().attribute, wsValue, bNotify);
+    SetAttributeByEnum(attr.value().attribute, wsValue, bNotify);
     return;
   }
   void* pKey = GetMapKey_Custom(wsAttr);
   SetMapModuleString(pKey, wsValue);
 }
 
-WideString CJX_Object::GetAttribute(WideStringView attr) {
-  return TryAttribute(attr, true).value_or(WideString());
+WideString CJX_Object::GetAttributeByString(WideStringView attr) {
+  Optional<WideString> result;
+  Optional<XFA_ATTRIBUTEINFO> enum_attr = XFA_GetAttributeByName(attr);
+  if (enum_attr.has_value())
+    result = TryAttribute(enum_attr.value().attribute, true);
+  else
+    result = GetMapModuleString(GetMapKey_Custom(attr));
+  return result.value_or(WideString());
 }
 
-WideString CJX_Object::GetAttribute(XFA_Attribute attr) {
+WideString CJX_Object::GetAttributeByEnum(XFA_Attribute attr) {
   return TryAttribute(attr, true).value_or(WideString());
 }
 
@@ -321,14 +327,6 @@
   return {};
 }
 
-Optional<WideString> CJX_Object::TryAttribute(WideStringView wsAttr,
-                                              bool bUseDefault) {
-  Optional<XFA_ATTRIBUTEINFO> attr = XFA_GetAttributeByName(wsAttr);
-  if (attr.has_value())
-    return TryAttribute(attr.value().attribute, bUseDefault);
-  return GetMapModuleString(GetMapKey_Custom(wsAttr));
-}
-
 void CJX_Object::RemoveAttribute(WideStringView wsAttr) {
   void* pKey = GetMapKey_Custom(wsAttr);
   if (pKey)
@@ -651,8 +649,8 @@
           wsContentType = *ret;
         if (wsContentType.EqualsASCII("text/html")) {
           wsContentType.clear();
-          SetAttribute(XFA_Attribute::ContentType, wsContentType.AsStringView(),
-                       false);
+          SetAttributeByEnum(XFA_Attribute::ContentType,
+                             wsContentType.AsStringView(), false);
         }
       }
 
@@ -727,8 +725,8 @@
 
         CXFA_Node* pChildValue = pValue->GetFirstChild();
         if (pChildValue && XFA_FieldIsMultiListBox(GetXFANode())) {
-          pChildValue->JSObject()->SetAttribute(XFA_Attribute::ContentType,
-                                                L"text/xml", false);
+          pChildValue->JSObject()->SetAttributeByEnum(
+              XFA_Attribute::ContentType, L"text/xml", false);
         }
         if (pChildValue)
           return pChildValue->JSObject()->TryContent(bScriptModify, bProto);
@@ -1086,12 +1084,12 @@
                                        bool bSetting,
                                        XFA_Attribute eAttribute) {
   if (!bSetting) {
-    pValue->SetString(GetAttribute(eAttribute).ToUTF8().AsStringView());
+    pValue->SetString(GetAttributeByEnum(eAttribute).ToUTF8().AsStringView());
     return;
   }
 
   WideString wsValue = pValue->ToWideString();
-  SetAttribute(eAttribute, wsValue.AsStringView(), true);
+  SetAttributeByEnum(eAttribute, wsValue.AsStringView(), true);
   if (eAttribute != XFA_Attribute::Use ||
       GetXFAObject()->GetElementType() != XFA_Element::Desc) {
     return;
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index 35206e4..c54d666 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -138,14 +138,15 @@
                        const std::vector<v8::Local<v8::Value>>& params);
 
   bool HasAttribute(XFA_Attribute eAttr);
-  void SetAttribute(XFA_Attribute eAttr, WideStringView wsValue, bool bNotify);
-  void SetAttribute(WideStringView wsAttr,
-                    WideStringView wsValue,
-                    bool bNotify);
+  void SetAttributeByEnum(XFA_Attribute eAttr,
+                          WideStringView wsValue,
+                          bool bNotify);
+  void SetAttributeByString(WideStringView wsAttr,
+                            WideStringView wsValue,
+                            bool bNotify);
   void RemoveAttribute(WideStringView wsAttr);
-  WideString GetAttribute(WideStringView attr);
-  WideString GetAttribute(XFA_Attribute attr);
-  Optional<WideString> TryAttribute(WideStringView wsAttr, bool bUseDefault);
+  WideString GetAttributeByString(WideStringView attr);
+  WideString GetAttributeByEnum(XFA_Attribute attr);
   Optional<WideString> TryAttribute(XFA_Attribute eAttr, bool bUseDefault);
 
   Optional<WideString> TryContent(bool bScriptModify, bool bProto);
diff --git a/fxjs/xfa/cjx_tree.cpp b/fxjs/xfa/cjx_tree.cpp
index 151b0f9..c36d301 100644
--- a/fxjs/xfa/cjx_tree.cpp
+++ b/fxjs/xfa/cjx_tree.cpp
@@ -109,7 +109,7 @@
   }
 
   uint32_t dwFlag = XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_ALL;
-  WideString wsExpression = GetAttribute(XFA_Attribute::Name) + L"[*]";
+  WideString wsExpression = GetAttributeByEnum(XFA_Attribute::Name) + L"[*]";
   ResolveNodeList(pValue, wsExpression, dwFlag, nullptr);
 }
 
diff --git a/xfa/fxfa/parser/cxfa_document_builder.cpp b/xfa/fxfa/parser/cxfa_document_builder.cpp
index 907c93f..e78b4ca 100644
--- a/xfa/fxfa/parser/cxfa_document_builder.cpp
+++ b/xfa/fxfa/parser/cxfa_document_builder.cpp
@@ -667,8 +667,8 @@
         if (!pXFAChild)
           return nullptr;
         if (ePacketID == XFA_PacketType::Config) {
-          pXFAChild->JSObject()->SetAttribute(XFA_Attribute::Name,
-                                              wsTagName.AsStringView(), false);
+          pXFAChild->JSObject()->SetAttributeByEnum(
+              XFA_Attribute::Name, wsTagName.AsStringView(), false);
         }
 
         bool IsNeedValue = true;
@@ -687,8 +687,8 @@
               attr.value().attribute != XFA_Attribute::Save) {
             continue;
           }
-          pXFAChild->JSObject()->SetAttribute(attr.value().attribute,
-                                              it.second.AsStringView(), false);
+          pXFAChild->JSObject()->SetAttributeByEnum(
+              attr.value().attribute, it.second.AsStringView(), false);
         }
         pXFANode->InsertChildAndNotify(pXFAChild, nullptr);
         if (eType == XFA_Element::Validate || eType == XFA_Element::Locale) {
diff --git a/xfa/fxfa/parser/cxfa_nodelocale.cpp b/xfa/fxfa/parser/cxfa_nodelocale.cpp
index 9ef9945..95cb4eb 100644
--- a/xfa/fxfa/parser/cxfa_nodelocale.cpp
+++ b/xfa/fxfa/parser/cxfa_nodelocale.cpp
@@ -134,7 +134,7 @@
                                           WideStringView wsName) const {
   CXFA_Node* pChild = pParent ? pParent->GetFirstChild() : nullptr;
   while (pChild) {
-    if (pChild->JSObject()->GetAttribute(XFA_Attribute::Name) == wsName)
+    if (pChild->JSObject()->GetAttributeByEnum(XFA_Attribute::Name) == wsName)
       return pChild;
 
     pChild = pChild->GetNextSibling();