summaryrefslogtreecommitdiff
path: root/fpdfsdk/cpdfsdk_actionhandler.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-05 22:33:31 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-05 22:33:31 +0000
commitc22d671728605bc614dc84ec6a42a5647808b30d (patch)
treece4ec68b844414d1ce1f7275181795677b4ca87e /fpdfsdk/cpdfsdk_actionhandler.cpp
parent7edcf2ce07e87022361a0e00fde27aad738c0621 (diff)
downloadpdfium-c22d671728605bc614dc84ec6a42a5647808b30d.tar.xz
Introduce IJS_Runtime::ScopedEventContext helper class.chromium/3451
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 <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fpdfsdk/cpdfsdk_actionhandler.cpp')
-rw-r--r--fpdfsdk/cpdfsdk_actionhandler.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/fpdfsdk/cpdfsdk_actionhandler.cpp b/fpdfsdk/cpdfsdk_actionhandler.cpp
index d7bcd7f350..5b72082104 100644
--- a/fpdfsdk/cpdfsdk_actionhandler.cpp
+++ b/fpdfsdk/cpdfsdk_actionhandler.cpp
@@ -539,12 +539,8 @@ void CPDFSDK_ActionHandler::RunScriptForAction(
void CPDFSDK_ActionHandler::RunScript(CPDFSDK_FormFillEnvironment* pFormFillEnv,
const WideString& script,
const RunScriptCallback& cb) {
- IJS_Runtime* pRuntime = pFormFillEnv->GetIJSRuntime();
- IJS_EventContext* pContext = pRuntime->NewEventContext();
-
- cb(pContext);
-
+ IJS_Runtime::ScopedEventContext pContext(pFormFillEnv->GetIJSRuntime());
+ cb(pContext.Get());
pContext->RunScript(script);
- pRuntime->ReleaseEventContext(pContext);
// TODO(dsinclair): Return error if RunScript returns a IJS_Runtime::JS_Error.
}