diff options
author | Jochen Eisinger <jochen@chromium.org> | 2015-07-30 17:44:35 +0200 |
---|---|---|
committer | Jochen Eisinger <jochen@chromium.org> | 2015-07-30 17:44:35 +0200 |
commit | 06b60021edacf7e4f2d1b1468a3aa898bab10301 (patch) | |
tree | 6c0177fefc0d839594abe81224fde3aae9951352 /fpdfsdk/src/javascript | |
parent | 4e57057c361897834b77b4c84b412f949427f974 (diff) | |
download | pdfium-06b60021edacf7e4f2d1b1468a3aa898bab10301.tar.xz |
Merge to XFA: Plumb in an externally created v8::Isolate
Origin Review URL:
- https://codereview.chromium.org/1234053003
- https://codereview.chromium.org/1241863004
- https://codereview.chromium.org/1235303003
R=tsepez@chromium.org
BUG=
Review URL: https://codereview.chromium.org/1263963002 .
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index 346b642913..d68b268591 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -37,7 +37,11 @@ IFXJS_Runtime* CJS_RuntimeFactory::NewJSRuntime(CPDFDoc_Environ { if (!m_bInit) { - JS_Initial(); + unsigned int embedderDataSlot = 0; + if (pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) { + embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot; + } + JS_Initial(embedderDataSlot); m_bInit = TRUE; } return new CJS_Runtime(pApp); @@ -107,16 +111,22 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) : m_pApp(pApp), m_pDocument(NULL), m_bBlocking(FALSE), - m_pFieldEventPath(NULL) + m_pFieldEventPath(NULL), + m_isolate(NULL) { 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 { + } 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 CJS_ArrayBufferAllocator()); + v8::Isolate::CreateParams params; params.array_buffer_allocator = m_pArrayBufferAllocator.get(); m_isolate = v8::Isolate::New(params); - } + } v8::Isolate* isolate = m_isolate; v8::Isolate::Scope isolate_scope(isolate); |