summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/javascript/Consts.cpp2
-rw-r--r--fpdfsdk/javascript/JS_Define.h23
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp11
-rw-r--r--fpdfsdk/javascript/cjs_runtime.h10
4 files changed, 21 insertions, 25 deletions
diff --git a/fpdfsdk/javascript/Consts.cpp b/fpdfsdk/javascript/Consts.cpp
index b71d0a34b3..19988a61ea 100644
--- a/fpdfsdk/javascript/Consts.cpp
+++ b/fpdfsdk/javascript/Consts.cpp
@@ -148,7 +148,7 @@ void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) {
(rt)->GetIsolate(), (name), \
[](const v8::FunctionCallbackInfo<v8::Value>& info) { \
CJS_Runtime* pLocalRuntime = static_cast<CJS_Runtime*>( \
- FXJS_GetRuntimeFromIsolate(info.GetIsolate())); \
+ FXJS_GetCurrentEngineFromIsolate(info.GetIsolate())); \
if (pLocalRuntime) \
info.GetReturnValue().Set(pLocalRuntime->GetConstArray(name)); \
}); \
diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h
index 4c24a4de7b..b9ae1408f6 100644
--- a/fpdfsdk/javascript/JS_Define.h
+++ b/fpdfsdk/javascript/JS_Define.h
@@ -78,7 +78,7 @@ void JSPropGetter(const char* prop_name_string,
const v8::PropertyCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
CJS_Runtime* pRuntime =
- static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
+ static_cast<CJS_Runtime*>(FXJS_GetCurrentEngineFromIsolate(isolate));
if (!pRuntime)
return;
IJS_Context* pContext = pRuntime->GetCurrentContext();
@@ -104,7 +104,7 @@ void JSPropSetter(const char* prop_name_string,
const v8::PropertyCallbackInfo<void>& info) {
v8::Isolate* isolate = info.GetIsolate();
CJS_Runtime* pRuntime =
- static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
+ static_cast<CJS_Runtime*>(FXJS_GetCurrentEngineFromIsolate(isolate));
if (!pRuntime)
return;
IJS_Context* pContext = pRuntime->GetCurrentContext();
@@ -143,7 +143,7 @@ void JSMethod(const char* method_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
CJS_Runtime* pRuntime =
- static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
+ static_cast<CJS_Runtime*>(FXJS_GetCurrentEngineFromIsolate(isolate));
if (!pRuntime)
return;
IJS_Context* pContext = pRuntime->GetCurrentContext();
@@ -245,7 +245,7 @@ void JSMethod(const char* method_name_string,
}
#define DECLARE_JS_CLASS_RICH_PART() \
- static void JSConstructor(IJS_Runtime* pRuntime, v8::Local<v8::Object> obj); \
+ static void JSConstructor(CFXJS_Engine* pEngine, v8::Local<v8::Object> obj); \
static void JSDestructor(v8::Local<v8::Object> obj); \
static void DefineProps(v8::Isolate* pIsoalte); \
static void DefineMethods(v8::Isolate* pIsoalte); \
@@ -254,12 +254,12 @@ void JSMethod(const char* method_name_string,
#define IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, \
class_name) \
- void js_class_name::JSConstructor(IJS_Runtime* pIRuntime, \
+ void js_class_name::JSConstructor(CFXJS_Engine* pEngine, \
v8::Local<v8::Object> obj) { \
CJS_Object* pObj = new js_class_name(obj); \
pObj->SetEmbedObject(new class_alternate(pObj)); \
FXJS_SetPrivate(nullptr, obj, (void*)pObj); \
- pObj->InitInstance(pIRuntime); \
+ pObj->InitInstance(static_cast<CJS_Runtime*>(pEngine)); \
} \
void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \
js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(nullptr, obj); \
@@ -366,7 +366,7 @@ void JSSpecialPropGet(const char* class_name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
CJS_Runtime* pRuntime =
- static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
+ static_cast<CJS_Runtime*>(FXJS_GetCurrentEngineFromIsolate(isolate));
if (!pRuntime)
return;
IJS_Context* pContext = pRuntime->GetCurrentContext();
@@ -393,7 +393,7 @@ void JSSpecialPropPut(const char* class_name,
const v8::PropertyCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
CJS_Runtime* pRuntime =
- static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(isolate));
+ static_cast<CJS_Runtime*>(FXJS_GetCurrentEngineFromIsolate(isolate));
if (!pRuntime)
return;
IJS_Context* pContext = pRuntime->GetCurrentContext();
@@ -416,7 +416,8 @@ void JSSpecialPropDel(const char* class_name,
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
v8::Isolate* isolate = info.GetIsolate();
- IJS_Runtime* pRuntime = FXJS_GetRuntimeFromIsolate(isolate);
+ CJS_Runtime* pRuntime =
+ static_cast<CJS_Runtime*>(FXJS_GetCurrentEngineFromIsolate(isolate));
if (!pRuntime)
return;
IJS_Context* pContext = pRuntime->GetCurrentContext();
@@ -440,8 +441,8 @@ template <FX_BOOL (*F)(IJS_Context*,
CFX_WideString&)>
void JSGlobalFunc(const char* func_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) {
- CJS_Runtime* pRuntime =
- static_cast<CJS_Runtime*>(FXJS_GetRuntimeFromIsolate(info.GetIsolate()));
+ CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(
+ FXJS_GetCurrentEngineFromIsolate(info.GetIsolate()));
if (!pRuntime)
return;
IJS_Context* pContext = pRuntime->GetCurrentContext();
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index 7eaf1451ca..36d888a2ea 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -58,8 +58,7 @@ CJS_Runtime* CJS_Runtime::FromContext(const IJS_Context* cc) {
CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
: m_pApp(pApp),
m_pDocument(nullptr),
- m_bBlocking(FALSE),
- m_isolate(nullptr),
+ m_bBlocking(false),
m_isolateManaged(false) {
#ifndef PDF_ENABLE_XFA
IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform;
@@ -96,7 +95,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
v8::HandleScope handle_scope(isolate);
if (CPDFXFA_App::GetInstance()->IsJavaScriptInitialized()) {
CJS_Context* pContext = (CJS_Context*)NewContext();
- FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
+ FXJS_InitializeEngine(GetIsolate(), this, &m_context, &m_StaticObjects);
ReleaseContext(pContext);
return;
}
@@ -110,7 +109,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
#endif
CJS_Context* pContext = (CJS_Context*)NewContext();
- FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects);
+ FXJS_InitializeEngine(GetIsolate(), this, &m_context, &m_StaticObjects);
ReleaseContext(pContext);
}
@@ -120,7 +119,7 @@ CJS_Runtime::~CJS_Runtime() {
m_ContextArray.clear();
m_ConstArrays.clear();
- FXJS_ReleaseRuntime(GetIsolate(), &m_context, &m_StaticObjects);
+ FXJS_ReleaseEngine(GetIsolate(), &m_context, &m_StaticObjects);
m_context.Reset();
if (m_isolateManaged)
m_isolate->Dispose();
@@ -284,7 +283,7 @@ FX_BOOL CJS_Runtime::GetValueByName(const CFX_ByteStringC& utf8Name,
// Do so now.
// TODO(tsepez): redesign PDF-side objects to not rely on v8::Context's
// embedder data slots, and/or to always use the right context.
- FXJS_SetRuntimeForV8Context(old_context, this);
+ FXJS_SetEngineForV8Context(old_context, this);
v8::Local<v8::Value> propvalue =
context->Global()->Get(v8::String::NewFromUtf8(
diff --git a/fpdfsdk/javascript/cjs_runtime.h b/fpdfsdk/javascript/cjs_runtime.h
index c43a34b720..16432d5394 100644
--- a/fpdfsdk/javascript/cjs_runtime.h
+++ b/fpdfsdk/javascript/cjs_runtime.h
@@ -20,7 +20,7 @@
class CJS_Context;
-class CJS_Runtime : public IJS_Runtime {
+class CJS_Runtime : public IJS_Runtime, public CFXJS_Engine {
public:
class Observer {
public:
@@ -77,13 +77,9 @@ class CJS_Runtime : public IJS_Runtime {
std::vector<std::unique_ptr<CJS_Context>> m_ContextArray;
CPDFDoc_Environment* const m_pApp;
CPDFSDK_Document* m_pDocument;
- FX_BOOL m_bBlocking;
- std::set<FieldEvent> m_FieldEventSet;
- v8::Isolate* m_isolate;
+ bool m_bBlocking;
bool m_isolateManaged;
- v8::Global<v8::Context> m_context;
- std::vector<v8::Global<v8::Object>*> m_StaticObjects;
- std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays;
+ std::set<FieldEvent> m_FieldEventSet;
std::set<Observer*> m_observers;
};