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 --- fxjs/cfxjse_engine.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'fxjs/cfxjse_engine.cpp') diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp index 90fcc312db..2361a64441 100644 --- a/fxjs/cfxjse_engine.cpp +++ b/fxjs/cfxjse_engine.cpp @@ -145,13 +145,10 @@ bool CFXJSE_Engine::RunScript(CXFA_Script::Type eScriptType, } AutoRestorer nodeRestorer(&m_pThisObject); m_pThisObject = pThisObject; - CFXJSE_Value* pValue = pThisObject ? GetJSValueFromMap(pThisObject) : nullptr; - - IJS_EventContext* ctx = m_pSubordinateRuntime->NewEventContext(); - bool ret = m_JsContext->ExecuteScript(btScript.c_str(), hRetValue, pValue); - m_pSubordinateRuntime->ReleaseEventContext(ctx); - return ret; + CFXJSE_Value* pValue = pThisObject ? GetJSValueFromMap(pThisObject) : nullptr; + IJS_Runtime::ScopedEventContext ctx(m_pSubordinateRuntime.Get()); + return m_JsContext->ExecuteScript(btScript.c_str(), hRetValue, pValue); } bool CFXJSE_Engine::QueryNodeByFlag(CXFA_Node* refNode, -- cgit v1.2.3