diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-11-25 16:05:49 -0800 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-11-25 16:05:49 -0800 |
commit | 51da093564cdfd32a6ac02ad75e981787a0f1b35 (patch) | |
tree | 9885c9445759de43e45db33a975b79de45b8dd8a /fpdfsdk/src/javascript/JS_Runtime.cpp | |
parent | 43dd873cb0e92ca777d3ed9d905bc7955556220b (diff) | |
download | pdfium-51da093564cdfd32a6ac02ad75e981787a0f1b35.tar.xz |
Inflict PDF_ENABLE_XFA ifdefs on XFA fpdfsdk/
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1477583002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Runtime.cpp')
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index b195b42957..2d0d7f6e76 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -6,8 +6,10 @@ #include "JS_Runtime.h" +#ifdef PDF_ENABLE_XFA #include "../../../xfa/src/fxjse/src/value.h" #include "../../include/fpdfxfa/fpdfxfa_app.h" +#endif #include "Consts.h" #include "Document.h" #include "Field.h" @@ -51,6 +53,15 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) m_bBlocking(FALSE), m_isolate(NULL), m_isolateManaged(false) { +#ifndef PDF_ENABLE_XFA + 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; +#else if (CPDFXFA_App::GetInstance()->GetJSERuntime()) { // TODO(tsepez): CPDFXFA_App should also use the embedder provided isolate. m_isolate = (v8::Isolate*)CPDFXFA_App::GetInstance()->GetJSERuntime(); @@ -64,7 +75,11 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) embedderDataSlot = pPlatform->m_v8EmbedderSlot; } FXJS_Initialize(embedderDataSlot, pExternalIsolate); +#endif } +#ifndef PDF_ENABLE_XFA + FXJS_Initialize(embedderDataSlot, pExternalIsolate); +#else m_isolateManaged = FXJS_GetIsolate(&m_isolate); } @@ -77,13 +92,20 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects); ReleaseContext(pContext); return; +#endif } +#ifndef PDF_ENABLE_XFA + m_isolateManaged = FXJS_GetIsolate(&m_isolate); +#else +#endif if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0) DefineJSObjects(); +#ifdef PDF_ENABLE_XFA CPDFXFA_App::GetInstance()->SetJavaScriptInitialized(TRUE); +#endif CJS_Context* pContext = (CJS_Context*)NewContext(); FXJS_InitializeRuntime(GetIsolate(), this, &m_context, &m_StaticObjects); ReleaseContext(pContext); @@ -97,6 +119,9 @@ 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; @@ -108,7 +133,9 @@ CJS_Runtime::~CJS_Runtime() { void CJS_Runtime::DefineJSObjects() { v8::Isolate::Scope isolate_scope(GetIsolate()); +#ifdef PDF_ENABLE_XFA v8::Locker locker(GetIsolate()); +#endif v8::HandleScope handle_scope(GetIsolate()); v8::Local<v8::Context> context = v8::Context::New(GetIsolate()); v8::Context::Scope context_scope(context); @@ -181,7 +208,9 @@ IJS_Context* CJS_Runtime::GetCurrentContext() { void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) { if (m_pDocument != pReaderDoc) { v8::Isolate::Scope isolate_scope(m_isolate); +#ifdef PDF_ENABLE_XFA v8::Locker locker(m_isolate); +#endif v8::HandleScope handle_scope(m_isolate); v8::Local<v8::Context> context = v8::Local<v8::Context>::New(m_isolate, m_context); @@ -227,6 +256,7 @@ v8::Local<v8::Context> CJS_Runtime::NewJSContext() { return v8::Local<v8::Context>::New(m_isolate, m_context); } +#ifdef PDF_ENABLE_XFA CFX_WideString ChangeObjName(const CFX_WideString& str) { CFX_WideString sRet = str; sRet.Replace(L"_", L"."); @@ -293,6 +323,7 @@ FX_BOOL CJS_Runtime::SetHValueByName(const CFX_ByteStringC& utf8Name, return TRUE; } +#endif void CJS_Runtime::AddObserver(Observer* observer) { ASSERT(m_observers.find(observer) == m_observers.end()); m_observers.insert(observer); |