diff options
Diffstat (limited to 'fpdfsdk/javascript/cjs_runtime.cpp')
-rw-r--r-- | fpdfsdk/javascript/cjs_runtime.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp index f55a59cee6..bf50ca92c6 100644 --- a/fpdfsdk/javascript/cjs_runtime.cpp +++ b/fpdfsdk/javascript/cjs_runtime.cpp @@ -21,7 +21,7 @@ #include "fpdfsdk/javascript/JS_Value.h" #include "fpdfsdk/javascript/PublicMethods.h" #include "fpdfsdk/javascript/app.h" -#include "fpdfsdk/javascript/cjs_context.h" +#include "fpdfsdk/javascript/cjs_event_context.h" #include "fpdfsdk/javascript/color.h" #include "fpdfsdk/javascript/console.h" #include "fpdfsdk/javascript/event.h" @@ -51,9 +51,8 @@ IJS_Runtime* IJS_Runtime::Create(CPDFSDK_FormFillEnvironment* pFormFillEnv) { } // static -CJS_Runtime* CJS_Runtime::FromContext(const IJS_Context* cc) { - const CJS_Context* pContext = static_cast<const CJS_Context*>(cc); - return pContext->GetJSRuntime(); +CJS_Runtime* CJS_Runtime::FromEventContext(const IJS_EventContext* cc) { + return static_cast<const CJS_EventContext*>(cc)->GetJSRuntime(); } // static @@ -89,10 +88,9 @@ CJS_Runtime::CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv) if (m_isolateManaged || FXJS_GlobalIsolateRefCount() == 0) DefineJSObjects(); - CJS_Context* pContext = (CJS_Context*)NewContext(); + IJS_EventContext* pContext = NewEventContext(); InitializeEngine(); - ReleaseContext(pContext); - + ReleaseEventContext(pContext); SetFormFillEnvToDocument(); } @@ -153,22 +151,23 @@ void CJS_Runtime::DefineJSObjects() { CJS_Annot::DefineJSObjects(this, FXJSOBJTYPE_DYNAMIC); } -IJS_Context* CJS_Runtime::NewContext() { - m_ContextArray.push_back(std::unique_ptr<CJS_Context>(new CJS_Context(this))); - return m_ContextArray.back().get(); +IJS_EventContext* CJS_Runtime::NewEventContext() { + m_EventContextArray.push_back( + std::unique_ptr<CJS_EventContext>(new CJS_EventContext(this))); + return m_EventContextArray.back().get(); } -void CJS_Runtime::ReleaseContext(IJS_Context* pContext) { - for (auto it = m_ContextArray.begin(); it != m_ContextArray.end(); ++it) { - if (it->get() == static_cast<CJS_Context*>(pContext)) { - m_ContextArray.erase(it); - return; - } - } +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); } -IJS_Context* CJS_Runtime::GetCurrentContext() { - return m_ContextArray.empty() ? nullptr : m_ContextArray.back().get(); +IJS_EventContext* CJS_Runtime::GetCurrentEventContext() { + return m_EventContextArray.empty() ? nullptr + : m_EventContextArray.back().get(); } void CJS_Runtime::SetFormFillEnvToDocument() { |