diff options
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 50 | ||||
-rw-r--r-- | fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h | 12 | ||||
-rw-r--r-- | fxjs/cfxjse_engine.cpp | 8 | ||||
-rw-r--r-- | fxjs/cjs_runtime.cpp | 8 | ||||
-rw-r--r-- | fxjs/cjs_runtime.h | 8 | ||||
-rw-r--r-- | fxjs/cjs_runtimestub.cpp | 6 | ||||
-rw-r--r-- | fxjs/ijs_runtime.h | 8 | ||||
-rw-r--r-- | xfa/fxfa/fxfa.h | 13 |
8 files changed, 63 insertions, 50 deletions
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index d47c145700..0833759429 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -984,34 +984,44 @@ bool CPDFXFA_DocEnvironment::SubmitInternal(CXFA_FFDoc* hDoc, return true; } -bool CPDFXFA_DocEnvironment::SetGlobalProperty(CXFA_FFDoc* hDoc, - const ByteStringView& szPropName, - CFXJSE_Value* pValue) { +bool CPDFXFA_DocEnvironment::SetPropertyInNonXFAGlobalObject( + CXFA_FFDoc* hDoc, + const ByteStringView& szPropName, + CFXJSE_Value* pValue) { if (hDoc != m_pContext->GetXFADoc()) return false; - if (!m_pContext->GetFormFillEnv() || - !m_pContext->GetFormFillEnv()->GetIJSRuntime()) { - return false; - } + CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); - IJS_EventContext* pContext = pFormFillEnv->GetIJSRuntime()->NewEventContext(); - bool bRet = pFormFillEnv->GetIJSRuntime()->SetValueByName(szPropName, pValue); - pFormFillEnv->GetIJSRuntime()->ReleaseEventContext(pContext); + if (!pFormFillEnv) + return false; + + IJS_Runtime* pIJSRuntime = pFormFillEnv->GetIJSRuntime(); + if (!pIJSRuntime) + return false; + + IJS_EventContext* pContext = pIJSRuntime->NewEventContext(); + bool bRet = pIJSRuntime->SetValueByNameInGlobalObject(szPropName, pValue); + pIJSRuntime->ReleaseEventContext(pContext); return bRet; } -bool CPDFXFA_DocEnvironment::GetGlobalProperty(CXFA_FFDoc* hDoc, - const ByteStringView& szPropName, - CFXJSE_Value* pValue) { +bool CPDFXFA_DocEnvironment::GetPropertyFromNonXFAGlobalObject( + CXFA_FFDoc* hDoc, + const ByteStringView& szPropName, + CFXJSE_Value* pValue) { if (hDoc != m_pContext->GetXFADoc()) return false; - if (!m_pContext->GetFormFillEnv() || - !m_pContext->GetFormFillEnv()->GetIJSRuntime()) { - return false; - } + CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv(); - IJS_EventContext* pContext = pFormFillEnv->GetIJSRuntime()->NewEventContext(); - bool bRet = pFormFillEnv->GetIJSRuntime()->GetValueByName(szPropName, pValue); - pFormFillEnv->GetIJSRuntime()->ReleaseEventContext(pContext); + if (!pFormFillEnv) + return false; + + IJS_Runtime* pIJSRuntime = pFormFillEnv->GetIJSRuntime(); + if (!pIJSRuntime) + return false; + + IJS_EventContext* pContext = pIJSRuntime->NewEventContext(); + bool bRet = pIJSRuntime->GetValueByNameFromGlobalObject(szPropName, pValue); + pIJSRuntime->ReleaseEventContext(pContext); return bRet; } diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h index 4e037210b2..03aae3d765 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h @@ -64,12 +64,12 @@ class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment { bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) override; - bool GetGlobalProperty(CXFA_FFDoc* hDoc, - const ByteStringView& szPropName, - CFXJSE_Value* pValue) override; - bool SetGlobalProperty(CXFA_FFDoc* hDoc, - const ByteStringView& szPropName, - CFXJSE_Value* pValue) override; + bool GetPropertyFromNonXFAGlobalObject(CXFA_FFDoc* hDoc, + const ByteStringView& szPropName, + CFXJSE_Value* pValue) override; + bool SetPropertyInNonXFAGlobalObject(CXFA_FFDoc* hDoc, + const ByteStringView& szPropName, + CFXJSE_Value* pValue) override; RetainPtr<IFX_SeekableReadStream> OpenLinkedFile( CXFA_FFDoc* hDoc, diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp index 198e1d5fa8..84981666df 100644 --- a/fxjs/cfxjse_engine.cpp +++ b/fxjs/cfxjse_engine.cpp @@ -202,8 +202,8 @@ void CFXJSE_Engine::GlobalPropertySetter(CFXJSE_Value* pObject, if (!pNotify) return; - pNotify->GetDocEnvironment()->SetGlobalProperty(pNotify->GetHDOC(), - szPropName, pValue); + pNotify->GetDocEnvironment()->SetPropertyInNonXFAGlobalObject( + pNotify->GetHDOC(), szPropName, pValue); } void CFXJSE_Engine::GlobalPropertyGetter(CFXJSE_Value* pObject, @@ -259,8 +259,8 @@ void CFXJSE_Engine::GlobalPropertyGetter(CFXJSE_Value* pObject, if (!pNotify) return; - pNotify->GetDocEnvironment()->GetGlobalProperty(pNotify->GetHDOC(), - szPropName, pValue); + pNotify->GetDocEnvironment()->GetPropertyFromNonXFAGlobalObject( + pNotify->GetHDOC(), szPropName, pValue); } int32_t CFXJSE_Engine::GlobalPropTypeGetter(CFXJSE_Value* pOriginalValue, diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp index bffd77cba7..4031304b83 100644 --- a/fxjs/cjs_runtime.cpp +++ b/fxjs/cjs_runtime.cpp @@ -231,8 +231,8 @@ WideString ChangeObjName(const WideString& str) { return sRet; } -bool CJS_Runtime::GetValueByName(const ByteStringView& utf8Name, - CFXJSE_Value* pValue) { +bool CJS_Runtime::GetValueByNameFromGlobalObject(const ByteStringView& utf8Name, + CFXJSE_Value* pValue) { v8::Isolate::Scope isolate_scope(GetIsolate()); v8::HandleScope handle_scope(GetIsolate()); v8::Local<v8::Context> context = NewLocalContext(); @@ -248,8 +248,8 @@ bool CJS_Runtime::GetValueByName(const ByteStringView& utf8Name, return true; } -bool CJS_Runtime::SetValueByName(const ByteStringView& utf8Name, - CFXJSE_Value* pValue) { +bool CJS_Runtime::SetValueByNameInGlobalObject(const ByteStringView& utf8Name, + CFXJSE_Value* pValue) { if (utf8Name.IsEmpty() || !pValue) return false; diff --git a/fxjs/cjs_runtime.h b/fxjs/cjs_runtime.h index 5d55b9a492..9d0d47fa81 100644 --- a/fxjs/cjs_runtime.h +++ b/fxjs/cjs_runtime.h @@ -53,10 +53,10 @@ class CJS_Runtime : public IJS_Runtime, v8::Local<v8::Value> MaybeCoerceToNumber(v8::Local<v8::Value> value); #ifdef PDF_ENABLE_XFA - bool GetValueByName(const ByteStringView& utf8Name, - CFXJSE_Value* pValue) override; - bool SetValueByName(const ByteStringView& utf8Name, - CFXJSE_Value* pValue) override; + bool GetValueByNameFromGlobalObject(const ByteStringView& utf8Name, + CFXJSE_Value* pValue) override; + bool SetValueByNameInGlobalObject(const ByteStringView& utf8Name, + CFXJSE_Value* pValue) override; #endif // PDF_ENABLE_XFA private: diff --git a/fxjs/cjs_runtimestub.cpp b/fxjs/cjs_runtimestub.cpp index 964b0ff9d6..105bb6f114 100644 --- a/fxjs/cjs_runtimestub.cpp +++ b/fxjs/cjs_runtimestub.cpp @@ -30,11 +30,13 @@ class CJS_RuntimeStub final : public IJS_Runtime { } #ifdef PDF_ENABLE_XFA - bool GetValueByName(const ByteStringView&, CFXJSE_Value*) override { + bool GetValueByNameFromGlobalObject(const ByteStringView&, + CFXJSE_Value*) override { return false; } - bool SetValueByName(const ByteStringView&, CFXJSE_Value*) override { + bool SetValueByNameInGlobalObject(const ByteStringView&, + CFXJSE_Value*) override { return false; } #endif // PDF_ENABLE_XFA diff --git a/fxjs/ijs_runtime.h b/fxjs/ijs_runtime.h index 9fe5d2fed8..b97c65ef90 100644 --- a/fxjs/ijs_runtime.h +++ b/fxjs/ijs_runtime.h @@ -34,10 +34,10 @@ class IJS_Runtime { virtual int ExecuteScript(const WideString& script, WideString* info) = 0; #ifdef PDF_ENABLE_XFA - virtual bool GetValueByName(const ByteStringView& utf8Name, - CFXJSE_Value* pValue) = 0; - virtual bool SetValueByName(const ByteStringView& utf8Name, - CFXJSE_Value* pValue) = 0; + virtual bool GetValueByNameFromGlobalObject(const ByteStringView& utf8Name, + CFXJSE_Value* pValue) = 0; + virtual bool SetValueByNameInGlobalObject(const ByteStringView& utf8Name, + CFXJSE_Value* pValue) = 0; #endif // PDF_ENABLE_XFA protected: diff --git a/xfa/fxfa/fxfa.h b/xfa/fxfa/fxfa.h index b9998779a7..4a1f8b32fc 100644 --- a/xfa/fxfa/fxfa.h +++ b/xfa/fxfa/fxfa.h @@ -251,12 +251,13 @@ class IXFA_DocEnvironment { virtual FX_ARGB GetHighlightColor(CXFA_FFDoc* hDoc) = 0; virtual bool Submit(CXFA_FFDoc* hDoc, CXFA_Submit* submit) = 0; - virtual bool GetGlobalProperty(CXFA_FFDoc* hDoc, - const ByteStringView& szPropName, - CFXJSE_Value* pValue) = 0; - virtual bool SetGlobalProperty(CXFA_FFDoc* hDoc, - const ByteStringView& szPropName, - CFXJSE_Value* pValue) = 0; + virtual bool GetPropertyFromNonXFAGlobalObject( + CXFA_FFDoc* hDoc, + const ByteStringView& szPropName, + CFXJSE_Value* pValue) = 0; + virtual bool SetPropertyInNonXFAGlobalObject(CXFA_FFDoc* hDoc, + const ByteStringView& szPropName, + CFXJSE_Value* pValue) = 0; virtual RetainPtr<IFX_SeekableReadStream> OpenLinkedFile( CXFA_FFDoc* hDoc, const WideString& wsLink) = 0; |