From c22d671728605bc614dc84ec6a42a5647808b30d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 5 Jun 2018 22:33:31 +0000 Subject: Introduce IJS_Runtime::ScopedEventContext helper class. This proves that m_EventContextArray is, in fact, a stack. Tidy one function by using AutoRestorer while at it. Change-Id: I319538b4eadcd9ce83319aa73861635dd5eb8c36 Reviewed-on: https://pdfium-review.googlesource.com/33970 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'fpdfsdk/fpdfxfa') diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp index f9f5981efb..81e5fd08f4 100644 --- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp +++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp @@ -994,10 +994,8 @@ bool CPDFXFA_DocEnvironment::SetPropertyInNonXFAGlobalObject( if (!pIJSRuntime) return false; - IJS_EventContext* pContext = pIJSRuntime->NewEventContext(); - bool bRet = pIJSRuntime->SetValueByNameInGlobalObject(szPropName, pValue); - pIJSRuntime->ReleaseEventContext(pContext); - return bRet; + IJS_Runtime::ScopedEventContext pContext(pIJSRuntime); + return pIJSRuntime->SetValueByNameInGlobalObject(szPropName, pValue); } bool CPDFXFA_DocEnvironment::GetPropertyFromNonXFAGlobalObject( @@ -1015,8 +1013,6 @@ bool CPDFXFA_DocEnvironment::GetPropertyFromNonXFAGlobalObject( if (!pIJSRuntime) return false; - IJS_EventContext* pContext = pIJSRuntime->NewEventContext(); - bool bRet = pIJSRuntime->GetValueByNameFromGlobalObject(szPropName, pValue); - pIJSRuntime->ReleaseEventContext(pContext); - return bRet; + IJS_Runtime::ScopedEventContext pContext(pIJSRuntime); + return pIJSRuntime->GetValueByNameFromGlobalObject(szPropName, pValue); } -- cgit v1.2.3