summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript/JS_Runtime.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-02 16:43:15 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-02 16:43:15 -0700
commit3dedace9623fef6161a8666e53a4ab2b9be61e4c (patch)
tree78fba57e1a3edcd064dead99da9a01e8a56055eb /fpdfsdk/src/javascript/JS_Runtime.cpp
parentac67d4765a8ac36cd00c9fc8b6f2b80a3e1cff72 (diff)
downloadpdfium-3dedace9623fef6161a8666e53a4ab2b9be61e4c.tar.xz
Pass v8::Isolate to PDFium at init time.
Move the external isolate and embedder slot from the IPDF_JSPlatforms struct supplied at the FPDFDOC_InitFormFillEnvironment() call time to arguments to the FPDF_InitLibraryWithConfig() call. This has several benefits: -- Avoids the crash that could happen if multiple FPDFDOC_InitFormFillEnvironmen() calls should happen to be made by an embedder with different slot values. -- Down the road, for XFA, there may be XFA but no FormFill environment. We support both forms for the time being, until the chrome side catches up, at which point we will deprecate the old way. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1367033002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Runtime.cpp')
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp25
1 files changed, 10 insertions, 15 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 1e1486df5c..5c463ce498 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -35,22 +35,17 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp)
m_bBlocking(FALSE),
m_isolate(NULL),
m_isolateManaged(false) {
- unsigned int embedderDataSlot = 0;
- if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) {
- m_isolate = reinterpret_cast<v8::Isolate*>(
- m_pApp->GetFormFillInfo()->m_pJsPlatform->m_isolate);
- embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot;
- }
- 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;
+ 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);
}
-
- FXJS_Initialize(embedderDataSlot);
+ m_isolateManaged = FXJS_GetIsolate(&m_isolate);
DefineJSObjects();
CJS_Context* pContext = (CJS_Context*)NewContext();