summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
authorjinming_wang <jinming_wang@foxitsoftware.com>2016-02-04 09:41:56 +0800
committerjinming_wang <jinming_wang@foxitsoftware.com>2016-02-04 09:41:56 +0800
commit486615821300724aef55035f4f831f548fb9cab6 (patch)
treeb5ccf7e0f7425a9039b6ea349a996396bad1cbf5 /fpdfsdk
parent99ddbfbcc3d0e8a52c8f8a4ec22462d9e00c1c6a (diff)
downloadpdfium-486615821300724aef55035f4f831f548fb9cab6.tar.xz
Pdfium does not create isolate when it runs in chromium
BUG=pdfium:373 R=jochen@chromium.org Review URL: https://codereview.chromium.org/1652873003 .
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/include/fpdfxfa/fpdfxfa_app.h3
-rw-r--r--fpdfsdk/src/fpdfview.cpp5
-rw-r--r--fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp10
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp2
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp5
5 files changed, 12 insertions, 13 deletions
diff --git a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h
index dd65042189..5ec6de5644 100644
--- a/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h
+++ b/fpdfsdk/include/fpdfxfa/fpdfxfa_app.h
@@ -19,7 +19,7 @@ class CPDFXFA_App : public IXFA_AppProvider {
CPDFXFA_App();
~CPDFXFA_App() override;
- FX_BOOL Initialize();
+ FX_BOOL Initialize(FXJSE_HRUNTIME hRuntime);
IXFA_App* GetXFAApp() { return m_pXFAApp; }
FX_BOOL AddFormFillEnv(CPDFDoc_Environment* pEnv);
@@ -92,6 +92,7 @@ class CPDFXFA_App : public IXFA_AppProvider {
FXJSE_HRUNTIME m_hJSERuntime;
IFXJS_Runtime* m_pJSRuntime;
CFX_WideString m_csAppType;
+ bool m_bOwnedRuntime;
};
#endif // FPDFXFA_APP_H_
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index ba647093eb..418d35d720 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -241,7 +241,10 @@ DLLEXPORT void STDCALL FPDF_InitLibraryWithConfig(
pModuleMgr->InitPageModule();
pModuleMgr->InitRenderModule();
#ifdef PDF_ENABLE_XFA
- CPDFXFA_App::GetInstance()->Initialize();
+ CPDFXFA_App::GetInstance()->Initialize(
+ (cfg && cfg->version >= 2)
+ ? reinterpret_cast<FXJSE_HRUNTIME>(cfg->m_pIsolate)
+ : nullptr);
#else // PDF_ENABLE_XFA
pModuleMgr->LoadEmbeddedGB1CMaps();
pModuleMgr->LoadEmbeddedJapan1CMaps();
diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
index 44e9c72ddc..1006bf9c44 100644
--- a/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
+++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp
@@ -31,7 +31,8 @@ CPDFXFA_App::CPDFXFA_App()
m_pXFAApp(NULL),
m_pFontMgr(NULL),
m_hJSERuntime(NULL),
- m_csAppType(JS_STR_VIEWERTYPE_STANDARD) {
+ m_csAppType(JS_STR_VIEWERTYPE_STANDARD),
+ m_bOwnedRuntime(false) {
m_pEnvList.RemoveAll();
}
@@ -43,7 +44,7 @@ CPDFXFA_App::~CPDFXFA_App() {
m_pXFAApp = NULL;
#ifdef PDF_ENABLE_XFA
- FXJSE_Runtime_Release(m_hJSERuntime);
+ FXJSE_Runtime_Release(m_hJSERuntime, m_bOwnedRuntime);
m_hJSERuntime = NULL;
FXJSE_Finalize();
@@ -51,12 +52,13 @@ CPDFXFA_App::~CPDFXFA_App() {
#endif
}
-FX_BOOL CPDFXFA_App::Initialize() {
+FX_BOOL CPDFXFA_App::Initialize(FXJSE_HRUNTIME hRuntime) {
#ifdef PDF_ENABLE_XFA
BC_Library_Init();
FXJSE_Initialize();
- m_hJSERuntime = FXJSE_Runtime_Create();
+ m_bOwnedRuntime = !hRuntime;
+ m_hJSERuntime = hRuntime ? hRuntime : FXJSE_Runtime_Create();
if (!m_hJSERuntime)
return FALSE;
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index ba6d748ade..95f392487a 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -121,9 +121,7 @@ CJS_Runtime::~CJS_Runtime() {
delete m_ContextArray.GetAt(i);
m_ContextArray.RemoveAll();
-#ifndef PDF_ENABLE_XFA
FXJS_ReleaseRuntime(GetIsolate(), &m_context, &m_StaticObjects);
-#endif
m_pApp = NULL;
m_pDocument = NULL;
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index 9b6b5fa445..f015f87136 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -370,11 +370,6 @@ void FXJS_ReleaseRuntime(v8::Isolate* pIsolate,
return;
pData->ReleaseDynamicObjsMap();
-#ifdef PDF_ENABLE_XFA
- // XFA, if present, should have already cleaned itself up.
- FXSYS_assert(!pData->m_pFXJSERuntimeData);
-#endif // PDF_ENABLE_XFA
-
int maxID = CFXJS_ObjDefinition::MaxID(pIsolate);
for (int i = 0; i < maxID; ++i) {
CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i);