diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-09-15 15:30:34 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-09-15 15:30:34 -0700 |
commit | 7d0fcbf8198f04a5a5bd15482fdbdae919fb1891 (patch) | |
tree | 61817fe7a1fa74c00a7610e8537df62f13e0d8f8 /fpdfsdk/src/javascript/JS_Runtime.cpp | |
parent | 5eb8ba2ef43bac9c8fb96f75357b21b0dbeefe80 (diff) | |
download | pdfium-7d0fcbf8198f04a5a5bd15482fdbdae919fb1891.tar.xz |
Merge to XFA: Refactor fxjs_v8 and add embeddertests for it.
(cherry picked from commit b17d62601b21dfce85718e08cfd0ffce3a45d74e)
(cherry picked from commit 09ed30750282bf56a92d0e646ab22c64bea81a36)
Manual edits:
fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp - add lockers.
fppdfsdk/src/javascript/JS_Runtime.cpp - rework XFA init path.
Original Review URL: https://codereview.chromium.org/1338073002 .
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1348433002 .
Diffstat (limited to 'fpdfsdk/src/javascript/JS_Runtime.cpp')
-rw-r--r-- | fpdfsdk/src/javascript/JS_Runtime.cpp | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index afc6db6ae5..a85067be1b 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -32,24 +32,14 @@ CJS_RuntimeFactory::~CJS_RuntimeFactory() {} IFXJS_Runtime* CJS_RuntimeFactory::NewJSRuntime(CPDFDoc_Environment* pApp) { - if (!m_bInit) { - unsigned int embedderDataSlot = 0; - if (pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) { - embedderDataSlot = - pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot; - } - JS_Initial(embedderDataSlot); - m_bInit = TRUE; - } + m_bInit = true; return new CJS_Runtime(pApp); } void CJS_RuntimeFactory::AddRef() { - // to do.Should be implemented as atom manipulation. m_nRef++; } void CJS_RuntimeFactory::Release() { if (m_bInit) { - // to do.Should be implemented as atom manipulation. if (--m_nRef == 0) { JS_Release(); m_bInit = FALSE; @@ -61,18 +51,6 @@ void CJS_RuntimeFactory::DeleteJSRuntime(IFXJS_Runtime* pRuntime) { delete (CJS_Runtime*)pRuntime; } -void* CJS_ArrayBufferAllocator::Allocate(size_t length) { - return calloc(1, length); -} - -void* CJS_ArrayBufferAllocator::AllocateUninitialized(size_t length) { - return malloc(length); -} - -void CJS_ArrayBufferAllocator::Free(void* data, size_t length) { - free(data); -} - /* ------------------------------ CJS_Runtime ------------------------------ */ v8::Global<v8::ObjectTemplate>& _getGlobalObjectTemplate(v8::Isolate* pIsolate); @@ -91,7 +69,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) m_pApp->GetFormFillInfo()->m_pJsPlatform->m_isolate); } if (!m_isolate) { - m_pArrayBufferAllocator.reset(new CJS_ArrayBufferAllocator()); + m_pArrayBufferAllocator.reset(new JS_ArrayBufferAllocator()); v8::Isolate::CreateParams params; params.array_buffer_allocator = m_pArrayBufferAllocator.get(); @@ -105,15 +83,19 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) v8::HandleScope handle_scope(isolate); if (CPDFXFA_App::GetInstance()->InitRuntime(FALSE)) { CJS_Context* pContext = (CJS_Context*)NewContext(); - JS_InitialRuntime(GetIsolate(), this, pContext, m_context); + JS_InitializeRuntime(GetIsolate(), this, pContext, m_context); ReleaseContext(pContext); return; } + unsigned int embedderDataSlot = 0; + if (m_pApp->GetFormFillInfo()->m_pJsPlatform->version >= 2) + embedderDataSlot = pApp->GetFormFillInfo()->m_pJsPlatform->m_v8EmbedderSlot; + JS_Initialize(embedderDataSlot); DefineJSObjects(); CJS_Context* pContext = (CJS_Context*)NewContext(); - JS_InitialRuntime(GetIsolate(), this, pContext, m_context); + JS_InitializeRuntime(GetIsolate(), this, pContext, m_context); ReleaseContext(pContext); } |