From 9cbd2dd8ff0812aae57a99d6a7dc285cc8b9e262 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 2 Feb 2018 17:24:58 +0000 Subject: Make global object function names clearer. Also tidy some sub-expressions. Change-Id: Ieabd5f6cea60e8ec03c8ce5ebe372fc80b05a7bb Reviewed-on: https://pdfium-review.googlesource.com/25150 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 50 ++++++++++++++++++------------ fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h | 12 +++---- 2 files changed, 36 insertions(+), 26 deletions(-) (limited to 'fpdfsdk') 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 OpenLinkedFile( CXFA_FFDoc* hDoc, -- cgit v1.2.3