summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/app.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/javascript/app.cpp')
-rw-r--r--fpdfsdk/javascript/app.cpp100
1 files changed, 48 insertions, 52 deletions
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 8d7420b7bd..18415dcea2 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -235,21 +235,21 @@ FX_BOOL app::activeDocs(IJS_Context* cc,
if (CPDFSDK_Document* pDoc = pApp->GetSDKDocument()) {
CJS_Document* pJSDocument = nullptr;
if (pDoc == pCurDoc) {
- v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate());
- if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID)
+ v8::Local<v8::Object> pObj = pRuntime->GetThisObj();
+ if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID) {
pJSDocument =
- (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
+ static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj));
+ }
} else {
- v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID);
+ v8::Local<v8::Object> pObj =
+ pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
pJSDocument =
- (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
+ static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj));
ASSERT(pJSDocument);
}
- aDocs.SetElement(pRuntime->GetIsolate(), 0,
- CJS_Value(pRuntime, pJSDocument));
+ aDocs.SetElement(pRuntime, 0, CJS_Value(pRuntime, pJSDocument));
}
- if (aDocs.GetLength() > 0)
+ if (aDocs.GetLength(pRuntime) > 0)
vp << aDocs;
else
vp.GetJSValue()->SetNull(pRuntime);
@@ -412,34 +412,34 @@ FX_BOOL app::alert(IJS_Context* cc,
CFX_WideString swMsg;
if (newParams[0].GetType() == CJS_Value::VT_object) {
CJS_Array carray;
- if (newParams[0].ConvertToArray(pRuntime->GetIsolate(), carray)) {
+ if (newParams[0].ConvertToArray(pRuntime, carray)) {
swMsg = L"[";
CJS_Value element(pRuntime);
- for (int i = 0; i < carray.GetLength(); ++i) {
+ for (int i = 0; i < carray.GetLength(pRuntime); ++i) {
if (i)
swMsg += L", ";
- carray.GetElement(pRuntime->GetIsolate(), i, element);
- swMsg += element.ToCFXWideString(pRuntime->GetIsolate());
+ carray.GetElement(pRuntime, i, element);
+ swMsg += element.ToCFXWideString(pRuntime);
}
swMsg += L"]";
} else {
- swMsg = newParams[0].ToCFXWideString(pRuntime->GetIsolate());
+ swMsg = newParams[0].ToCFXWideString(pRuntime);
}
} else {
- swMsg = newParams[0].ToCFXWideString(pRuntime->GetIsolate());
+ swMsg = newParams[0].ToCFXWideString(pRuntime);
}
int iIcon = 0;
if (newParams[1].GetType() != CJS_Value::VT_unknown)
- iIcon = newParams[1].ToInt(pRuntime->GetIsolate());
+ iIcon = newParams[1].ToInt(pRuntime);
int iType = 0;
if (newParams[2].GetType() != CJS_Value::VT_unknown)
- iType = newParams[2].ToInt(pRuntime->GetIsolate());
+ iType = newParams[2].ToInt(pRuntime);
CFX_WideString swTitle;
if (newParams[3].GetType() != CJS_Value::VT_unknown)
- swTitle = newParams[3].ToCFXWideString(pRuntime->GetIsolate());
+ swTitle = newParams[3].ToCFXWideString(pRuntime);
else
swTitle = JSGetStringFromID(pContext, IDS_STRING_JSALERT);
@@ -461,7 +461,7 @@ FX_BOOL app::beep(IJS_Context* cc,
CJS_Context* pContext = (CJS_Context*)cc;
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
CPDFDoc_Environment* pEnv = pRuntime->GetReaderApp();
- pEnv->JS_appBeep(params[0].ToInt(pRuntime->GetIsolate()));
+ pEnv->JS_appBeep(params[0].ToInt(pRuntime));
return TRUE;
}
@@ -500,23 +500,21 @@ FX_BOOL app::setInterval(IJS_Context* cc,
}
CFX_WideString script =
- params.size() > 0 ? params[0].ToCFXWideString(pRuntime->GetIsolate())
- : L"";
+ params.size() > 0 ? params[0].ToCFXWideString(pRuntime) : L"";
if (script.IsEmpty()) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
return TRUE;
}
- uint32_t dwInterval =
- params.size() > 1 ? params[1].ToInt(pRuntime->GetIsolate()) : 1000;
+ uint32_t dwInterval = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000;
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
m_Timers.push_back(std::unique_ptr<GlobalTimer>(
new GlobalTimer(this, pApp, pRuntime, 0, script, dwInterval, 0)));
- v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID);
- CJS_TimerObj* pJS_TimerObj = static_cast<CJS_TimerObj*>(
- FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj));
+ v8::Local<v8::Object> pRetObj =
+ pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID);
+ CJS_TimerObj* pJS_TimerObj =
+ static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj));
TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
pTimerObj->SetTimer(m_Timers.back().get());
@@ -536,23 +534,22 @@ FX_BOOL app::setTimeOut(IJS_Context* cc,
return FALSE;
}
- CFX_WideString script = params[0].ToCFXWideString(pRuntime->GetIsolate());
+ CFX_WideString script = params[0].ToCFXWideString(pRuntime);
if (script.IsEmpty()) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSAFNUMBER_KEYSTROKE);
return TRUE;
}
- uint32_t dwTimeOut =
- params.size() > 1 ? params[1].ToInt(pRuntime->GetIsolate()) : 1000;
+ uint32_t dwTimeOut = params.size() > 1 ? params[1].ToInt(pRuntime) : 1000;
CPDFDoc_Environment* pApp = pRuntime->GetReaderApp();
m_Timers.push_back(std::unique_ptr<GlobalTimer>(
new GlobalTimer(this, pApp, pRuntime, 1, script, dwTimeOut, dwTimeOut)));
- v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID);
+ v8::Local<v8::Object> pRetObj =
+ pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID);
- CJS_TimerObj* pJS_TimerObj = static_cast<CJS_TimerObj*>(
- FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj));
+ CJS_TimerObj* pJS_TimerObj =
+ static_cast<CJS_TimerObj*>(pRuntime->GetObjectPrivate(pRetObj));
TimerObj* pTimerObj = static_cast<TimerObj*>(pJS_TimerObj->GetEmbedObject());
pTimerObj->SetTimer(m_Timers.back().get());
@@ -571,7 +568,7 @@ FX_BOOL app::clearTimeOut(IJS_Context* cc,
return FALSE;
}
- app::ClearTimerCommon(params[0]);
+ app::ClearTimerCommon(pContext->GetJSRuntime(), params[0]);
return TRUE;
}
@@ -585,19 +582,19 @@ FX_BOOL app::clearInterval(IJS_Context* cc,
return FALSE;
}
- app::ClearTimerCommon(params[0]);
+ app::ClearTimerCommon(pContext->GetJSRuntime(), params[0]);
return TRUE;
}
-void app::ClearTimerCommon(const CJS_Value& param) {
+void app::ClearTimerCommon(CJS_Runtime* pRuntime, const CJS_Value& param) {
if (param.GetType() != CJS_Value::VT_object)
return;
- v8::Local<v8::Object> pObj = param.ToV8Object(GetJSObject()->GetIsolate());
- if (FXJS_GetObjDefnID(pObj) != CJS_TimerObj::g_nObjDefnID)
+ v8::Local<v8::Object> pObj = param.ToV8Object(pRuntime);
+ if (CFXJS_Engine::GetObjDefnID(pObj) != CJS_TimerObj::g_nObjDefnID)
return;
- CJS_Object* pJSObj = param.ToCJSObject(GetJSObject()->GetIsolate());
+ CJS_Object* pJSObj = param.ToCJSObject(pRuntime);
if (!pJSObj)
return;
@@ -671,11 +668,11 @@ FX_BOOL app::mailMsg(IJS_Context* cc,
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
- bool bUI = newParams[0].ToBool(pRuntime->GetIsolate());
+ bool bUI = newParams[0].ToBool(pRuntime);
CFX_WideString cTo;
if (newParams[1].GetType() != CJS_Value::VT_unknown) {
- cTo = newParams[1].ToCFXWideString(pRuntime->GetIsolate());
+ cTo = newParams[1].ToCFXWideString(pRuntime);
} else {
if (!bUI) {
// cTo parameter required when UI not invoked.
@@ -686,19 +683,19 @@ FX_BOOL app::mailMsg(IJS_Context* cc,
CFX_WideString cCc;
if (newParams[2].GetType() != CJS_Value::VT_unknown)
- cCc = newParams[2].ToCFXWideString(pRuntime->GetIsolate());
+ cCc = newParams[2].ToCFXWideString(pRuntime);
CFX_WideString cBcc;
if (newParams[3].GetType() != CJS_Value::VT_unknown)
- cBcc = newParams[3].ToCFXWideString(pRuntime->GetIsolate());
+ cBcc = newParams[3].ToCFXWideString(pRuntime);
CFX_WideString cSubject;
if (newParams[4].GetType() != CJS_Value::VT_unknown)
- cSubject = newParams[4].ToCFXWideString(pRuntime->GetIsolate());
+ cSubject = newParams[4].ToCFXWideString(pRuntime);
CFX_WideString cMsg;
if (newParams[5].GetType() != CJS_Value::VT_unknown)
- cMsg = newParams[5].ToCFXWideString(pRuntime->GetIsolate());
+ cMsg = newParams[5].ToCFXWideString(pRuntime);
pRuntime->BeginBlock();
pContext->GetReaderApp()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(),
@@ -794,24 +791,23 @@ FX_BOOL app::response(IJS_Context* cc,
sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
- CFX_WideString swQuestion =
- newParams[0].ToCFXWideString(pRuntime->GetIsolate());
+ CFX_WideString swQuestion = newParams[0].ToCFXWideString(pRuntime);
CFX_WideString swTitle = L"PDF";
if (newParams[1].GetType() != CJS_Value::VT_unknown)
- swTitle = newParams[1].ToCFXWideString(pRuntime->GetIsolate());
+ swTitle = newParams[1].ToCFXWideString(pRuntime);
CFX_WideString swDefault;
if (newParams[2].GetType() != CJS_Value::VT_unknown)
- swDefault = newParams[2].ToCFXWideString(pRuntime->GetIsolate());
+ swDefault = newParams[2].ToCFXWideString(pRuntime);
bool bPassword = false;
if (newParams[3].GetType() != CJS_Value::VT_unknown)
- bPassword = newParams[3].ToBool(pRuntime->GetIsolate());
+ bPassword = newParams[3].ToBool(pRuntime);
CFX_WideString swLabel;
if (newParams[4].GetType() != CJS_Value::VT_unknown)
- swLabel = newParams[4].ToCFXWideString(pRuntime->GetIsolate());
+ swLabel = newParams[4].ToCFXWideString(pRuntime);
const int MAX_INPUT_BYTES = 2048;
std::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]);