diff options
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r-- | fpdfsdk/src/javascript/Document.cpp | 28 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/Document.h | 2 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/Field.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/Field.h | 2 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Context.cpp | 18 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Context.h | 2 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Define.h | 16 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_EventHandler.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Object.h | 4 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 16 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.h | 3 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime_Stub.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/app.cpp | 11 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/global.cpp | 17 | ||||
-rw-r--r-- | fpdfsdk/src/javascript/global.h | 2 |
15 files changed, 76 insertions, 79 deletions
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp index c1bd029351..bcf8af6595 100644 --- a/fpdfsdk/src/javascript/Document.cpp +++ b/fpdfsdk/src/javascript/Document.cpp @@ -140,17 +140,12 @@ END_JS_STATIC_METHOD() IMPLEMENT_JS_CLASS(CJS_Document, Document) -FX_BOOL CJS_Document::InitInstance(IJS_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 --------------------------------- */ @@ -326,7 +321,7 @@ FX_BOOL Document::getField(IJS_Context* cc, CJS_Runtime* pRuntime = pContext->GetJSRuntime(); v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), pContext, CJS_Field::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); v8::Isolate* isolate = GetIsolate(cc); CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(isolate, pFieldObj); @@ -837,7 +832,7 @@ FX_BOOL Document::info(IJS_Context* cc, CJS_Context* pContext = (CJS_Context*)cc; CJS_Runtime* pRuntime = pContext->GetJSRuntime(); v8::Local<v8::Object> pObj = - FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext, -1); + 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()); @@ -1433,7 +1428,6 @@ FX_BOOL Document::icons(IJS_Context* cc, return TRUE; } - CJS_Context* pContext = static_cast<CJS_Context*>(cc); CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc); CJS_Array Icons(pRuntime); IconElement* pIconElement = NULL; @@ -1442,7 +1436,7 @@ FX_BOOL Document::icons(IJS_Context* cc, pIconElement = (*m_pIconTree)[i]; v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID); if (pObj.IsEmpty()) return FALSE; @@ -1485,7 +1479,7 @@ FX_BOOL Document::getIcon(IJS_Context* cc, Icon* pRetIcon = (*m_pIconTree)[i]->IconStream; v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID); if (pObj.IsEmpty()) return FALSE; @@ -1686,7 +1680,7 @@ FX_BOOL Document::getPrintParams(IJS_Context* cc, CJS_Context* pContext = (CJS_Context*)cc; CJS_Runtime* pRuntime = pContext->GetJSRuntime(); v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), pContext, CJS_PrintParamsObj::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_PrintParamsObj::g_nObjDefnID); // Not implemented yet. diff --git a/fpdfsdk/src/javascript/Document.h b/fpdfsdk/src/javascript/Document.h index 516045e35b..149102d0d1 100644 --- a/fpdfsdk/src/javascript/Document.h +++ b/fpdfsdk/src/javascript/Document.h @@ -310,7 +310,7 @@ class CJS_Document : public CJS_Object { ~CJS_Document() override {} // CJS_Object - FX_BOOL InitInstance(IJS_Context* cc) override; + void InitInstance(IJS_Runtime* pIRuntime) override; DECLARE_JS_CLASS(); diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp index f04c379d34..f3d12b479a 100644 --- a/fpdfsdk/src/javascript/Field.cpp +++ b/fpdfsdk/src/javascript/Field.cpp @@ -110,16 +110,10 @@ END_JS_STATIC_METHOD() IMPLEMENT_JS_CLASS(CJS_Field, Field) -FX_BOOL CJS_Field::InitInstance(IJS_Context* cc) { - CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); - - Field* pField = (Field*)GetEmbedObject(); - ASSERT(pField != NULL); - - pField->SetIsolate(pContext->GetJSRuntime()->GetIsolate()); - - return TRUE; +void CJS_Field::InitInstance(IJS_Runtime* pIRuntime) { + CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime); + Field* pField = static_cast<Field*>(GetEmbedObject()); + pField->SetIsolate(pRuntime->GetIsolate()); }; Field::Field(CJS_Object* pJSObject) @@ -3279,7 +3273,7 @@ FX_BOOL Field::buttonGetIcon(IJS_Context* cc, CJS_Context* pContext = (CJS_Context*)cc; CJS_Runtime* pRuntime = pContext->GetJSRuntime(); v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Icon::g_nObjDefnID); ASSERT(pObj.IsEmpty() == FALSE); CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); @@ -3488,7 +3482,7 @@ FX_BOOL Field::getArray(IJS_Context* cc, for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) { nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j)); v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), pContext, CJS_Field::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); ASSERT(!pObj.IsEmpty()); CJS_Field* pJSField = diff --git a/fpdfsdk/src/javascript/Field.h b/fpdfsdk/src/javascript/Field.h index b263241712..21ae04c960 100644 --- a/fpdfsdk/src/javascript/Field.h +++ b/fpdfsdk/src/javascript/Field.h @@ -501,7 +501,7 @@ class CJS_Field : public CJS_Object { CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {} ~CJS_Field(void) override {} - FX_BOOL InitInstance(IJS_Context* cc) override; + void InitInstance(IJS_Runtime* pIRuntime) override; DECLARE_JS_CLASS(); JS_STATIC_PROP(alignment, Field); diff --git a/fpdfsdk/src/javascript/JS_Context.cpp b/fpdfsdk/src/javascript/JS_Context.cpp index 4769dac4f7..a53e745786 100644 --- a/fpdfsdk/src/javascript/JS_Context.cpp +++ b/fpdfsdk/src/javascript/JS_Context.cpp @@ -33,7 +33,7 @@ CPDFDoc_Environment* CJS_Context::GetReaderApp() { } FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, - CFX_WideString& info) { + CFX_WideString* info) { v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate()); v8::Locker locker(m_pRuntime->GetIsolate()); v8::HandleScope handle_scope(m_pRuntime->GetIsolate()); @@ -41,7 +41,7 @@ FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, v8::Context::Scope context_scope(context); if (m_bBusy) { - info = JSGetStringFromID(this, IDS_STRING_JSBUSY); + *info = JSGetStringFromID(this, IDS_STRING_JSBUSY); return FALSE; } m_bBusy = TRUE; @@ -50,24 +50,20 @@ FX_BOOL CJS_Context::RunScript(const CFX_WideString& script, CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(), m_pEventHandler->EventType()); if (!m_pRuntime->AddEventToSet(event)) { - info = JSGetStringFromID(this, IDS_STRING_JSEVENT); + *info = JSGetStringFromID(this, IDS_STRING_JSEVENT); return FALSE; } - FXJSErr error = {NULL, NULL, 0}; + CFX_WideString sErrorMessage; int nRet = 0; if (script.GetLength() > 0) { - nRet = FXJS_Execute(m_pRuntime->GetIsolate(), this, script.c_str(), - script.GetLength(), &error); + nRet = m_pRuntime->Execute(this, script.c_str(), &sErrorMessage); } if (nRet < 0) { - CFX_WideString sLine; - sLine.Format(L"[ Line: %05d { %s } ] : %s", error.linnum - 1, error.srcline, - error.message); - info += sLine; + *info += sErrorMessage; } else { - info = JSGetStringFromID(this, IDS_STRING_RUN); + *info = JSGetStringFromID(this, IDS_STRING_RUN); } m_pRuntime->RemoveEventFromSet(event); diff --git a/fpdfsdk/src/javascript/JS_Context.h b/fpdfsdk/src/javascript/JS_Context.h index 7fbcbec876..dc5d8339bf 100644 --- a/fpdfsdk/src/javascript/JS_Context.h +++ b/fpdfsdk/src/javascript/JS_Context.h @@ -21,7 +21,7 @@ class CJS_Context : public IJS_Context { // IJS_Context FX_BOOL RunScript(const CFX_WideString& script, - CFX_WideString& info) override; + CFX_WideString* info) override; void OnApp_Init() override; void OnDoc_Open(CPDFSDK_Document* pDoc, const CFX_WideString& strTargetName) override; diff --git a/fpdfsdk/src/javascript/JS_Define.h b/fpdfsdk/src/javascript/JS_Define.h index 178e28f3da..252c50ff1b 100644 --- a/fpdfsdk/src/javascript/JS_Define.h +++ b/fpdfsdk/src/javascript/JS_Define.h @@ -245,22 +245,22 @@ void JSMethod(const char* method_name_string, DefineMethods(pIsolate); \ } -#define DECLARE_JS_CLASS_RICH_PART() \ - static void JSConstructor(IJS_Context* cc, 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); \ - static JSPropertySpec JS_Class_Properties[]; \ +#define DECLARE_JS_CLASS_RICH_PART() \ + static void JSConstructor(IJS_Runtime* pRuntime, 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); \ + static JSPropertySpec JS_Class_Properties[]; \ static JSMethodSpec JS_Class_Methods[]; #define IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, \ class_name) \ - void js_class_name::JSConstructor(IJS_Context* cc, \ + void js_class_name::JSConstructor(IJS_Runtime* pIRuntime, \ 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(cc); \ + pObj->InitInstance(pIRuntime); \ } \ void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \ js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(nullptr, obj); \ diff --git a/fpdfsdk/src/javascript/JS_EventHandler.cpp b/fpdfsdk/src/javascript/JS_EventHandler.cpp index dd5c4427ce..cb86fde24d 100644 --- a/fpdfsdk/src/javascript/JS_EventHandler.cpp +++ b/fpdfsdk/src/javascript/JS_EventHandler.cpp @@ -613,11 +613,11 @@ FX_BOOL CJS_EventHandler::Shift() { Field* CJS_EventHandler::Source() { CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), m_pJSContext, CJS_Document::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID); ASSERT(!pDocObj.IsEmpty()); v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), m_pJSContext, CJS_Field::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); ASSERT(!pFieldObj.IsEmpty()); CJS_Document* pJSDocument = @@ -636,11 +636,11 @@ Field* CJS_EventHandler::Source() { Field* CJS_EventHandler::Target_Field() { CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime(); v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), m_pJSContext, CJS_Document::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID); ASSERT(!pDocObj.IsEmpty()); v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), m_pJSContext, CJS_Field::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Field::g_nObjDefnID); ASSERT(!pFieldObj.IsEmpty()); CJS_Document* pJSDocument = diff --git a/fpdfsdk/src/javascript/JS_Object.h b/fpdfsdk/src/javascript/JS_Object.h index 563a316bd6..50751523f5 100644 --- a/fpdfsdk/src/javascript/JS_Object.h +++ b/fpdfsdk/src/javascript/JS_Object.h @@ -49,8 +49,8 @@ class CJS_Object { virtual FX_BOOL IsType(const FX_CHAR* sClassName) { return TRUE; } virtual CFX_ByteString GetClassName() { return ""; } - virtual FX_BOOL InitInstance(IJS_Context* cc) { return TRUE; } - virtual FX_BOOL ExitInstance() { return TRUE; } + virtual void InitInstance(IJS_Runtime* pIRuntime) {} + virtual void ExitInstance() {} v8::Local<v8::Object> ToV8Object() { return m_pV8Object.Get(m_pIsolate); } diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index 1d2fa84323..8b0475b851 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -77,7 +77,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, pContext, m_context); + FXJS_InitializeRuntime(GetIsolate(), this, m_context); ReleaseContext(pContext); return; } @@ -88,7 +88,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); CJS_Context* pContext = (CJS_Context*)NewContext(); - FXJS_InitializeRuntime(GetIsolate(), this, pContext, m_context); + FXJS_InitializeRuntime(GetIsolate(), this, m_context); ReleaseContext(pContext); } @@ -208,6 +208,18 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) { } } +int CJS_Runtime::Execute(IJS_Context* cc, + const wchar_t* script, + CFX_WideString* info) { + FXJSErr error = {}; + int nRet = FXJS_Execute(m_isolate, cc, script, &error); + if (nRet < 0) { + info->Format(L"[ Line: %05d { %s } ] : %s", error.linnum - 1, error.srcline, + error.message); + } + return nRet; +} + bool CJS_Runtime::AddEventToSet(const FieldEvent& event) { return m_FieldEventSet.insert(event).second; } diff --git a/fpdfsdk/src/javascript/JS_Runtime.h b/fpdfsdk/src/javascript/JS_Runtime.h index c259a4188e..4772823d7f 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.h +++ b/fpdfsdk/src/javascript/JS_Runtime.h @@ -40,6 +40,9 @@ class CJS_Runtime : public IJS_Runtime { IJS_Context* GetCurrentContext() override; void SetReaderDocument(CPDFSDK_Document* pReaderDoc) override; CPDFSDK_Document* GetReaderDocument() override { return m_pDocument; } + int Execute(IJS_Context* cc, + const wchar_t* script, + CFX_WideString* info) override; CPDFDoc_Environment* GetReaderApp() const { return m_pApp; } diff --git a/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp index ea1e6c1c55..7e3d78881a 100644 --- a/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime_Stub.cpp @@ -15,7 +15,7 @@ class CJS_ContextStub final : public IJS_Context { // IJS_Context: FX_BOOL RunScript(const CFX_WideString& script, - CFX_WideString& info) override { + CFX_WideString* info) override { return FALSE; } @@ -146,6 +146,12 @@ class CJS_RuntimeStub final : public IJS_Runtime { return FALSE; } + int Execute(IJS_Context* cc, + const wchar_t* script, + CFX_WideString* info) override { + return 0; + } + protected: CPDFSDK_Document* m_pDoc; nonstd::unique_ptr<CJS_ContextStub> m_pContext; diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp index 80edaa6c93..80a9b17aa9 100644 --- a/fpdfsdk/src/javascript/app.cpp +++ b/fpdfsdk/src/javascript/app.cpp @@ -124,7 +124,7 @@ FX_BOOL app::activeDocs(IJS_Context* cc, (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); } else { v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), pContext, CJS_Document::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_Document::g_nObjDefnID); pJSDocument = (CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj); ASSERT(pJSDocument != NULL); @@ -409,7 +409,7 @@ FX_BOOL app::setInterval(IJS_Context* cc, m_aTimer.Add(pTimer); v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID); CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); @@ -450,7 +450,7 @@ FX_BOOL app::setTimeOut(IJS_Context* cc, m_aTimer.Add(pTimer); v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj( - pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID); + pRuntime->GetIsolate(), pRuntime, CJS_TimerObj::g_nObjDefnID); CJS_TimerObj* pJS_TimerObj = (CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj); TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject(); @@ -560,14 +560,11 @@ void app::TimerProc(CJS_Timer* pTimer) { } void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) { - ASSERT(pRuntime != NULL); - if (!pRuntime->IsBlocking()) { IJS_Context* pContext = pRuntime->NewContext(); - ASSERT(pContext != NULL); pContext->OnExternal_Exec(); CFX_WideString wtInfo; - pContext->RunScript(wsScript, wtInfo); + pContext->RunScript(wsScript, &wtInfo); pRuntime->ReleaseContext(pContext); } } diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp index 97a74e792d..403cf58ebf 100644 --- a/fpdfsdk/src/javascript/global.cpp +++ b/fpdfsdk/src/javascript/global.cpp @@ -88,17 +88,12 @@ END_JS_STATIC_METHOD() IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, JSGlobalAlternate, global); -FX_BOOL CJS_Global::InitInstance(IJS_Context* cc) { - CJS_Context* pContext = (CJS_Context*)cc; - ASSERT(pContext != NULL); - - JSGlobalAlternate* pGlobal = (JSGlobalAlternate*)GetEmbedObject(); - ASSERT(pGlobal != NULL); - - pGlobal->Initial(pContext->GetReaderApp()); - - return TRUE; -}; +void CJS_Global::InitInstance(IJS_Runtime* pIRuntime) { + CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime); + JSGlobalAlternate* pGlobal = + static_cast<JSGlobalAlternate*>(GetEmbedObject()); + pGlobal->Initial(pRuntime->GetReaderApp()); +} JSGlobalAlternate::JSGlobalAlternate(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject), m_pApp(NULL) { diff --git a/fpdfsdk/src/javascript/global.h b/fpdfsdk/src/javascript/global.h index 30f5d07b31..174e63a760 100644 --- a/fpdfsdk/src/javascript/global.h +++ b/fpdfsdk/src/javascript/global.h @@ -82,7 +82,7 @@ class CJS_Global : public CJS_Object { ~CJS_Global() override {} // CJS_Object - FX_BOOL InitInstance(IJS_Context* cc) override; + void InitInstance(IJS_Runtime* pIRuntime) override; DECLARE_SPECIAL_JS_CLASS(); JS_SPECIAL_STATIC_METHOD(setPersistent, JSGlobalAlternate, global); |