Make global object function names clearer.

Also tidy some sub-expressions.

Change-Id: Ieabd5f6cea60e8ec03c8ce5ebe372fc80b05a7bb
Reviewed-on: https://pdfium-review.googlesource.com/25150
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index d47c145..0833759 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -984,34 +984,44 @@
   return true;
 }
 
-bool CPDFXFA_DocEnvironment::SetGlobalProperty(CXFA_FFDoc* hDoc,
-                                               const ByteStringView& szPropName,
-                                               CFXJSE_Value* pValue) {
+bool CPDFXFA_DocEnvironment::SetPropertyInNonXFAGlobalObject(
+    CXFA_FFDoc* hDoc,
+    const ByteStringView& szPropName,
+    CFXJSE_Value* pValue) {
   if (hDoc != m_pContext->GetXFADoc())
     return false;
-  if (!m_pContext->GetFormFillEnv() ||
-      !m_pContext->GetFormFillEnv()->GetIJSRuntime()) {
-    return false;
-  }
+
   CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
-  IJS_EventContext* pContext = pFormFillEnv->GetIJSRuntime()->NewEventContext();
-  bool bRet = pFormFillEnv->GetIJSRuntime()->SetValueByName(szPropName, pValue);
-  pFormFillEnv->GetIJSRuntime()->ReleaseEventContext(pContext);
+  if (!pFormFillEnv)
+    return false;
+
+  IJS_Runtime* pIJSRuntime = pFormFillEnv->GetIJSRuntime();
+  if (!pIJSRuntime)
+    return false;
+
+  IJS_EventContext* pContext = pIJSRuntime->NewEventContext();
+  bool bRet = pIJSRuntime->SetValueByNameInGlobalObject(szPropName, pValue);
+  pIJSRuntime->ReleaseEventContext(pContext);
   return bRet;
 }
 
-bool CPDFXFA_DocEnvironment::GetGlobalProperty(CXFA_FFDoc* hDoc,
-                                               const ByteStringView& szPropName,
-                                               CFXJSE_Value* pValue) {
+bool CPDFXFA_DocEnvironment::GetPropertyFromNonXFAGlobalObject(
+    CXFA_FFDoc* hDoc,
+    const ByteStringView& szPropName,
+    CFXJSE_Value* pValue) {
   if (hDoc != m_pContext->GetXFADoc())
     return false;
-  if (!m_pContext->GetFormFillEnv() ||
-      !m_pContext->GetFormFillEnv()->GetIJSRuntime()) {
-    return false;
-  }
+
   CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
-  IJS_EventContext* pContext = pFormFillEnv->GetIJSRuntime()->NewEventContext();
-  bool bRet = pFormFillEnv->GetIJSRuntime()->GetValueByName(szPropName, pValue);
-  pFormFillEnv->GetIJSRuntime()->ReleaseEventContext(pContext);
+  if (!pFormFillEnv)
+    return false;
+
+  IJS_Runtime* pIJSRuntime = pFormFillEnv->GetIJSRuntime();
+  if (!pIJSRuntime)
+    return false;
+
+  IJS_EventContext* pContext = pIJSRuntime->NewEventContext();
+  bool bRet = pIJSRuntime->GetValueByNameFromGlobalObject(szPropName, pValue);
+  pIJSRuntime->ReleaseEventContext(pContext);
   return bRet;
 }
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
index 4e03721..03aae3d 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
@@ -64,12 +64,12 @@
 
   bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) override;
 
-  bool GetGlobalProperty(CXFA_FFDoc* hDoc,
-                         const ByteStringView& szPropName,
-                         CFXJSE_Value* pValue) override;
-  bool SetGlobalProperty(CXFA_FFDoc* hDoc,
-                         const ByteStringView& szPropName,
-                         CFXJSE_Value* pValue) override;
+  bool GetPropertyFromNonXFAGlobalObject(CXFA_FFDoc* hDoc,
+                                         const ByteStringView& szPropName,
+                                         CFXJSE_Value* pValue) override;
+  bool SetPropertyInNonXFAGlobalObject(CXFA_FFDoc* hDoc,
+                                       const ByteStringView& szPropName,
+                                       CFXJSE_Value* pValue) override;
 
   RetainPtr<IFX_SeekableReadStream> OpenLinkedFile(
       CXFA_FFDoc* hDoc,
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index 198e1d5..84981666 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -202,8 +202,8 @@
   if (!pNotify)
     return;
 
-  pNotify->GetDocEnvironment()->SetGlobalProperty(pNotify->GetHDOC(),
-                                                  szPropName, pValue);
+  pNotify->GetDocEnvironment()->SetPropertyInNonXFAGlobalObject(
+      pNotify->GetHDOC(), szPropName, pValue);
 }
 
 void CFXJSE_Engine::GlobalPropertyGetter(CFXJSE_Value* pObject,
@@ -259,8 +259,8 @@
   if (!pNotify)
     return;
 
-  pNotify->GetDocEnvironment()->GetGlobalProperty(pNotify->GetHDOC(),
-                                                  szPropName, pValue);
+  pNotify->GetDocEnvironment()->GetPropertyFromNonXFAGlobalObject(
+      pNotify->GetHDOC(), szPropName, pValue);
 }
 
 int32_t CFXJSE_Engine::GlobalPropTypeGetter(CFXJSE_Value* pOriginalValue,
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index bffd77c..4031304 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -231,8 +231,8 @@
   return sRet;
 }
 
-bool CJS_Runtime::GetValueByName(const ByteStringView& utf8Name,
-                                 CFXJSE_Value* pValue) {
+bool CJS_Runtime::GetValueByNameFromGlobalObject(const ByteStringView& utf8Name,
+                                                 CFXJSE_Value* pValue) {
   v8::Isolate::Scope isolate_scope(GetIsolate());
   v8::HandleScope handle_scope(GetIsolate());
   v8::Local<v8::Context> context = NewLocalContext();
@@ -248,8 +248,8 @@
   return true;
 }
 
-bool CJS_Runtime::SetValueByName(const ByteStringView& utf8Name,
-                                 CFXJSE_Value* pValue) {
+bool CJS_Runtime::SetValueByNameInGlobalObject(const ByteStringView& utf8Name,
+                                               CFXJSE_Value* pValue) {
   if (utf8Name.IsEmpty() || !pValue)
     return false;
 
diff --git a/fxjs/cjs_runtime.h b/fxjs/cjs_runtime.h
index 5d55b9a..9d0d47f 100644
--- a/fxjs/cjs_runtime.h
+++ b/fxjs/cjs_runtime.h
@@ -53,10 +53,10 @@
   v8::Local<v8::Value> MaybeCoerceToNumber(v8::Local<v8::Value> value);
 
 #ifdef PDF_ENABLE_XFA
-  bool GetValueByName(const ByteStringView& utf8Name,
-                      CFXJSE_Value* pValue) override;
-  bool SetValueByName(const ByteStringView& utf8Name,
-                      CFXJSE_Value* pValue) override;
+  bool GetValueByNameFromGlobalObject(const ByteStringView& utf8Name,
+                                      CFXJSE_Value* pValue) override;
+  bool SetValueByNameInGlobalObject(const ByteStringView& utf8Name,
+                                    CFXJSE_Value* pValue) override;
 #endif  // PDF_ENABLE_XFA
 
  private:
diff --git a/fxjs/cjs_runtimestub.cpp b/fxjs/cjs_runtimestub.cpp
index 964b0ff..105bb6f 100644
--- a/fxjs/cjs_runtimestub.cpp
+++ b/fxjs/cjs_runtimestub.cpp
@@ -30,11 +30,13 @@
   }
 
 #ifdef PDF_ENABLE_XFA
-  bool GetValueByName(const ByteStringView&, CFXJSE_Value*) override {
+  bool GetValueByNameFromGlobalObject(const ByteStringView&,
+                                      CFXJSE_Value*) override {
     return false;
   }
 
-  bool SetValueByName(const ByteStringView&, CFXJSE_Value*) override {
+  bool SetValueByNameInGlobalObject(const ByteStringView&,
+                                    CFXJSE_Value*) override {
     return false;
   }
 #endif  // PDF_ENABLE_XFA
diff --git a/fxjs/ijs_runtime.h b/fxjs/ijs_runtime.h
index 9fe5d2f..b97c65e 100644
--- a/fxjs/ijs_runtime.h
+++ b/fxjs/ijs_runtime.h
@@ -34,10 +34,10 @@
   virtual int ExecuteScript(const WideString& script, WideString* info) = 0;
 
 #ifdef PDF_ENABLE_XFA
-  virtual bool GetValueByName(const ByteStringView& utf8Name,
-                              CFXJSE_Value* pValue) = 0;
-  virtual bool SetValueByName(const ByteStringView& utf8Name,
-                              CFXJSE_Value* pValue) = 0;
+  virtual bool GetValueByNameFromGlobalObject(const ByteStringView& utf8Name,
+                                              CFXJSE_Value* pValue) = 0;
+  virtual bool SetValueByNameInGlobalObject(const ByteStringView& utf8Name,
+                                            CFXJSE_Value* pValue) = 0;
 #endif  // PDF_ENABLE_XFA
 
  protected:
diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h
index b999877..4a1f8b3 100644
--- a/xfa/fxfa/fxfa.h
+++ b/xfa/fxfa/fxfa.h
@@ -251,12 +251,13 @@
   virtual FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) = 0;
 
   virtual bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) = 0;
-  virtual bool GetGlobalProperty(CXFA_FFDoc* hDoc,
-                                 const ByteStringView& szPropName,
-                                 CFXJSE_Value* pValue) = 0;
-  virtual bool SetGlobalProperty(CXFA_FFDoc* hDoc,
-                                 const ByteStringView& szPropName,
-                                 CFXJSE_Value* pValue) = 0;
+  virtual bool GetPropertyFromNonXFAGlobalObject(
+      CXFA_FFDoc* hDoc,
+      const ByteStringView& szPropName,
+      CFXJSE_Value* pValue) = 0;
+  virtual bool SetPropertyInNonXFAGlobalObject(CXFA_FFDoc* hDoc,
+                                               const ByteStringView& szPropName,
+                                               CFXJSE_Value* pValue) = 0;
   virtual RetainPtr<IFX_SeekableReadStream> OpenLinkedFile(
       CXFA_FFDoc* hDoc,
       const WideString& wsLink) = 0;