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>
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index f55a59c..bf50ca9 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 @@
 }
 
 // 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 @@
   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 @@
   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() {