Remove still more v8::Context slot usage.

Removes CJS_Runtime::RuntimeFromIsolateCurrentContext()
Change-Id: I51abcf32aaafac522e1595edf663507c26781357
Reviewed-on: https://pdfium-review.googlesource.com/34230
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 5834ab9..1e01f96 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -311,9 +311,9 @@
 }
 
 void CJS_Global::UpdateGlobalPersistentVariables() {
-  CJS_Runtime* pRuntime =
-      static_cast<CJS_Runtime*>(CFXJS_Engine::EngineFromIsolateCurrentContext(
-          ToV8Object()->GetIsolate()));
+  CJS_Runtime* pRuntime = GetRuntime();
+  if (!pRuntime)
+    return;
 
   for (int i = 0, sz = m_pGlobalData->GetSize(); i < sz; i++) {
     CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i);
@@ -450,8 +450,9 @@
 
 void CJS_Global::PutObjectProperty(v8::Local<v8::Object> pObj,
                                    CJS_KeyValue* pData) {
-  CJS_Runtime* pRuntime =
-      CJS_Runtime::RuntimeFromIsolateCurrentContext(ToV8Object()->GetIsolate());
+  CJS_Runtime* pRuntime = GetRuntime();
+  if (pRuntime)
+    return;
 
   for (int i = 0, sz = pData->objData.Count(); i < sz; i++) {
     CJS_KeyValue* pObjData = pData->objData.GetAt(i);
diff --git a/fxjs/cjs_publicmethods.cpp b/fxjs/cjs_publicmethods.cpp
index d37706c..678aca5 100644
--- a/fxjs/cjs_publicmethods.cpp
+++ b/fxjs/cjs_publicmethods.cpp
@@ -120,8 +120,11 @@
                           const std::vector<v8::Local<v8::Value>>&)>
 void JSGlobalFunc(const char* func_name_string,
                   const v8::FunctionCallbackInfo<v8::Value>& info) {
-  CJS_Runtime* pRuntime =
-      CJS_Runtime::RuntimeFromIsolateCurrentContext(info.GetIsolate());
+  CJS_Object* pObj = CFXJS_Engine::GetObjectPrivate(info.Holder());
+  if (!pObj)
+    return;
+
+  CJS_Runtime* pRuntime = pObj->GetRuntime();
   if (!pRuntime)
     return;
 
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index 2896c5f..d7ee93f 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -46,13 +46,6 @@
 #include "fxjs/cfxjse_value.h"
 #endif  // PDF_ENABLE_XFA
 
-// static
-CJS_Runtime* CJS_Runtime::RuntimeFromIsolateCurrentContext(
-    v8::Isolate* pIsolate) {
-  return static_cast<CJS_Runtime*>(
-      CFXJS_Engine::EngineFromIsolateCurrentContext(pIsolate));
-}
-
 CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv)
     : m_pFormFillEnv(pFormFillEnv),
       m_bBlocking(false),
diff --git a/fxjs/cjs_runtime.h b/fxjs/cjs_runtime.h
index 0c32562..73b722d 100644
--- a/fxjs/cjs_runtime.h
+++ b/fxjs/cjs_runtime.h
@@ -27,8 +27,6 @@
  public:
   using FieldEvent = std::pair<WideString, JS_EVENT_T>;
 
-  static CJS_Runtime* RuntimeFromIsolateCurrentContext(v8::Isolate* pIsolate);
-
   explicit CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv);
   ~CJS_Runtime() override;
 
diff --git a/fxjs/js_define.cpp b/fxjs/js_define.cpp
index 3e14a3d..124fd91 100644
--- a/fxjs/js_define.cpp
+++ b/fxjs/js_define.cpp
@@ -236,8 +236,10 @@
       v8::Local<v8::Function> funC = v8::Local<v8::Function>::Cast(v);
       const int argc = 1;
       v8::Local<v8::Value> timeStr =
-          CJS_Runtime::RuntimeFromIsolateCurrentContext(pIsolate)->NewString(
-              str.AsStringView());
+          v8::String::NewFromUtf8(pIsolate,
+                                  FX_UTF8Encode(str.AsStringView()).c_str(),
+                                  v8::NewStringType::kNormal)
+              .ToLocalChecked();
       v8::Local<v8::Value> argv[argc] = {timeStr};
       v = funC->Call(context, context->Global(), argc, argv).ToLocalChecked();
       if (v->IsNumber()) {