summaryrefslogtreecommitdiff
path: root/fxjs/cjs_runtime.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 /fxjs/cjs_runtime.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 'fxjs/cjs_runtime.cpp')
-rw-r--r--fxjs/cjs_runtime.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/fxjs/cjs_runtime.cpp b/fxjs/cjs_runtime.cpp
index 22dc904c1f..a8640eaa34 100644
--- a/fxjs/cjs_runtime.cpp
+++ b/fxjs/cjs_runtime.cpp
@@ -80,9 +80,8 @@ CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv)
if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0)
DefineJSObjects();
- IJS_EventContext* pContext = NewEventContext();
+ ScopedEventContext pContext(this);
InitializeEngine();
- ReleaseEventContext(pContext);
SetFormFillEnvToDocument();
}
@@ -153,11 +152,8 @@ IJS_EventContext* CJS_Runtime::NewEventContext() {
}
void CJS_Runtime::ReleaseEventContext(IJS_EventContext* pContext) {
- auto it = std::find(m_EventContextArray.begin(), m_EventContextArray.end(),
- pdfium::FakeUniquePtr<CJS_EventContext>(
- static_cast<CJS_EventContext*>(pContext)));
- if (it != m_EventContextArray.end())
- m_EventContextArray.erase(it);
+ ASSERT(pContext == m_EventContextArray.back().get());
+ m_EventContextArray.pop_back();
}
CJS_EventContext* CJS_Runtime::GetCurrentEventContext() const {