summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript/cjs_runtime.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-10-11 12:38:01 -0700
committerCommit bot <commit-bot@chromium.org>2016-10-11 12:38:01 -0700
commit82e1767b757d96e6b81d3e42b24048a9bea387a8 (patch)
treeb7d14dfcd42ce6acf7a5552be0ff185cf0a9ed58 /fpdfsdk/javascript/cjs_runtime.cpp
parent9fa95efa11f211a6faf9b2adb27211f784aee89a (diff)
downloadpdfium-82e1767b757d96e6b81d3e42b24048a9bea387a8.tar.xz
Convert IJS_Runtime to CPDFSDK_FormFillEnvironment
This CL changes the use of CPDFSDK_Document to CPDFSDK_FormFillEnvironment. Review-Url: https://codereview.chromium.org/2394313002
Diffstat (limited to 'fpdfsdk/javascript/cjs_runtime.cpp')
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp31
1 files changed, 13 insertions, 18 deletions
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index af70dd17cc..d41726b315 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -47,8 +47,8 @@ void IJS_Runtime::Destroy() {
}
// static
-IJS_Runtime* IJS_Runtime::Create(CPDFSDK_FormFillEnvironment* pEnv) {
- return new CJS_Runtime(pEnv);
+IJS_Runtime* IJS_Runtime::Create(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+ return new CJS_Runtime(pFormFillEnv);
}
// static
@@ -63,14 +63,13 @@ CJS_Runtime* CJS_Runtime::CurrentRuntimeFromIsolate(v8::Isolate* pIsolate) {
CFXJS_Engine::CurrentEngineFromIsolate(pIsolate));
}
-CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pEnv)
- : m_pEnv(pEnv),
- m_pDocument(nullptr),
+CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv)
+ : m_pFormFillEnv(pFormFillEnv),
m_bBlocking(false),
m_isolateManaged(false) {
v8::Isolate* pIsolate = nullptr;
#ifndef PDF_ENABLE_XFA
- IPDF_JSPLATFORM* pPlatform = m_pEnv->GetFormFillInfo()->m_pJsPlatform;
+ IPDF_JSPLATFORM* pPlatform = m_pFormFillEnv->GetFormFillInfo()->m_pJsPlatform;
if (pPlatform->version <= 2) {
unsigned int embedderDataSlot = 0;
v8::Isolate* pExternalIsolate = nullptr;
@@ -88,7 +87,8 @@ CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pEnv)
pIsolate = CPDFXFA_App::GetInstance()->GetJSERuntime();
SetIsolate(pIsolate);
} else {
- IPDF_JSPLATFORM* pPlatform = m_pEnv->GetFormFillInfo()->m_pJsPlatform;
+ IPDF_JSPLATFORM* pPlatform =
+ m_pFormFillEnv->GetFormFillInfo()->m_pJsPlatform;
if (pPlatform->version <= 2) {
unsigned int embedderDataSlot = 0;
v8::Isolate* pExternalIsolate = nullptr;
@@ -122,6 +122,8 @@ CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pEnv)
CJS_Context* pContext = (CJS_Context*)NewContext();
InitializeEngine();
ReleaseContext(pContext);
+
+ SetFormFillEnvToDocument();
}
CJS_Runtime::~CJS_Runtime() {
@@ -199,19 +201,12 @@ IJS_Context* CJS_Runtime::GetCurrentContext() {
return m_ContextArray.empty() ? nullptr : m_ContextArray.back().get();
}
-void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
- if (m_pDocument == pReaderDoc)
- return;
-
+void CJS_Runtime::SetFormFillEnvToDocument() {
v8::Isolate::Scope isolate_scope(GetIsolate());
v8::HandleScope handle_scope(GetIsolate());
v8::Local<v8::Context> context = NewLocalContext();
v8::Context::Scope context_scope(context);
- m_pDocument = pReaderDoc;
- if (!pReaderDoc)
- return;
-
v8::Local<v8::Object> pThis = GetThisObj();
if (pThis.IsEmpty())
return;
@@ -228,11 +223,11 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
if (!pDocument)
return;
- pDocument->AttachDoc(pReaderDoc);
+ pDocument->SetFormFillEnv(m_pFormFillEnv);
}
-CPDFSDK_Document* CJS_Runtime::GetReaderDocument() {
- return m_pDocument;
+CPDFSDK_FormFillEnvironment* CJS_Runtime::GetFormFillEnv() const {
+ return m_pFormFillEnv;
}
int CJS_Runtime::ExecuteScript(const CFX_WideString& script,