Index: fpdfsdk/src/javascript/JS_Runtime.cpp |
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp |
index f20615402952c1cb44d1c6dc62aa6bb7dfcb98c7..bc5443daf614e609880efcc22ea0dad9b8a1df53 100644 |
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp |
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp |
@@ -45,17 +45,18 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) |
if (CPDFXFA_App::GetInstance()->GetJSERuntime()) { |
// TODO(tsepez): CPDFXFA_App should also use the embedder provided isolate. |
m_isolate = (v8::Isolate*)CPDFXFA_App::GetInstance()->GetJSERuntime(); |
- } else if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) { |
- m_isolate = reinterpret_cast<v8::Isolate*>( |
- m_pApp->GetFormFillInfo()->m_pJsPlatform->m_isolate); |
- } |
- if (!m_isolate) { |
- m_pArrayBufferAllocator.reset(new FXJS_ArrayBufferAllocator()); |
- |
- v8::Isolate::CreateParams params; |
- params.array_buffer_allocator = m_pArrayBufferAllocator.get(); |
- m_isolate = v8::Isolate::New(params); |
- m_isolateManaged = true; |
+ } else { |
+ IPDF_JSPLATFORM* pPlatform = m_pApp->GetFormFillInfo()->m_pJsPlatform; |
+ if (pPlatform->version <= 2) { |
+ unsigned int embedderDataSlot = 0; |
+ v8::Isolate* pExternalIsolate = nullptr; |
+ if (pPlatform->version == 2) { |
+ pExternalIsolate = reinterpret_cast<v8::Isolate*>(pPlatform->m_isolate); |
+ embedderDataSlot = pPlatform->m_v8EmbedderSlot; |
+ } |
+ FXJS_Initialize(embedderDataSlot, pExternalIsolate); |
+ } |
+ m_isolateManaged = FXJS_GetIsolate(&m_isolate); |
} |
v8::Isolate* isolate = m_isolate; |
@@ -69,10 +70,6 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) |
return; |
} |
- unsigned int embedderDataSlot = 0; |
- if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) |
- embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot; |
- FXJS_Initialize(embedderDataSlot); |
DefineJSObjects(); |
CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); |