diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_formfillenvironment.cpp | 10 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_formfillenvironment.h | 6 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/fpdfformfill.cpp | 4 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.cpp | 8 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_context.h | 2 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 16 | ||||
-rw-r--r-- | fpdfsdk/fsdk_actionhandler.cpp | 12 |
8 files changed, 32 insertions, 34 deletions
diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.cpp b/fpdfsdk/cpdfsdk_formfillenvironment.cpp index 955c184e95..7ac7a0ea32 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.cpp +++ b/fpdfsdk/cpdfsdk_formfillenvironment.cpp @@ -206,12 +206,12 @@ void CPDFSDK_FormFillEnvironment::JS_docgotoPage(int nPageNum) { m_pInfo->m_pJsPlatform->Doc_gotoPage(m_pInfo->m_pJsPlatform, nPageNum); } -IJS_Runtime* CPDFSDK_FormFillEnvironment::GetJSRuntime() { - if (!IsJSInitiated()) +IJS_Runtime* CPDFSDK_FormFillEnvironment::GetIJSRuntime() { + if (!IsJSPlatformPresent()) return nullptr; - if (!m_pJSRuntime) - m_pJSRuntime.reset(IJS_Runtime::Create(this)); - return m_pJSRuntime.get(); + if (!m_pIJSRuntime) + m_pIJSRuntime = IJS_Runtime::Create(this); + return m_pIJSRuntime.get(); } CPDFSDK_AnnotHandlerMgr* CPDFSDK_FormFillEnvironment::GetAnnotHandlerMgr() { diff --git a/fpdfsdk/cpdfsdk_formfillenvironment.h b/fpdfsdk/cpdfsdk_formfillenvironment.h index 31a1c5156c..f00630c18b 100644 --- a/fpdfsdk/cpdfsdk_formfillenvironment.h +++ b/fpdfsdk/cpdfsdk_formfillenvironment.h @@ -205,7 +205,7 @@ class CPDFSDK_FormFillEnvironment FPDF_BOOL bAnnotations); void JS_docgotoPage(int nPageNum); - bool IsJSInitiated() const { return m_pInfo && m_pInfo->m_pJsPlatform; } + bool IsJSPlatformPresent() const { return m_pInfo && m_pInfo->m_pJsPlatform; } ByteString GetAppName() const { return ""; } CFX_SystemHandler* GetSysHandler() const { return m_pSysHandler.get(); } FPDF_FORMFILLINFO* GetFormFillInfo() const { return m_pInfo; } @@ -213,7 +213,7 @@ class CPDFSDK_FormFillEnvironment // Creates if not present. CFFL_InteractiveFormFiller* GetInteractiveFormFiller(); CPDFSDK_AnnotHandlerMgr* GetAnnotHandlerMgr(); // Creates if not present. - IJS_Runtime* GetJSRuntime(); // Creates if not present. + IJS_Runtime* GetIJSRuntime(); // Creates if not present. CPDFSDK_ActionHandler* GetActionHandler(); // Creates if not present. CPDFSDK_InterForm* GetInterForm(); // Creates if not present. @@ -223,7 +223,7 @@ class CPDFSDK_FormFillEnvironment FPDF_FORMFILLINFO* const m_pInfo; std::unique_ptr<CPDFSDK_AnnotHandlerMgr> m_pAnnotHandlerMgr; std::unique_ptr<CPDFSDK_ActionHandler> m_pActionHandler; - std::unique_ptr<IJS_Runtime> m_pJSRuntime; + std::unique_ptr<IJS_Runtime> m_pIJSRuntime; std::map<UnderlyingPageType*, std::unique_ptr<CPDFSDK_PageView>> m_PageMap; std::unique_ptr<CPDFSDK_InterForm> m_pInterForm; CPDFSDK_Annot::ObservedPtr m_pFocusAnnot; diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 3b76dca682..2d25894c5d 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -247,7 +247,7 @@ void CPDFSDK_InterForm::SynchronizeField(CPDF_FormField* pFormField) { #endif // PDF_ENABLE_XFA void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { - if (!m_pFormFillEnv->IsJSInitiated()) + if (!m_pFormFillEnv->IsJSPlatformPresent()) return; if (m_bBusy) @@ -260,7 +260,7 @@ void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { return; } - IJS_Runtime* pRuntime = m_pFormFillEnv->GetJSRuntime(); + IJS_Runtime* pRuntime = m_pFormFillEnv->GetIJSRuntime(); int nSize = m_pInterForm->CountFieldsInCalculationOrder(); for (int i = 0; i < nSize; i++) { CPDF_FormField* pField = m_pInterForm->GetFieldInCalculationOrder(i); @@ -301,12 +301,12 @@ void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, bool& bFormatted) { WideString sValue = pFormField->GetValue(); - if (!m_pFormFillEnv->IsJSInitiated()) { + if (!m_pFormFillEnv->IsJSPlatformPresent()) { bFormatted = false; return sValue; } - IJS_Runtime* pRuntime = m_pFormFillEnv->GetJSRuntime(); + IJS_Runtime* pRuntime = m_pFormFillEnv->GetIJSRuntime(); if (pFormField->GetFieldType() == FormFieldType::kComboBox && pFormField->CountSelectedItems() > 0) { int index = pFormField->GetSelectedIndex(0); diff --git a/fpdfsdk/fpdfformfill.cpp b/fpdfsdk/fpdfformfill.cpp index 10aecb3fde..eba1ac5656 100644 --- a/fpdfsdk/fpdfformfill.cpp +++ b/fpdfsdk/fpdfformfill.cpp @@ -770,7 +770,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentJSAction(FPDF_FORMHANDLE hHandle) { CPDFSDK_FormFillEnvironment* pFormFillEnv = HandleToCPDFSDKEnvironment(hHandle); - if (pFormFillEnv && pFormFillEnv->IsJSInitiated()) + if (pFormFillEnv && pFormFillEnv->IsJSPlatformPresent()) pFormFillEnv->ProcJavascriptFun(); } @@ -778,7 +778,7 @@ FPDF_EXPORT void FPDF_CALLCONV FORM_DoDocumentOpenAction(FPDF_FORMHANDLE hHandle) { CPDFSDK_FormFillEnvironment* pFormFillEnv = HandleToCPDFSDKEnvironment(hHandle); - if (pFormFillEnv && pFormFillEnv->IsJSInitiated()) + if (pFormFillEnv && pFormFillEnv->IsJSPlatformPresent()) pFormFillEnv->ProcOpenAction(); } diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp index d05e2f6b34..784344f1c6 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.cpp @@ -104,7 +104,7 @@ bool CPDFXFA_Context::LoadXFADoc() { return false; } m_pXFADoc->StopLoad(); - m_pXFADoc->GetXFADoc()->InitScriptContext(GetJSERuntime()); + m_pXFADoc->GetXFADoc()->InitScriptContext(GetCJSRuntime()->GetIsolate()); if (m_pXFADoc->GetFormType() == FormType::kXFAFull) m_FormType = FormType::kXFAFull; @@ -198,14 +198,12 @@ void CPDFXFA_Context::ClearChangeMark() { m_pFormFillEnv->ClearChangeMark(); } -v8::Isolate* CPDFXFA_Context::GetJSERuntime() const { +CJS_Runtime* CPDFXFA_Context::GetCJSRuntime() const { if (!m_pFormFillEnv) return nullptr; // XFA requires V8, if we have V8 then we have a CJS_Runtime and not the stub. - CJS_Runtime* runtime = - static_cast<CJS_Runtime*>(m_pFormFillEnv->GetJSRuntime()); - return runtime->GetIsolate(); + return static_cast<CJS_Runtime*>(m_pFormFillEnv->GetIJSRuntime()); } WideString CPDFXFA_Context::GetAppTitle() const { diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h index acef8f2aa8..3eca1b548c 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h @@ -45,7 +45,7 @@ class CPDFXFA_Context : public IXFA_AppProvider { return m_FormType == FormType::kXFAFull || m_FormType == FormType::kXFAForeground; } - v8::Isolate* GetJSERuntime() const; + CJS_Runtime* GetCJSRuntime() const; CXFA_FFApp* GetXFAApp() { return m_pXFAApp.get(); } CPDFSDK_FormFillEnvironment* GetFormFillEnv() const { diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index f3acf5624c..d47c145700 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -990,13 +990,13 @@ bool CPDFXFA_DocEnvironment::SetGlobalProperty(CXFA_FFDoc* hDoc, if (hDoc != m_pContext->GetXFADoc()) return false; if (!m_pContext->GetFormFillEnv() || - !m_pContext->GetFormFillEnv()->GetJSRuntime()) { + !m_pContext->GetFormFillEnv()->GetIJSRuntime()) { return false; } CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); - IJS_EventContext* pContext = pFormFillEnv->GetJSRuntime()->NewEventContext(); - bool bRet = pFormFillEnv->GetJSRuntime()->SetValueByName(szPropName, pValue); - pFormFillEnv->GetJSRuntime()->ReleaseEventContext(pContext); + IJS_EventContext* pContext = pFormFillEnv->GetIJSRuntime()->NewEventContext(); + bool bRet = pFormFillEnv->GetIJSRuntime()->SetValueByName(szPropName, pValue); + pFormFillEnv->GetIJSRuntime()->ReleaseEventContext(pContext); return bRet; } @@ -1006,12 +1006,12 @@ bool CPDFXFA_DocEnvironment::GetGlobalProperty(CXFA_FFDoc* hDoc, if (hDoc != m_pContext->GetXFADoc()) return false; if (!m_pContext->GetFormFillEnv() || - !m_pContext->GetFormFillEnv()->GetJSRuntime()) { + !m_pContext->GetFormFillEnv()->GetIJSRuntime()) { return false; } CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); - IJS_EventContext* pContext = pFormFillEnv->GetJSRuntime()->NewEventContext(); - bool bRet = pFormFillEnv->GetJSRuntime()->GetValueByName(szPropName, pValue); - pFormFillEnv->GetJSRuntime()->ReleaseEventContext(pContext); + IJS_EventContext* pContext = pFormFillEnv->GetIJSRuntime()->NewEventContext(); + bool bRet = pFormFillEnv->GetIJSRuntime()->GetValueByName(szPropName, pValue); + pFormFillEnv->GetIJSRuntime()->ReleaseEventContext(pContext); return bRet; } diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp index 6fcf9d41c1..0059bb919c 100644 --- a/fpdfsdk/fsdk_actionhandler.cpp +++ b/fpdfsdk/fsdk_actionhandler.cpp @@ -49,7 +49,7 @@ bool CPDFSDK_ActionHandler::DoAction_FieldJavaScript( CPDF_FormField* pFormField, PDFSDK_FieldAction* data) { ASSERT(pFormFillEnv); - if (pFormFillEnv->IsJSInitiated() && + if (pFormFillEnv->IsJSPlatformPresent() && JsAction.GetType() == CPDF_Action::JavaScript) { WideString swJS = JsAction.GetJavaScript(); if (!swJS.IsEmpty()) { @@ -124,7 +124,7 @@ bool CPDFSDK_ActionHandler::ExecuteDocumentOpenAction( ASSERT(pFormFillEnv); if (action.GetType() == CPDF_Action::JavaScript) { - if (pFormFillEnv->IsJSInitiated()) { + if (pFormFillEnv->IsJSPlatformPresent()) { WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) RunDocumentOpenJavaScript(pFormFillEnv, L"", swJS); @@ -184,7 +184,7 @@ bool CPDFSDK_ActionHandler::ExecuteDocumentPageAction( ASSERT(pFormFillEnv); if (action.GetType() == CPDF_Action::JavaScript) { - if (pFormFillEnv->IsJSInitiated()) { + if (pFormFillEnv->IsJSPlatformPresent()) { WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) RunDocumentPageJavaScript(pFormFillEnv, type, swJS); @@ -229,7 +229,7 @@ bool CPDFSDK_ActionHandler::ExecuteFieldAction( ASSERT(pFormFillEnv); if (action.GetType() == CPDF_Action::JavaScript) { - if (pFormFillEnv->IsJSInitiated()) { + if (pFormFillEnv->IsJSPlatformPresent()) { WideString swJS = action.GetJavaScript(); if (!swJS.IsEmpty()) { RunFieldJavaScript(pFormFillEnv, pFormField, type, data, swJS); @@ -526,7 +526,7 @@ void CPDFSDK_ActionHandler::RunScriptForAction( const CPDF_Action& action, CPDFSDK_FormFillEnvironment* pFormFillEnv, std::function<void(IJS_EventContext* context)> cb) { - if (!pFormFillEnv->IsJSInitiated()) + if (!pFormFillEnv->IsJSPlatformPresent()) return; WideString swJS = action.GetJavaScript(); @@ -540,7 +540,7 @@ void CPDFSDK_ActionHandler::RunScript( CPDFSDK_FormFillEnvironment* pFormFillEnv, const WideString& script, std::function<void(IJS_EventContext* context)> cb) { - IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime(); + IJS_Runtime* pRuntime = pFormFillEnv->GetIJSRuntime(); IJS_EventContext* pContext = pRuntime->NewEventContext(); cb(pContext); |