summaryrefslogtreecommitdiff
path: root/fxjs/ijs_runtime.h
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/ijs_runtime.h
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/ijs_runtime.h')
-rw-r--r--fxjs/ijs_runtime.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/fxjs/ijs_runtime.h b/fxjs/ijs_runtime.h
index a21aae86de..9f15abaee0 100644
--- a/fxjs/ijs_runtime.h
+++ b/fxjs/ijs_runtime.h
@@ -34,10 +34,26 @@ class IJS_Runtime {
JS_Error(int line, int column, const WideString& exception);
};
+ class ScopedEventContext {
+ public:
+ explicit ScopedEventContext(IJS_Runtime* pRuntime)
+ : m_pRuntime(pRuntime), m_pContext(pRuntime->NewEventContext()) {}
+
+ ~ScopedEventContext() { m_pRuntime->ReleaseEventContext(m_pContext); }
+
+ IJS_EventContext* Get() const { return m_pContext; }
+ IJS_EventContext* operator->() const { return m_pContext; }
+
+ private:
+ IJS_Runtime* m_pRuntime;
+ IJS_EventContext* m_pContext;
+ };
+
static void Initialize(unsigned int slot, void* isolate);
static void Destroy();
static std::unique_ptr<IJS_Runtime> Create(
CPDFSDK_FormFillEnvironment* pFormFillEnv);
+
virtual ~IJS_Runtime();
virtual CJS_Runtime* AsCJSRuntime() = 0;