Remove most non-const reference parameters in CJX_Object.

Also remove a parameter that is always set to true.

Change-Id: Ib10313aec8ff41952c9b97d1da2d80297759100b
Reviewed-on: https://pdfium-review.googlesource.com/c/47210
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index 4f28096..33e0641 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -317,7 +317,7 @@
 
   void* pKey = GetMapKey_Custom(wsAttr);
   WideStringView wsValueC;
-  if (!GetMapModuleString(pKey, wsValueC))
+  if (!GetMapModuleString(pKey, &wsValueC))
     return {};
 
   return {WideString(wsValueC)};
@@ -332,7 +332,7 @@
 Optional<bool> CJX_Object::TryBoolean(XFA_Attribute eAttr, bool bUseDefault) {
   void* pValue = nullptr;
   void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
-  if (GetMapModuleValue(pKey, pValue))
+  if (GetMapModuleValue(pKey, &pValue))
     return {!!pValue};
   if (!bUseDefault)
     return {};
@@ -369,7 +369,7 @@
                                          bool bUseDefault) {
   void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
   void* pValue = nullptr;
-  if (GetMapModuleValue(pKey, pValue))
+  if (GetMapModuleValue(pKey, &pValue))
     return {static_cast<int32_t>(reinterpret_cast<uintptr_t>(pValue))};
   if (!bUseDefault)
     return {};
@@ -381,7 +381,7 @@
                                                  bool bUseDefault) const {
   void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
   void* pValue = nullptr;
-  if (GetMapModuleValue(pKey, pValue)) {
+  if (GetMapModuleValue(pKey, &pValue)) {
     return {
         static_cast<XFA_AttributeValue>(reinterpret_cast<uintptr_t>(pValue))};
   }
@@ -420,7 +420,7 @@
   void* pKey = GetMapKey_Element(GetXFAObject()->GetElementType(), eAttr);
   void* pValue;
   int32_t iBytes;
-  if (GetMapModuleBuffer(pKey, pValue, iBytes, true) &&
+  if (GetMapModuleBuffer(pKey, &pValue, &iBytes) &&
       iBytes == sizeof(CXFA_Measurement)) {
     return {*static_cast<CXFA_Measurement*>(pValue)};
   }
@@ -514,8 +514,7 @@
     void* pData;
     int32_t iBytes = 0;
     WideString* pStr = nullptr;
-    if (GetMapModuleBuffer(pKey, pData, iBytes, true) &&
-        iBytes == sizeof(void*)) {
+    if (GetMapModuleBuffer(pKey, &pData, &iBytes) && iBytes == sizeof(void*)) {
       memcpy(&pData, pData, iBytes);
       pStr = reinterpret_cast<WideString*>(pData);
     }
@@ -523,7 +522,7 @@
       return {*pStr};
   } else {
     WideStringView wsValueC;
-    if (GetMapModuleString(pKey, wsValueC))
+    if (GetMapModuleString(pKey, &wsValueC))
       return {WideString(wsValueC)};
   }
   if (!bUseDefault)
@@ -906,14 +905,14 @@
   CreateMapModuleData()->m_ValueMap[pKey] = pValue;
 }
 
-bool CJX_Object::GetMapModuleValue(void* pKey, void*& pValue) const {
+bool CJX_Object::GetMapModuleValue(void* pKey, void** pValue) const {
   for (const CXFA_Node* pNode = ToNode(GetXFAObject()); pNode;
        pNode = pNode->GetTemplateNodeIfExists()) {
     XFA_MAPMODULEDATA* pModule = pNode->JSObject()->GetMapModuleData();
     if (pModule) {
       auto it = pModule->m_ValueMap.find(pKey);
       if (it != pModule->m_ValueMap.end()) {
-        pValue = it->second;
+        *pValue = it->second;
         return true;
       }
     }
@@ -923,15 +922,16 @@
   return false;
 }
 
-bool CJX_Object::GetMapModuleString(void* pKey, WideStringView& wsValue) {
-  void* pValue;
+bool CJX_Object::GetMapModuleString(void* pKey, WideStringView* pValue) {
+  void* pRawValue;
   int32_t iBytes;
-  if (!GetMapModuleBuffer(pKey, pValue, iBytes, true))
+  if (!GetMapModuleBuffer(pKey, &pRawValue, &iBytes))
     return false;
 
   // Defensive measure: no out-of-bounds pointers even if zero length.
   int32_t iChars = iBytes / sizeof(wchar_t);
-  wsValue = WideStringView(iChars ? (const wchar_t*)pValue : nullptr, iChars);
+  *pValue = WideStringView(
+      iChars ? static_cast<const wchar_t*>(pRawValue) : nullptr, iChars);
   return true;
 }
 
@@ -963,9 +963,8 @@
 }
 
 bool CJX_Object::GetMapModuleBuffer(void* pKey,
-                                    void*& pValue,
-                                    int32_t& iBytes,
-                                    bool bProtoAlso) const {
+                                    void** pValue,
+                                    int32_t* pBytes) const {
   XFA_MAPDATABLOCK* pBuffer = nullptr;
   for (const CXFA_Node* pNode = ToNode(GetXFAObject()); pNode;
        pNode = pNode->GetTemplateNodeIfExists()) {
@@ -977,14 +976,14 @@
         break;
       }
     }
-    if (!bProtoAlso || pNode->GetPacketType() == XFA_PacketType::Datasets)
+    if (pNode->GetPacketType() == XFA_PacketType::Datasets)
       break;
   }
   if (!pBuffer)
     return false;
 
-  pValue = pBuffer->GetData();
-  iBytes = pBuffer->iBytes;
+  *pValue = pBuffer->GetData();
+  *pBytes = pBuffer->iBytes;
   return true;
 }
 
diff --git a/fxjs/xfa/cjx_object.h b/fxjs/xfa/cjx_object.h
index 5e3025f..cdcfa1d 100644
--- a/fxjs/xfa/cjx_object.h
+++ b/fxjs/xfa/cjx_object.h
@@ -243,16 +243,13 @@
   XFA_MAPMODULEDATA* CreateMapModuleData();
   XFA_MAPMODULEDATA* GetMapModuleData() const;
   void SetMapModuleValue(void* pKey, void* pValue);
-  bool GetMapModuleValue(void* pKey, void*& pValue) const;
-  bool GetMapModuleString(void* pKey, WideStringView& wsValue);
+  bool GetMapModuleValue(void* pKey, void** pValue) const;
+  bool GetMapModuleString(void* pKey, WideStringView* pValue);
   void SetMapModuleBuffer(void* pKey,
                           void* pValue,
                           int32_t iBytes,
                           const XFA_MAPDATABLOCKCALLBACKINFO* pCallbackInfo);
-  bool GetMapModuleBuffer(void* pKey,
-                          void*& pValue,
-                          int32_t& iBytes,
-                          bool bProtoAlso) const;
+  bool GetMapModuleBuffer(void* pKey, void** pValue, int32_t* pBytes) const;
   bool HasMapModuleKey(void* pKey);
   void ClearMapModuleBuffer();
   void RemoveMapModuleKey(void* pKey);