Remove most CJS_Value Set methods

This CL removes all of the Set(*) methods from CJS_Value except for
Set(v8::Local<v8::Value>). All uses of Set are changed to convert to
a v8::Value before setting.

Change-Id: I6e4d2cebec42fce5c039dc0a3abe46086cfdd34f
Reviewed-on: https://pdfium-review.googlesource.com/16610
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp
index 19e94f3..c9fbaaf 100644
--- a/fpdfsdk/javascript/Annot.cpp
+++ b/fpdfsdk/javascript/Annot.cpp
@@ -44,7 +44,8 @@
   }
 
   CPDF_Annot* pPDFAnnot = ToBAAnnot(m_pAnnot.Get())->GetPDFAnnot();
-  vp->Set(pRuntime, CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict()));
+  vp->Set(pRuntime->NewBoolean(
+      CPDF_Annot::IsAnnotationHidden(pPDFAnnot->GetAnnotDict())));
   return true;
 }
 
@@ -80,7 +81,8 @@
     return false;
   }
 
-  vp->Set(pRuntime, ToBAAnnot(m_pAnnot.Get())->GetAnnotName());
+  vp->Set(
+      pRuntime->NewString(ToBAAnnot(m_pAnnot.Get())->GetAnnotName().c_str()));
   return true;
 }
 
@@ -103,8 +105,11 @@
     return false;
   }
 
-  vp->Set(pRuntime, CPDF_Annot::AnnotSubtypeToString(
-                        ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype()));
+  vp->Set(pRuntime->NewString(
+      WideString::FromLocal(CPDF_Annot::AnnotSubtypeToString(
+                                ToBAAnnot(m_pAnnot.Get())->GetAnnotSubtype())
+                                .c_str())
+          .c_str()));
   return true;
 }
 
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 1f023fb..a47deea 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -172,7 +172,8 @@
 
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
   CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
-  vp->Set(pRuntime, static_cast<int>(pPDFForm->CountFields(WideString())));
+  vp->Set(pRuntime->NewNumber(
+      static_cast<int>(pPDFForm->CountFields(WideString()))));
   return true;
 }
 
@@ -191,7 +192,7 @@
     return false;
   }
 
-  vp->Set(pRuntime, !!m_pFormFillEnv->GetChangeMark());
+  vp->Set(pRuntime->NewBoolean(!!m_pFormFillEnv->GetChangeMark()));
   return true;
 }
 
@@ -212,7 +213,7 @@
 bool Document::get_ADBE(CJS_Runtime* pRuntime,
                         CJS_Value* vp,
                         WideString* sError) {
-  vp->SetNull(pRuntime);
+  vp->Set(pRuntime->NewNull());
   return true;
 }
 
@@ -231,7 +232,7 @@
   }
 
   if (CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView())
-    vp->Set(pRuntime, pPageView->GetPageIndex());
+    vp->Set(pRuntime->NewNumber(pPageView->GetPageIndex()));
   return true;
 }
 
@@ -311,7 +312,7 @@
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
   CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
   if (pPDFForm->CountFields(wideName) <= 0) {
-    vRet.SetNull(pRuntime);
+    vRet.Set(pRuntime->NewNull());
     return true;
   }
 
@@ -324,7 +325,7 @@
       static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
   Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
   pField->AttachField(this, wideName);
-  vRet = CJS_Value(pRuntime, pJSField);
+  vRet = CJS_Value(pJSField);
   return true;
 }
 
@@ -584,7 +585,7 @@
 
   std::vector<CPDF_FormField*> aFields;
   for (int i = 0, isz = aName.GetLength(pRuntime); i < isz; ++i) {
-    CJS_Value valElement = aName.GetElement(pRuntime, i);
+    CJS_Value valElement(aName.GetElement(pRuntime, i));
     WideString swVal = valElement.ToWideString(pRuntime);
     for (int j = 0, jsz = pPDFForm->CountFields(swVal); j < jsz; ++j)
       aFields.push_back(pPDFForm->GetField(j, swVal));
@@ -631,7 +632,7 @@
   WideString strURL;
   bool bFDF = true;
   bool bEmpty = false;
-  CJS_Value v = params[0];
+  CJS_Value v(params[0]);
   if (v.GetType() == CJS_Value::VT_string) {
     strURL = params[0].ToWideString(pRuntime);
     if (nSize > 1)
@@ -644,16 +645,16 @@
     v8::Local<v8::Object> pObj = params[0].ToV8Object(pRuntime);
     v8::Local<v8::Value> pValue = pRuntime->GetObjectProperty(pObj, L"cURL");
     if (!pValue.IsEmpty())
-      strURL = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+      strURL = CJS_Value(pValue).ToWideString(pRuntime);
 
     pValue = pRuntime->GetObjectProperty(pObj, L"bFDF");
-    bFDF = CJS_Value(pRuntime, pValue).ToBool(pRuntime);
+    bFDF = CJS_Value(pValue).ToBool(pRuntime);
 
     pValue = pRuntime->GetObjectProperty(pObj, L"bEmpty");
-    bEmpty = CJS_Value(pRuntime, pValue).ToBool(pRuntime);
+    bEmpty = CJS_Value(pValue).ToBool(pRuntime);
 
     pValue = pRuntime->GetObjectProperty(pObj, L"aFields");
-    aFields = CJS_Array(CJS_Value(pRuntime, pValue).ToV8Array(pRuntime));
+    aFields = CJS_Array(CJS_Value(pValue).ToV8Array(pRuntime));
   }
 
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
@@ -669,7 +670,7 @@
 
   std::vector<CPDF_FormField*> fieldObjects;
   for (int i = 0, sz = aFields.GetLength(pRuntime); i < sz; ++i) {
-    CJS_Value valName = aFields.GetElement(pRuntime, i);
+    CJS_Value valName(aFields.GetElement(pRuntime, i));
     WideString sName = valName.ToWideString(pRuntime);
     CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
     for (int j = 0, jsz = pPDFForm->CountFields(sName); j < jsz; ++j) {
@@ -734,22 +735,22 @@
     v8::Local<v8::Object> pObj = params[0].ToV8Object(pRuntime);
 
     v8::Local<v8::Value> pValue = pRuntime->GetObjectProperty(pObj, L"bUI");
-    bUI = CJS_Value(pRuntime, pValue).ToBool(pRuntime);
+    bUI = CJS_Value(pValue).ToBool(pRuntime);
 
     pValue = pRuntime->GetObjectProperty(pObj, L"cTo");
-    cTo = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+    cTo = CJS_Value(pValue).ToWideString(pRuntime);
 
     pValue = pRuntime->GetObjectProperty(pObj, L"cCc");
-    cCc = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+    cCc = CJS_Value(pValue).ToWideString(pRuntime);
 
     pValue = pRuntime->GetObjectProperty(pObj, L"cBcc");
-    cBcc = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+    cBcc = CJS_Value(pValue).ToWideString(pRuntime);
 
     pValue = pRuntime->GetObjectProperty(pObj, L"cSubject");
-    cSubject = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+    cSubject = CJS_Value(pValue).ToWideString(pRuntime);
 
     pValue = pRuntime->GetObjectProperty(pObj, L"cMsg");
-    cMsg = CJS_Value(pRuntime, pValue).ToWideString(pRuntime);
+    cMsg = CJS_Value(pValue).ToWideString(pRuntime);
   }
 
   pRuntime->BeginBlock();
@@ -832,7 +833,7 @@
           pObj, wsKey, pRuntime->NewBoolean(!!pValueObj->GetInteger()));
     }
   }
-  vp->Set(pRuntime, pObj);
+  vp->Set(pObj);
   return true;
 }
 
@@ -856,7 +857,8 @@
   if (!pDictionary)
     return false;
 
-  vp->Set(pRuntime, pDictionary->GetUnicodeTextFor(propName));
+  vp->Set(
+      pRuntime->NewString(pDictionary->GetUnicodeTextFor(propName).c_str()));
   return true;
 }
 
@@ -915,7 +917,7 @@
     *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  vp->Set(pRuntime, m_bDelay);
+  vp->Set(pRuntime->NewBoolean(m_bDelay));
   return true;
 }
 
@@ -1021,7 +1023,7 @@
     *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  vp->Set(pRuntime, m_pFormFillEnv->GetPageCount());
+  vp->Set(pRuntime->NewNumber(m_pFormFillEnv->GetPageCount()));
   return true;
 }
 
@@ -1036,7 +1038,7 @@
                             CJS_Value* vp,
                             WideString* sError) {
   // In Chrome case, should always return true.
-  vp->Set(pRuntime, true);
+  vp->Set(pRuntime->NewBoolean(true));
   return true;
 }
 
@@ -1049,7 +1051,7 @@
 bool Document::get_filesize(CJS_Runtime* pRuntime,
                             CJS_Value* vp,
                             WideString* sError) {
-  vp->Set(pRuntime, 0);
+  vp->Set(pRuntime->NewNumber(0));
   return true;
 }
 
@@ -1091,7 +1093,7 @@
     *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  vp->Set(pRuntime, m_pFormFillEnv->JS_docGetFilePath());
+  vp->Set(pRuntime->NewString(m_pFormFillEnv->JS_docGetFilePath().c_str()));
   return true;
 }
 
@@ -1105,7 +1107,7 @@
 bool Document::get_base_URL(CJS_Runtime* pRuntime,
                             CJS_Value* vp,
                             WideString* sError) {
-  vp->Set(pRuntime, m_cwBaseURL);
+  vp->Set(pRuntime->NewString(m_cwBaseURL.c_str()));
   return true;
 }
 
@@ -1125,7 +1127,7 @@
   }
 
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
-  vp->Set(pRuntime, !!pInterForm->IsCalculateEnabled());
+  vp->Set(pRuntime->NewBoolean(!!pInterForm->IsCalculateEnabled()));
   return true;
 }
 
@@ -1158,9 +1160,10 @@
   }
 
   if (i > 0 && i < wsFilePath.GetLength())
-    vp->Set(pRuntime, wsFilePath.GetBuffer(wsFilePath.GetLength()) + i);
+    vp->Set(
+        pRuntime->NewString(wsFilePath.GetBuffer(wsFilePath.GetLength()) + i));
   else
-    vp->Set(pRuntime, L"");
+    vp->Set(pRuntime->NewString(L""));
 
   return true;
 }
@@ -1179,7 +1182,8 @@
     *sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  vp->Set(pRuntime, app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()));
+  vp->Set(pRuntime->NewString(
+      app::SysPathToPDFPath(m_pFormFillEnv->JS_docGetFilePath()).c_str()));
   return true;
 }
 
@@ -1275,7 +1279,7 @@
       static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
   Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
   pAnnot->SetSDKAnnot(pSDKBAAnnot);
-  vRet = CJS_Value(pRuntime, pJS_Annot);
+  vRet = CJS_Value(pJS_Annot);
   return true;
 }
 
@@ -1313,7 +1317,7 @@
           static_cast<CJS_Annot*>(pRuntime->GetObjectPrivate(pObj));
       Annot* pAnnot = static_cast<Annot*>(pJS_Annot->GetEmbedObject());
       pAnnot->SetSDKAnnot(static_cast<CPDFSDK_BAAnnot*>(pSDKAnnotCur.Get()));
-      annots.SetElement(pRuntime, i, CJS_Value(pRuntime, pJS_Annot));
+      annots.SetElement(pRuntime, i, CJS_Value(pJS_Annot));
     }
   }
   vRet = CJS_Value(pRuntime, annots);
@@ -1324,7 +1328,7 @@
                           const std::vector<CJS_Value>& params,
                           CJS_Value& vRet,
                           WideString& sError) {
-  vRet.SetNull(pRuntime);
+  vRet.Set(pRuntime->NewNull());
   return true;
 }
 
@@ -1388,7 +1392,7 @@
                          CJS_Value* vp,
                          WideString* sError) {
   if (m_IconNames.empty()) {
-    vp->SetNull(pRuntime);
+    vp->Set(pRuntime->NewNull());
     return true;
   }
 
@@ -1404,10 +1408,10 @@
         static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
     Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
     pIcon->SetIconName(name);
-    Icons.SetElement(pRuntime, i++, CJS_Value(pRuntime, pJS_Icon));
+    Icons.SetElement(pRuntime, i++, CJS_Value(pJS_Icon));
   }
 
-  vp->Set(pRuntime, Icons);
+  vp->Set(Icons.ToV8Array(pRuntime));
   return true;
 }
 
@@ -1440,7 +1444,7 @@
   CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
   Icon* pIcon = static_cast<Icon*>(pJS_Icon->GetEmbedObject());
   pIcon->SetIconName(*it);
-  vRet = CJS_Value(pRuntime, pJS_Icon);
+  vRet = CJS_Value(pJS_Icon);
   return true;
 }
 
@@ -1622,7 +1626,7 @@
 
   // Not implemented yet.
 
-  vRet = CJS_Value(pRuntime, pRetObj);
+  vRet = CJS_Value(pRetObj);
   return true;
 }
 
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 155e7ce..ce94fd8 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -400,16 +400,16 @@
 
   switch (pFormControl->GetControlAlignment()) {
     case 1:
-      vp->Set(pRuntime, L"center");
+      vp->Set(pRuntime->NewString(L"center"));
       break;
     case 0:
-      vp->Set(pRuntime, L"left");
+      vp->Set(pRuntime->NewString(L"left"));
       break;
     case 2:
-      vp->Set(pRuntime, L"right");
+      vp->Set(pRuntime->NewString(L"right"));
       break;
     default:
-      vp->Set(pRuntime, L"");
+      vp->Set(pRuntime->NewString(L""));
   }
 
   return true;
@@ -442,22 +442,22 @@
 
   switch (pWidget->GetBorderStyle()) {
     case BorderStyle::SOLID:
-      vp->Set(pRuntime, L"solid");
+      vp->Set(pRuntime->NewString(L"solid"));
       break;
     case BorderStyle::DASH:
-      vp->Set(pRuntime, L"dashed");
+      vp->Set(pRuntime->NewString(L"dashed"));
       break;
     case BorderStyle::BEVELED:
-      vp->Set(pRuntime, L"beveled");
+      vp->Set(pRuntime->NewString(L"beveled"));
       break;
     case BorderStyle::INSET:
-      vp->Set(pRuntime, L"inset");
+      vp->Set(pRuntime->NewString(L"inset"));
       break;
     case BorderStyle::UNDERLINE:
-      vp->Set(pRuntime, L"underline");
+      vp->Set(pRuntime->NewString(L"underline"));
       break;
     default:
-      vp->Set(pRuntime, L"");
+      vp->Set(pRuntime->NewString(L""));
       break;
   }
   return true;
@@ -555,7 +555,7 @@
   float fBottom;
   IconFit.GetIconPosition(fLeft, fBottom);
 
-  vp->Set(pRuntime, static_cast<int32_t>(fLeft));
+  vp->Set(pRuntime->NewNumber(static_cast<int32_t>(fLeft)));
   return true;
 }
 
@@ -589,7 +589,7 @@
   float fBottom;
   IconFit.GetIconPosition(fLeft, fBottom);
 
-  vp->Set(pRuntime, static_cast<int32_t>(fBottom));
+  vp->Set(pRuntime->NewNumber(static_cast<int32_t>(fBottom)));
   return true;
 }
 
@@ -617,7 +617,7 @@
   if (!pFormControl)
     return false;
 
-  vp->Set(pRuntime, pFormControl->GetIconFit().GetFittingBounds());
+  vp->Set(pRuntime->NewBoolean(pFormControl->GetIconFit().GetFittingBounds()));
   return true;
 }
 
@@ -645,7 +645,7 @@
   if (!pFormControl)
     return false;
 
-  vp->Set(pRuntime, pFormControl->GetTextPosition());
+  vp->Set(pRuntime->NewNumber(pFormControl->GetTextPosition()));
   return true;
 }
 
@@ -673,7 +673,8 @@
   if (!pFormControl)
     return false;
 
-  vp->Set(pRuntime, pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1);
+  vp->Set(pRuntime->NewBoolean(
+      pFormControl->GetIconFit().IsProportionalScale() ? 0 : 1));
   return true;
 }
 
@@ -705,16 +706,16 @@
   int ScaleM = IconFit.GetScaleMethod();
   switch (ScaleM) {
     case CPDF_IconFit::Always:
-      vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Always));
+      vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Always)));
       break;
     case CPDF_IconFit::Bigger:
-      vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Bigger));
+      vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Bigger)));
       break;
     case CPDF_IconFit::Never:
-      vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Never));
+      vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Never)));
       break;
     case CPDF_IconFit::Smaller:
-      vp->Set(pRuntime, static_cast<int32_t>(CPDF_IconFit::Smaller));
+      vp->Set(pRuntime->NewNumber(static_cast<int32_t>(CPDF_IconFit::Smaller)));
       break;
   }
   return true;
@@ -744,8 +745,8 @@
 
   CPDFSDK_InterForm* pRDInterForm = m_pFormFillEnv->GetInterForm();
   CPDF_InterForm* pInterForm = pRDInterForm->GetInterForm();
-  vp->Set(pRuntime, static_cast<int32_t>(
-                        pInterForm->FindFieldInCalculationOrder(pFormField)));
+  vp->Set(pRuntime->NewNumber(static_cast<int32_t>(
+      pInterForm->FindFieldInCalculationOrder(pFormField))));
   return true;
 }
 
@@ -769,7 +770,7 @@
   if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
     return false;
 
-  vp->Set(pRuntime, static_cast<int32_t>(pFormField->GetMaxLen()));
+  vp->Set(pRuntime->NewNumber(static_cast<int32_t>(pFormField->GetMaxLen())));
   return true;
 }
 
@@ -791,7 +792,8 @@
   if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_COMB));
+  vp->Set(
+      pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_COMB)));
   return true;
 }
 
@@ -817,8 +819,8 @@
     return false;
   }
 
-  vp->Set(pRuntime,
-          !!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_COMMITONSELCHANGE)));
   return true;
 }
 
@@ -844,11 +846,11 @@
 
   int count = pFormField->CountSelectedItems();
   if (count <= 0) {
-    vp->Set(pRuntime, -1);
+    vp->Set(pRuntime->NewNumber(-1));
     return true;
   }
   if (count == 1) {
-    vp->Set(pRuntime, pFormField->GetSelectedIndex(0));
+    vp->Set(pRuntime->NewNumber(pFormField->GetSelectedIndex(0)));
     return true;
   }
 
@@ -857,7 +859,7 @@
     SelArray.SetElement(pRuntime, i,
                         CJS_Value(pRuntime, pFormField->GetSelectedIndex(i)));
   }
-  vp->Set(pRuntime, SelArray);
+  vp->Set(SelArray.ToV8Array(pRuntime));
 
   return true;
 }
@@ -939,7 +941,7 @@
       return false;
     }
 
-    vp->Set(pRuntime, pFormField->GetDefaultValue());
+    vp->Set(pRuntime->NewString(pFormField->GetDefaultValue().c_str()));
     return true;
 }
 
@@ -963,7 +965,8 @@
   if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSCROLL)));
   return true;
 }
 
@@ -989,8 +992,8 @@
     return false;
   }
 
-  vp->Set(pRuntime,
-          !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_DONOTSPELLCHECK)));
   return true;
 }
 
@@ -1013,7 +1016,7 @@
 bool Field::get_delay(CJS_Runtime* pRuntime,
                       CJS_Value* vp,
                       WideString* sError) {
-  vp->Set(pRuntime, m_bDelay);
+  vp->Set(pRuntime->NewBoolean(m_bDelay));
   return true;
 }
 
@@ -1045,16 +1048,16 @@
 
   uint32_t dwFlag = pWidget->GetFlags();
   if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
-    vp->Set(pRuntime, 1);
+    vp->Set(pRuntime->NewNumber(1));
     return true;
   }
   if (ANNOTFLAG_PRINT & dwFlag) {
     if (ANNOTFLAG_NOVIEW & dwFlag)
-      vp->Set(pRuntime, 3);
+      vp->Set(pRuntime->NewNumber(3));
     else
-      vp->Set(pRuntime, 0);
+      vp->Set(pRuntime->NewNumber(0));
   } else {
-    vp->Set(pRuntime, 2);
+    vp->Set(pRuntime->NewNumber(2));
   }
   return true;
 }
@@ -1111,7 +1114,7 @@
 }
 
 bool Field::get_doc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
-  vp->Set(pRuntime, m_pJSDoc->GetCJSDoc());
+  vp->Set(m_pJSDoc->GetCJSDoc()->ToV8Object());
   return true;
 }
 
@@ -1132,7 +1135,8 @@
   if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT));
+  vp->Set(
+      pRuntime->NewBoolean(!!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT)));
   return true;
 }
 
@@ -1177,7 +1181,7 @@
         CJS_Value(pRuntime, pFormControl->GetExportValue().c_str()));
   }
 
-  vp->Set(pRuntime, ExportValusArray);
+  vp->Set(ExportValusArray.ToV8Array(pRuntime));
   return true;
 }
 
@@ -1208,7 +1212,8 @@
   if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)));
   return true;
 }
 
@@ -1263,7 +1268,7 @@
     return false;
   }
 
-  vp->Set(pRuntime, color::ConvertPWLColorToArray(pRuntime, color));
+  vp->Set(color::ConvertPWLColorToArray(pRuntime, color).ToV8Array(pRuntime));
   return true;
 }
 
@@ -1297,8 +1302,8 @@
     return false;
 
   uint32_t dwFlags = pWidget->GetFlags();
-  vp->Set(pRuntime,
-          ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags);
+  vp->Set(pRuntime->NewBoolean(ANNOTFLAG_INVISIBLE & dwFlags ||
+                               ANNOTFLAG_HIDDEN & dwFlags));
   return true;
 }
 
@@ -1345,19 +1350,19 @@
   int eHM = pFormControl->GetHighlightingMode();
   switch (eHM) {
     case CPDF_FormControl::None:
-      vp->Set(pRuntime, L"none");
+      vp->Set(pRuntime->NewString(L"none"));
       break;
     case CPDF_FormControl::Push:
-      vp->Set(pRuntime, L"push");
+      vp->Set(pRuntime->NewString(L"push"));
       break;
     case CPDF_FormControl::Invert:
-      vp->Set(pRuntime, L"invert");
+      vp->Set(pRuntime->NewString(L"invert"));
       break;
     case CPDF_FormControl::Outline:
-      vp->Set(pRuntime, L"outline");
+      vp->Set(pRuntime->NewString(L"outline"));
       break;
     case CPDF_FormControl::Toggle:
-      vp->Set(pRuntime, L"toggle");
+      vp->Set(pRuntime->NewString(L"toggle"));
       break;
   }
   return true;
@@ -1392,7 +1397,7 @@
   if (!pWidget)
     return false;
 
-  vp->Set(pRuntime, pWidget->GetBorderWidth());
+  vp->Set(pRuntime->NewNumber(pWidget->GetBorderWidth()));
   return true;
 }
 
@@ -1463,7 +1468,8 @@
   if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)));
   return true;
 }
 
@@ -1486,7 +1492,8 @@
   if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)));
   return true;
 }
 
@@ -1502,7 +1509,7 @@
   if (FieldArray.empty())
     return false;
 
-  vp->Set(pRuntime, m_FieldName);
+  vp->Set(pRuntime->NewString(m_FieldName.c_str()));
   return true;
 }
 
@@ -1525,7 +1532,7 @@
     return false;
   }
 
-  vp->Set(pRuntime, pFormField->CountOptions());
+  vp->Set(pRuntime->NewNumber(pFormField->CountOptions()));
   return true;
 }
 
@@ -1547,7 +1554,7 @@
   std::vector<CPDFSDK_Annot::ObservedPtr> widgets;
   m_pFormFillEnv->GetInterForm()->GetWidgets(pFormField, &widgets);
   if (widgets.empty()) {
-    vp->Set(pRuntime, -1);
+    vp->Set(pRuntime->NewNumber(-1));
     return true;
   }
 
@@ -1569,7 +1576,7 @@
     ++i;
   }
 
-  vp->Set(pRuntime, PageArray);
+  vp->Set(PageArray.ToV8Array(pRuntime));
   return true;
 }
 
@@ -1593,7 +1600,8 @@
   if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)));
   return true;
 }
 
@@ -1618,7 +1626,7 @@
   if (!pWidget)
     return false;
 
-  vp->Set(pRuntime, !!(pWidget->GetFlags() & ANNOTFLAG_PRINT));
+  vp->Set(pRuntime->NewBoolean(!!(pWidget->GetFlags() & ANNOTFLAG_PRINT)));
   return true;
 }
 
@@ -1692,7 +1700,8 @@
   if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)));
   return true;
 }
 
@@ -1712,7 +1721,8 @@
   if (FieldArray.empty())
     return false;
 
-  vp->Set(pRuntime, !!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY));
+  vp->Set(pRuntime->NewBoolean(
+      !!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY)));
   return true;
 }
 
@@ -1747,7 +1757,7 @@
                      CJS_Value(pRuntime, static_cast<int32_t>(crRect.right)));
   rcArray.SetElement(pRuntime, 3,
                      CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom)));
-  vp->Set(pRuntime, rcArray);
+  vp->Set(rcArray.ToV8Array(pRuntime));
   return true;
 }
 
@@ -1760,16 +1770,15 @@
     return false;
 
   CJS_Array rcArray = vp.ToArray(pRuntime);
-  CJS_Value Upper_Leftx = rcArray.GetElement(pRuntime, 0);
-  CJS_Value Upper_Lefty = rcArray.GetElement(pRuntime, 1);
-  CJS_Value Lower_Rightx = rcArray.GetElement(pRuntime, 2);
-  CJS_Value Lower_Righty = rcArray.GetElement(pRuntime, 3);
-
   float pArray[4];
-  pArray[0] = static_cast<float>(Upper_Leftx.ToInt(pRuntime));
-  pArray[1] = static_cast<float>(Lower_Righty.ToInt(pRuntime));
-  pArray[2] = static_cast<float>(Lower_Rightx.ToInt(pRuntime));
-  pArray[3] = static_cast<float>(Upper_Lefty.ToInt(pRuntime));
+  pArray[0] =
+      static_cast<float>(rcArray.GetElement(pRuntime, 0).ToInt(pRuntime));
+  pArray[1] =
+      static_cast<float>(rcArray.GetElement(pRuntime, 1).ToInt(pRuntime));
+  pArray[2] =
+      static_cast<float>(rcArray.GetElement(pRuntime, 2).ToInt(pRuntime));
+  pArray[3] =
+      static_cast<float>(rcArray.GetElement(pRuntime, 3).ToInt(pRuntime));
 
   CFX_FloatRect crRect(pArray);
   if (m_bDelay) {
@@ -1852,7 +1861,8 @@
   if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)));
   return true;
 }
 
@@ -1879,7 +1889,8 @@
   if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
     return false;
 
-  vp->Set(pRuntime, !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT));
+  vp->Set(pRuntime->NewBoolean(
+      !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)));
   return true;
 }
 
@@ -1916,7 +1927,7 @@
   if (!pFormControl)
     return false;
 
-  vp->Set(pRuntime, pFormControl->GetRotation());
+  vp->Set(pRuntime->NewNumber(pFormControl->GetRotation()));
   return true;
 }
 
@@ -1961,7 +1972,7 @@
     return false;
   }
 
-  vp->Set(pRuntime, color::ConvertPWLColorToArray(pRuntime, color));
+  vp->Set(color::ConvertPWLColorToArray(pRuntime, color).ToV8Array(pRuntime));
   return true;
 }
 
@@ -2017,7 +2028,8 @@
       csBCaption = "check";
       break;
   }
-  vp->Set(pRuntime, csBCaption);
+  vp->Set(
+      pRuntime->NewString(WideString::FromLocal(csBCaption.c_str()).c_str()));
   return true;
 }
 
@@ -2069,7 +2081,7 @@
   if (iColorType == CFX_Color::kTransparent)
     crRet = CFX_Color(CFX_Color::kTransparent);
 
-  vp->Set(pRuntime, color::ConvertPWLColorToArray(pRuntime, crRet));
+  vp->Set(color::ConvertPWLColorToArray(pRuntime, crRet).ToV8Array(pRuntime));
   return true;
 }
 
@@ -2107,7 +2119,8 @@
   if (!pFont)
     return false;
 
-  vp->Set(pRuntime, pFont->GetBaseFont());
+  vp->Set(pRuntime->NewString(
+      WideString::FromLocal(pFont->GetBaseFont().c_str()).c_str()));
   return true;
 }
 
@@ -2141,7 +2154,7 @@
   float fFontSize;
   CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
   FieldAppearance.GetFont(&fFontSize);
-  vp->Set(pRuntime, static_cast<int>(fFontSize));
+  vp->Set(pRuntime->NewNumber(static_cast<int>(fFontSize)));
   return true;
 }
 
@@ -2160,31 +2173,31 @@
   CPDF_FormField* pFormField = FieldArray[0];
   switch (pFormField->GetFieldType()) {
     case FIELDTYPE_UNKNOWN:
-      vp->Set(pRuntime, L"unknown");
+      vp->Set(pRuntime->NewString(L"unknown"));
       break;
     case FIELDTYPE_PUSHBUTTON:
-      vp->Set(pRuntime, L"button");
+      vp->Set(pRuntime->NewString(L"button"));
       break;
     case FIELDTYPE_CHECKBOX:
-      vp->Set(pRuntime, L"checkbox");
+      vp->Set(pRuntime->NewString(L"checkbox"));
       break;
     case FIELDTYPE_RADIOBUTTON:
-      vp->Set(pRuntime, L"radiobutton");
+      vp->Set(pRuntime->NewString(L"radiobutton"));
       break;
     case FIELDTYPE_COMBOBOX:
-      vp->Set(pRuntime, L"combobox");
+      vp->Set(pRuntime->NewString(L"combobox"));
       break;
     case FIELDTYPE_LISTBOX:
-      vp->Set(pRuntime, L"listbox");
+      vp->Set(pRuntime->NewString(L"listbox"));
       break;
     case FIELDTYPE_TEXTFIELD:
-      vp->Set(pRuntime, L"text");
+      vp->Set(pRuntime->NewString(L"text"));
       break;
     case FIELDTYPE_SIGNATURE:
-      vp->Set(pRuntime, L"signature");
+      vp->Set(pRuntime->NewString(L"signature"));
       break;
     default:
-      vp->Set(pRuntime, L"unknown");
+      vp->Set(pRuntime->NewString(L"unknown"));
       break;
   }
   return true;
@@ -2205,7 +2218,7 @@
   if (FieldArray.empty())
     return false;
 
-  vp->Set(pRuntime, FieldArray[0]->GetAlternateName());
+  vp->Set(pRuntime->NewString(FieldArray[0]->GetAlternateName().c_str()));
   return true;
 }
 
@@ -2229,12 +2242,12 @@
       return false;
     case FIELDTYPE_COMBOBOX:
     case FIELDTYPE_TEXTFIELD:
-      vp->Set(pRuntime, pFormField->GetValue());
+      vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
       break;
     case FIELDTYPE_LISTBOX: {
       if (pFormField->CountSelectedItems() > 1) {
         CJS_Array ValueArray;
-        CJS_Value ElementValue(pRuntime);
+        CJS_Value ElementValue;
         int iIndex;
         for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
           iIndex = pFormField->GetSelectedIndex(i);
@@ -2246,9 +2259,9 @@
           }
           ValueArray.SetElement(pRuntime, i, ElementValue);
         }
-        vp->Set(pRuntime, ValueArray);
+        vp->Set(ValueArray.ToV8Array(pRuntime));
       } else {
-        vp->Set(pRuntime, pFormField->GetValue());
+        vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
       }
       break;
     }
@@ -2257,18 +2270,19 @@
       bool bFind = false;
       for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
         if (pFormField->GetControl(i)->IsChecked()) {
-          vp->Set(pRuntime, pFormField->GetControl(i)->GetExportValue());
+          vp->Set(pRuntime->NewString(
+              pFormField->GetControl(i)->GetExportValue().c_str()));
           bFind = true;
           break;
         }
       }
       if (!bFind)
-        vp->Set(pRuntime, L"Off");
+        vp->Set(pRuntime->NewString(L"Off"));
 
       break;
     }
     default:
-      vp->Set(pRuntime, pFormField->GetValue());
+      vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
       break;
   }
   vp->MaybeCoerceToNumber(pRuntime);
@@ -2283,9 +2297,9 @@
 
   std::vector<WideString> strArray;
   if (vp.IsArrayObject()) {
-    CJS_Array ValueArray = vp.ToArray(pRuntime);
+    CJS_Array ValueArray(vp.ToArray(pRuntime));
     for (int i = 0, sz = ValueArray.GetLength(pRuntime); i < sz; i++) {
-      CJS_Value ElementValue = ValueArray.GetElement(pRuntime, i);
+      CJS_Value ElementValue(ValueArray.GetElement(pRuntime, i));
       strArray.push_back(ElementValue.ToWideString(pRuntime));
     }
   } else {
@@ -2370,7 +2384,8 @@
     if (!pFormField->CountControls())
       return false;
 
-    vp->Set(pRuntime, pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off");
+    vp->Set(pRuntime->NewString(
+        pFormField->GetControl(0)->IsChecked() ? L"Yes" : L"Off"));
     return true;
   }
 
@@ -2378,10 +2393,11 @@
       !(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)) {
     for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
       if (pFormField->GetControl(i)->IsChecked()) {
-        vp->Set(pRuntime, pFormField->GetControl(i)->GetExportValue().c_str());
+        vp->Set(pRuntime->NewString(
+            pFormField->GetControl(i)->GetExportValue().c_str()));
         break;
       } else {
-        vp->Set(pRuntime, L"Off");
+        vp->Set(pRuntime->NewString(L"Off"));
       }
     }
     return true;
@@ -2389,9 +2405,9 @@
 
   if (pFormField->GetFieldType() == FIELDTYPE_LISTBOX &&
       (pFormField->CountSelectedItems() > 1)) {
-    vp->Set(pRuntime, L"");
+    vp->Set(pRuntime->NewString(L""));
   } else {
-    vp->Set(pRuntime, pFormField->GetValue().c_str());
+    vp->Set(pRuntime->NewString(pFormField->GetValue().c_str()));
   }
 
   return true;
@@ -2485,7 +2501,7 @@
     return false;
 
   CJS_Icon* pJS_Icon = static_cast<CJS_Icon*>(pRuntime->GetObjectPrivate(pObj));
-  vRet = CJS_Value(pRuntime, pJS_Icon);
+  vRet = CJS_Value(pJS_Icon);
   return true;
 }
 
@@ -2619,7 +2635,7 @@
         static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pObj));
     Field* pField = static_cast<Field*>(pJSField->GetEmbedObject());
     pField->AttachField(m_pJSDoc, *pStr);
-    FormFieldArray.SetElement(pRuntime, j++, CJS_Value(pRuntime, pJSField));
+    FormFieldArray.SetElement(pRuntime, j++, CJS_Value(pJSField));
   }
 
   vRet = CJS_Value(pRuntime, FormFieldArray);
@@ -2835,7 +2851,7 @@
 bool Field::get_source(CJS_Runtime* pRuntime,
                        CJS_Value* vp,
                        WideString* sError) {
-  vp->Set(pRuntime, static_cast<CJS_Object*>(nullptr));
+  vp->Set(v8::Local<v8::Value>());
   return true;
 }
 
diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp
index a5fa3fa..53f549d 100644
--- a/fpdfsdk/javascript/Icon.cpp
+++ b/fpdfsdk/javascript/Icon.cpp
@@ -26,7 +26,7 @@
 Icon::~Icon() {}
 
 bool Icon::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
-  vp->Set(pRuntime, m_swIconName);
+  vp->Set(pRuntime->NewString(m_swIconName.c_str()));
   return true;
 }
 
diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h
index 4bcdcdf..46469d7 100644
--- a/fpdfsdk/javascript/JS_Define.h
+++ b/fpdfsdk/javascript/JS_Define.h
@@ -52,13 +52,13 @@
   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
   WideString sError;
 
-  CJS_Value prop_value(pRuntime);
+  CJS_Value prop_value;
   if (!(pObj->*M)(pRuntime, &prop_value, &sError)) {
     pRuntime->Error(
         JSFormatErrorString(class_name_string, prop_name_string, sError));
     return;
   }
-  info.GetReturnValue().Set(prop_value.ToV8Value(pRuntime));
+  info.GetReturnValue().Set(prop_value.ToV8Value());
 }
 
 template <class C, bool (C::*M)(CJS_Runtime*, const CJS_Value&, WideString*)>
@@ -80,7 +80,7 @@
   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
   WideString sError;
 
-  CJS_Value prop_value(pRuntime, value);
+  CJS_Value prop_value(value);
   if (!(pObj->*M)(pRuntime, prop_value, &sError)) {
     pRuntime->Error(
         JSFormatErrorString(class_name_string, prop_name_string, sError));
@@ -113,23 +113,25 @@
       CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate());
   if (!pRuntime)
     return;
+
   std::vector<CJS_Value> parameters;
-  for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
-    parameters.push_back(CJS_Value(pRuntime, info[i]));
-  }
+  for (unsigned int i = 0; i < (unsigned int)info.Length(); i++)
+    parameters.push_back(CJS_Value(info[i]));
+
   CJS_Object* pJSObj =
       static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(info.Holder()));
   if (!pJSObj)
     return;
+
   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
   WideString sError;
-  CJS_Value valueRes(pRuntime);
+  CJS_Value valueRes;
   if (!(pObj->*M)(pRuntime, parameters, valueRes, sError)) {
     pRuntime->Error(
         JSFormatErrorString(class_name_string, method_name_string, sError));
     return;
   }
-  info.GetReturnValue().Set(valueRes.ToV8Value(pRuntime));
+  info.GetReturnValue().Set(valueRes.ToV8Value());
 }
 
 #define JS_STATIC_METHOD(method_name, class_name)                             \
diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp
index fb38e8cb..7de267e 100644
--- a/fpdfsdk/javascript/JS_Value.cpp
+++ b/fpdfsdk/javascript/JS_Value.cpp
@@ -178,90 +178,43 @@
 
 }  // namespace
 
-CJS_Value::CJS_Value(CJS_Runtime* pRuntime) {}
+CJS_Value::CJS_Value() {}
 
-CJS_Value::CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue)
-    : m_pValue(pValue) {}
+CJS_Value::CJS_Value(v8::Local<v8::Value> pValue) : m_pValue(pValue) {}
 
 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, int iValue)
-    : CJS_Value(pRuntime, pRuntime->NewNumber(iValue)) {}
+    : CJS_Value(pRuntime->NewNumber(iValue)) {}
 
 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, bool bValue)
-    : CJS_Value(pRuntime, pRuntime->NewBoolean(bValue)) {}
+    : CJS_Value(pRuntime->NewBoolean(bValue)) {}
 
 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, double dValue)
-    : CJS_Value(pRuntime, pRuntime->NewNumber(dValue)) {}
+    : CJS_Value(pRuntime->NewNumber(dValue)) {}
 
-CJS_Value::CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj) {
+CJS_Value::CJS_Value(CJS_Object* pObj) {
   if (pObj)
     m_pValue = pObj->ToV8Object();
 }
 
 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const wchar_t* pWstr)
-    : CJS_Value(pRuntime, pRuntime->NewString(pWstr)) {}
+    : CJS_Value(pRuntime->NewString(pWstr)) {}
 
 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const char* pStr)
-    : CJS_Value(pRuntime,
-                pRuntime->NewString(WideString::FromLocal(pStr).c_str())) {}
+    : CJS_Value(pRuntime->NewString(WideString::FromLocal(pStr).c_str())) {}
 
 CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const CJS_Array& array)
-    : CJS_Value(pRuntime, array.ToV8Array(pRuntime)) {}
+    : CJS_Value(array.ToV8Array(pRuntime)) {}
 
-CJS_Value::CJS_Value(CJS_Runtime* pRuntime, const CJS_Date& date)
-    : CJS_Value(pRuntime, date.ToV8Date(pRuntime)) {}
+CJS_Value::CJS_Value(const CJS_Date& date) : CJS_Value(date.ToV8Date()) {}
 
 CJS_Value::~CJS_Value() {}
 
 CJS_Value::CJS_Value(const CJS_Value& other) = default;
 
-void CJS_Value::SetNull(CJS_Runtime* pRuntime) {
-  m_pValue = pRuntime->NewNull();
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue) {
+void CJS_Value::Set(v8::Local<v8::Value> pValue) {
   m_pValue = pValue;
 }
 
-void CJS_Value::Set(CJS_Runtime* pRuntime, int val) {
-  m_pValue = pRuntime->NewNumber(val);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, bool val) {
-  m_pValue = pRuntime->NewBoolean(val);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, double val) {
-  m_pValue = pRuntime->NewNumber(val);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, CJS_Object* pObj) {
-  m_pValue = pObj->ToV8Object();
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, CJS_Document* pJsDoc) {
-  m_pValue = pJsDoc->ToV8Object();
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const ByteString& str) {
-  m_pValue = pRuntime->NewString(WideString::FromLocal(str.c_str()).c_str());
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const WideString& str) {
-  m_pValue = pRuntime->NewString(str.c_str());
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const wchar_t* c_string) {
-  m_pValue = pRuntime->NewString(c_string);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const CJS_Array& array) {
-  m_pValue = array.ToV8Array(pRuntime);
-}
-
-void CJS_Value::Set(CJS_Runtime* pRuntime, const CJS_Date& date) {
-  m_pValue = date.ToV8Date(pRuntime);
-}
-
 int CJS_Value::ToInt(CJS_Runtime* pRuntime) const {
   return pRuntime->ToInt32(m_pValue);
 }
@@ -292,7 +245,7 @@
   return CJS_Array(pRuntime->ToArray(m_pValue));
 }
 
-CJS_Date CJS_Value::ToDate(CJS_Runtime* pRuntime) const {
+CJS_Date CJS_Value::ToDate() const {
   ASSERT(IsDateObject());
   v8::Local<v8::Value> mutable_value = m_pValue;
   return CJS_Date(mutable_value.As<v8::Date>());
@@ -310,7 +263,7 @@
   return ByteString::FromUnicode(ToWideString(pRuntime));
 }
 
-v8::Local<v8::Value> CJS_Value::ToV8Value(CJS_Runtime* pRuntime) const {
+v8::Local<v8::Value> CJS_Value::ToV8Value() const {
   return m_pValue;
 }
 
@@ -378,9 +331,9 @@
 
 CJS_Value CJS_Array::GetElement(CJS_Runtime* pRuntime, unsigned index) const {
   if (!m_pArray.IsEmpty())
-    return CJS_Value(pRuntime, pRuntime->GetArrayElement(m_pArray, index));
-
-  return CJS_Value(pRuntime);
+    return CJS_Value(
+        v8::Local<v8::Value>(pRuntime->GetArrayElement(m_pArray, index)));
+  return {};
 }
 
 void CJS_Array::SetElement(CJS_Runtime* pRuntime,
@@ -389,7 +342,7 @@
   if (m_pArray.IsEmpty())
     m_pArray = pRuntime->NewArray();
 
-  pRuntime->PutArrayElement(m_pArray, index, value.ToV8Value(pRuntime));
+  pRuntime->PutArrayElement(m_pArray, index, value.ToV8Value());
 }
 
 int CJS_Array::GetLength(CJS_Runtime* pRuntime) const {
@@ -470,7 +423,7 @@
   return JS_GetSecFromTime(JS_LocalTime(pRuntime->ToDouble(m_pDate)));
 }
 
-v8::Local<v8::Date> CJS_Date::ToV8Date(CJS_Runtime* pRuntime) const {
+v8::Local<v8::Date> CJS_Date::ToV8Date() const {
   return m_pDate;
 }
 
@@ -585,7 +538,7 @@
     ...) {
   ASSERT(nKeywords);
 
-  std::vector<CJS_Value> result(nKeywords, CJS_Value(pRuntime));
+  std::vector<CJS_Value> result(nKeywords, CJS_Value());
   size_t size = std::min(originals.size(), nKeywords);
   for (size_t i = 0; i < size; ++i)
     result[i] = originals[i];
@@ -595,7 +548,7 @@
     return result;
   }
   v8::Local<v8::Object> pObj = originals[0].ToV8Object(pRuntime);
-  result[0] = CJS_Value(pRuntime);  // Make unknown.
+  result[0] = CJS_Value();  // Make unknown.
 
   va_list ap;
   va_start(ap, nKeywords);
@@ -603,7 +556,7 @@
     const wchar_t* property = va_arg(ap, const wchar_t*);
     v8::Local<v8::Value> v8Value = pRuntime->GetObjectProperty(pObj, property);
     if (!v8Value->IsUndefined())
-      result[i] = CJS_Value(pRuntime, v8Value);
+      result[i] = CJS_Value(v8Value);
   }
   va_end(ap);
   return result;
diff --git a/fpdfsdk/javascript/JS_Value.h b/fpdfsdk/javascript/JS_Value.h
index 49dd249..72d381e 100644
--- a/fpdfsdk/javascript/JS_Value.h
+++ b/fpdfsdk/javascript/JS_Value.h
@@ -32,34 +32,22 @@
 
   static Type GetValueType(v8::Local<v8::Value> value);
 
-  explicit CJS_Value(CJS_Runtime* pRuntime);
-  CJS_Value(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue);
+  CJS_Value();
+  explicit CJS_Value(v8::Local<v8::Value> pValue);
   CJS_Value(CJS_Runtime* pRuntime, int iValue);
   CJS_Value(CJS_Runtime* pRuntime, double dValue);
   CJS_Value(CJS_Runtime* pRuntime, bool bValue);
-  CJS_Value(CJS_Runtime* pRuntime, CJS_Object* pObj);
+  explicit CJS_Value(CJS_Object* pObj);
   CJS_Value(CJS_Runtime* pRuntime, const char* pStr);
   CJS_Value(CJS_Runtime* pRuntime, const wchar_t* pWstr);
   CJS_Value(CJS_Runtime* pRuntime, const CJS_Array& array);
-  CJS_Value(CJS_Runtime* pRuntime, const CJS_Date& date);
-  CJS_Value(CJS_Runtime* pRuntime, const CJS_Object* object);
+  explicit CJS_Value(const CJS_Date& date);
   CJS_Value(const CJS_Value& other);
 
   ~CJS_Value();
 
   // These calls may re-enter JS (and hence invalidate objects).
-  void Set(CJS_Runtime* pRuntime, int val);
-  void Set(CJS_Runtime* pRuntime, bool val);
-  void Set(CJS_Runtime* pRuntime, double val);
-  void Set(CJS_Runtime* pRuntime, CJS_Object* pObj);
-  void Set(CJS_Runtime* pRuntime, CJS_Document* pJsDoc);
-  void Set(CJS_Runtime* pRuntime, const ByteString&);
-  void Set(CJS_Runtime* pRuntime, const WideString&);
-  void Set(CJS_Runtime* pRuntime, const wchar_t* c_string);
-  void Set(CJS_Runtime* pRuntime, const CJS_Array& array);
-  void Set(CJS_Runtime* pRuntime, const CJS_Date& date);
-  void Set(CJS_Runtime* pRuntime, v8::Local<v8::Value> pValue);
-  void SetNull(CJS_Runtime* pRuntime);
+  void Set(v8::Local<v8::Value> pValue);
 
   Type GetType() const { return GetValueType(m_pValue); }
 
@@ -70,12 +58,12 @@
   CJS_Object* ToObject(CJS_Runtime* pRuntime) const;
   CJS_Document* ToDocument(CJS_Runtime* pRuntime) const;
   CJS_Array ToArray(CJS_Runtime* pRuntime) const;
-  CJS_Date ToDate(CJS_Runtime* pRuntime) const;
+  CJS_Date ToDate() const;
   WideString ToWideString(CJS_Runtime* pRuntime) const;
   ByteString ToByteString(CJS_Runtime* pRuntime) const;
   v8::Local<v8::Object> ToV8Object(CJS_Runtime* pRuntime) const;
   v8::Local<v8::Array> ToV8Array(CJS_Runtime* pRuntime) const;
-  v8::Local<v8::Value> ToV8Value(CJS_Runtime* pRuntime) const;
+  v8::Local<v8::Value> ToV8Value() const;
 
   // Replace the current |m_pValue| with a v8::Number if possible
   // to make one from the current |m_pValue|.
@@ -133,7 +121,7 @@
   int GetMinutes(CJS_Runtime* pRuntime) const;
   int GetSeconds(CJS_Runtime* pRuntime) const;
 
-  v8::Local<v8::Date> ToV8Date(CJS_Runtime* pRuntime) const;
+  v8::Local<v8::Date> ToV8Date() const;
   WideString ToWideString(int style) const;
 
  protected:
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 5e42800..ccd2cfc 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -122,15 +122,15 @@
     return;
   std::vector<CJS_Value> parameters;
   for (unsigned int i = 0; i < (unsigned int)info.Length(); i++) {
-    parameters.push_back(CJS_Value(pRuntime, info[i]));
+    parameters.push_back(CJS_Value(info[i]));
   }
-  CJS_Value valueRes(pRuntime);
+  CJS_Value valueRes;
   WideString sError;
   if (!(*F)(pRuntime, parameters, valueRes, sError)) {
     pRuntime->Error(JSFormatErrorString(func_name_string, nullptr, sError));
     return;
   }
-  info.GetReturnValue().Set(valueRes.ToV8Value(pRuntime));
+  info.GetReturnValue().Set(valueRes.ToV8Value());
 }
 
 }  // namespace
@@ -896,7 +896,7 @@
     if (iNegStyle == 1 || iNegStyle == 3) {
       if (Field* fTarget = pEvent->Target_Field()) {
         CJS_Array arColor;
-        CJS_Value vColElm(pRuntime);
+        CJS_Value vColElm;
         vColElm = CJS_Value(pRuntime, L"RGB");
         arColor.SetElement(pRuntime, 0, vColElm);
         vColElm = CJS_Value(pRuntime, 1);
@@ -913,7 +913,7 @@
     if (iNegStyle == 1 || iNegStyle == 3) {
       if (Field* fTarget = pEvent->Target_Field()) {
         CJS_Array arColor;
-        CJS_Value vColElm(pRuntime);
+        CJS_Value vColElm;
         vColElm = CJS_Value(pRuntime, L"RGB");
         arColor.SetElement(pRuntime, 0, vColElm);
         vColElm = CJS_Value(pRuntime, 0);
@@ -921,7 +921,7 @@
         arColor.SetElement(pRuntime, 2, vColElm);
         arColor.SetElement(pRuntime, 3, vColElm);
 
-        CJS_Value vProp(pRuntime);
+        CJS_Value vProp;
         fTarget->get_text_color(pRuntime, &vProp, &sError);
 
         CFX_Color crProp =
@@ -1661,7 +1661,7 @@
     return false;
   }
 
-  CJS_Value params1 = params[1];
+  CJS_Value params1(params[1]);
   if (!params1.IsArrayObject() && params1.GetType() != CJS_Value::VT_string) {
     sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
     return false;
@@ -1826,7 +1826,7 @@
   if (nums.GetLength(pRuntime) > 0)
     vRet = CJS_Value(pRuntime, nums);
   else
-    vRet.SetNull(pRuntime);
+    vRet.Set(pRuntime->NewNull());
 
   return true;
 }
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 9894bb8..1c822df 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -217,11 +217,11 @@
     pJSDocument = static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj));
 
   CJS_Array aDocs;
-  aDocs.SetElement(pRuntime, 0, CJS_Value(pRuntime, pJSDocument));
+  aDocs.SetElement(pRuntime, 0, CJS_Value(pJSDocument));
   if (aDocs.GetLength(pRuntime) > 0)
-    vp->Set(pRuntime, aDocs);
+    vp->Set(aDocs.ToV8Array(pRuntime));
   else
-    vp->SetNull(pRuntime);
+    vp->Set(pRuntime->NewNull());
 
   return true;
 }
@@ -235,7 +235,7 @@
 bool app::get_calculate(CJS_Runtime* pRuntime,
                         CJS_Value* vp,
                         WideString* sError) {
-  vp->Set(pRuntime, m_bCalculate);
+  vp->Set(pRuntime->NewBoolean(m_bCalculate));
   return true;
 }
 
@@ -250,7 +250,7 @@
 bool app::get_forms_version(CJS_Runtime* pRuntime,
                             CJS_Value* vp,
                             WideString* sError) {
-  vp->Set(pRuntime, JS_NUM_FORMSVERSION);
+  vp->Set(pRuntime->NewNumber(JS_NUM_FORMSVERSION));
   return true;
 }
 
@@ -263,7 +263,7 @@
 bool app::get_viewer_type(CJS_Runtime* pRuntime,
                           CJS_Value* vp,
                           WideString* sError) {
-  vp->Set(pRuntime, JS_STR_VIEWERTYPE);
+  vp->Set(pRuntime->NewString(JS_STR_VIEWERTYPE));
   return true;
 }
 
@@ -276,7 +276,7 @@
 bool app::get_viewer_variation(CJS_Runtime* pRuntime,
                                CJS_Value* vp,
                                WideString* sError) {
-  vp->Set(pRuntime, JS_STR_VIEWERVARIATION);
+  vp->Set(pRuntime->NewString(JS_STR_VIEWERVARIATION));
   return true;
 }
 
@@ -292,11 +292,11 @@
 #ifdef PDF_ENABLE_XFA
   CPDFXFA_Context* pXFAContext = pRuntime->GetFormFillEnv()->GetXFAContext();
   if (pXFAContext->ContainsXFAForm()) {
-    vp->Set(pRuntime, JS_NUM_VIEWERVERSION_XFA);
+    vp->Set(pRuntime->NewNumber(JS_NUM_VIEWERVERSION_XFA));
     return true;
   }
 #endif  // PDF_ENABLE_XFA
-  vp->Set(pRuntime, JS_NUM_VIEWERVERSION);
+  vp->Set(pRuntime->NewNumber(JS_NUM_VIEWERVERSION));
   return true;
 }
 
@@ -316,11 +316,11 @@
 
   WideString platfrom = pFormFillEnv->GetPlatform();
   if (!platfrom.IsEmpty()) {
-    vp->Set(pRuntime, platfrom);
+    vp->Set(pRuntime->NewString(platfrom.c_str()));
     return true;
   }
 #endif
-  vp->Set(pRuntime, JS_STR_PLATFORM);
+  vp->Set(pRuntime->NewString(JS_STR_PLATFORM));
   return true;
 }
 
@@ -340,11 +340,11 @@
 
   WideString language = pFormFillEnv->GetLanguage();
   if (!language.IsEmpty()) {
-    vp->Set(pRuntime, language);
+    vp->Set(pRuntime->NewString(language.c_str()));
     return true;
   }
 #endif
-  vp->Set(pRuntime, JS_STR_LANGUAGE);
+  vp->Set(pRuntime->NewString(JS_STR_LANGUAGE));
   return true;
 }
 
@@ -508,7 +508,7 @@
   TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
   pTimerObj->SetTimer(timerRef);
 
-  vRet = CJS_Value(pRuntime, pRetObj);
+  vRet = CJS_Value(pRetObj);
   return true;
 }
 
@@ -542,7 +542,7 @@
       static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj));
   TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
   pTimerObj->SetTimer(timerRef);
-  vRet = CJS_Value(pRuntime, pRetObj);
+  vRet = CJS_Value(pRetObj);
   return true;
 }
 
@@ -694,7 +694,7 @@
 bool app::get_runtime_highlight(CJS_Runtime* pRuntime,
                                 CJS_Value* vp,
                                 WideString* sError) {
-  vp->Set(pRuntime, m_bRuntimeHighLight);
+  vp->Set(pRuntime->NewBoolean(m_bRuntimeHighLight));
   return true;
 }
 
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 2eccdae..37ab1cc 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -261,7 +261,7 @@
 bool color::GetPropertyHelper(CJS_Runtime* pRuntime,
                               CJS_Value* vp,
                               CFX_Color* var) {
-  vp->Set(pRuntime, ConvertPWLColorToArray(pRuntime, *var));
+  vp->Set(ConvertPWLColorToArray(pRuntime, *var).ToV8Array(pRuntime));
   return true;
 }
 
diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp
index 11b8b01..361afa8 100644
--- a/fpdfsdk/javascript/event.cpp
+++ b/fpdfsdk/javascript/event.cpp
@@ -51,7 +51,7 @@
                        WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->Change());
+  vp->Set(pRuntime->NewString(pEvent->Change().c_str()));
   return true;
 }
 
@@ -74,7 +74,7 @@
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
 
-  vp->Set(pRuntime, pEvent->ChangeEx());
+  vp->Set(pRuntime->NewString(pEvent->ChangeEx().c_str()));
   return true;
 }
 
@@ -90,7 +90,7 @@
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
 
-  vp->Set(pRuntime, pEvent->CommitKey());
+  vp->Set(pRuntime->NewNumber(pEvent->CommitKey()));
   return true;
 }
 
@@ -109,7 +109,7 @@
   if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
     return false;
 
-  vp->Set(pRuntime, pEvent->FieldFull());
+  vp->Set(pRuntime->NewBoolean(pEvent->FieldFull()));
   return true;
 }
 
@@ -124,7 +124,7 @@
                          WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->KeyDown());
+  vp->Set(pRuntime->NewBoolean(pEvent->KeyDown()));
   return true;
 }
 
@@ -139,7 +139,7 @@
                          WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->Modifier());
+  vp->Set(pRuntime->NewBoolean(pEvent->Modifier()));
   return true;
 }
 
@@ -152,7 +152,7 @@
 bool event::get_name(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->Name());
+  vp->Set(pRuntime->NewString(pEvent->Name()));
   return true;
 }
 
@@ -165,7 +165,7 @@
 bool event::get_rc(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->Rc());
+  vp->Set(pRuntime->NewBoolean(pEvent->Rc()));
   return true;
 }
 
@@ -223,7 +223,7 @@
   if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
     return true;
 
-  vp->Set(pRuntime, pEvent->SelEnd());
+  vp->Set(pRuntime->NewNumber(pEvent->SelEnd()));
   return true;
 }
 
@@ -249,7 +249,7 @@
   if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
     return true;
 
-  vp->Set(pRuntime, pEvent->SelStart());
+  vp->Set(pRuntime->NewNumber(pEvent->SelStart()));
   return true;
 }
 
@@ -271,7 +271,7 @@
                       WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->Shift());
+  vp->Set(pRuntime->NewBoolean(pEvent->Shift()));
   return true;
 }
 
@@ -286,7 +286,7 @@
                        WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->Source()->GetJSObject());
+  vp->Set(pEvent->Source()->GetJSObject()->ToV8Object());
   return true;
 }
 
@@ -301,7 +301,7 @@
                        WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->Target_Field()->GetJSObject());
+  vp->Set(pEvent->Target_Field()->GetJSObject()->ToV8Object());
   return true;
 }
 
@@ -316,7 +316,7 @@
                             WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->TargetName());
+  vp->Set(pRuntime->NewString(pEvent->TargetName().c_str()));
   return true;
 }
 
@@ -329,7 +329,7 @@
 bool event::get_type(CJS_Runtime* pRuntime, CJS_Value* vp, WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->Type());
+  vp->Set(pRuntime->NewString(pEvent->Type()));
   return true;
 }
 
@@ -351,7 +351,7 @@
   if (!pEvent->m_pValue)
     return false;
 
-  vp->Set(pRuntime, pEvent->Value());
+  vp->Set(pRuntime->NewString(pEvent->Value().c_str()));
   return true;
 }
 
@@ -376,7 +376,7 @@
                             WideString* sError) {
   CJS_EventHandler* pEvent =
       pRuntime->GetCurrentEventContext()->GetEventHandler();
-  vp->Set(pRuntime, pEvent->WillCommit());
+  vp->Set(pRuntime->NewBoolean(pEvent->WillCommit()));
   return true;
 }
 
diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp
index ee76469..a226bb2 100644
--- a/fpdfsdk/javascript/global.cpp
+++ b/fpdfsdk/javascript/global.cpp
@@ -104,12 +104,12 @@
   WideString propname =
       WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
 
-  CJS_Value value(pRuntime);
+  CJS_Value value;
   if (!pObj->GetProperty(pRuntime, propname.c_str(), &value)) {
     pRuntime->Error(JSFormatErrorString(class_name, "GetProperty", L""));
     return;
   }
-  info.GetReturnValue().Set(value.ToV8Value(pRuntime));
+  info.GetReturnValue().Set(value.ToV8Value());
 }
 
 template <class Alt>
@@ -131,7 +131,7 @@
   v8::String::Utf8Value utf8_value(property);
   WideString propname =
       WideString::FromUTF8(ByteStringView(*utf8_value, utf8_value.length()));
-  CJS_Value prop_value(pRuntime, value);
+  CJS_Value prop_value(value);
   if (!pObj->SetProperty(pRuntime, propname.c_str(), prop_value)) {
     pRuntime->Error(JSFormatErrorString(class_name, "PutProperty", L""));
   }
@@ -287,33 +287,33 @@
                                     CJS_Value* vp) {
   auto it = m_MapGlobal.find(ByteString::FromUnicode(propname));
   if (it == m_MapGlobal.end()) {
-    vp->SetNull(pRuntime);
+    vp->Set(pRuntime->NewNull());
     return true;
   }
 
   JSGlobalData* pData = it->second.get();
   if (pData->bDeleted) {
-    vp->SetNull(pRuntime);
+    vp->Set(pRuntime->NewNull());
     return true;
   }
 
   switch (pData->nType) {
     case JS_GlobalDataType::NUMBER:
-      vp->Set(pRuntime, pData->dData);
+      vp->Set(pRuntime->NewNumber(pData->dData));
       return true;
     case JS_GlobalDataType::BOOLEAN:
-      vp->Set(pRuntime, pData->bData);
+      vp->Set(pRuntime->NewBoolean(pData->bData));
       return true;
     case JS_GlobalDataType::STRING:
-      vp->Set(pRuntime, pData->sData);
+      vp->Set(pRuntime->NewString(
+          WideString::FromLocal(pData->sData.c_str()).c_str()));
       return true;
     case JS_GlobalDataType::OBJECT: {
-      vp->Set(pRuntime,
-              v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData));
+      vp->Set(v8::Local<v8::Object>::New(pRuntime->GetIsolate(), pData->pData));
       return true;
     }
     case JS_GlobalDataType::NULLOBJ:
-      vp->SetNull(pRuntime);
+      vp->Set(pRuntime->NewNull());
       return true;
     default:
       break;
@@ -485,7 +485,7 @@
         array.Add(pObjElement);
       } break;
       case CJS_Value::VT_string: {
-        ByteString sValue = CJS_Value(pRuntime, v).ToByteString(pRuntime);
+        ByteString sValue = CJS_Value(v).ToByteString(pRuntime);
         CJS_KeyValue* pObjElement = new CJS_KeyValue;
         pObjElement->nType = JS_GlobalDataType::STRING;
         pObjElement->sKey = sKey;
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 9b63823..3d669b3 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -151,7 +151,7 @@
     return false;
   }
 
-  CJS_Date jsDate = p2.ToDate(pRuntime);
+  CJS_Date jsDate = p2.ToDate();
   if (!jsDate.IsValidDate(pRuntime)) {
     sError = JSGetStringFromID(IDS_STRING_JSPRINT2);
     return false;
@@ -396,9 +396,9 @@
   }
 
   if (!std::isnan(dDate)) {
-    vRet = CJS_Value(pRuntime, CJS_Date(pRuntime, dDate));
+    vRet = CJS_Value(CJS_Date(pRuntime, dDate));
   } else {
-    vRet.SetNull(pRuntime);
+    vRet.Set(pRuntime->NewNull());
   }
 
   return true;