Clean up CPDF_AnnotList.
[pdfium.git] / fpdfsdk / src / javascript / Document.cpp
index 91805b8..4c7e191 100644 (file)
@@ -4,23 +4,23 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#include "../../include/javascript/JavaScript.h"
-#include "../../include/javascript/IJavaScript.h"
-#include "../../include/javascript/JS_Define.h"
-#include "../../include/javascript/JS_Object.h"
-#include "../../include/javascript/JS_Value.h"
-#include "../../include/javascript/Document.h"
-#include "../../include/javascript/JS_EventHandler.h"
-#include "../../include/javascript/JS_Context.h"
-#include "../../include/javascript/JS_Runtime.h"
-#include "../../include/javascript/app.h"
-#include "../../include/javascript/Field.h"
-#include "../../include/javascript/Icon.h"
-#include "../../include/javascript/resource.h"
+#include "Document.h"
 
 #include "../../../third_party/base/numerics/safe_math.h"
-
-static v8::Isolate* GetIsolate(IFXJS_Context* cc) {
+#include "../../include/fsdk_mgr.h"  // For CPDFDoc_Environment.
+#include "../../include/javascript/IJavaScript.h"
+#include "Field.h"
+#include "Icon.h"
+#include "JS_Context.h"
+#include "JS_Define.h"
+#include "JS_EventHandler.h"
+#include "JS_Object.h"
+#include "JS_Runtime.h"
+#include "JS_Value.h"
+#include "app.h"
+#include "resource.h"
+
+static v8::Isolate* GetIsolate(IJS_Context* cc) {
   CJS_Context* pContext = (CJS_Context*)cc;
   ASSERT(pContext != NULL);
 
@@ -140,17 +140,12 @@ END_JS_STATIC_METHOD()
 
 IMPLEMENT_JS_CLASS(CJS_Document, Document)
 
-FX_BOOL CJS_Document::InitInstance(IFXJS_Context* cc) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  ASSERT(pContext != NULL);
-
-  Document* pDoc = (Document*)GetEmbedObject();
-  ASSERT(pDoc != NULL);
-
-  pDoc->AttachDoc(pContext->GetReaderDocument());
-  pDoc->SetIsolate(pContext->GetJSRuntime()->GetIsolate());
-  return TRUE;
-};
+void CJS_Document::InitInstance(IJS_Runtime* pIRuntime) {
+  CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime);
+  Document* pDoc = static_cast<Document*>(GetEmbedObject());
+  pDoc->AttachDoc(pRuntime->GetReaderDocument());
+  pDoc->SetIsolate(pRuntime->GetIsolate());
+}
 
 /* --------------------------------- Document ---------------------------------
  */
@@ -182,7 +177,7 @@ Document::~Document() {
 }
 
 // the total number of fileds in document.
-FX_BOOL Document::numFields(IFXJS_Context* cc,
+FX_BOOL Document::numFields(IJS_Context* cc,
                             CJS_PropValue& vp,
                             CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -196,7 +191,7 @@ FX_BOOL Document::numFields(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::dirty(IFXJS_Context* cc,
+FX_BOOL Document::dirty(IJS_Context* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   ASSERT(m_pDocument != NULL);
@@ -220,7 +215,7 @@ FX_BOOL Document::dirty(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::ADBE(IFXJS_Context* cc,
+FX_BOOL Document::ADBE(IJS_Context* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   ASSERT(m_pDocument != NULL);
@@ -233,7 +228,7 @@ FX_BOOL Document::ADBE(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::pageNum(IFXJS_Context* cc,
+FX_BOOL Document::pageNum(IJS_Context* cc,
                           CJS_PropValue& vp,
                           CFX_WideString& sError) {
   ASSERT(m_pDocument != NULL);
@@ -260,12 +255,7 @@ FX_BOOL Document::pageNum(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::ParserParams(JSObject* pObj, CJS_AnnotObj& annotobj) {
-  // Not supported.
-  return TRUE;
-}
-
-FX_BOOL Document::addAnnot(IFXJS_Context* cc,
+FX_BOOL Document::addAnnot(IJS_Context* cc,
                            const CJS_Parameters& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -273,7 +263,7 @@ FX_BOOL Document::addAnnot(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::addField(IFXJS_Context* cc,
+FX_BOOL Document::addField(IJS_Context* cc,
                            const CJS_Parameters& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -281,7 +271,7 @@ FX_BOOL Document::addField(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::exportAsText(IFXJS_Context* cc,
+FX_BOOL Document::exportAsText(IJS_Context* cc,
                                const CJS_Parameters& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError) {
@@ -289,7 +279,7 @@ FX_BOOL Document::exportAsText(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::exportAsFDF(IFXJS_Context* cc,
+FX_BOOL Document::exportAsFDF(IJS_Context* cc,
                               const CJS_Parameters& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
@@ -297,7 +287,7 @@ FX_BOOL Document::exportAsFDF(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::exportAsXFDF(IFXJS_Context* cc,
+FX_BOOL Document::exportAsXFDF(IJS_Context* cc,
                                const CJS_Parameters& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError) {
@@ -310,7 +300,7 @@ FX_BOOL Document::exportAsXFDF(IFXJS_Context* cc,
 // note: the paremter cName, this is clue how to treat if the cName is not a
 // valiable filed name in this document
 
-FX_BOOL Document::getField(IFXJS_Context* cc,
+FX_BOOL Document::getField(IJS_Context* cc,
                            const CJS_Parameters& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -330,11 +320,11 @@ FX_BOOL Document::getField(IFXJS_Context* cc,
   }
 
   CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-  JSFXObject pFieldObj = JS_NewFxDynamicObj(
-      *pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Field"));
+  v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj(
+      pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID);
 
   v8::Isolate* isolate = GetIsolate(cc);
-  CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate, pFieldObj);
+  CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(isolate, pFieldObj);
   Field* pField = (Field*)pJSField->GetEmbedObject();
   pField->AttachField(this, wideName);
 
@@ -343,7 +333,7 @@ FX_BOOL Document::getField(IFXJS_Context* cc,
 }
 
 // Gets the name of the nth field in the document
-FX_BOOL Document::getNthFieldName(IFXJS_Context* cc,
+FX_BOOL Document::getNthFieldName(IJS_Context* cc,
                                   const CJS_Parameters& params,
                                   CJS_Value& vRet,
                                   CFX_WideString& sError) {
@@ -369,7 +359,7 @@ FX_BOOL Document::getNthFieldName(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::importAnFDF(IFXJS_Context* cc,
+FX_BOOL Document::importAnFDF(IJS_Context* cc,
                               const CJS_Parameters& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
@@ -377,7 +367,7 @@ FX_BOOL Document::importAnFDF(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::importAnXFDF(IFXJS_Context* cc,
+FX_BOOL Document::importAnXFDF(IJS_Context* cc,
                                const CJS_Parameters& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError) {
@@ -385,7 +375,7 @@ FX_BOOL Document::importAnXFDF(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::importTextData(IFXJS_Context* cc,
+FX_BOOL Document::importTextData(IJS_Context* cc,
                                  const CJS_Parameters& params,
                                  CJS_Value& vRet,
                                  CFX_WideString& sError) {
@@ -400,7 +390,7 @@ FX_BOOL Document::importTextData(IFXJS_Context* cc,
 // int CPDFSDK_Document::mailForm(FX_BOOL bUI,String cto,string ccc,string
 // cbcc,string cSubject,string cms);
 
-FX_BOOL Document::mailForm(IFXJS_Context* cc,
+FX_BOOL Document::mailForm(IJS_Context* cc,
                            const CJS_Parameters& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -441,15 +431,10 @@ FX_BOOL Document::mailForm(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::print(IFXJS_Context* cc,
+FX_BOOL Document::print(IJS_Context* cc,
                         const CJS_Parameters& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  ASSERT(pContext != NULL);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-  ASSERT(pRuntime != NULL);
-
   FX_BOOL bUI = TRUE;
   int nStart = 0;
   int nEnd = 0;
@@ -461,11 +446,10 @@ FX_BOOL Document::print(IFXJS_Context* cc,
 
   int nlength = params.size();
   if (nlength == 9) {
-    if (params[8].GetType() == VT_fxobject) {
-      JSFXObject pObj = params[8].ToV8Object();
+    if (params[8].GetType() == CJS_Value::VT_fxobject) {
+      v8::Local<v8::Object> pObj = params[8].ToV8Object();
       {
-        if (JS_GetObjDefnID(pObj) ==
-            JS_GetObjDefnID(*pRuntime, L"PrintParamsObj")) {
+        if (FXJS_GetObjDefnID(pObj) == CJS_PrintParamsObj::g_nObjDefnID) {
           if (CJS_Object* pJSObj = params[8].ToCJSObject()) {
             if (PrintParamsObj* pprintparamsObj =
                     (PrintParamsObj*)pJSObj->GetEmbedObject()) {
@@ -515,7 +499,7 @@ FX_BOOL Document::print(IFXJS_Context* cc,
 // comment:
 // note: if the filed name is not retional, adobe is dumb for it.
 
-FX_BOOL Document::removeField(IFXJS_Context* cc,
+FX_BOOL Document::removeField(IJS_Context* cc,
                               const CJS_Parameters& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
@@ -573,12 +557,10 @@ FX_BOOL Document::removeField(IFXJS_Context* cc,
 // comment:
 // note: if the fields names r not rational, aodbe is dumb for it.
 
-FX_BOOL Document::resetForm(IFXJS_Context* cc,
+FX_BOOL Document::resetForm(IJS_Context* cc,
                             const CJS_Parameters& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError) {
-  ASSERT(m_pDocument != NULL);
-
   if (!(m_pDocument->GetPermissions(FPDFPERM_MODIFY) ||
         m_pDocument->GetPermissions(FPDFPERM_ANNOT_FORM) ||
         m_pDocument->GetPermissions(FPDFPERM_FILL_FORM)))
@@ -586,20 +568,16 @@ FX_BOOL Document::resetForm(IFXJS_Context* cc,
 
   CPDFSDK_InterForm* pInterForm =
       (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
-  ASSERT(pInterForm != NULL);
-
   CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
-  ASSERT(pPDFForm != NULL);
-
-  v8::Isolate* isolate = GetIsolate(cc);
-  CJS_Array aName(isolate);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Array aName(pRuntime);
 
   if (params.size() > 0) {
     switch (params[0].GetType()) {
       default:
         aName.Attach(params[0].ToV8Array());
         break;
-      case VT_string:
+      case CJS_Value::VT_string:
         aName.SetElement(0, params[0]);
         break;
     }
@@ -607,10 +585,9 @@ FX_BOOL Document::resetForm(IFXJS_Context* cc,
     CFX_PtrArray aFields;
 
     for (int i = 0, isz = aName.GetLength(); i < isz; i++) {
-      CJS_Value valElement(isolate);
+      CJS_Value valElement(pRuntime);
       aName.GetElement(i, valElement);
       CFX_WideString swVal = valElement.ToCFXWideString();
-
       for (int j = 0, jsz = pPDFForm->CountFields(swVal); j < jsz; j++) {
         aFields.Add((void*)pPDFForm->GetField(j, swVal));
       }
@@ -628,7 +605,7 @@ FX_BOOL Document::resetForm(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::saveAs(IFXJS_Context* cc,
+FX_BOOL Document::saveAs(IJS_Context* cc,
                          const CJS_Parameters& params,
                          CJS_Value& vRet,
                          CFX_WideString& sError) {
@@ -636,11 +613,10 @@ FX_BOOL Document::saveAs(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::submitForm(IFXJS_Context* cc,
+FX_BOOL Document::submitForm(IJS_Context* cc,
                              const CJS_Parameters& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
-  ASSERT(m_pDocument != NULL);
   CJS_Context* pContext = (CJS_Context*)cc;
   int nSize = params.size();
   if (nSize < 1) {
@@ -648,14 +624,15 @@ FX_BOOL Document::submitForm(IFXJS_Context* cc,
     return FALSE;
   }
 
+  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  v8::Isolate* isolate = pRuntime->GetIsolate();
+  CJS_Array aFields(pRuntime);
   CFX_WideString strURL;
   FX_BOOL bFDF = TRUE;
   FX_BOOL bEmpty = FALSE;
-  v8::Isolate* isolate = GetIsolate(cc);
-  CJS_Array aFields(isolate);
 
   CJS_Value v = params[0];
-  if (v.GetType() == VT_string) {
+  if (v.GetType() == CJS_Value::VT_string) {
     strURL = params[0].ToCFXWideString();
     if (nSize > 1)
       bFDF = params[1].ToBool();
@@ -663,22 +640,24 @@ FX_BOOL Document::submitForm(IFXJS_Context* cc,
       bEmpty = params[2].ToBool();
     if (nSize > 3)
       aFields.Attach(params[3].ToV8Array());
-  } else if (v.GetType() == VT_object) {
-    JSObject pObj = params[0].ToV8Object();
-    v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cURL");
+  } else if (v.GetType() == CJS_Value::VT_object) {
+    v8::Local<v8::Object> pObj = params[0].ToV8Object();
+    v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"cURL");
     if (!pValue.IsEmpty())
       strURL =
-          CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
-    pValue = JS_GetObjectElement(isolate, pObj, L"bFDF");
-    bFDF = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
-    pValue = JS_GetObjectElement(isolate, pObj, L"bEmpty");
-    bEmpty = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToBool();
-    pValue = JS_GetObjectElement(isolate, pObj, L"aFields");
+          CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+
+    pValue = FXJS_GetObjectElement(isolate, pObj, L"bFDF");
+    bFDF = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool();
+
+    pValue = FXJS_GetObjectElement(isolate, pObj, L"bEmpty");
+    bEmpty = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToBool();
+
+    pValue = FXJS_GetObjectElement(isolate, pObj, L"aFields");
     aFields.Attach(
-        CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToV8Array());
+        CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToV8Array());
   }
 
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
   CPDFSDK_InterForm* pInterForm =
       (CPDFSDK_InterForm*)m_pDocument->GetInterForm();
   CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
@@ -694,7 +673,7 @@ FX_BOOL Document::submitForm(IFXJS_Context* cc,
 
   CFX_PtrArray fieldObjects;
   for (int i = 0, sz = aFields.GetLength(); i < sz; i++) {
-    CJS_Value valName(isolate);
+    CJS_Value valName(pRuntime);
     aFields.GetElement(i, valName);
 
     CFX_WideString sName = valName.ToCFXWideString();
@@ -736,18 +715,16 @@ FX_BOOL Document::ExtractFolderName(CPDFSDK_Document* pDoc,
   return FALSE;
 }
 
-FX_BOOL Document::bookmarkRoot(IFXJS_Context* cc,
+FX_BOOL Document::bookmarkRoot(IJS_Context* cc,
                                CJS_PropValue& vp,
                                CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::mailDoc(IFXJS_Context* cc,
+FX_BOOL Document::mailDoc(IJS_Context* cc,
                           const CJS_Parameters& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
-  ASSERT(m_pDocument != NULL);
-
   FX_BOOL bUI = TRUE;
   CFX_WideString cTo = L"";
   CFX_WideString cCc = L"";
@@ -768,36 +745,34 @@ FX_BOOL Document::mailDoc(IFXJS_Context* cc,
   if (params.size() >= 6)
     cMsg = params[5].ToCFXWideString();
 
-  v8::Isolate* isolate = GetIsolate(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  v8::Isolate* isolate = pRuntime->GetIsolate();
 
-  if (params.size() >= 1 && params[0].GetType() == VT_object) {
-    JSObject pObj = params[0].ToV8Object();
+  if (params.size() >= 1 && params[0].GetType() == CJS_Value::VT_object) {
+    v8::Local<v8::Object> pObj = params[0].ToV8Object();
 
-    v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"bUI");
-    bUI = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToInt();
+    v8::Local<v8::Value> pValue = FXJS_GetObjectElement(isolate, pObj, L"bUI");
+    bUI = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToInt();
 
-    pValue = JS_GetObjectElement(isolate, pObj, L"cTo");
-    cTo = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+    pValue = FXJS_GetObjectElement(isolate, pObj, L"cTo");
+    cTo = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
 
-    pValue = JS_GetObjectElement(isolate, pObj, L"cCc");
-    cCc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+    pValue = FXJS_GetObjectElement(isolate, pObj, L"cCc");
+    cCc = CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
 
-    pValue = JS_GetObjectElement(isolate, pObj, L"cBcc");
-    cBcc = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+    pValue = FXJS_GetObjectElement(isolate, pObj, L"cBcc");
+    cBcc =
+        CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
 
-    pValue = JS_GetObjectElement(isolate, pObj, L"cSubject");
+    pValue = FXJS_GetObjectElement(isolate, pObj, L"cSubject");
     cSubject =
-        CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+        CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
 
-    pValue = JS_GetObjectElement(isolate, pObj, L"cMsg");
-    cMsg = CJS_Value(isolate, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
+    pValue = FXJS_GetObjectElement(isolate, pObj, L"cMsg");
+    cMsg =
+        CJS_Value(pRuntime, pValue, GET_VALUE_TYPE(pValue)).ToCFXWideString();
   }
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  ASSERT(pContext != NULL);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-  ASSERT(pRuntime != NULL);
-
   pRuntime->BeginBlock();
   CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp();
   pEnv->JS_docmailForm(NULL, 0, bUI, cTo.c_str(), cSubject.c_str(), cCc.c_str(),
@@ -807,12 +782,10 @@ FX_BOOL Document::mailDoc(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::author(IFXJS_Context* cc,
+FX_BOOL Document::author(IJS_Context* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
-  ASSERT(m_pDocument != NULL);
-
-  CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+  CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
   if (!pDictionary)
     return FALSE;
 
@@ -831,12 +804,10 @@ FX_BOOL Document::author(IFXJS_Context* cc,
   }
 }
 
-FX_BOOL Document::info(IFXJS_Context* cc,
+FX_BOOL Document::info(IJS_Context* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
-  ASSERT(m_pDocument != NULL);
-
-  CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+  CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
   if (!pDictionary)
     return FALSE;
 
@@ -854,16 +825,18 @@ FX_BOOL Document::info(IFXJS_Context* cc,
   if (vp.IsGetting()) {
     CJS_Context* pContext = (CJS_Context*)cc;
     CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-    JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext, -1);
-    JS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str());
-    JS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str());
-    JS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str());
-    JS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str());
-    JS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str());
-    JS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str());
-    JS_PutObjectString(isolate, pObj, L"CreationDate", cwCreationDate.c_str());
-    JS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str());
-    JS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str());
+    v8::Local<v8::Object> pObj =
+        FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pRuntime, -1);
+    FXJS_PutObjectString(isolate, pObj, L"Author", cwAuthor.c_str());
+    FXJS_PutObjectString(isolate, pObj, L"Title", cwTitle.c_str());
+    FXJS_PutObjectString(isolate, pObj, L"Subject", cwSubject.c_str());
+    FXJS_PutObjectString(isolate, pObj, L"Keywords", cwKeywords.c_str());
+    FXJS_PutObjectString(isolate, pObj, L"Creator", cwCreator.c_str());
+    FXJS_PutObjectString(isolate, pObj, L"Producer", cwProducer.c_str());
+    FXJS_PutObjectString(isolate, pObj, L"CreationDate",
+                         cwCreationDate.c_str());
+    FXJS_PutObjectString(isolate, pObj, L"ModDate", cwModDate.c_str());
+    FXJS_PutObjectString(isolate, pObj, L"Trapped", cwTrapped.c_str());
 
     // It's to be compatible to non-standard info dictionary.
     FX_POSITION pos = pDictionary->GetStartPos();
@@ -871,26 +844,27 @@ FX_BOOL Document::info(IFXJS_Context* cc,
       CFX_ByteString bsKey;
       CPDF_Object* pValueObj = pDictionary->GetNextElement(pos, bsKey);
       CFX_WideString wsKey = CFX_WideString::FromUTF8(bsKey, bsKey.GetLength());
-      if ((pValueObj->GetType() == PDFOBJ_STRING) ||
-          (pValueObj->GetType() == PDFOBJ_NAME))
-        JS_PutObjectString(isolate, pObj, wsKey.c_str(),
-                           pValueObj->GetUnicodeText().c_str());
-      if (pValueObj->GetType() == PDFOBJ_NUMBER)
-        JS_PutObjectNumber(isolate, pObj, wsKey.c_str(),
-                           (float)pValueObj->GetNumber());
-      if (pValueObj->GetType() == PDFOBJ_BOOLEAN)
-        JS_PutObjectBoolean(isolate, pObj, wsKey.c_str(),
-                            (bool)pValueObj->GetInteger());
+
+      if (pValueObj->IsString() || pValueObj->IsName()) {
+        FXJS_PutObjectString(isolate, pObj, wsKey.c_str(),
+                             pValueObj->GetUnicodeText().c_str());
+      } else if (pValueObj->IsNumber()) {
+        FXJS_PutObjectNumber(isolate, pObj, wsKey.c_str(),
+                             (float)pValueObj->GetNumber());
+      } else if (pValueObj->IsBoolean()) {
+        FXJS_PutObjectBoolean(isolate, pObj, wsKey.c_str(),
+                              (bool)pValueObj->GetInteger());
+      }
     }
     vp << pObj;
   }
   return TRUE;
 }
 
-FX_BOOL Document::creationDate(IFXJS_Context* cc,
+FX_BOOL Document::creationDate(IJS_Context* cc,
                                CJS_PropValue& vp,
                                CFX_WideString& sError) {
-  CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+  CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
   if (!pDictionary)
     return FALSE;
 
@@ -908,10 +882,10 @@ FX_BOOL Document::creationDate(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::creator(IFXJS_Context* cc,
+FX_BOOL Document::creator(IJS_Context* cc,
                           CJS_PropValue& vp,
                           CFX_WideString& sError) {
-  CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+  CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
   if (!pDictionary)
     return FALSE;
 
@@ -929,7 +903,7 @@ FX_BOOL Document::creator(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::delay(IFXJS_Context* cc,
+FX_BOOL Document::delay(IJS_Context* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   if (vp.IsGetting()) {
@@ -964,10 +938,10 @@ FX_BOOL Document::delay(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::keywords(IFXJS_Context* cc,
+FX_BOOL Document::keywords(IJS_Context* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
-  CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+  CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
   if (!pDictionary)
     return FALSE;
 
@@ -985,10 +959,10 @@ FX_BOOL Document::keywords(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::modDate(IFXJS_Context* cc,
+FX_BOOL Document::modDate(IJS_Context* cc,
                           CJS_PropValue& vp,
                           CFX_WideString& sError) {
-  CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+  CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
   if (!pDictionary)
     return FALSE;
 
@@ -1006,10 +980,10 @@ FX_BOOL Document::modDate(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::producer(IFXJS_Context* cc,
+FX_BOOL Document::producer(IJS_Context* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
-  CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+  CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
   if (!pDictionary)
     return FALSE;
 
@@ -1027,10 +1001,10 @@ FX_BOOL Document::producer(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::subject(IFXJS_Context* cc,
+FX_BOOL Document::subject(IJS_Context* cc,
                           CJS_PropValue& vp,
                           CFX_WideString& sError) {
-  CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+  CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
   if (!pDictionary)
     return FALSE;
 
@@ -1048,13 +1022,13 @@ FX_BOOL Document::subject(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::title(IFXJS_Context* cc,
+FX_BOOL Document::title(IJS_Context* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
-  if (m_pDocument == NULL || m_pDocument->GetDocument() == NULL)
+  if (m_pDocument == NULL || m_pDocument->GetPDFDocument() == NULL)
     return FALSE;
 
-  CPDF_Dictionary* pDictionary = m_pDocument->GetDocument()->GetInfo();
+  CPDF_Dictionary* pDictionary = m_pDocument->GetPDFDocument()->GetInfo();
   if (!pDictionary)
     return FALSE;
 
@@ -1072,7 +1046,7 @@ FX_BOOL Document::title(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::numPages(IFXJS_Context* cc,
+FX_BOOL Document::numPages(IJS_Context* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1084,7 +1058,7 @@ FX_BOOL Document::numPages(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::external(IFXJS_Context* cc,
+FX_BOOL Document::external(IJS_Context* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
   // In Chrome case,should always return true.
@@ -1094,7 +1068,7 @@ FX_BOOL Document::external(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::filesize(IFXJS_Context* cc,
+FX_BOOL Document::filesize(IJS_Context* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1106,19 +1080,19 @@ FX_BOOL Document::filesize(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::mouseX(IFXJS_Context* cc,
+FX_BOOL Document::mouseX(IJS_Context* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::mouseY(IFXJS_Context* cc,
+FX_BOOL Document::mouseY(IJS_Context* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::baseURL(IFXJS_Context* cc,
+FX_BOOL Document::baseURL(IJS_Context* cc,
                           CJS_PropValue& vp,
                           CFX_WideString& sError) {
   if (vp.IsGetting()) {
@@ -1129,7 +1103,7 @@ FX_BOOL Document::baseURL(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::calculate(IFXJS_Context* cc,
+FX_BOOL Document::calculate(IJS_Context* cc,
                             CJS_PropValue& vp,
                             CFX_WideString& sError) {
   ASSERT(m_pDocument != NULL);
@@ -1153,7 +1127,7 @@ FX_BOOL Document::calculate(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::documentFileName(IFXJS_Context* cc,
+FX_BOOL Document::documentFileName(IJS_Context* cc,
                                    CJS_PropValue& vp,
                                    CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1217,7 +1191,7 @@ CFX_WideString Document::CutString(CFX_WideString cbFrom) {
   return cbRet;
 }
 
-FX_BOOL Document::path(IFXJS_Context* cc,
+FX_BOOL Document::path(IJS_Context* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1229,26 +1203,26 @@ FX_BOOL Document::path(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::pageWindowRect(IFXJS_Context* cc,
+FX_BOOL Document::pageWindowRect(IJS_Context* cc,
                                  CJS_PropValue& vp,
                                  CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::layout(IFXJS_Context* cc,
+FX_BOOL Document::layout(IJS_Context* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::addLink(IFXJS_Context* cc,
+FX_BOOL Document::addLink(IJS_Context* cc,
                           const CJS_Parameters& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::closeDoc(IFXJS_Context* cc,
+FX_BOOL Document::closeDoc(IJS_Context* cc,
                            const CJS_Parameters& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -1256,21 +1230,21 @@ FX_BOOL Document::closeDoc(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::getPageBox(IFXJS_Context* cc,
+FX_BOOL Document::getPageBox(IJS_Context* cc,
                              const CJS_Parameters& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::getAnnot(IFXJS_Context* cc,
+FX_BOOL Document::getAnnot(IJS_Context* cc,
                            const CJS_Parameters& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::getAnnots(IFXJS_Context* cc,
+FX_BOOL Document::getAnnots(IJS_Context* cc,
                             const CJS_Parameters& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError) {
@@ -1278,7 +1252,7 @@ FX_BOOL Document::getAnnots(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::getAnnot3D(IFXJS_Context* cc,
+FX_BOOL Document::getAnnot3D(IJS_Context* cc,
                              const CJS_Parameters& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
@@ -1286,22 +1260,22 @@ FX_BOOL Document::getAnnot3D(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::getAnnots3D(IFXJS_Context* cc,
+FX_BOOL Document::getAnnots3D(IJS_Context* cc,
                               const CJS_Parameters& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
-  vRet = VT_undefined;
+  vRet = CJS_Value::VT_undefined;
   return TRUE;
 }
 
-FX_BOOL Document::getOCGs(IFXJS_Context* cc,
+FX_BOOL Document::getOCGs(IJS_Context* cc,
                           const CJS_Parameters& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::getLinks(IFXJS_Context* cc,
+FX_BOOL Document::getLinks(IJS_Context* cc,
                            const CJS_Parameters& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -1358,7 +1332,7 @@ IconElement* IconTree::operator[](int iIndex) {
   return NULL;
 }
 
-FX_BOOL Document::addIcon(IFXJS_Context* cc,
+FX_BOOL Document::addIcon(IJS_Context* cc,
                           const CJS_Parameters& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
@@ -1369,14 +1343,13 @@ FX_BOOL Document::addIcon(IFXJS_Context* cc,
   }
   CFX_WideString swIconName = params[0].ToCFXWideString();
 
-  if (params[1].GetType() != VT_object) {
+  if (params[1].GetType() != CJS_Value::VT_object) {
     sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
     return FALSE;
   }
-  JSFXObject pJSIcon = params[1].ToV8Object();
 
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-  if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) {
+  v8::Local<v8::Object> pJSIcon = params[1].ToV8Object();
+  if (FXJS_GetObjDefnID(pJSIcon) != CJS_Icon::g_nObjDefnID) {
     sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
     return FALSE;
   }
@@ -1399,7 +1372,7 @@ FX_BOOL Document::addIcon(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::icons(IFXJS_Context* cc,
+FX_BOOL Document::icons(IJS_Context* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1413,22 +1386,19 @@ FX_BOOL Document::icons(IFXJS_Context* cc,
     return TRUE;
   }
 
-  CJS_Array Icons(m_isolate);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Array Icons(pRuntime);
   IconElement* pIconElement = NULL;
   int iIconTreeLength = m_pIconTree->GetLength();
-
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-
   for (int i = 0; i < iIconTreeLength; i++) {
     pIconElement = (*m_pIconTree)[i];
 
-    JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext,
-                                         JS_GetObjDefnID(*pRuntime, L"Icon"));
+    v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
+        pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID);
     if (pObj.IsEmpty())
       return FALSE;
 
-    CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj);
+    CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj);
     if (!pJS_Icon)
       return FALSE;
 
@@ -1438,14 +1408,14 @@ FX_BOOL Document::icons(IFXJS_Context* cc,
 
     pIcon->SetStream(pIconElement->IconStream->GetStream());
     pIcon->SetIconName(pIconElement->IconName);
-    Icons.SetElement(i, CJS_Value(m_isolate, pJS_Icon));
+    Icons.SetElement(i, CJS_Value(pRuntime, pJS_Icon));
   }
 
   vp << Icons;
   return TRUE;
 }
 
-FX_BOOL Document::getIcon(IFXJS_Context* cc,
+FX_BOOL Document::getIcon(IJS_Context* cc,
                           const CJS_Parameters& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
@@ -1466,12 +1436,12 @@ FX_BOOL Document::getIcon(IFXJS_Context* cc,
     if ((*m_pIconTree)[i]->IconName == swIconName) {
       Icon* pRetIcon = (*m_pIconTree)[i]->IconStream;
 
-      JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext,
-                                           JS_GetObjDefnID(*pRuntime, L"Icon"));
+      v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
+          pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID);
       if (pObj.IsEmpty())
         return FALSE;
 
-      CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj);
+      CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(m_isolate, pObj);
       if (!pJS_Icon)
         return FALSE;
 
@@ -1489,7 +1459,7 @@ FX_BOOL Document::getIcon(IFXJS_Context* cc,
   return FALSE;
 }
 
-FX_BOOL Document::removeIcon(IFXJS_Context* cc,
+FX_BOOL Document::removeIcon(IJS_Context* cc,
                              const CJS_Parameters& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
@@ -1497,7 +1467,7 @@ FX_BOOL Document::removeIcon(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::createDataObject(IFXJS_Context* cc,
+FX_BOOL Document::createDataObject(IJS_Context* cc,
                                    const CJS_Parameters& params,
                                    CJS_Value& vRet,
                                    CFX_WideString& sError) {
@@ -1505,13 +1475,13 @@ FX_BOOL Document::createDataObject(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::media(IFXJS_Context* cc,
+FX_BOOL Document::media(IJS_Context* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::calculateNow(IFXJS_Context* cc,
+FX_BOOL Document::calculateNow(IJS_Context* cc,
                                const CJS_Parameters& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError) {
@@ -1529,13 +1499,13 @@ FX_BOOL Document::calculateNow(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::Collab(IFXJS_Context* cc,
+FX_BOOL Document::Collab(IJS_Context* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::getPageNthWord(IFXJS_Context* cc,
+FX_BOOL Document::getPageNthWord(IJS_Context* cc,
                                  const CJS_Parameters& params,
                                  CJS_Value& vRet,
                                  CFX_WideString& sError) {
@@ -1548,7 +1518,7 @@ FX_BOOL Document::getPageNthWord(IFXJS_Context* cc,
   int nWordNo = params.GetSize() > 1 ? params[1].ToInt() : 0;
   bool bStrip = params.GetSize() > 2 ? params[2].ToBool() : true;
 
-  CPDF_Document* pDocument = m_pDocument->GetDocument();
+  CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
   if (!pDocument)
     return FALSE;
 
@@ -1597,7 +1567,7 @@ FX_BOOL Document::getPageNthWord(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::getPageNthWordQuads(IFXJS_Context* cc,
+FX_BOOL Document::getPageNthWordQuads(IJS_Context* cc,
                                       const CJS_Parameters& params,
                                       CJS_Value& vRet,
                                       CFX_WideString& sError) {
@@ -1609,7 +1579,7 @@ FX_BOOL Document::getPageNthWordQuads(IFXJS_Context* cc,
   return FALSE;
 }
 
-FX_BOOL Document::getPageNumWords(IFXJS_Context* cc,
+FX_BOOL Document::getPageNumWords(IJS_Context* cc,
                                   const CJS_Parameters& params,
                                   CJS_Value& vRet,
                                   CFX_WideString& sError) {
@@ -1620,7 +1590,7 @@ FX_BOOL Document::getPageNumWords(IFXJS_Context* cc,
 
   int nPageNo = params.GetSize() > 0 ? params[0].ToInt() : 0;
 
-  CPDF_Document* pDocument = m_pDocument->GetDocument();
+  CPDF_Document* pDocument = m_pDocument->GetPDFDocument();
   ASSERT(pDocument != NULL);
 
   CJS_Context* pContext = static_cast<CJS_Context*>(cc);
@@ -1656,14 +1626,14 @@ FX_BOOL Document::getPageNumWords(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::getPrintParams(IFXJS_Context* cc,
+FX_BOOL Document::getPrintParams(IJS_Context* cc,
                                  const CJS_Parameters& params,
                                  CJS_Value& vRet,
                                  CFX_WideString& sError) {
   CJS_Context* pContext = (CJS_Context*)cc;
   CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-  JSFXObject pRetObj = JS_NewFxDynamicObj(
-      *pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"PrintParamsObj"));
+  v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
+      pRuntime->GetIsolate(), pRuntime, CJS_PrintParamsObj::g_nObjDefnID);
 
   // Not implemented yet.
 
@@ -1745,7 +1715,7 @@ CFX_WideString Document::GetObjWordStr(CPDF_TextObject* pTextObj,
   return swRet;
 }
 
-FX_BOOL Document::zoom(IFXJS_Context* cc,
+FX_BOOL Document::zoom(IJS_Context* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   return TRUE;
@@ -1761,13 +1731,13 @@ FX_BOOL Document::zoom(IFXJS_Context* cc,
 (refW,  ReflowWidth)
 */
 
-FX_BOOL Document::zoomType(IFXJS_Context* cc,
+FX_BOOL Document::zoomType(IJS_Context* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
   return TRUE;
 }
 
-FX_BOOL Document::deletePages(IFXJS_Context* cc,
+FX_BOOL Document::deletePages(IJS_Context* cc,
                               const CJS_Parameters& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
@@ -1775,7 +1745,7 @@ FX_BOOL Document::deletePages(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::extractPages(IFXJS_Context* cc,
+FX_BOOL Document::extractPages(IJS_Context* cc,
                                const CJS_Parameters& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError) {
@@ -1783,7 +1753,7 @@ FX_BOOL Document::extractPages(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::insertPages(IFXJS_Context* cc,
+FX_BOOL Document::insertPages(IJS_Context* cc,
                               const CJS_Parameters& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
@@ -1791,7 +1761,7 @@ FX_BOOL Document::insertPages(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::replacePages(IFXJS_Context* cc,
+FX_BOOL Document::replacePages(IJS_Context* cc,
                                const CJS_Parameters& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError) {
@@ -1799,7 +1769,7 @@ FX_BOOL Document::replacePages(IFXJS_Context* cc,
   return TRUE;
 }
 
-FX_BOOL Document::getURL(IFXJS_Context* cc,
+FX_BOOL Document::getURL(IJS_Context* cc,
                          const CJS_Parameters& params,
                          CJS_Value& vRet,
                          CFX_WideString& sError) {