Pass CJS_Runtime to JS callbacks.
This is much more convenient, since only a fraction of them
need an IJS_EventContext, which can be obtained from the
CJS_Runtime.
Make GetCurrentEventContext() specific to CJS_Runtime, and
return the concrete type. This saves a lot of casting.
Change-Id: If79a3bcbf44de513f3caace153099234cc313d47
Reviewed-on: https://pdfium-review.googlesource.com/2793
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index bf50ca9..8466e4d 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -51,11 +51,6 @@
}
// static
-CJS_Runtime* CJS_Runtime::FromEventContext(const IJS_EventContext* cc) {
- return static_cast<const CJS_EventContext*>(cc)->GetJSRuntime();
-}
-
-// static
CJS_Runtime* CJS_Runtime::CurrentRuntimeFromIsolate(v8::Isolate* pIsolate) {
return static_cast<CJS_Runtime*>(
CFXJS_Engine::CurrentEngineFromIsolate(pIsolate));
@@ -165,7 +160,7 @@
m_EventContextArray.erase(it);
}
-IJS_EventContext* CJS_Runtime::GetCurrentEventContext() {
+CJS_EventContext* CJS_Runtime::GetCurrentEventContext() const {
return m_EventContextArray.empty() ? nullptr
: m_EventContextArray.back().get();
}