diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-02-16 11:49:55 -0800 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-02-16 20:23:48 +0000 |
commit | d6ae2afa821c87e84790d5c04bbc172a7b12f08f (patch) | |
tree | 10beb72deaffca61ccc54a3fb49ea0d9636579bb /fpdfsdk/javascript/cjs_runtime.cpp | |
parent | 49f7deb494064351c72ef4d31577e04f634e63f3 (diff) | |
download | pdfium-d6ae2afa821c87e84790d5c04bbc172a7b12f08f.tar.xz |
Rename IJS_Context to IJS_EventContext.
Prevents confusion with v8::Context, which is wrapped by a
different IJS_ class.
Change-Id: Iff75809e65015c0f810294de1f0d8ecf963150a3
Reviewed-on: https://pdfium-review.googlesource.com/2751
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Reviewed-by: dsinclair <dsinclair@chromium.org>
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() { |