summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-07 10:17:53 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-07 10:17:53 -0700
commita72e8e2c4392df725c7e35ed1ae3f891e79e49ec (patch)
tree99eb91f764c428cd34a3b84e8b9e9bfb239d9e5a /fpdfsdk/src/javascript
parentcd56a7d6fb05bd0babf316a84280a26ecc649d45 (diff)
downloadpdfium-a72e8e2c4392df725c7e35ed1ae3f891e79e49ec.tar.xz
Merge to XFA: Pass v8::Isolate to PDFium at init time.
New code changes in JS_Runtime.cpp. (cherry picked from commit 3dedace9623fef6161a8666e53a4ab2b9be61e4c) Original Review URL: https://codereview.chromium.org/1367033002 . Also merge to XFA: Run FXJS_V8 embedder tests against a shared isolate, since the two go together. (cherry picked from commit 4ea721cb7954898a9722c389dae86c62957352d0) Original Review URL: https://codereview.chromium.org/1377293004 . R=thestig@chromium.org Review URL: https://codereview.chromium.org/1381633008 .
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp27
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.h2
2 files changed, 12 insertions, 17 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index f206154029..bc5443daf6 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);
diff --git a/fpdfsdk/src/javascript/JS_Runtime.h b/fpdfsdk/src/javascript/JS_Runtime.h
index 0576980233..1034ae8c8b 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.h
+++ b/fpdfsdk/src/javascript/JS_Runtime.h
@@ -10,7 +10,6 @@
#include <set>
#include <utility>
-#include "../../../third_party/base/nonstd_unique_ptr.h"
#include "../../../core/include/fxcrt/fx_basic.h"
#include "../../include/javascript/IJavaScript.h"
#include "../../include/jsapi/fxjs_v8.h"
@@ -71,7 +70,6 @@ class CJS_Runtime : public IFXJS_Runtime {
std::set<FieldEvent> m_FieldEventSet;
v8::Isolate* m_isolate;
bool m_isolateManaged;
- nonstd::unique_ptr<FXJS_ArrayBufferAllocator> m_pArrayBufferAllocator;
v8::Global<v8::Context> m_context;
std::set<Observer*> m_observers;
};