Remove CJS_Object::GetIsolate()

It has one caller, which can retrieve the isolate using a CJS_Runtime
reference.

Change-Id: I7a4b52feecbcd7533beb015a9846680552de2f09
Fixed: pdfium:1739
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/86572
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index 849c00f..e55252b 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -334,7 +334,11 @@
   }
 }
 
-void CJS_Global::CommitGlobalPersisitentVariables(CJS_Runtime* pRuntime) {
+void CJS_Global::CommitGlobalPersisitentVariables() {
+  CJS_Runtime* pRuntime = GetRuntime();
+  if (!pRuntime)
+    return;
+
   for (const auto& iter : m_MapGlobal) {
     ByteString name = iter.first;
     JSGlobalData* pData = iter.second.get();
@@ -357,7 +361,7 @@
         break;
       case CFX_Value::DataType::kObject: {
         v8::Local<v8::Object> obj =
-            v8::Local<v8::Object>::New(GetIsolate(), pData->pData);
+            v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData);
         m_pGlobalData->SetGlobalVariableObject(name,
                                                ObjectToArray(pRuntime, obj));
         m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
diff --git a/fxjs/cjs_global.h b/fxjs/cjs_global.h
index 6e7f5a7..5bb9e0f 100644
--- a/fxjs/cjs_global.h
+++ b/fxjs/cjs_global.h
@@ -76,7 +76,8 @@
   static const JSMethodSpec MethodSpecs[];
 
   void UpdateGlobalPersistentVariables();
-  void CommitGlobalPersisitentVariables(CJS_Runtime* pRuntime);
+  // TODO(crbug.com/pdfium/926): This method is never called.
+  void CommitGlobalPersisitentVariables();
   void DestroyGlobalPersisitentVariables();
   CJS_Result SetGlobalVariables(const ByteString& propname,
                                 CFX_Value::DataType nType,
diff --git a/fxjs/cjs_object.cpp b/fxjs/cjs_object.cpp
index 817b4fa..a96ccad 100644
--- a/fxjs/cjs_object.cpp
+++ b/fxjs/cjs_object.cpp
@@ -39,8 +39,6 @@
 }
 
 CJS_Object::CJS_Object(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime)
-    : m_pIsolate(pObject->GetIsolate()),
-      m_pV8Object(GetIsolate(), pObject),
-      m_pRuntime(pRuntime) {}
+    : m_pV8Object(pObject->GetIsolate(), pObject), m_pRuntime(pRuntime) {}
 
 CJS_Object::~CJS_Object() = default;
diff --git a/fxjs/cjs_object.h b/fxjs/cjs_object.h
index e451f25..b44a186 100644
--- a/fxjs/cjs_object.h
+++ b/fxjs/cjs_object.h
@@ -48,12 +48,12 @@
   CJS_Object(v8::Local<v8::Object> pObject, CJS_Runtime* pRuntime);
   virtual ~CJS_Object();
 
-  v8::Local<v8::Object> ToV8Object() { return m_pV8Object.Get(GetIsolate()); }
-  v8::Isolate* GetIsolate() const { return m_pIsolate.Get(); }
+  v8::Local<v8::Object> ToV8Object() {
+    return m_pV8Object.Get(GetRuntime()->GetIsolate());
+  }
   CJS_Runtime* GetRuntime() const { return m_pRuntime.Get(); }
 
  private:
-  UnownedPtr<v8::Isolate> m_pIsolate;
   v8::Global<v8::Object> m_pV8Object;
   ObservedPtr<CJS_Runtime> m_pRuntime;
 };