summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-09-10 11:56:37 -0700
committerTom Sepez <tsepez@chromium.org>2015-09-10 11:56:37 -0700
commit6df59849472958e7de96da6d9fc7b223b7c1f1c3 (patch)
tree90b4908f6de484252f9757010b7002c4f0365a58 /fpdfsdk/src/javascript
parent0d0935d3d6603dd7d851b1d5828635230f4c43ca (diff)
downloadpdfium-6df59849472958e7de96da6d9fc7b223b7c1f1c3.tar.xz
Remove some abstractions in fxjs_v8.h.
It's too hard to keep mapping between v8 and fx abstractions; the lack of transparency prevents those skilled in v8 only from working on this code. Apparently, the original intention was to confine v8 types to fpdfsdk/{include,src}/jsapi, but fpdfsdk/{include,src}/javascript is already well-polluted with v8 types. Also remove no-op JS_SetThisObj(). Also remove unused ParserParams() [noticed because it was incorrectly passing handles as pointers]. Also remove cast operator from CJS_Runtime and call GetIsolate() explicitly. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1332973002 .
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r--fpdfsdk/src/javascript/Consts.cpp48
-rw-r--r--fpdfsdk/src/javascript/Document.cpp41
-rw-r--r--fpdfsdk/src/javascript/Field.cpp10
-rw-r--r--fpdfsdk/src/javascript/JS_Context.cpp4
-rw-r--r--fpdfsdk/src/javascript/JS_EventHandler.cpp20
-rw-r--r--fpdfsdk/src/javascript/JS_Object.cpp2
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp61
-rw-r--r--fpdfsdk/src/javascript/JS_Value.cpp12
-rw-r--r--fpdfsdk/src/javascript/app.cpp36
-rw-r--r--fpdfsdk/src/javascript/global.cpp37
10 files changed, 141 insertions, 130 deletions
diff --git a/fpdfsdk/src/javascript/Consts.cpp b/fpdfsdk/src/javascript/Consts.cpp
index 4529f013fe..77cf445d77 100644
--- a/fpdfsdk/src/javascript/Consts.cpp
+++ b/fpdfsdk/src/javascript/Consts.cpp
@@ -130,28 +130,28 @@ IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype)
/* ------------------------------ CJS_GlobalConsts
* ------------------------------ */
-int CJS_GlobalConsts::Init(IJS_Runtime* pRuntime) {
- DEFINE_GLOBAL_CONST(pRuntime, IDS_GREATER_THAN, Invalid value
+int CJS_GlobalConsts::Init(v8::Isolate* pIsolate) {
+ DEFINE_GLOBAL_CONST(pIsolate, IDS_GREATER_THAN, Invalid value
: must be greater than or equal to % s.);
DEFINE_GLOBAL_CONST(
- pRuntime, IDS_GT_AND_LT, Invalid value
+ pIsolate, IDS_GT_AND_LT, Invalid value
: must be greater than or equal to % s and less than or equal to % s.);
- DEFINE_GLOBAL_CONST(pRuntime, IDS_LESS_THAN, Invalid value
+ DEFINE_GLOBAL_CONST(pIsolate, IDS_LESS_THAN, Invalid value
: must be less than or equal to % s.);
- DEFINE_GLOBAL_CONST(pRuntime, IDS_INVALID_MONTH, **Invalid**);
- DEFINE_GLOBAL_CONST(pRuntime, IDS_INVALID_DATE, Invalid date / time
+ DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_MONTH, **Invalid**);
+ DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_DATE, Invalid date / time
: please ensure that the date / time exists.Field);
- DEFINE_GLOBAL_CONST(pRuntime, IDS_INVALID_VALUE,
+ DEFINE_GLOBAL_CONST(pIsolate, IDS_INVALID_VALUE,
The value entered does not match the format of the field);
- DEFINE_GLOBAL_CONST(pRuntime, IDS_AM, am);
- DEFINE_GLOBAL_CONST(pRuntime, IDS_PM, pm);
+ DEFINE_GLOBAL_CONST(pIsolate, IDS_AM, am);
+ DEFINE_GLOBAL_CONST(pIsolate, IDS_PM, pm);
DEFINE_GLOBAL_CONST(
- pRuntime, IDS_MONTH_INFO,
+ pIsolate, IDS_MONTH_INFO,
January[1] February[2] March[3] April[4] May[5] June[6] July[7] August
[8] September[9] October[10] November[11] December[12] Sept[9] Jan
[1] Feb[2] Mar[3] Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov
[11] Dec[12]);
- DEFINE_GLOBAL_CONST(pRuntime, IDS_STARTUP_CONSOLE_MSG, ** ^ _ ^ **);
+ DEFINE_GLOBAL_CONST(pIsolate, IDS_STARTUP_CONSOLE_MSG, ** ^ _ ^ **);
return 0;
}
@@ -159,11 +159,11 @@ int CJS_GlobalConsts::Init(IJS_Runtime* pRuntime) {
/* ------------------------------ CJS_GlobalArrays
* ------------------------------ */
-int CJS_GlobalArrays::Init(IJS_Runtime* pRuntime) {
+int CJS_GlobalArrays::Init(v8::Isolate* pIsolate) {
{
const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP";
const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
@@ -173,14 +173,14 @@ int CJS_GlobalArrays::Init(IJS_Runtime* pRuntime) {
L"[+-]?\\.\\d+", /* -.1 */
L"[+-]?\\d+\\." /* -1. */
};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_COMMA_SEP";
const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*,?\\d*"};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
@@ -190,31 +190,31 @@ int CJS_GlobalArrays::Init(IJS_Runtime* pRuntime) {
L"[+-]?[.,]\\d+", /* -,1 */
L"[+-]?\\d+[.,]" /* -1, */
};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
const FX_WCHAR* ArrayName = L"RE_ZIP_ENTRY";
const FX_WCHAR* ArrayContent[] = {L"\\d{0,5}"};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
const FX_WCHAR* ArrayName = L"RE_ZIP_COMMIT";
const FX_WCHAR* ArrayContent[] = {L"\\d{5}"};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
const FX_WCHAR* ArrayName = L"RE_ZIP4_ENTRY";
const FX_WCHAR* ArrayContent[] = {L"\\d{0,5}(\\.|[- ])?\\d{0,4}"};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
const FX_WCHAR* ArrayName = L"RE_ZIP4_COMMIT";
const FX_WCHAR* ArrayContent[] = {L"\\d{5}(\\.|[- ])?\\d{4}"};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
@@ -232,7 +232,7 @@ int CJS_GlobalArrays::Init(IJS_Runtime* pRuntime) {
*/
L"011(\\.|[- \\d])*" /* international */
};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
@@ -243,21 +243,21 @@ int CJS_GlobalArrays::Init(IJS_Runtime* pRuntime) {
L"\\(\\d{3}\\)(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", /* (408) 555-1234 */
L"011(\\.|[- \\d])*" /* international */
};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
const FX_WCHAR* ArrayName = L"RE_SSN_ENTRY";
const FX_WCHAR* ArrayContent[] = {
L"\\d{0,3}(\\.|[- ])?\\d{0,2}(\\.|[- ])?\\d{0,4}"};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
{
const FX_WCHAR* ArrayName = L"RE_SSN_COMMIT";
const FX_WCHAR* ArrayContent[] = {
L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"};
- DEFINE_GLOBAL_ARRAY(pRuntime);
+ DEFINE_GLOBAL_ARRAY(pIsolate);
}
return 0;
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index 91805b825e..a8a4ebc491 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -260,11 +260,6 @@ 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,
const CJS_Parameters& params,
CJS_Value& vRet,
@@ -330,8 +325,9 @@ 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 =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
v8::Isolate* isolate = GetIsolate(cc);
CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(isolate, pFieldObj);
@@ -462,10 +458,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();
+ v8::Local<v8::Object> pObj = params[8].ToV8Object();
{
if (JS_GetObjDefnID(pObj) ==
- JS_GetObjDefnID(*pRuntime, L"PrintParamsObj")) {
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")) {
if (CJS_Object* pJSObj = params[8].ToCJSObject()) {
if (PrintParamsObj* pprintparamsObj =
(PrintParamsObj*)pJSObj->GetEmbedObject()) {
@@ -664,7 +660,7 @@ FX_BOOL Document::submitForm(IFXJS_Context* cc,
if (nSize > 3)
aFields.Attach(params[3].ToV8Array());
} else if (v.GetType() == VT_object) {
- JSObject pObj = params[0].ToV8Object();
+ v8::Local<v8::Object> pObj = params[0].ToV8Object();
v8::Local<v8::Value> pValue = JS_GetObjectElement(isolate, pObj, L"cURL");
if (!pValue.IsEmpty())
strURL =
@@ -771,7 +767,7 @@ FX_BOOL Document::mailDoc(IFXJS_Context* cc,
v8::Isolate* isolate = GetIsolate(cc);
if (params.size() >= 1 && params[0].GetType() == VT_object) {
- JSObject pObj = params[0].ToV8Object();
+ 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();
@@ -854,7 +850,8 @@ 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);
+ v8::Local<v8::Object> pObj =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), 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());
@@ -1373,10 +1370,11 @@ FX_BOOL Document::addIcon(IFXJS_Context* cc,
sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
return FALSE;
}
- JSFXObject pJSIcon = params[1].ToV8Object();
+ v8::Local<v8::Object> pJSIcon = params[1].ToV8Object();
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- if (JS_GetObjDefnID(pJSIcon) != JS_GetObjDefnID(*pRuntime, L"Icon")) {
+ if (JS_GetObjDefnID(pJSIcon) !=
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
return FALSE;
}
@@ -1423,8 +1421,9 @@ FX_BOOL Document::icons(IFXJS_Context* cc,
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 =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon"));
if (pObj.IsEmpty())
return FALSE;
@@ -1466,8 +1465,9 @@ 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 =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon"));
if (pObj.IsEmpty())
return FALSE;
@@ -1662,8 +1662,9 @@ FX_BOOL Document::getPrintParams(IFXJS_Context* cc,
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 = JS_NewFxDynamicObj(
+ pRuntime->GetIsolate(), pContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj"));
// Not implemented yet.
diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp
index c44636872b..a0570cb56c 100644
--- a/fpdfsdk/src/javascript/Field.cpp
+++ b/fpdfsdk/src/javascript/Field.cpp
@@ -3315,8 +3315,9 @@ FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc,
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
ASSERT(pRuntime != NULL);
- JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext,
- JS_GetObjDefnID(*pRuntime, L"Icon"));
+ v8::Local<v8::Object> pObj =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon"));
ASSERT(pObj.IsEmpty() == FALSE);
CJS_Icon* pJS_Icon = (CJS_Icon*)JS_GetPrivate(pObj);
@@ -3530,8 +3531,9 @@ FX_BOOL Field::getArray(IFXJS_Context* cc,
for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) {
CFX_WideString* pStr = swSort.GetAt(j);
- JSFXObject pObj = JS_NewFxDynamicObj(*pRuntime, pContext,
- JS_GetObjDefnID(*pRuntime, L"Field"));
+ v8::Local<v8::Object> pObj =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
ASSERT(pObj.IsEmpty() == FALSE);
CJS_Field* pJSField = (CJS_Field*)JS_GetPrivate(pObj);
diff --git a/fpdfsdk/src/javascript/JS_Context.cpp b/fpdfsdk/src/javascript/JS_Context.cpp
index 1e42b50138..2bee913ed7 100644
--- a/fpdfsdk/src/javascript/JS_Context.cpp
+++ b/fpdfsdk/src/javascript/JS_Context.cpp
@@ -55,8 +55,8 @@ FX_BOOL CJS_Context::RunScript(const CFX_WideString& script,
FXJSErr error = {NULL, NULL, 0};
int nRet = 0;
if (script.GetLength() > 0) {
- nRet = JS_Execute(*m_pRuntime, this, script.c_str(), script.GetLength(),
- &error);
+ nRet = JS_Execute(m_pRuntime->GetIsolate(), this, script.c_str(),
+ script.GetLength(), &error);
}
if (nRet < 0) {
diff --git a/fpdfsdk/src/javascript/JS_EventHandler.cpp b/fpdfsdk/src/javascript/JS_EventHandler.cpp
index 1eee92ddc1..acaacf2943 100644
--- a/fpdfsdk/src/javascript/JS_EventHandler.cpp
+++ b/fpdfsdk/src/javascript/JS_EventHandler.cpp
@@ -615,11 +615,13 @@ Field* CJS_EventHandler::Source() {
CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
- JSFXObject pDocObj = JS_NewFxDynamicObj(
- *pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Document"));
+ v8::Local<v8::Object> pDocObj =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
ASSERT(pDocObj.IsEmpty() == FALSE);
- JSFXObject pFieldObj = JS_NewFxDynamicObj(
- *pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Field"));
+ v8::Local<v8::Object> pFieldObj =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
ASSERT(pFieldObj.IsEmpty() == FALSE);
CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj);
@@ -650,11 +652,13 @@ Field* CJS_EventHandler::Target_Field() {
CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
- JSFXObject pDocObj = JS_NewFxDynamicObj(
- *pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Document"));
+ v8::Local<v8::Object> pDocObj =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
ASSERT(pDocObj.IsEmpty() == FALSE);
- JSFXObject pFieldObj = JS_NewFxDynamicObj(
- *pRuntime, m_pJSContext, JS_GetObjDefnID(*pRuntime, L"Field"));
+ v8::Local<v8::Object> pFieldObj =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
ASSERT(pFieldObj.IsEmpty() == FALSE);
CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pDocObj);
diff --git a/fpdfsdk/src/javascript/JS_Object.cpp b/fpdfsdk/src/javascript/JS_Object.cpp
index 02978982d8..17e987d96a 100644
--- a/fpdfsdk/src/javascript/JS_Object.cpp
+++ b/fpdfsdk/src/javascript/JS_Object.cpp
@@ -83,7 +83,7 @@ void DisposeObject(const v8::WeakCallbackInfo<CJS_Object>& data) {
data.SetSecondPassCallback(FreeObject);
}
-CJS_Object::CJS_Object(JSFXObject pObject) : m_pEmbedObj(NULL) {
+CJS_Object::CJS_Object(v8::Local<v8::Object> pObject) : m_pEmbedObj(NULL) {
v8::Local<v8::Context> context = pObject->CreationContext();
m_pIsolate = context->GetIsolate();
m_pObject.Reset(m_pIsolate, pObject);
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 4ef34a8d20..e3b3ed0f49 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -116,7 +116,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
InitJSObjects();
CJS_Context* pContext = (CJS_Context*)NewContext();
- JS_InitialRuntime(*this, this, pContext, m_context);
+ JS_InitialRuntime(GetIsolate(), this, pContext, m_context);
ReleaseContext(pContext);
}
@@ -125,9 +125,7 @@ CJS_Runtime::~CJS_Runtime() {
delete m_ContextArray.GetAt(i);
m_ContextArray.RemoveAll();
-
- JS_ReleaseRuntime(*this, m_context);
-
+ JS_ReleaseRuntime(GetIsolate(), m_context);
RemoveEventsInLoop(m_pFieldEventPath);
m_pApp = NULL;
@@ -145,59 +143,59 @@ FX_BOOL CJS_Runtime::InitJSObjects() {
v8::Local<v8::Context> context = v8::Context::New(GetIsolate());
v8::Context::Scope context_scope(context);
// 0 - 8
- if (CJS_Border::Init(*this, JS_STATIC) < 0)
+ if (CJS_Border::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Display::Init(*this, JS_STATIC) < 0)
+ if (CJS_Display::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Font::Init(*this, JS_STATIC) < 0)
+ if (CJS_Font::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Highlight::Init(*this, JS_STATIC) < 0)
+ if (CJS_Highlight::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Position::Init(*this, JS_STATIC) < 0)
+ if (CJS_Position::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_ScaleHow::Init(*this, JS_STATIC) < 0)
+ if (CJS_ScaleHow::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_ScaleWhen::Init(*this, JS_STATIC) < 0)
+ if (CJS_ScaleWhen::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Style::Init(*this, JS_STATIC) < 0)
+ if (CJS_Style::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Zoomtype::Init(*this, JS_STATIC) < 0)
+ if (CJS_Zoomtype::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
// 9 - 11
- if (CJS_App::Init(*this, JS_STATIC) < 0)
+ if (CJS_App::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Color::Init(*this, JS_STATIC) < 0)
+ if (CJS_Color::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Console::Init(*this, JS_STATIC) < 0)
+ if (CJS_Console::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
// 12 - 14
- if (CJS_Document::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_Document::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
- if (CJS_Event::Init(*this, JS_STATIC) < 0)
+ if (CJS_Event::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Field::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_Field::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
// 15 - 17
- if (CJS_Global::Init(*this, JS_STATIC) < 0)
+ if (CJS_Global::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_Icon::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_Icon::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
- if (CJS_Util::Init(*this, JS_STATIC) < 0)
+ if (CJS_Util::Init(GetIsolate(), JS_STATIC) < 0)
return FALSE;
- if (CJS_PublicMethods::Init(*this) < 0)
+ if (CJS_PublicMethods::Init(GetIsolate()) < 0)
return FALSE;
- if (CJS_GlobalConsts::Init(*this) < 0)
+ if (CJS_GlobalConsts::Init(GetIsolate()) < 0)
return FALSE;
- if (CJS_GlobalArrays::Init(*this) < 0)
+ if (CJS_GlobalArrays::Init(GetIsolate()) < 0)
return FALSE;
- if (CJS_TimerObj::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_TimerObj::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
- if (CJS_PrintParamsObj::Init(*this, JS_DYNAMIC) < 0)
+ if (CJS_PrintParamsObj::Init(GetIsolate(), JS_DYNAMIC) < 0)
return FALSE;
return TRUE;
@@ -236,20 +234,17 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
v8::Context::Scope context_scope(context);
m_pDocument = pReaderDoc;
-
if (pReaderDoc) {
- JSObject pThis = JS_GetThisObj(*this);
+ v8::Local<v8::Object> pThis = JS_GetThisObj(GetIsolate());
if (!pThis.IsEmpty()) {
- if (JS_GetObjDefnID(pThis) == JS_GetObjDefnID(*this, L"Document")) {
+ if (JS_GetObjDefnID(pThis) ==
+ JS_GetObjDefnID(GetIsolate(), L"Document")) {
if (CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pThis)) {
if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject())
pDocument->AttachDoc(pReaderDoc);
}
}
}
- JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"Document"));
- } else {
- JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"app"));
}
}
}
diff --git a/fpdfsdk/src/javascript/JS_Value.cpp b/fpdfsdk/src/javascript/JS_Value.cpp
index faa1eeb6fc..7fb2116e1f 100644
--- a/fpdfsdk/src/javascript/JS_Value.cpp
+++ b/fpdfsdk/src/javascript/JS_Value.cpp
@@ -39,7 +39,7 @@ CJS_Value::CJS_Value(v8::Isolate* isolate, const double& dValue)
operator=(dValue);
}
-CJS_Value::CJS_Value(v8::Isolate* isolate, JSFXObject pJsObj)
+CJS_Value::CJS_Value(v8::Isolate* isolate, v8::Local<v8::Object> pJsObj)
: m_isolate(isolate) {
operator=(pJsObj);
}
@@ -53,7 +53,7 @@ CJS_Value::CJS_Value(v8::Isolate* isolate, CJS_Document* pJsDoc)
: m_isolate(isolate) {
m_eType = VT_object;
if (pJsDoc)
- m_pValue = (JSFXObject)*pJsDoc;
+ m_pValue = (v8::Local<v8::Object>)*pJsDoc;
}
CJS_Value::CJS_Value(v8::Isolate* isolate, const FX_WCHAR* pWstr)
@@ -168,13 +168,13 @@ void CJS_Value::operator=(v8::Local<v8::Object> pObj) {
void CJS_Value::operator=(CJS_Object* pObj) {
if (pObj)
- operator=((JSFXObject)*pObj);
+ operator=((v8::Local<v8::Object>)*pObj);
}
void CJS_Value::operator=(CJS_Document* pJsDoc) {
m_eType = VT_object;
if (pJsDoc) {
- m_pValue = static_cast<JSFXObject>(*pJsDoc);
+ m_pValue = static_cast<v8::Local<v8::Object>>(*pJsDoc);
}
}
@@ -341,12 +341,12 @@ void CJS_PropValue::operator>>(CJS_Document*& ppJsDoc) const {
ppJsDoc = static_cast<CJS_Document*>(CJS_Value::ToCJSObject());
}
-void CJS_PropValue::operator<<(JSFXObject pObj) {
+void CJS_PropValue::operator<<(v8::Local<v8::Object> pObj) {
ASSERT(!m_bIsSetting);
CJS_Value::operator=(pObj);
}
-void CJS_PropValue::operator>>(JSFXObject& ppObj) const {
+void CJS_PropValue::operator>>(v8::Local<v8::Object>& ppObj) const {
ASSERT(m_bIsSetting);
ppObj = CJS_Value::ToV8Object();
}
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 6db5d9a97f..a6794514d9 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -122,13 +122,15 @@ FX_BOOL app::activeDocs(IFXJS_Context* cc,
if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) {
CJS_Document* pJSDocument = NULL;
if (pDoc == pCurDoc) {
- JSFXObject pObj = JS_GetThisObj(*pRuntime);
- if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"Document"))
+ v8::Local<v8::Object> pObj = JS_GetThisObj(pRuntime->GetIsolate());
+ if (JS_GetObjDefnID(pObj) ==
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"))
pJSDocument =
(CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(), pObj);
} else {
- JSFXObject pObj = JS_NewFxDynamicObj(
- *pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"Document"));
+ v8::Local<v8::Object> pObj = JS_NewFxDynamicObj(
+ pRuntime->GetIsolate(), pContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
pJSDocument = (CJS_Document*)JS_GetPrivate(pRuntime->GetIsolate(), pObj);
ASSERT(pJSDocument != NULL);
}
@@ -268,7 +270,7 @@ FX_BOOL app::alert(IFXJS_Context* cc,
if (iSize == 1) {
if (params[0].GetType() == VT_object) {
- JSObject pObj = params[0].ToV8Object();
+ v8::Local<v8::Object> pObj = params[0].ToV8Object();
{
v8::Local<v8::Value> pValue =
JS_GetObjectElement(isolate, pObj, L"cMsg");
@@ -413,8 +415,9 @@ FX_BOOL app::setInterval(IFXJS_Context* cc,
// pTimer->SetStartTime(GetTickCount());
pTimer->SetJSTimer(dwInterval);
- JSFXObject pRetObj = JS_NewFxDynamicObj(
- *pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"TimerObj"));
+ v8::Local<v8::Object> pRetObj =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
CJS_TimerObj* pJS_TimerObj =
(CJS_TimerObj*)JS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
@@ -465,8 +468,9 @@ FX_BOOL app::setTimeOut(IFXJS_Context* cc,
pTimer->SetTimeOut(dwTimeOut);
pTimer->SetJSTimer(dwTimeOut);
- JSFXObject pRetObj = JS_NewFxDynamicObj(
- *pRuntime, pContext, JS_GetObjDefnID(*pRuntime, L"TimerObj"));
+ v8::Local<v8::Object> pRetObj =
+ JS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
CJS_TimerObj* pJS_TimerObj =
(CJS_TimerObj*)JS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
@@ -497,9 +501,10 @@ FX_BOOL app::clearTimeOut(IFXJS_Context* cc,
}
if (params[0].GetType() == VT_fxobject) {
- JSFXObject pObj = params[0].ToV8Object();
+ v8::Local<v8::Object> pObj = params[0].ToV8Object();
{
- if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj")) {
+ if (JS_GetObjDefnID(pObj) ==
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")) {
if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
@@ -539,9 +544,10 @@ FX_BOOL app::clearInterval(IFXJS_Context* cc,
}
if (params[0].GetType() == VT_fxobject) {
- JSFXObject pObj = params[0].ToV8Object();
+ v8::Local<v8::Object> pObj = params[0].ToV8Object();
{
- if (JS_GetObjDefnID(pObj) == JS_GetObjDefnID(*pRuntime, L"TimerObj")) {
+ if (JS_GetObjDefnID(pObj) ==
+ JS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")) {
if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
@@ -636,7 +642,7 @@ FX_BOOL app::mailMsg(IFXJS_Context* cc,
return FALSE;
if (params[0].GetType() == VT_object) {
- JSObject pObj = params[0].ToV8Object();
+ 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)).ToBool();
@@ -774,7 +780,7 @@ FX_BOOL app::response(IFXJS_Context* cc,
int iLength = params.size();
if (iLength > 0 && params[0].GetType() == VT_object) {
- JSObject pObj = params[0].ToV8Object();
+ v8::Local<v8::Object> pObj = params[0].ToV8Object();
v8::Local<v8::Value> pValue =
JS_GetObjectElement(isolate, pObj, L"cQuestion");
swQuestion =
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index 94148762e2..e817eca32c 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -158,7 +158,7 @@ FX_BOOL JSGlobalAlternate::DoProperty(IFXJS_Context* cc,
false, sData, v8::Local<v8::Object>(), FALSE);
}
case VT_object: {
- JSObject pData;
+ v8::Local<v8::Object> pData;
vp >> pData;
return SetGlobalVariables(sPropName, JS_GLOBALDATA_TYPE_OBJECT, 0,
false, "", pData, FALSE);
@@ -246,7 +246,7 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NUMBER,
pData->data.dData, false, "",
v8::Local<v8::Object>(), pData->bPersistent == 1);
- JS_PutObjectNumber(NULL, (JSFXObject)(*m_pJSObject),
+ JS_PutObjectNumber(NULL, (v8::Local<v8::Object>)(*m_pJSObject),
pData->data.sKey.UTF8Decode().c_str(),
pData->data.dData);
break;
@@ -254,7 +254,7 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_BOOLEAN, 0,
(bool)(pData->data.bData == 1), "",
v8::Local<v8::Object>(), pData->bPersistent == 1);
- JS_PutObjectBoolean(NULL, (JSFXObject)(*m_pJSObject),
+ JS_PutObjectBoolean(NULL, (v8::Local<v8::Object>)(*m_pJSObject),
pData->data.sKey.UTF8Decode().c_str(),
(bool)(pData->data.bData == 1));
break;
@@ -262,27 +262,29 @@ void JSGlobalAlternate::UpdateGlobalPersistentVariables() {
SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_STRING, 0,
false, pData->data.sData, v8::Local<v8::Object>(),
pData->bPersistent == 1);
- JS_PutObjectString(NULL, (JSFXObject)(*m_pJSObject),
+ JS_PutObjectString(NULL, (v8::Local<v8::Object>)(*m_pJSObject),
pData->data.sKey.UTF8Decode().c_str(),
pData->data.sData.UTF8Decode().c_str());
break;
case JS_GLOBALDATA_TYPE_OBJECT: {
- IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject));
+ v8::Isolate* pRuntime =
+ JS_GetRuntime((v8::Local<v8::Object>)(*m_pJSObject));
v8::Local<v8::Object> pObj = JS_NewFxDynamicObj(pRuntime, NULL, -1);
PutObjectProperty(pObj, &pData->data);
SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_OBJECT, 0,
- false, "", (JSObject)pObj, pData->bPersistent == 1);
- JS_PutObjectObject(NULL, (JSFXObject)(*m_pJSObject),
+ false, "", (v8::Local<v8::Object>)pObj,
+ pData->bPersistent == 1);
+ JS_PutObjectObject(NULL, (v8::Local<v8::Object>)(*m_pJSObject),
pData->data.sKey.UTF8Decode().c_str(),
- (JSObject)pObj);
+ (v8::Local<v8::Object>)pObj);
} break;
case JS_GLOBALDATA_TYPE_NULL:
SetGlobalVariables(pData->data.sKey, JS_GLOBALDATA_TYPE_NULL, 0, false,
"", v8::Local<v8::Object>(),
pData->bPersistent == 1);
- JS_PutObjectNull(NULL, (JSFXObject)(*m_pJSObject),
+ JS_PutObjectNull(NULL, (v8::Local<v8::Object>)(*m_pJSObject),
pData->data.sKey.UTF8Decode().c_str());
break;
}
@@ -398,30 +400,31 @@ void JSGlobalAlternate::PutObjectProperty(v8::Local<v8::Object> pObj,
switch (pObjData->nType) {
case JS_GLOBALDATA_TYPE_NUMBER:
- JS_PutObjectNumber(NULL, (JSObject)pObj,
+ JS_PutObjectNumber(NULL, (v8::Local<v8::Object>)pObj,
pObjData->sKey.UTF8Decode().c_str(),
pObjData->dData);
break;
case JS_GLOBALDATA_TYPE_BOOLEAN:
- JS_PutObjectBoolean(NULL, (JSObject)pObj,
+ JS_PutObjectBoolean(NULL, (v8::Local<v8::Object>)pObj,
pObjData->sKey.UTF8Decode().c_str(),
(bool)(pObjData->bData == 1));
break;
case JS_GLOBALDATA_TYPE_STRING:
- JS_PutObjectString(NULL, (JSObject)pObj,
+ JS_PutObjectString(NULL, (v8::Local<v8::Object>)pObj,
pObjData->sKey.UTF8Decode().c_str(),
pObjData->sData.UTF8Decode().c_str());
break;
case JS_GLOBALDATA_TYPE_OBJECT: {
- IJS_Runtime* pRuntime = JS_GetRuntime((JSFXObject)(*m_pJSObject));
+ v8::Isolate* pRuntime =
+ JS_GetRuntime((v8::Local<v8::Object>)(*m_pJSObject));
v8::Local<v8::Object> pNewObj = JS_NewFxDynamicObj(pRuntime, NULL, -1);
PutObjectProperty(pNewObj, pObjData);
- JS_PutObjectObject(NULL, (JSObject)pObj,
+ JS_PutObjectObject(NULL, (v8::Local<v8::Object>)pObj,
pObjData->sKey.UTF8Decode().c_str(),
- (JSObject)pNewObj);
+ (v8::Local<v8::Object>)pNewObj);
} break;
case JS_GLOBALDATA_TYPE_NULL:
- JS_PutObjectNull(NULL, (JSObject)pObj,
+ JS_PutObjectNull(NULL, (v8::Local<v8::Object>)pObj,
pObjData->sKey.UTF8Decode().c_str());
break;
}
@@ -440,7 +443,7 @@ FX_BOOL JSGlobalAlternate::SetGlobalVariables(const FX_CHAR* propname,
double dData,
bool bData,
const CFX_ByteString& sData,
- JSObject pData,
+ v8::Local<v8::Object> pData,
bool bDefaultPersistent) {
if (!propname)
return FALSE;