From 808a99e8c6f72713ca9492508faa4b8445ae0d33 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Thu, 10 Sep 2015 12:28:37 -0700 Subject: Merge to XFA: Remove some abstractions in fxjs_v8.h. Conflicts: fpdfsdk/src/javascript/Document.cpp fpdfsdk/src/javascript/JS_Runtime.cpp fpdfsdk/src/jsapi/fxjs_v8.cpp New: fpdfsdk/src/fpdfxfa/fpdfxfa_app.cpp (cherry picked from commit 6df59849472958e7de96da6d9fc7b223b7c1f1c3) Original Review URL: https://codereview.chromium.org/1332973002 . R=thestig@chromium.org Review URL: https://codereview.chromium.org/1334833003 . --- fpdfsdk/src/javascript/JS_Runtime.cpp | 63 +++++++++++++++++------------------ 1 file changed, 30 insertions(+), 33 deletions(-) (limited to 'fpdfsdk/src/javascript/JS_Runtime.cpp') diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp index 927965e5a4..062dd25b29 100644 --- a/fpdfsdk/src/javascript/JS_Runtime.cpp +++ b/fpdfsdk/src/javascript/JS_Runtime.cpp @@ -94,8 +94,8 @@ void CJS_ArrayBufferAllocator::Free(void* data, size_t length) { } /* ------------------------------ CJS_Runtime ------------------------------ */ -extern v8::Global& _getGlobalObjectTemplate( - IJS_Runtime* pJSRuntime); +v8::Global& _getGlobalObjectTemplate(v8::Isolate* pIsolate); + CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) : m_pApp(pApp), m_pDocument(NULL), @@ -125,7 +125,7 @@ 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(*this, this, pContext, m_context); + JS_InitialRuntime(GetIsolate(), this, pContext, m_context); ReleaseContext(pContext); return; } @@ -133,7 +133,7 @@ CJS_Runtime::CJS_Runtime(CPDFDoc_Environment* pApp) InitJSObjects(); CJS_Context* pContext = (CJS_Context*)NewContext(); - JS_InitialRuntime(*this, this, pContext, m_context); + JS_InitialRuntime(GetIsolate(), this, pContext, m_context); ReleaseContext(pContext); } @@ -163,59 +163,59 @@ FX_BOOL CJS_Runtime::InitJSObjects() { v8::Local context = v8::Context::New(GetIsolate()); v8::Context::Scope context_scope(context); // 0 - 8 - if (CJS_Border::Init(*this, JS_STATIC) < 0) + if (CJS_Border::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Display::Init(*this, JS_STATIC) < 0) + if (CJS_Display::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Font::Init(*this, JS_STATIC) < 0) + if (CJS_Font::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Highlight::Init(*this, JS_STATIC) < 0) + if (CJS_Highlight::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Position::Init(*this, JS_STATIC) < 0) + if (CJS_Position::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_ScaleHow::Init(*this, JS_STATIC) < 0) + if (CJS_ScaleHow::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_ScaleWhen::Init(*this, JS_STATIC) < 0) + if (CJS_ScaleWhen::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Style::Init(*this, JS_STATIC) < 0) + if (CJS_Style::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Zoomtype::Init(*this, JS_STATIC) < 0) + if (CJS_Zoomtype::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; // 9 - 11 - if (CJS_App::Init(*this, JS_STATIC) < 0) + if (CJS_App::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Color::Init(*this, JS_STATIC) < 0) + if (CJS_Color::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Console::Init(*this, JS_STATIC) < 0) + if (CJS_Console::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; // 12 - 14 - if (CJS_Document::Init(*this, JS_DYNAMIC) < 0) + if (CJS_Document::Init(GetIsolate(), JS_DYNAMIC) < 0) return FALSE; - if (CJS_Event::Init(*this, JS_STATIC) < 0) + if (CJS_Event::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Field::Init(*this, JS_DYNAMIC) < 0) + if (CJS_Field::Init(GetIsolate(), JS_DYNAMIC) < 0) return FALSE; // 15 - 17 - if (CJS_Global::Init(*this, JS_STATIC) < 0) + if (CJS_Global::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_Icon::Init(*this, JS_DYNAMIC) < 0) + if (CJS_Icon::Init(GetIsolate(), JS_DYNAMIC) < 0) return FALSE; - if (CJS_Util::Init(*this, JS_STATIC) < 0) + if (CJS_Util::Init(GetIsolate(), JS_STATIC) < 0) return FALSE; - if (CJS_PublicMethods::Init(*this) < 0) + if (CJS_PublicMethods::Init(GetIsolate()) < 0) return FALSE; - if (CJS_GlobalConsts::Init(*this) < 0) + if (CJS_GlobalConsts::Init(GetIsolate()) < 0) return FALSE; - if (CJS_GlobalArrays::Init(*this) < 0) + if (CJS_GlobalArrays::Init(GetIsolate()) < 0) return FALSE; - if (CJS_TimerObj::Init(*this, JS_DYNAMIC) < 0) + if (CJS_TimerObj::Init(GetIsolate(), JS_DYNAMIC) < 0) return FALSE; - if (CJS_PrintParamsObj::Init(*this, JS_DYNAMIC) < 0) + if (CJS_PrintParamsObj::Init(GetIsolate(), JS_DYNAMIC) < 0) return FALSE; return TRUE; @@ -255,20 +255,17 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) { v8::Context::Scope context_scope(context); m_pDocument = pReaderDoc; - if (pReaderDoc) { - JSObject pThis = JS_GetThisObj(*this); + v8::Local pThis = JS_GetThisObj(GetIsolate()); if (!pThis.IsEmpty()) { - if (JS_GetObjDefnID(pThis) == JS_GetObjDefnID(*this, L"Document")) { + if (JS_GetObjDefnID(pThis) == + JS_GetObjDefnID(GetIsolate(), L"Document")) { if (CJS_Document* pJSDocument = (CJS_Document*)JS_GetPrivate(pThis)) { if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject()) pDocument->AttachDoc(pReaderDoc); } } } - JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"Document")); - } else { - JS_SetThisObj(*this, JS_GetObjDefnID(*this, L"app")); } } } -- cgit v1.2.3