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/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp
index b22ccb1..4229fcd 100644
--- a/fpdfsdk/cpdfsdk_interform.cpp
+++ b/fpdfsdk/cpdfsdk_interform.cpp
@@ -30,7 +30,7 @@
 #include "fpdfsdk/fsdk_define.h"
 #include "fpdfsdk/fxedit/fxet_edit.h"
 #include "fpdfsdk/ipdfsdk_annothandler.h"
-#include "fpdfsdk/javascript/ijs_context.h"
+#include "fpdfsdk/javascript/ijs_event_context.h"
 #include "fpdfsdk/javascript/ijs_runtime.h"
 #include "fpdfsdk/pdfwindow/PWL_Utils.h"
 #include "third_party/base/stl_util.h"
@@ -253,7 +253,7 @@
     if (csJS.IsEmpty())
       continue;
 
-    IJS_Context* pContext = pRuntime->NewContext();
+    IJS_EventContext* pContext = pRuntime->NewEventContext();
     CFX_WideString sOldValue = pField->GetValue();
     CFX_WideString sValue = sOldValue;
     bool bRC = true;
@@ -261,12 +261,10 @@
 
     CFX_WideString sInfo;
     bool bRet = pContext->RunScript(csJS, &sInfo);
-    pRuntime->ReleaseContext(pContext);
-
+    pRuntime->ReleaseEventContext(pContext);
     if (bRet && bRC && sValue.Compare(sOldValue) != 0)
       pField->SetValue(sValue, true);
   }
-
   m_bBusy = false;
 }
 
@@ -296,12 +294,11 @@
       if (!script.IsEmpty()) {
         CFX_WideString Value = sValue;
 
-        IJS_Context* pContext = pRuntime->NewContext();
+        IJS_EventContext* pContext = pRuntime->NewEventContext();
         pContext->OnField_Format(pFormField, Value, true);
         CFX_WideString sInfo;
         bool bRet = pContext->RunScript(script, &sInfo);
-        pRuntime->ReleaseContext(pContext);
-
+        pRuntime->ReleaseEventContext(pContext);
         if (bRet) {
           sValue = Value;
           bFormatted = true;
@@ -309,7 +306,6 @@
       }
     }
   }
-
   return sValue;
 }
 
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_context.h b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
index e1c357f..9a2a517 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_context.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_context.h
@@ -17,8 +17,8 @@
 class CPDFSDK_FormFillEnvironment;
 class CPDFXFA_Page;
 class CXFA_FFDocHandler;
+class IJS_EventContext;
 class IJS_Runtime;
-class IJS_Context;
 
 enum LoadStatus {
   FXFA_LOADSTATUS_PRELOAD = 0,
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
index ec62927..962dbba 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.cpp
@@ -38,13 +38,15 @@
 #define FXFA_XFA_ALL 0x01111111
 
 CPDFXFA_DocEnvironment::CPDFXFA_DocEnvironment(CPDFXFA_Context* pContext)
-    : m_pContext(pContext), m_pJSContext(nullptr) {
+    : m_pContext(pContext), m_pJSEventContext(nullptr) {
   ASSERT(m_pContext);
 }
 
 CPDFXFA_DocEnvironment::~CPDFXFA_DocEnvironment() {
-  if (m_pJSContext && m_pContext->GetFormFillEnv())
-    m_pContext->GetFormFillEnv()->GetJSRuntime()->ReleaseContext(m_pJSContext);
+  if (m_pJSEventContext && m_pContext->GetFormFillEnv()) {
+    m_pContext->GetFormFillEnv()->GetJSRuntime()->ReleaseEventContext(
+        m_pJSEventContext);
+  }
 }
 
 void CPDFXFA_DocEnvironment::SetChangeMark(CXFA_FFDoc* hDoc) {
@@ -1023,8 +1025,8 @@
   }
 
   CPDFSDK_FormFillEnvironment* pFormFillEnv = m_pContext->GetFormFillEnv();
-  if (!m_pJSContext)
-    m_pJSContext = pFormFillEnv->GetJSRuntime()->NewContext();
+  if (!m_pJSEventContext)
+    m_pJSEventContext = pFormFillEnv->GetJSRuntime()->NewEventContext();
 
   return pFormFillEnv->GetJSRuntime()->GetValueByName(szPropName, pValue);
 }
diff --git a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
index d7cb169..dc18d9a 100644
--- a/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
+++ b/fpdfsdk/fpdfxfa/cpdfxfa_docenvironment.h
@@ -12,7 +12,7 @@
 #include "xfa/fxfa/fxfa.h"
 
 class CPDFXFA_Context;
-class IJS_Context;
+class IJS_EventContext;
 
 class CPDFXFA_DocEnvironment : public IXFA_DocEnvironment {
  public:
@@ -107,8 +107,8 @@
                         FPDF_DWORD flag);
   void ToXFAContentFlags(CFX_WideString csSrcContent, FPDF_DWORD& flag);
 
-  CPDFXFA_Context* const m_pContext;  // Not owned;
-  IJS_Context* m_pJSContext;
+  CPDFXFA_Context* const m_pContext;    // Not owned.
+  IJS_EventContext* m_pJSEventContext;  // Not owned.
 };
 
 #endif  // FPDFSDK_FPDFXFA_CPDFXFA_DOCENVIRONMENT_H_
diff --git a/fpdfsdk/fsdk_actionhandler.cpp b/fpdfsdk/fsdk_actionhandler.cpp
index 61d2a52..dc99f32 100644
--- a/fpdfsdk/fsdk_actionhandler.cpp
+++ b/fpdfsdk/fsdk_actionhandler.cpp
@@ -14,7 +14,7 @@
 #include "fpdfsdk/cpdfsdk_formfillenvironment.h"
 #include "fpdfsdk/cpdfsdk_interform.h"
 #include "fpdfsdk/fsdk_define.h"
-#include "fpdfsdk/javascript/ijs_context.h"
+#include "fpdfsdk/javascript/ijs_event_context.h"
 #include "fpdfsdk/javascript/ijs_runtime.h"
 #include "third_party/base/stl_util.h"
 
@@ -157,16 +157,15 @@
       CFX_WideString swJS = action.GetJavaScript();
       if (!swJS.IsEmpty()) {
         IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
-        IJS_Context* pContext = pRuntime->NewContext();
+        IJS_EventContext* pContext = pRuntime->NewEventContext();
         pContext->OnLink_MouseUp(pFormFillEnv);
 
         CFX_WideString csInfo;
         bool bRet = pContext->RunScript(swJS, &csInfo);
+        pRuntime->ReleaseEventContext(pContext);
         if (!bRet) {
           // FIXME: return error.
         }
-
-        pRuntime->ReleaseContext(pContext);
       }
     }
   } else {
@@ -282,14 +281,13 @@
       CFX_WideString swJS = action.GetJavaScript();
       if (!swJS.IsEmpty()) {
         IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
-        IJS_Context* pContext = pRuntime->NewContext();
+        IJS_EventContext* pContext = pRuntime->NewEventContext();
         CFX_WideString csInfo;
         bool bRet = pContext->RunScript(swJS, &csInfo);
+        pRuntime->ReleaseEventContext(pContext);
         if (!bRet) {
           // FIXME: return error.
         }
-
-        pRuntime->ReleaseContext(pContext);
       }
     }
   } else {
@@ -322,16 +320,15 @@
       CFX_WideString swJS = action.GetJavaScript();
       if (!swJS.IsEmpty()) {
         IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
-        IJS_Context* pContext = pRuntime->NewContext();
+        IJS_EventContext* pContext = pRuntime->NewEventContext();
         pContext->OnBookmark_MouseUp(pBookmark);
 
         CFX_WideString csInfo;
         bool bRet = pContext->RunScript(swJS, &csInfo);
+        pRuntime->ReleaseEventContext(pContext);
         if (!bRet) {
           // FIXME: return error.
         }
-
-        pRuntime->ReleaseContext(pContext);
       }
     }
   } else {
@@ -478,7 +475,7 @@
   ASSERT(type != CPDF_AAction::Format);
 
   IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
-  IJS_Context* pContext = pRuntime->NewContext();
+  IJS_EventContext* pContext = pRuntime->NewEventContext();
   switch (type) {
     case CPDF_AAction::CursorEnter:
       pContext->OnField_MouseEnter(data.bModifier, data.bShift, pFormField);
@@ -518,11 +515,10 @@
 
   CFX_WideString csInfo;
   bool bRet = pContext->RunScript(script, &csInfo);
+  pRuntime->ReleaseEventContext(pContext);
   if (!bRet) {
     // FIXME: return error.
   }
-
-  pRuntime->ReleaseContext(pContext);
 }
 
 void CPDFSDK_ActionHandler::RunDocumentOpenJavaScript(
@@ -530,16 +526,15 @@
     const CFX_WideString& sScriptName,
     const CFX_WideString& script) {
   IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
-  IJS_Context* pContext = pRuntime->NewContext();
+  IJS_EventContext* pContext = pRuntime->NewEventContext();
   pContext->OnDoc_Open(pFormFillEnv, sScriptName);
 
   CFX_WideString csInfo;
   bool bRet = pContext->RunScript(script, &csInfo);
+  pRuntime->ReleaseEventContext(pContext);
   if (!bRet) {
     // FIXME: return error.
   }
-
-  pRuntime->ReleaseContext(pContext);
 }
 
 void CPDFSDK_ActionHandler::RunDocumentPageJavaScript(
@@ -547,7 +542,7 @@
     CPDF_AAction::AActionType type,
     const CFX_WideString& script) {
   IJS_Runtime* pRuntime = pFormFillEnv->GetJSRuntime();
-  IJS_Context* pContext = pRuntime->NewContext();
+  IJS_EventContext* pContext = pRuntime->NewEventContext();
   switch (type) {
     case CPDF_AAction::OpenPage:
       pContext->OnPage_Open(pFormFillEnv);
@@ -583,11 +578,10 @@
 
   CFX_WideString csInfo;
   bool bRet = pContext->RunScript(script, &csInfo);
+  pRuntime->ReleaseEventContext(pContext);
   if (!bRet) {
     // FIXME: return error.
   }
-
-  pRuntime->ReleaseContext(pContext);
 }
 
 bool CPDFSDK_ActionHandler::DoAction_Hide(
diff --git a/fpdfsdk/javascript/Annot.cpp b/fpdfsdk/javascript/Annot.cpp
index 1aef463..1a496ec 100644
--- a/fpdfsdk/javascript/Annot.cpp
+++ b/fpdfsdk/javascript/Annot.cpp
@@ -9,7 +9,7 @@
 #include "fpdfsdk/javascript/JS_Define.h"
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 
 namespace {
 
@@ -37,7 +37,9 @@
 
 Annot::~Annot() {}
 
-bool Annot::hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Annot::hidden(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
   if (vp.IsGetting()) {
     if (!m_pAnnot) {
       sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
@@ -71,7 +73,9 @@
   return true;
 }
 
-bool Annot::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Annot::name(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError) {
   if (vp.IsGetting()) {
     if (!m_pAnnot) {
       sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
@@ -92,7 +96,9 @@
   return true;
 }
 
-bool Annot::type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Annot::type(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError) {
   if (vp.IsSetting()) {
     sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
     return false;
diff --git a/fpdfsdk/javascript/Annot.h b/fpdfsdk/javascript/Annot.h
index 39073e6..dffa713 100644
--- a/fpdfsdk/javascript/Annot.h
+++ b/fpdfsdk/javascript/Annot.h
@@ -17,9 +17,9 @@
   explicit Annot(CJS_Object* pJSObject);
   ~Annot() override;
 
-  bool hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool hidden(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool name(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool type(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
 
   void SetSDKAnnot(CPDFSDK_BAAnnot* annot);
 
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 1a0a53c..38600ed 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -30,7 +30,7 @@
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
 #include "fpdfsdk/javascript/app.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 #include "fpdfsdk/javascript/cjs_runtime.h"
 #include "fpdfsdk/javascript/resource.h"
 #include "third_party/base/numerics/safe_math.h"
@@ -163,7 +163,7 @@
 }
 
 // the total number of fileds in document.
-bool Document::numFields(IJS_Context* cc,
+bool Document::numFields(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -180,7 +180,7 @@
   return true;
 }
 
-bool Document::dirty(IJS_Context* cc,
+bool Document::dirty(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (!m_pFormFillEnv) {
@@ -189,28 +189,28 @@
   }
   if (vp.IsGetting()) {
     vp << !!m_pFormFillEnv->GetChangeMark();
-  } else {
-    bool bChanged = false;
-    vp >> bChanged;
-
-    if (bChanged)
-      m_pFormFillEnv->SetChangeMark();
-    else
-      m_pFormFillEnv->ClearChangeMark();
+    return true;
   }
+  bool bChanged = false;
+  vp >> bChanged;
+  if (bChanged)
+    m_pFormFillEnv->SetChangeMark();
+  else
+    m_pFormFillEnv->ClearChangeMark();
+
   return true;
 }
 
-bool Document::ADBE(IJS_Context* cc,
+bool Document::ADBE(IJS_EventContext* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError) {
   if (vp.IsGetting())
-    vp.GetJSValue()->SetNull(CJS_Runtime::FromContext(cc));
+    vp.GetJSValue()->SetNull(CJS_Runtime::FromEventContext(cc));
 
   return true;
 }
 
-bool Document::pageNum(IJS_Context* cc,
+bool Document::pageNum(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   if (!m_pFormFillEnv) {
@@ -218,27 +218,24 @@
     return false;
   }
   if (vp.IsGetting()) {
-    if (CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView()) {
+    if (CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetCurrentView())
       vp << pPageView->GetPageIndex();
-    }
-  } else {
-    int iPageCount = m_pFormFillEnv->GetPageCount();
-    int iPageNum = 0;
-    vp >> iPageNum;
-
-    if (iPageNum >= 0 && iPageNum < iPageCount) {
-      m_pFormFillEnv->JS_docgotoPage(iPageNum);
-    } else if (iPageNum >= iPageCount) {
-      m_pFormFillEnv->JS_docgotoPage(iPageCount - 1);
-    } else if (iPageNum < 0) {
-      m_pFormFillEnv->JS_docgotoPage(0);
-    }
+    return true;
   }
+  int iPageCount = m_pFormFillEnv->GetPageCount();
+  int iPageNum = 0;
+  vp >> iPageNum;
+  if (iPageNum >= 0 && iPageNum < iPageCount)
+    m_pFormFillEnv->JS_docgotoPage(iPageNum);
+  else if (iPageNum >= iPageCount)
+    m_pFormFillEnv->JS_docgotoPage(iPageCount - 1);
+  else if (iPageNum < 0)
+    m_pFormFillEnv->JS_docgotoPage(0);
 
   return true;
 }
 
-bool Document::addAnnot(IJS_Context* cc,
+bool Document::addAnnot(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
@@ -246,7 +243,7 @@
   return true;
 }
 
-bool Document::addField(IJS_Context* cc,
+bool Document::addField(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
@@ -254,7 +251,7 @@
   return true;
 }
 
-bool Document::exportAsText(IJS_Context* cc,
+bool Document::exportAsText(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError) {
@@ -262,7 +259,7 @@
   return true;
 }
 
-bool Document::exportAsFDF(IJS_Context* cc,
+bool Document::exportAsFDF(IJS_EventContext* cc,
                            const std::vector<CJS_Value>& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -270,7 +267,7 @@
   return true;
 }
 
-bool Document::exportAsXFDF(IJS_Context* cc,
+bool Document::exportAsXFDF(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError) {
@@ -283,7 +280,7 @@
 // note: the paremter cName, this is clue how to treat if the cName is not a
 // valiable filed name in this document
 
-bool Document::getField(IJS_Context* cc,
+bool Document::getField(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
@@ -295,8 +292,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString wideName = params[0].ToCFXWideString(pRuntime);
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
   CPDF_InterForm* pPDFForm = pInterForm->GetInterForm();
@@ -317,7 +313,7 @@
 }
 
 // Gets the name of the nth field in the document
-bool Document::getNthFieldName(IJS_Context* cc,
+bool Document::getNthFieldName(IJS_EventContext* cc,
                                const std::vector<CJS_Value>& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError) {
@@ -329,8 +325,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int nIndex = params[0].ToInt(pRuntime);
   if (nIndex < 0) {
     sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
@@ -346,7 +341,7 @@
   return true;
 }
 
-bool Document::importAnFDF(IJS_Context* cc,
+bool Document::importAnFDF(IJS_EventContext* cc,
                            const std::vector<CJS_Value>& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -354,7 +349,7 @@
   return true;
 }
 
-bool Document::importAnXFDF(IJS_Context* cc,
+bool Document::importAnXFDF(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError) {
@@ -362,7 +357,7 @@
   return true;
 }
 
-bool Document::importTextData(IJS_Context* cc,
+bool Document::importTextData(IJS_EventContext* cc,
                               const std::vector<CJS_Value>& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
@@ -373,7 +368,7 @@
 // exports the form data and mails the resulting fdf file as an attachment to
 // all recipients.
 // comment: need reader supports
-bool Document::mailForm(IJS_Context* cc,
+bool Document::mailForm(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
@@ -385,10 +380,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
     return false;
   }
-
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int iLength = params.size();
   bool bUI = iLength > 0 ? params[0].ToBool(pRuntime) : true;
   CFX_WideString cTo = iLength > 1 ? params[1].ToCFXWideString(pRuntime) : L"";
@@ -397,14 +389,13 @@
   CFX_WideString cSubject =
       iLength > 4 ? params[4].ToCFXWideString(pRuntime) : L"";
   CFX_WideString cMsg = iLength > 5 ? params[5].ToCFXWideString(pRuntime) : L"";
-
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
   CFX_ByteTextBuf textBuf;
   if (!pInterForm->ExportFormToFDFTextBuf(textBuf))
     return false;
 
   pRuntime->BeginBlock();
-  CPDFSDK_FormFillEnvironment* pFormFillEnv = pContext->GetFormFillEnv();
+  CPDFSDK_FormFillEnvironment* pFormFillEnv = pRuntime->GetFormFillEnv();
   pFormFillEnv->JS_docmailForm(textBuf.GetBuffer(), textBuf.GetLength(), bUI,
                                cTo.c_str(), cSubject.c_str(), cCc.c_str(),
                                cBcc.c_str(), cMsg.c_str());
@@ -412,7 +403,7 @@
   return true;
 }
 
-bool Document::print(IJS_Context* cc,
+bool Document::print(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError) {
@@ -420,10 +411,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   bool bUI = true;
   int nStart = 0;
   int nEnd = 0;
@@ -432,7 +420,6 @@
   bool bPrintAsImage = false;
   bool bReverse = false;
   bool bAnnotations = false;
-
   int nlength = params.size();
   if (nlength == 9) {
     if (params[8].GetType() == CJS_Value::VT_object) {
@@ -485,7 +472,7 @@
 // comment:
 // note: if the filed name is not rational, adobe is dumb for it.
 
-bool Document::removeField(IJS_Context* cc,
+bool Document::removeField(IJS_EventContext* cc,
                            const std::vector<CJS_Value>& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -502,8 +489,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
     return false;
   }
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString sFieldName = params[0].ToCFXWideString(pRuntime);
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
   std::vector<CPDFSDK_Annot::ObservedPtr> widgets;
@@ -546,7 +532,7 @@
 // comment:
 // note: if the fields names r not rational, aodbe is dumb for it.
 
-bool Document::resetForm(IJS_Context* cc,
+bool Document::resetForm(IJS_EventContext* cc,
                          const std::vector<CJS_Value>& params,
                          CJS_Value& vRet,
                          CFX_WideString& sError) {
@@ -571,7 +557,7 @@
     return true;
   }
 
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
   CJS_Runtime* pRuntime = pContext->GetJSRuntime();
 
   switch (params[0].GetType()) {
@@ -600,7 +586,7 @@
   return true;
 }
 
-bool Document::saveAs(IJS_Context* cc,
+bool Document::saveAs(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError) {
@@ -608,14 +594,14 @@
   return true;
 }
 
-bool Document::syncAnnotScan(IJS_Context* cc,
+bool Document::syncAnnotScan(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
   return true;
 }
 
-bool Document::submitForm(IJS_Context* cc,
+bool Document::submitForm(IJS_EventContext* cc,
                           const std::vector<CJS_Value>& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
@@ -628,8 +614,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_Array aFields;
   CFX_WideString strURL;
   bool bFDF = true;
@@ -698,20 +683,19 @@
   m_pFormFillEnv.Reset(pFormFillEnv);
 }
 
-bool Document::bookmarkRoot(IJS_Context* cc,
+bool Document::bookmarkRoot(IJS_EventContext* cc,
                             CJS_PropValue& vp,
                             CFX_WideString& sError) {
   return true;
 }
 
-bool Document::mailDoc(IJS_Context* cc,
+bool Document::mailDoc(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
 
   // TODO(tsepez): Check maximum number of allowed params.
-
   bool bUI = true;
   CFX_WideString cTo = L"";
   CFX_WideString cCc = L"";
@@ -719,8 +703,6 @@
   CFX_WideString cSubject = L"";
   CFX_WideString cMsg = L"";
 
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-
   if (params.size() >= 1)
     bUI = params[0].ToBool(pRuntime);
   if (params.size() >= 2)
@@ -761,17 +743,16 @@
   pFormFillEnv->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(), cSubject.c_str(),
                                cCc.c_str(), cBcc.c_str(), cMsg.c_str());
   pRuntime->EndBlock();
-
   return true;
 }
 
-bool Document::author(IJS_Context* cc,
+bool Document::author(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   return getPropertyInternal(cc, vp, "Author", sError);
 }
 
-bool Document::info(IJS_Context* cc,
+bool Document::info(IJS_EventContext* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -797,9 +778,7 @@
   CFX_WideString cwModDate = pDictionary->GetUnicodeTextFor("ModDate");
   CFX_WideString cwTrapped = pDictionary->GetUnicodeTextFor("Trapped");
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
-
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   v8::Local<v8::Object> pObj = pRuntime->NewFxDynamicObj(-1);
   pRuntime->PutObjectProperty(pObj, L"Author", pRuntime->NewString(cwAuthor));
   pRuntime->PutObjectProperty(pObj, L"Title", pRuntime->NewString(cwTitle));
@@ -834,7 +813,7 @@
   return true;
 }
 
-bool Document::getPropertyInternal(IJS_Context* cc,
+bool Document::getPropertyInternal(IJS_EventContext* cc,
                                    CJS_PropValue& vp,
                                    const CFX_ByteString& propName,
                                    CFX_WideString& sError) {
@@ -862,19 +841,19 @@
   return true;
 }
 
-bool Document::creationDate(IJS_Context* cc,
+bool Document::creationDate(IJS_EventContext* cc,
                             CJS_PropValue& vp,
                             CFX_WideString& sError) {
   return getPropertyInternal(cc, vp, "CreationDate", sError);
 }
 
-bool Document::creator(IJS_Context* cc,
+bool Document::creator(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   return getPropertyInternal(cc, vp, "Creator", sError);
 }
 
-bool Document::delay(IJS_Context* cc,
+bool Document::delay(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (!m_pFormFillEnv) {
@@ -883,49 +862,50 @@
   }
   if (vp.IsGetting()) {
     vp << m_bDelay;
-  } else {
-    if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) {
-      sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
-      return false;
-    }
-    vp >> m_bDelay;
-    if (m_bDelay) {
-      m_DelayData.clear();
-    } else {
-      std::list<std::unique_ptr<CJS_DelayData>> DelayDataToProcess;
-      DelayDataToProcess.swap(m_DelayData);
-      for (const auto& pData : DelayDataToProcess)
-        Field::DoDelay(m_pFormFillEnv.Get(), pData.get());
-    }
+    return true;
   }
+  if (!m_pFormFillEnv->GetPermissions(FPDFPERM_MODIFY)) {
+    sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
+    return false;
+  }
+  vp >> m_bDelay;
+  if (m_bDelay) {
+    m_DelayData.clear();
+    return true;
+  }
+  std::list<std::unique_ptr<CJS_DelayData>> DelayDataToProcess;
+  DelayDataToProcess.swap(m_DelayData);
+  for (const auto& pData : DelayDataToProcess)
+    Field::DoDelay(m_pFormFillEnv.Get(), pData.get());
+
   return true;
 }
 
-bool Document::keywords(IJS_Context* cc,
+bool Document::keywords(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   return getPropertyInternal(cc, vp, "Keywords", sError);
 }
 
-bool Document::modDate(IJS_Context* cc,
+bool Document::modDate(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   return getPropertyInternal(cc, vp, "ModDate", sError);
 }
 
-bool Document::producer(IJS_Context* cc,
+bool Document::producer(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   return getPropertyInternal(cc, vp, "Producer", sError);
 }
 
-bool Document::subject(IJS_Context* cc,
+bool Document::subject(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   return getPropertyInternal(cc, vp, "Subject", sError);
 }
 
-bool Document::title(IJS_Context* cc,
+bool Document::title(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (!m_pFormFillEnv || !m_pFormFillEnv->GetUnderlyingDocument()) {
@@ -935,7 +915,7 @@
   return getPropertyInternal(cc, vp, "Title", sError);
 }
 
-bool Document::numPages(IJS_Context* cc,
+bool Document::numPages(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -950,7 +930,7 @@
   return true;
 }
 
-bool Document::external(IJS_Context* cc,
+bool Document::external(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   // In Chrome case, should always return true.
@@ -960,7 +940,7 @@
   return true;
 }
 
-bool Document::filesize(IJS_Context* cc,
+bool Document::filesize(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -971,19 +951,21 @@
   return true;
 }
 
-bool Document::mouseX(IJS_Context* cc,
+bool Document::mouseX(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   return true;
 }
 
-bool Document::mouseY(IJS_Context* cc,
+bool Document::mouseY(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   return true;
 }
 
-bool Document::URL(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Document::URL(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
   if (vp.IsSetting()) {
     sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
     return false;
@@ -996,7 +978,7 @@
   return true;
 }
 
-bool Document::baseURL(IJS_Context* cc,
+bool Document::baseURL(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   if (vp.IsGetting()) {
@@ -1007,7 +989,7 @@
   return true;
 }
 
-bool Document::calculate(IJS_Context* cc,
+bool Document::calculate(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   if (!m_pFormFillEnv) {
@@ -1017,15 +999,15 @@
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
   if (vp.IsGetting()) {
     vp << !!pInterForm->IsCalculateEnabled();
-  } else {
-    bool bCalculate;
-    vp >> bCalculate;
-    pInterForm->EnableCalculate(bCalculate);
+    return true;
   }
+  bool bCalculate;
+  vp >> bCalculate;
+  pInterForm->EnableCalculate(bCalculate);
   return true;
 }
 
-bool Document::documentFileName(IJS_Context* cc,
+bool Document::documentFileName(IJS_EventContext* cc,
                                 CJS_PropValue& vp,
                                 CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1050,7 +1032,7 @@
   return true;
 }
 
-bool Document::path(IJS_Context* cc,
+bool Document::path(IJS_EventContext* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1065,40 +1047,40 @@
   return true;
 }
 
-bool Document::pageWindowRect(IJS_Context* cc,
+bool Document::pageWindowRect(IJS_EventContext* cc,
                               CJS_PropValue& vp,
                               CFX_WideString& sError) {
   return true;
 }
 
-bool Document::layout(IJS_Context* cc,
+bool Document::layout(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   return true;
 }
 
-bool Document::addLink(IJS_Context* cc,
+bool Document::addLink(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
   return true;
 }
 
-bool Document::closeDoc(IJS_Context* cc,
+bool Document::closeDoc(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
   return true;
 }
 
-bool Document::getPageBox(IJS_Context* cc,
+bool Document::getPageBox(IJS_EventContext* cc,
                           const std::vector<CJS_Value>& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
   return true;
 }
 
-bool Document::getAnnot(IJS_Context* cc,
+bool Document::getAnnot(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
@@ -1110,8 +1092,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int nPageNo = params[0].ToInt(pRuntime);
   CFX_WideString swAnnotName = params[1].ToCFXWideString(pRuntime);
   CPDFSDK_PageView* pPageView = m_pFormFillEnv->GetPageView(nPageNo);
@@ -1150,7 +1131,7 @@
   return true;
 }
 
-bool Document::getAnnots(IJS_Context* cc,
+bool Document::getAnnots(IJS_EventContext* cc,
                          const std::vector<CJS_Value>& params,
                          CJS_Value& vRet,
                          CFX_WideString& sError) {
@@ -1158,8 +1139,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
 
   // TODO(tonikitoo): Add support supported parameters as per
   // the PDF spec.
@@ -1200,29 +1180,29 @@
   return true;
 }
 
-bool Document::getAnnot3D(IJS_Context* cc,
+bool Document::getAnnot3D(IJS_EventContext* cc,
                           const std::vector<CJS_Value>& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
-  vRet.SetNull(CJS_Runtime::FromContext(cc));
+  vRet.SetNull(CJS_Runtime::FromEventContext(cc));
   return true;
 }
 
-bool Document::getAnnots3D(IJS_Context* cc,
+bool Document::getAnnots3D(IJS_EventContext* cc,
                            const std::vector<CJS_Value>& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
   return true;
 }
 
-bool Document::getOCGs(IJS_Context* cc,
+bool Document::getOCGs(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
   return true;
 }
 
-bool Document::getLinks(IJS_Context* cc,
+bool Document::getLinks(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
@@ -1234,7 +1214,7 @@
           rect.right >= LinkRect.right && rect.bottom >= LinkRect.bottom);
 }
 
-bool Document::addIcon(IJS_Context* cc,
+bool Document::addIcon(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
@@ -1243,10 +1223,8 @@
     return false;
   }
 
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString swIconName = params[0].ToCFXWideString(pRuntime);
-
   if (params[1].GetType() != CJS_Value::VT_object) {
     sError = JSGetStringFromID(IDS_STRING_JSTYPEERROR);
     return false;
@@ -1269,7 +1247,7 @@
   return true;
 }
 
-bool Document::icons(IJS_Context* cc,
+bool Document::icons(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1277,7 +1255,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   if (m_Icons.empty()) {
     vp.GetJSValue()->SetNull(pRuntime);
     return true;
@@ -1310,7 +1288,7 @@
   return true;
 }
 
-bool Document::getIcon(IJS_Context* cc,
+bool Document::getIcon(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
@@ -1322,7 +1300,7 @@
   if (m_Icons.empty())
     return false;
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString swIconName = params[0].ToCFXWideString(pRuntime);
 
   for (const auto& pIconElement : m_Icons) {
@@ -1353,7 +1331,7 @@
   return false;
 }
 
-bool Document::removeIcon(IJS_Context* cc,
+bool Document::removeIcon(IJS_EventContext* cc,
                           const std::vector<CJS_Value>& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
@@ -1361,7 +1339,7 @@
   return true;
 }
 
-bool Document::createDataObject(IJS_Context* cc,
+bool Document::createDataObject(IJS_EventContext* cc,
                                 const std::vector<CJS_Value>& params,
                                 CJS_Value& vRet,
                                 CFX_WideString& sError) {
@@ -1369,13 +1347,13 @@
   return true;
 }
 
-bool Document::media(IJS_Context* cc,
+bool Document::media(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   return true;
 }
 
-bool Document::calculateNow(IJS_Context* cc,
+bool Document::calculateNow(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError) {
@@ -1393,13 +1371,13 @@
   return true;
 }
 
-bool Document::Collab(IJS_Context* cc,
+bool Document::Collab(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   return true;
 }
 
-bool Document::getPageNthWord(IJS_Context* cc,
+bool Document::getPageNthWord(IJS_EventContext* cc,
                               const std::vector<CJS_Value>& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
@@ -1411,7 +1389,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
     return false;
   }
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
 
   // TODO(tsepez): check maximum allowable params.
 
@@ -1458,7 +1436,7 @@
   return true;
 }
 
-bool Document::getPageNthWordQuads(IJS_Context* cc,
+bool Document::getPageNthWordQuads(IJS_EventContext* cc,
                                    const std::vector<CJS_Value>& params,
                                    CJS_Value& vRet,
                                    CFX_WideString& sError) {
@@ -1473,7 +1451,7 @@
   return false;
 }
 
-bool Document::getPageNumWords(IJS_Context* cc,
+bool Document::getPageNumWords(IJS_EventContext* cc,
                                const std::vector<CJS_Value>& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError) {
@@ -1485,7 +1463,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSNOPERMISSION);
     return false;
   }
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int nPageNo = params.size() > 0 ? params[0].ToInt(pRuntime) : 0;
   CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
   if (nPageNo < 0 || nPageNo >= pDocument->GetPageCount()) {
@@ -1510,12 +1488,11 @@
   return true;
 }
 
-bool Document::getPrintParams(IJS_Context* cc,
+bool Document::getPrintParams(IJS_EventContext* cc,
                               const std::vector<CJS_Value>& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   v8::Local<v8::Object> pRetObj =
       pRuntime->NewFxDynamicObj(CJS_PrintParamsObj::g_nObjDefnID);
 
@@ -1597,7 +1574,7 @@
   return swRet;
 }
 
-bool Document::zoom(IJS_Context* cc,
+bool Document::zoom(IJS_EventContext* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError) {
   return true;
@@ -1613,13 +1590,13 @@
 (refW,  ReflowWidth)
 */
 
-bool Document::zoomType(IJS_Context* cc,
+bool Document::zoomType(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   return true;
 }
 
-bool Document::deletePages(IJS_Context* cc,
+bool Document::deletePages(IJS_EventContext* cc,
                            const std::vector<CJS_Value>& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -1627,7 +1604,7 @@
   return true;
 }
 
-bool Document::extractPages(IJS_Context* cc,
+bool Document::extractPages(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError) {
@@ -1635,7 +1612,7 @@
   return true;
 }
 
-bool Document::insertPages(IJS_Context* cc,
+bool Document::insertPages(IJS_EventContext* cc,
                            const std::vector<CJS_Value>& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError) {
@@ -1643,7 +1620,7 @@
   return true;
 }
 
-bool Document::replacePages(IJS_Context* cc,
+bool Document::replacePages(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError) {
@@ -1651,7 +1628,7 @@
   return true;
 }
 
-bool Document::getURL(IJS_Context* cc,
+bool Document::getURL(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError) {
@@ -1659,7 +1636,7 @@
   return true;
 }
 
-bool Document::gotoNamedDest(IJS_Context* cc,
+bool Document::gotoNamedDest(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
@@ -1671,7 +1648,7 @@
     sError = JSGetStringFromID(IDS_STRING_JSBADOBJECT);
     return false;
   }
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString wideName = params[0].ToCFXWideString(pRuntime);
   CFX_ByteString utf8Name = wideName.UTF8Encode();
   CPDF_Document* pDocument = m_pFormFillEnv->GetPDFDocument();
diff --git a/fpdfsdk/javascript/Document.h b/fpdfsdk/javascript/Document.h
index 7786c77..97a93c5 100644
--- a/fpdfsdk/javascript/Document.h
+++ b/fpdfsdk/javascript/Document.h
@@ -61,211 +61,231 @@
   explicit Document(CJS_Object* pJSObject);
   ~Document() override;
 
-  bool ADBE(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool author(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool baseURL(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool bookmarkRoot(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool calculate(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool Collab(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool creationDate(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool creator(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool delay(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool dirty(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool documentFileName(IJS_Context* cc,
+  bool ADBE(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool author(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool baseURL(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool bookmarkRoot(IJS_EventContext* cc,
+                    CJS_PropValue& vp,
+                    CFX_WideString& sError);
+  bool calculate(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool Collab(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool creationDate(IJS_EventContext* cc,
+                    CJS_PropValue& vp,
+                    CFX_WideString& sError);
+  bool creator(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool delay(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool dirty(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool documentFileName(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError);
-  bool external(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool filesize(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool icons(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool info(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool keywords(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool layout(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool modDate(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool mouseX(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool mouseY(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool numFields(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool numPages(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool pageNum(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool pageWindowRect(IJS_Context* cc,
+  bool external(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool filesize(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool icons(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool info(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool keywords(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool layout(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool media(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool modDate(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool mouseX(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool mouseY(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool numFields(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool numPages(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool pageNum(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool pageWindowRect(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError);
-  bool path(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool producer(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool subject(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool title(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool zoom(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool zoomType(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool path(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool producer(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool subject(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool title(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool zoom(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool zoomType(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
 
-  bool addAnnot(IJS_Context* cc,
+  bool addAnnot(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool addField(IJS_Context* cc,
+  bool addField(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool addLink(IJS_Context* cc,
+  bool addLink(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool addIcon(IJS_Context* cc,
+  bool addIcon(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool calculateNow(IJS_Context* cc,
+  bool calculateNow(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool closeDoc(IJS_Context* cc,
+  bool closeDoc(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool createDataObject(IJS_Context* cc,
+  bool createDataObject(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError);
-  bool deletePages(IJS_Context* cc,
+  bool deletePages(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
-  bool exportAsText(IJS_Context* cc,
+  bool exportAsText(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool exportAsFDF(IJS_Context* cc,
+  bool exportAsFDF(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
-  bool exportAsXFDF(IJS_Context* cc,
+  bool exportAsXFDF(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool extractPages(IJS_Context* cc,
+  bool extractPages(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool getAnnot(IJS_Context* cc,
+  bool getAnnot(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool getAnnots(IJS_Context* cc,
+  bool getAnnots(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
-  bool getAnnot3D(IJS_Context* cc,
+  bool getAnnot3D(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError);
-  bool getAnnots3D(IJS_Context* cc,
+  bool getAnnots3D(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
-  bool getField(IJS_Context* cc,
+  bool getField(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool getIcon(IJS_Context* cc,
+  bool getIcon(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool getLinks(IJS_Context* cc,
+  bool getLinks(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool getNthFieldName(IJS_Context* cc,
+  bool getNthFieldName(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError);
-  bool getOCGs(IJS_Context* cc,
+  bool getOCGs(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool getPageBox(IJS_Context* cc,
+  bool getPageBox(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError);
-  bool getPageNthWord(IJS_Context* cc,
+  bool getPageNthWord(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError);
-  bool getPageNthWordQuads(IJS_Context* cc,
+  bool getPageNthWordQuads(IJS_EventContext* cc,
                            const std::vector<CJS_Value>& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError);
-  bool getPageNumWords(IJS_Context* cc,
+  bool getPageNumWords(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError);
-  bool getPrintParams(IJS_Context* cc,
+  bool getPrintParams(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError);
-  bool getURL(IJS_Context* cc,
+  bool getURL(IJS_EventContext* cc,
               const std::vector<CJS_Value>& params,
               CJS_Value& vRet,
               CFX_WideString& sError);
-  bool gotoNamedDest(IJS_Context* cc,
+  bool gotoNamedDest(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
-  bool importAnFDF(IJS_Context* cc,
+  bool importAnFDF(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
-  bool importAnXFDF(IJS_Context* cc,
+  bool importAnXFDF(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool importTextData(IJS_Context* cc,
+  bool importTextData(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError);
-  bool insertPages(IJS_Context* cc,
+  bool insertPages(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
-  bool mailForm(IJS_Context* cc,
+  bool mailForm(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool print(IJS_Context* cc,
+  bool print(IJS_EventContext* cc,
              const std::vector<CJS_Value>& params,
              CJS_Value& vRet,
              CFX_WideString& sError);
-  bool removeField(IJS_Context* cc,
+  bool removeField(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
-  bool replacePages(IJS_Context* cc,
+  bool replacePages(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool resetForm(IJS_Context* cc,
+  bool resetForm(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
-  bool saveAs(IJS_Context* cc,
+  bool saveAs(IJS_EventContext* cc,
               const std::vector<CJS_Value>& params,
               CJS_Value& vRet,
               CFX_WideString& sError);
-  bool submitForm(IJS_Context* cc,
+  bool submitForm(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError);
-  bool syncAnnotScan(IJS_Context* cc,
+  bool syncAnnotScan(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
-  bool mailDoc(IJS_Context* cc,
+  bool mailDoc(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool removeIcon(IJS_Context* cc,
+  bool removeIcon(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError);
-  bool URL(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool URL(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
 
   void SetFormFillEnv(CPDFSDK_FormFillEnvironment* pFormFillEnv);
   CPDFSDK_FormFillEnvironment* GetFormFillEnv() const {
@@ -280,7 +300,7 @@
   int CountWords(CPDF_TextObject* pTextObj);
   CFX_WideString GetObjWordStr(CPDF_TextObject* pTextObj, int nWordIndex);
 
-  bool getPropertyInternal(IJS_Context* cc,
+  bool getPropertyInternal(IJS_EventContext* cc,
                            CJS_PropValue& vp,
                            const CFX_ByteString& propName,
                            CFX_WideString& sError);
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index e04cbd6..3eb3f8e 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -26,7 +26,7 @@
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
 #include "fpdfsdk/javascript/PublicMethods.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 #include "fpdfsdk/javascript/cjs_runtime.h"
 #include "fpdfsdk/javascript/color.h"
 
@@ -375,7 +375,7 @@
   return pFormField->GetControl(m_nFormControlIndex);
 }
 
-bool Field::alignment(IJS_Context* cc,
+bool Field::alignment(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -431,7 +431,7 @@
   // Not supported.
 }
 
-bool Field::borderStyle(IJS_Context* cc,
+bool Field::borderStyle(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -540,7 +540,7 @@
   }
 }
 
-bool Field::buttonAlignX(IJS_Context* cc,
+bool Field::buttonAlignX(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -589,7 +589,7 @@
   // Not supported.
 }
 
-bool Field::buttonAlignY(IJS_Context* cc,
+bool Field::buttonAlignY(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -638,7 +638,7 @@
   // Not supported.
 }
 
-bool Field::buttonFitBounds(IJS_Context* cc,
+bool Field::buttonFitBounds(IJS_EventContext* cc,
                             CJS_PropValue& vp,
                             CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -682,7 +682,7 @@
   // Not supported.
 }
 
-bool Field::buttonPosition(IJS_Context* cc,
+bool Field::buttonPosition(IJS_EventContext* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -725,7 +725,7 @@
   // Not supported.
 }
 
-bool Field::buttonScaleHow(IJS_Context* cc,
+bool Field::buttonScaleHow(IJS_EventContext* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -773,7 +773,7 @@
   // Not supported.
 }
 
-bool Field::buttonScaleWhen(IJS_Context* cc,
+bool Field::buttonScaleWhen(IJS_EventContext* cc,
                             CJS_PropValue& vp,
                             CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -832,7 +832,7 @@
   // Not supported.
 }
 
-bool Field::calcOrderIndex(IJS_Context* cc,
+bool Field::calcOrderIndex(IJS_EventContext* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -876,7 +876,7 @@
   // Not supported.
 }
 
-bool Field::charLimit(IJS_Context* cc,
+bool Field::charLimit(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -915,7 +915,9 @@
   // Not supported.
 }
 
-bool Field::comb(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Field::comb(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
 
   if (vp.IsSetting()) {
@@ -956,7 +958,7 @@
   // Not supported.
 }
 
-bool Field::commitOnSelChange(IJS_Context* cc,
+bool Field::commitOnSelChange(IJS_EventContext* cc,
                               CJS_PropValue& vp,
                               CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -1001,10 +1003,10 @@
   // Not supported.
 }
 
-bool Field::currentValueIndices(IJS_Context* cc,
+bool Field::currentValueIndices(IJS_EventContext* cc,
                                 CJS_PropValue& vp,
                                 CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
 
   if (vp.IsSetting()) {
     if (!m_bCanSet)
@@ -1087,7 +1089,7 @@
   }
 }
 
-bool Field::defaultStyle(IJS_Context* cc,
+bool Field::defaultStyle(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   return false;
@@ -1099,7 +1101,7 @@
   // Not supported.
 }
 
-bool Field::defaultValue(IJS_Context* cc,
+bool Field::defaultValue(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -1140,7 +1142,7 @@
   // Not supported.
 }
 
-bool Field::doNotScroll(IJS_Context* cc,
+bool Field::doNotScroll(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -1183,7 +1185,7 @@
   // Not supported.
 }
 
-bool Field::doNotSpellCheck(IJS_Context* cc,
+bool Field::doNotSpellCheck(IJS_EventContext* cc,
                             CJS_PropValue& vp,
                             CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -1223,22 +1225,23 @@
   }
 }
 
-bool Field::delay(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
-  if (vp.IsSetting()) {
-    if (!m_bCanSet)
-      return false;
-
-    bool bVP;
-    vp >> bVP;
-
-    SetDelay(bVP);
-  } else {
+bool Field::delay(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError) {
+  if (!vp.IsSetting()) {
     vp << m_bDelay;
+    return true;
   }
+  if (!m_bCanSet)
+    return false;
+
+  bool bVP;
+  vp >> bVP;
+  SetDelay(bVP);
   return true;
 }
 
-bool Field::display(IJS_Context* cc,
+bool Field::display(IJS_EventContext* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1247,43 +1250,40 @@
 
     int nVP;
     vp >> nVP;
-
     if (m_bDelay) {
       AddDelay_Int(FP_DISPLAY, nVP);
     } else {
       Field::SetDisplay(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                         nVP);
     }
+    return true;
+  }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
+
+  CPDF_FormField* pFormField = FieldArray[0];
+  ASSERT(pFormField);
+  CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
+  CPDFSDK_Widget* pWidget =
+      pInterForm->GetWidget(GetSmartFieldControl(pFormField));
+  if (!pWidget)
+    return false;
+
+  uint32_t dwFlag = pWidget->GetFlags();
+  if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
+    vp << (int32_t)1;
   } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    ASSERT(pFormField);
-    CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
-    CPDFSDK_Widget* pWidget =
-        pInterForm->GetWidget(GetSmartFieldControl(pFormField));
-    if (!pWidget)
-      return false;
-
-    uint32_t dwFlag = pWidget->GetFlags();
-
-    if (ANNOTFLAG_INVISIBLE & dwFlag || ANNOTFLAG_HIDDEN & dwFlag) {
-      vp << (int32_t)1;
-    } else {
-      if (ANNOTFLAG_PRINT & dwFlag) {
-        if (ANNOTFLAG_NOVIEW & dwFlag) {
-          vp << (int32_t)3;
-        } else {
-          vp << (int32_t)0;
-        }
+    if (ANNOTFLAG_PRINT & dwFlag) {
+      if (ANNOTFLAG_NOVIEW & dwFlag) {
+        vp << (int32_t)3;
       } else {
-        vp << (int32_t)2;
+        vp << (int32_t)0;
       }
+    } else {
+      vp << (int32_t)2;
     }
   }
-
   return true;
 }
 
@@ -1323,15 +1323,17 @@
   }
 }
 
-bool Field::doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
-  if (!vp.IsGetting()) {
+bool Field::doc(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError) {
+  if (!vp.IsGetting())
     return false;
-  }
+
   vp << m_pJSDoc->GetCJSDoc();
   return true;
 }
 
-bool Field::editable(IJS_Context* cc,
+bool Field::editable(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1340,25 +1342,21 @@
 
     bool bVP;
     vp >> bVP;
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
-      return false;
-
-    if (pFormField->GetFieldFlags() & FIELDFLAG_EDIT)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_COMBOBOX)
+    return false;
+
+  vp << !!(pFormField->GetFieldFlags() & FIELDFLAG_EDIT);
   return true;
 }
 
-bool Field::exportValues(IJS_Context* cc,
+bool Field::exportValues(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1370,42 +1368,36 @@
       pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON) {
     return false;
   }
+  if (vp.IsSetting())
+    return m_bCanSet && vp.GetJSValue()->IsArrayObject();
 
-  if (vp.IsSetting()) {
-    if (!m_bCanSet)
-      return false;
-
-    if (!vp.GetJSValue()->IsArrayObject())
-      return false;
-  } else {
-    CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
-    CJS_Array ExportValusArray;
-    if (m_nFormControlIndex < 0) {
-      for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
-        CPDF_FormControl* pFormControl = pFormField->GetControl(i);
-        ExportValusArray.SetElement(
-            pRuntime, i,
-            CJS_Value(pRuntime, pFormControl->GetExportValue().c_str()));
-      }
-    } else {
-      if (m_nFormControlIndex >= pFormField->CountControls())
-        return false;
-
-      CPDF_FormControl* pFormControl =
-          pFormField->GetControl(m_nFormControlIndex);
-      if (!pFormControl)
-        return false;
-
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
+  CJS_Array ExportValusArray;
+  if (m_nFormControlIndex < 0) {
+    for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
+      CPDF_FormControl* pFormControl = pFormField->GetControl(i);
       ExportValusArray.SetElement(
-          pRuntime, 0,
+          pRuntime, i,
           CJS_Value(pRuntime, pFormControl->GetExportValue().c_str()));
     }
-    vp << ExportValusArray;
+  } else {
+    if (m_nFormControlIndex >= pFormField->CountControls())
+      return false;
+
+    CPDF_FormControl* pFormControl =
+        pFormField->GetControl(m_nFormControlIndex);
+    if (!pFormControl)
+      return false;
+
+    ExportValusArray.SetElement(
+        pRuntime, 0,
+        CJS_Value(pRuntime, pFormControl->GetExportValue().c_str()));
   }
+  vp << ExportValusArray;
   return true;
 }
 
-bool Field::fileSelect(IJS_Context* cc,
+bool Field::fileSelect(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1422,19 +1414,16 @@
 
     bool bVP;
     vp >> bVP;
-  } else {
-    if (pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
+  vp << !!(pFormField->GetFieldFlags() & FIELDFLAG_FILESELECT);
   return true;
 }
 
-bool Field::fillColor(IJS_Context* cc,
+bool Field::fillColor(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_Array crArray;
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
   if (FieldArray.empty())
@@ -1457,41 +1446,39 @@
       Field::SetFillColor(m_pFormFillEnv.Get(), m_FieldName,
                           m_nFormControlIndex, color);
     }
-  } else {
-    CPDF_FormField* pFormField = FieldArray[0];
-    ASSERT(pFormField);
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
-
-    int iColorType;
-    pFormControl->GetBackgroundColor(iColorType);
-
-    CPWL_Color color;
-    if (iColorType == COLORTYPE_TRANSPARENT) {
-      color = CPWL_Color(COLORTYPE_TRANSPARENT);
-    } else if (iColorType == COLORTYPE_GRAY) {
-      color = CPWL_Color(COLORTYPE_GRAY,
-                         pFormControl->GetOriginalBackgroundColor(0));
-    } else if (iColorType == COLORTYPE_RGB) {
-      color =
-          CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0),
-                     pFormControl->GetOriginalBackgroundColor(1),
-                     pFormControl->GetOriginalBackgroundColor(2));
-    } else if (iColorType == COLORTYPE_CMYK) {
-      color = CPWL_Color(COLORTYPE_CMYK,
-                         pFormControl->GetOriginalBackgroundColor(0),
-                         pFormControl->GetOriginalBackgroundColor(1),
-                         pFormControl->GetOriginalBackgroundColor(2),
-                         pFormControl->GetOriginalBackgroundColor(3));
-    } else {
-      return false;
-    }
-
-    color::ConvertPWLColorToArray(pRuntime, color, &crArray);
-    vp << crArray;
+    return true;
   }
+  CPDF_FormField* pFormField = FieldArray[0];
+  ASSERT(pFormField);
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
 
+  int iColorType;
+  pFormControl->GetBackgroundColor(iColorType);
+
+  CPWL_Color color;
+  if (iColorType == COLORTYPE_TRANSPARENT) {
+    color = CPWL_Color(COLORTYPE_TRANSPARENT);
+  } else if (iColorType == COLORTYPE_GRAY) {
+    color =
+        CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBackgroundColor(0));
+  } else if (iColorType == COLORTYPE_RGB) {
+    color =
+        CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBackgroundColor(0),
+                   pFormControl->GetOriginalBackgroundColor(1),
+                   pFormControl->GetOriginalBackgroundColor(2));
+  } else if (iColorType == COLORTYPE_CMYK) {
+    color =
+        CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBackgroundColor(0),
+                   pFormControl->GetOriginalBackgroundColor(1),
+                   pFormControl->GetOriginalBackgroundColor(2),
+                   pFormControl->GetOriginalBackgroundColor(3));
+  } else {
+    return false;
+  }
+  color::ConvertPWLColorToArray(pRuntime, color, &crArray);
+  vp << crArray;
   return true;
 }
 
@@ -1502,40 +1489,40 @@
   // Not supported.
 }
 
-bool Field::hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Field::hidden(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
   if (vp.IsSetting()) {
     if (!m_bCanSet)
       return false;
 
     bool bVP;
     vp >> bVP;
-
     if (m_bDelay) {
       AddDelay_Bool(FP_HIDDEN, bVP);
     } else {
       Field::SetHidden(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                        bVP);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    ASSERT(pFormField);
-    CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
-    CPDFSDK_Widget* pWidget =
-        pInterForm->GetWidget(GetSmartFieldControl(pFormField));
-    if (!pWidget)
-      return false;
-
-    uint32_t dwFlags = pWidget->GetFlags();
-
-    if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
+
+  CPDF_FormField* pFormField = FieldArray[0];
+  ASSERT(pFormField);
+  CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
+  CPDFSDK_Widget* pWidget =
+      pInterForm->GetWidget(GetSmartFieldControl(pFormField));
+  if (!pWidget)
+    return false;
+
+  uint32_t dwFlags = pWidget->GetFlags();
+  if (ANNOTFLAG_INVISIBLE & dwFlags || ANNOTFLAG_HIDDEN & dwFlags)
+    vp << true;
+  else
+    vp << false;
 
   return true;
 }
@@ -1548,11 +1535,10 @@
   SetDisplay(pFormFillEnv, swFieldName, nControlIndex, display);
 }
 
-bool Field::highlight(IJS_Context* cc,
+bool Field::highlight(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
-
   if (vp.IsSetting()) {
     if (!m_bCanSet)
       return false;
@@ -1566,39 +1552,38 @@
       Field::SetHighlight(m_pFormFillEnv.Get(), m_FieldName,
                           m_nFormControlIndex, strMode);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
-      return false;
-
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
-
-    int eHM = pFormControl->GetHighlightingMode();
-    switch (eHM) {
-      case CPDF_FormControl::None:
-        vp << L"none";
-        break;
-      case CPDF_FormControl::Push:
-        vp << L"push";
-        break;
-      case CPDF_FormControl::Invert:
-        vp << L"invert";
-        break;
-      case CPDF_FormControl::Outline:
-        vp << L"outline";
-        break;
-      case CPDF_FormControl::Toggle:
-        vp << L"toggle";
-        break;
-    }
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
+    return false;
+
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
+
+  int eHM = pFormControl->GetHighlightingMode();
+  switch (eHM) {
+    case CPDF_FormControl::None:
+      vp << L"none";
+      break;
+    case CPDF_FormControl::Push:
+      vp << L"push";
+      break;
+    case CPDF_FormControl::Invert:
+      vp << L"invert";
+      break;
+    case CPDF_FormControl::Outline:
+      vp << L"outline";
+      break;
+    case CPDF_FormControl::Toggle:
+      vp << L"toggle";
+      break;
+  }
   return true;
 }
 
@@ -1609,7 +1594,7 @@
   // Not supported.
 }
 
-bool Field::lineWidth(IJS_Context* cc,
+bool Field::lineWidth(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -1625,28 +1610,27 @@
       Field::SetLineWidth(m_pFormFillEnv.Get(), m_FieldName,
                           m_nFormControlIndex, iWidth);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    ASSERT(pFormField);
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
-
-    CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
-    if (!pFormField->CountControls())
-      return false;
-
-    CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
-    if (!pWidget)
-      return false;
-
-    vp << (int32_t)pWidget->GetBorderWidth();
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
+  CPDF_FormField* pFormField = FieldArray[0];
+  ASSERT(pFormField);
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
+
+  CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
+  if (!pFormField->CountControls())
+    return false;
+
+  CPDFSDK_Widget* pWidget = pInterForm->GetWidget(pFormField->GetControl(0));
+  if (!pWidget)
+    return false;
+
+  vp << (int32_t)pWidget->GetBorderWidth();
   return true;
 }
 
@@ -1689,7 +1673,7 @@
   }
 }
 
-bool Field::multiline(IJS_Context* cc,
+bool Field::multiline(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -1707,20 +1691,20 @@
       Field::SetMultiline(m_pFormFillEnv.Get(), m_FieldName,
                           m_nFormControlIndex, bVP);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
-      return false;
-
-    if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
+
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+    return false;
+
+  if (pFormField->GetFieldFlags() & FIELDFLAG_MULTILINE)
+    vp << true;
+  else
+    vp << false;
 
   return true;
 }
@@ -1732,39 +1716,33 @@
   // Not supported.
 }
 
-bool Field::multipleSelection(IJS_Context* cc,
+bool Field::multipleSelection(IJS_EventContext* cc,
                               CJS_PropValue& vp,
                               CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
-
   if (vp.IsSetting()) {
     if (!m_bCanSet)
       return false;
 
     bool bVP;
     vp >> bVP;
-
     if (m_bDelay) {
       AddDelay_Bool(FP_MULTIPLESELECTION, bVP);
     } else {
       Field::SetMultipleSelection(m_pFormFillEnv.Get(), m_FieldName,
                                   m_nFormControlIndex, bVP);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
-      return false;
-
-    if (pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_LISTBOX)
+    return false;
+
+  vp << !!(pFormField->GetFieldFlags() & FIELDFLAG_MULTISELECT);
   return true;
 }
 
@@ -1775,7 +1753,9 @@
   // Not supported.
 }
 
-bool Field::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Field::name(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
@@ -1784,11 +1764,10 @@
     return false;
 
   vp << m_FieldName;
-
   return true;
 }
 
-bool Field::numItems(IJS_Context* cc,
+bool Field::numItems(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (!vp.IsGetting())
@@ -1808,7 +1787,9 @@
   return true;
 }
 
-bool Field::page(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Field::page(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError) {
   if (!vp.IsGetting()) {
     sError = JSGetStringFromID(IDS_STRING_JSREADONLY);
     return false;
@@ -1829,7 +1810,7 @@
     return true;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_Array PageArray;
   int i = 0;
   for (const auto& pObserved : widgets) {
@@ -1852,7 +1833,7 @@
   return true;
 }
 
-bool Field::password(IJS_Context* cc,
+bool Field::password(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -1863,28 +1844,24 @@
 
     bool bVP;
     vp >> bVP;
-
     if (m_bDelay) {
       AddDelay_Bool(FP_PASSWORD, bVP);
     } else {
       Field::SetPassword(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                          bVP);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
-      return false;
-
-    if (pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
 
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
+
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+    return false;
+
+  vp << !!(pFormField->GetFieldFlags() & FIELDFLAG_PASSWORD);
   return true;
 }
 
@@ -1895,7 +1872,9 @@
   // Not supported.
 }
 
-bool Field::print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Field::print(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError) {
   CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
   if (FieldArray.empty())
@@ -1951,23 +1930,20 @@
         }
       }
     }
-  } else {
-    CPDF_FormField* pFormField = FieldArray[0];
-    CPDFSDK_Widget* pWidget =
-        pInterForm->GetWidget(GetSmartFieldControl(pFormField));
-    if (!pWidget)
-      return false;
-
-    if (pWidget->GetFlags() & ANNOTFLAG_PRINT)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
 
+  CPDF_FormField* pFormField = FieldArray[0];
+  CPDFSDK_Widget* pWidget =
+      pInterForm->GetWidget(GetSmartFieldControl(pFormField));
+  if (!pWidget)
+    return false;
+
+  vp << !!(pWidget->GetFlags() & ANNOTFLAG_PRINT);
   return true;
 }
 
-bool Field::radiosInUnison(IJS_Context* cc,
+bool Field::radiosInUnison(IJS_EventContext* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -1980,22 +1956,17 @@
 
     bool bVP;
     vp >> bVP;
-
-  } else {
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
-      return false;
-
-    if (pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON)
+    return false;
 
+  vp << !!(pFormField->GetFieldFlags() & FIELDFLAG_RADIOSINUNISON);
   return true;
 }
 
-bool Field::readonly(IJS_Context* cc,
+bool Field::readonly(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -2008,20 +1979,16 @@
 
     bool bVP;
     vp >> bVP;
-
-  } else {
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldFlags() & FIELDFLAG_READONLY)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
-
+  vp << !!(FieldArray[0]->GetFieldFlags() & FIELDFLAG_READONLY);
   return true;
 }
 
-bool Field::rect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+bool Field::rect(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError) {
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_Value Upper_Leftx(pRuntime);
   CJS_Value Upper_Lefty(pRuntime);
   CJS_Value Lower_Rightx(pRuntime);
@@ -2053,31 +2020,31 @@
       Field::SetRect(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                      crRect);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
-    CPDFSDK_Widget* pWidget =
-        pInterForm->GetWidget(GetSmartFieldControl(pFormField));
-    if (!pWidget)
-      return false;
-
-    CFX_FloatRect crRect = pWidget->GetRect();
-    Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left));
-    Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top));
-    Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right));
-    Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom));
-
-    CJS_Array rcArray;
-    rcArray.SetElement(pRuntime, 0, Upper_Leftx);
-    rcArray.SetElement(pRuntime, 1, Upper_Lefty);
-    rcArray.SetElement(pRuntime, 2, Lower_Rightx);
-    rcArray.SetElement(pRuntime, 3, Lower_Righty);
-    vp << rcArray;
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
+
+  CPDF_FormField* pFormField = FieldArray[0];
+  CPDFSDK_InterForm* pInterForm = m_pFormFillEnv->GetInterForm();
+  CPDFSDK_Widget* pWidget =
+      pInterForm->GetWidget(GetSmartFieldControl(pFormField));
+  if (!pWidget)
+    return false;
+
+  CFX_FloatRect crRect = pWidget->GetRect();
+  Upper_Leftx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.left));
+  Upper_Lefty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.top));
+  Lower_Rightx = CJS_Value(pRuntime, static_cast<int32_t>(crRect.right));
+  Lower_Righty = CJS_Value(pRuntime, static_cast<int32_t>(crRect.bottom));
+
+  CJS_Array rcArray;
+  rcArray.SetElement(pRuntime, 0, Upper_Leftx);
+  rcArray.SetElement(pRuntime, 1, Upper_Lefty);
+  rcArray.SetElement(pRuntime, 2, Lower_Rightx);
+  rcArray.SetElement(pRuntime, 3, Lower_Righty);
+  vp << rcArray;
   return true;
 }
 
@@ -2139,7 +2106,7 @@
   }
 }
 
-bool Field::required(IJS_Context* cc,
+bool Field::required(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -2152,22 +2119,17 @@
 
     bool bVP;
     vp >> bVP;
-
-  } else {
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
-      return false;
-
-    if (pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() == FIELDTYPE_PUSHBUTTON)
+    return false;
 
+  vp << !!(pFormField->GetFieldFlags() & FIELDFLAG_REQUIRED);
   return true;
 }
 
-bool Field::richText(IJS_Context* cc,
+bool Field::richText(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -2178,35 +2140,31 @@
 
     bool bVP;
     vp >> bVP;
-
-    if (m_bDelay) {
+    if (m_bDelay)
       AddDelay_Bool(FP_RICHTEXT, bVP);
-    }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
-      return false;
-
-    if (pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT)
-      vp << true;
-    else
-      vp << false;
+    return true;
   }
 
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
+
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_TEXTFIELD)
+    return false;
+
+  vp << !!(pFormField->GetFieldFlags() & FIELDFLAG_RICHTEXT);
   return true;
 }
 
-bool Field::richValue(IJS_Context* cc,
+bool Field::richValue(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   return true;
 }
 
-bool Field::rotation(IJS_Context* cc,
+bool Field::rotation(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -2217,26 +2175,24 @@
 
     int nVP;
     vp >> nVP;
-
     if (m_bDelay) {
       AddDelay_Int(FP_ROTATION, nVP);
     } else {
       Field::SetRotation(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                          nVP);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
-
-    vp << (int32_t)pFormControl->GetRotation();
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
+  CPDF_FormField* pFormField = FieldArray[0];
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
+
+  vp << (int32_t)pFormControl->GetRotation();
   return true;
 }
 
@@ -2247,10 +2203,10 @@
   // Not supported.
 }
 
-bool Field::strokeColor(IJS_Context* cc,
+bool Field::strokeColor(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_Array crArray;
 
   if (vp.IsSetting()) {
@@ -2264,49 +2220,46 @@
 
     CPWL_Color color;
     color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
-
     if (m_bDelay) {
       AddDelay_Color(FP_STROKECOLOR, color);
     } else {
       Field::SetStrokeColor(m_pFormFillEnv.Get(), m_FieldName,
                             m_nFormControlIndex, color);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
-
-    int iColorType;
-    pFormControl->GetBorderColor(iColorType);
-
-    CPWL_Color color;
-    if (iColorType == COLORTYPE_TRANSPARENT) {
-      color = CPWL_Color(COLORTYPE_TRANSPARENT);
-    } else if (iColorType == COLORTYPE_GRAY) {
-      color =
-          CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0));
-    } else if (iColorType == COLORTYPE_RGB) {
-      color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0),
-                         pFormControl->GetOriginalBorderColor(1),
-                         pFormControl->GetOriginalBorderColor(2));
-    } else if (iColorType == COLORTYPE_CMYK) {
-      color =
-          CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0),
-                     pFormControl->GetOriginalBorderColor(1),
-                     pFormControl->GetOriginalBorderColor(2),
-                     pFormControl->GetOriginalBorderColor(3));
-    } else {
-      return false;
-    }
-
-    color::ConvertPWLColorToArray(pRuntime, color, &crArray);
-    vp << crArray;
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
+
+  CPDF_FormField* pFormField = FieldArray[0];
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
+
+  int iColorType;
+  pFormControl->GetBorderColor(iColorType);
+
+  CPWL_Color color;
+  if (iColorType == COLORTYPE_TRANSPARENT) {
+    color = CPWL_Color(COLORTYPE_TRANSPARENT);
+  } else if (iColorType == COLORTYPE_GRAY) {
+    color = CPWL_Color(COLORTYPE_GRAY, pFormControl->GetOriginalBorderColor(0));
+  } else if (iColorType == COLORTYPE_RGB) {
+    color = CPWL_Color(COLORTYPE_RGB, pFormControl->GetOriginalBorderColor(0),
+                       pFormControl->GetOriginalBorderColor(1),
+                       pFormControl->GetOriginalBorderColor(2));
+  } else if (iColorType == COLORTYPE_CMYK) {
+    color = CPWL_Color(COLORTYPE_CMYK, pFormControl->GetOriginalBorderColor(0),
+                       pFormControl->GetOriginalBorderColor(1),
+                       pFormControl->GetOriginalBorderColor(2),
+                       pFormControl->GetOriginalBorderColor(3));
+  } else {
+    return false;
+  }
+
+  color::ConvertPWLColorToArray(pRuntime, color, &crArray);
+  vp << crArray;
   return true;
 }
 
@@ -2317,7 +2270,9 @@
   // Not supported.
 }
 
-bool Field::style(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Field::style(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
 
   if (vp.IsSetting()) {
@@ -2333,47 +2288,46 @@
       Field::SetStyle(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                       csBCaption);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+    return true;
+  }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON &&
-        pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) {
-      return false;
-    }
-
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
-
-    CFX_WideString csWCaption = pFormControl->GetNormalCaption();
-    CFX_ByteString csBCaption;
-
-    switch (csWCaption[0]) {
-      case L'l':
-        csBCaption = "circle";
-        break;
-      case L'8':
-        csBCaption = "cross";
-        break;
-      case L'u':
-        csBCaption = "diamond";
-        break;
-      case L'n':
-        csBCaption = "square";
-        break;
-      case L'H':
-        csBCaption = "star";
-        break;
-      default:  // L'4'
-        csBCaption = "check";
-        break;
-    }
-    vp << csBCaption;
+  CPDF_FormField* pFormField = FieldArray[0];
+  if (pFormField->GetFieldType() != FIELDTYPE_RADIOBUTTON &&
+      pFormField->GetFieldType() != FIELDTYPE_CHECKBOX) {
+    return false;
   }
 
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
+
+  CFX_WideString csWCaption = pFormControl->GetNormalCaption();
+  CFX_ByteString csBCaption;
+
+  switch (csWCaption[0]) {
+    case L'l':
+      csBCaption = "circle";
+      break;
+    case L'8':
+      csBCaption = "cross";
+      break;
+    case L'u':
+      csBCaption = "diamond";
+      break;
+    case L'n':
+      csBCaption = "square";
+      break;
+    case L'H':
+      csBCaption = "star";
+      break;
+    default:  // L'4'
+      csBCaption = "check";
+      break;
+  }
+  vp << csBCaption;
   return true;
 }
 
@@ -2384,16 +2338,16 @@
   // Not supported.
 }
 
-bool Field::submitName(IJS_Context* cc,
+bool Field::submitName(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   return true;
 }
 
-bool Field::textColor(IJS_Context* cc,
+bool Field::textColor(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_Array crArray;
 
   if (vp.IsSetting()) {
@@ -2407,40 +2361,42 @@
 
     CPWL_Color color;
     color::ConvertArrayToPWLColor(pRuntime, crArray, &color);
-
     if (m_bDelay) {
       AddDelay_Color(FP_TEXTCOLOR, color);
     } else {
       Field::SetTextColor(m_pFormFillEnv.Get(), m_FieldName,
                           m_nFormControlIndex, color);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
-
-    int iColorType;
-    FX_ARGB color;
-    CPDF_DefaultAppearance FieldAppearance =
-        pFormControl->GetDefaultAppearance();
-    FieldAppearance.GetColor(color, iColorType);
-    int32_t a, r, g, b;
-    ArgbDecode(color, a, r, g, b);
-
-    CPWL_Color crRet =
-        CPWL_Color(COLORTYPE_RGB, r / 255.0f, g / 255.0f, b / 255.0f);
-
-    if (iColorType == COLORTYPE_TRANSPARENT)
-      crRet = CPWL_Color(COLORTYPE_TRANSPARENT);
-
-    color::ConvertPWLColorToArray(pRuntime, crRet, &crArray);
-    vp << crArray;
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
+
+  CPDF_FormField* pFormField = FieldArray[0];
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
+
+  int iColorType;
+  FX_ARGB color;
+  CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
+  FieldAppearance.GetColor(color, iColorType);
+
+  int32_t a;
+  int32_t r;
+  int32_t g;
+  int32_t b;
+  ArgbDecode(color, a, r, g, b);
+
+  CPWL_Color crRet =
+      CPWL_Color(COLORTYPE_RGB, r / 255.0f, g / 255.0f, b / 255.0f);
+
+  if (iColorType == COLORTYPE_TRANSPARENT)
+    crRet = CPWL_Color(COLORTYPE_TRANSPARENT);
+
+  color::ConvertPWLColorToArray(pRuntime, crRet, &crArray);
+  vp << crArray;
   return true;
 }
 
@@ -2451,7 +2407,7 @@
   // Not supported.
 }
 
-bool Field::textFont(IJS_Context* cc,
+bool Field::textFont(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -2471,32 +2427,28 @@
       Field::SetTextFont(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                          csFontName);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    ASSERT(pFormField);
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
-
-    int nFieldType = pFormField->GetFieldType();
-
-    if (nFieldType == FIELDTYPE_PUSHBUTTON ||
-        nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_LISTBOX ||
-        nFieldType == FIELDTYPE_TEXTFIELD) {
-      CPDF_Font* pFont = pFormControl->GetDefaultControlFont();
-      if (!pFont)
-        return false;
-
-      vp << pFont->GetBaseFont();
-    } else {
-      return false;
-    }
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
+  CPDF_FormField* pFormField = FieldArray[0];
+  ASSERT(pFormField);
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
+
+  int nFieldType = pFormField->GetFieldType();
+  if (nFieldType != FIELDTYPE_PUSHBUTTON && nFieldType != FIELDTYPE_COMBOBOX &&
+      nFieldType != FIELDTYPE_LISTBOX && nFieldType != FIELDTYPE_TEXTFIELD) {
+    return false;
+  }
+  CPDF_Font* pFont = pFormControl->GetDefaultControlFont();
+  if (!pFont)
+    return false;
+
+  vp << pFont->GetBaseFont();
   return true;
 }
 
@@ -2507,7 +2459,7 @@
   // Not supported.
 }
 
-bool Field::textSize(IJS_Context* cc,
+bool Field::textSize(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -2518,34 +2470,30 @@
 
     int nVP;
     vp >> nVP;
-
     if (m_bDelay) {
       AddDelay_Int(FP_TEXTSIZE, nVP);
     } else {
       Field::SetTextSize(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                          nVP);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    ASSERT(pFormField);
-    CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
-    if (!pFormControl)
-      return false;
-
-    CPDF_DefaultAppearance FieldAppearance =
-        pFormControl->GetDefaultAppearance();
-
-    CFX_ByteString csFontNameTag;
-    FX_FLOAT fFontSize;
-    FieldAppearance.GetFont(csFontNameTag, fFontSize);
-
-    vp << (int)fFontSize;
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
+  CPDF_FormField* pFormField = FieldArray[0];
+  ASSERT(pFormField);
+  CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
+  if (!pFormControl)
+    return false;
+
+  CPDF_DefaultAppearance FieldAppearance = pFormControl->GetDefaultAppearance();
+
+  CFX_ByteString csFontNameTag;
+  FX_FLOAT fFontSize;
+  FieldAppearance.GetFont(csFontNameTag, fFontSize);
+  vp << (int)fFontSize;
   return true;
 }
 
@@ -2556,7 +2504,9 @@
   // Not supported.
 }
 
-bool Field::type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Field::type(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
@@ -2594,11 +2544,10 @@
       vp << L"unknown";
       break;
   }
-
   return true;
 }
 
-bool Field::userName(IJS_Context* cc,
+bool Field::userName(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   ASSERT(m_pFormFillEnv);
@@ -2616,15 +2565,13 @@
       Field::SetUserName(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                          swName);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
-
-    CPDF_FormField* pFormField = FieldArray[0];
-    vp << (CFX_WideString)pFormField->GetAlternateName();
+    return true;
   }
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
 
+  vp << FieldArray[0]->GetAlternateName();
   return true;
 }
 
@@ -2635,8 +2582,10 @@
   // Not supported.
 }
 
-bool Field::value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+bool Field::value(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError) {
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
 
   if (vp.IsSetting()) {
     if (!m_bCanSet)
@@ -2663,57 +2612,58 @@
       Field::SetValue(m_pFormFillEnv.Get(), m_FieldName, m_nFormControlIndex,
                       strArray);
     }
-  } else {
-    std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
-    if (FieldArray.empty())
-      return false;
+    return true;
+  }
 
-    CPDF_FormField* pFormField = FieldArray[0];
-    switch (pFormField->GetFieldType()) {
-      case FIELDTYPE_PUSHBUTTON:
-        return false;
-      case FIELDTYPE_COMBOBOX:
-      case FIELDTYPE_TEXTFIELD: {
-        vp << pFormField->GetValue();
-      } break;
-      case FIELDTYPE_LISTBOX: {
-        if (pFormField->CountSelectedItems() > 1) {
-          CJS_Array ValueArray;
-          CJS_Value ElementValue(pRuntime);
-          int iIndex;
-          for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
-            iIndex = pFormField->GetSelectedIndex(i);
+  std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
+  if (FieldArray.empty())
+    return false;
+
+  CPDF_FormField* pFormField = FieldArray[0];
+  switch (pFormField->GetFieldType()) {
+    case FIELDTYPE_PUSHBUTTON:
+      return false;
+    case FIELDTYPE_COMBOBOX:
+    case FIELDTYPE_TEXTFIELD: {
+      vp << pFormField->GetValue();
+    } break;
+    case FIELDTYPE_LISTBOX: {
+      if (pFormField->CountSelectedItems() > 1) {
+        CJS_Array ValueArray;
+        CJS_Value ElementValue(pRuntime);
+        int iIndex;
+        for (int i = 0, sz = pFormField->CountSelectedItems(); i < sz; i++) {
+          iIndex = pFormField->GetSelectedIndex(i);
+          ElementValue =
+              CJS_Value(pRuntime, pFormField->GetOptionValue(iIndex).c_str());
+          if (FXSYS_wcslen(ElementValue.ToCFXWideString(pRuntime).c_str()) ==
+              0) {
             ElementValue =
-                CJS_Value(pRuntime, pFormField->GetOptionValue(iIndex).c_str());
-            if (FXSYS_wcslen(ElementValue.ToCFXWideString(pRuntime).c_str()) ==
-                0) {
-              ElementValue = CJS_Value(
-                  pRuntime, pFormField->GetOptionLabel(iIndex).c_str());
-            }
-            ValueArray.SetElement(pRuntime, i, ElementValue);
+                CJS_Value(pRuntime, pFormField->GetOptionLabel(iIndex).c_str());
           }
-          vp << ValueArray;
-        } else {
-          vp << pFormField->GetValue();
+          ValueArray.SetElement(pRuntime, i, ElementValue);
         }
-      } break;
-      case FIELDTYPE_CHECKBOX:
-      case FIELDTYPE_RADIOBUTTON: {
-        bool bFind = false;
-        for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
-          if (pFormField->GetControl(i)->IsChecked()) {
-            vp << pFormField->GetControl(i)->GetExportValue();
-            bFind = true;
-            break;
-          }
-        }
-        if (!bFind)
-          vp << L"Off";
-      } break;
-      default:
+        vp << ValueArray;
+      } else {
         vp << pFormField->GetValue();
-        break;
-    }
+      }
+    } break;
+    case FIELDTYPE_CHECKBOX:
+    case FIELDTYPE_RADIOBUTTON: {
+      bool bFind = false;
+      for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) {
+        if (pFormField->GetControl(i)->IsChecked()) {
+          vp << pFormField->GetControl(i)->GetExportValue();
+          bFind = true;
+          break;
+        }
+      }
+      if (!bFind)
+        vp << L"Off";
+    } break;
+    default:
+      vp << pFormField->GetValue();
+      break;
   }
   vp.GetJSValue()->MaybeCoerceToNumber(pRuntime);
   return true;
@@ -2773,7 +2723,7 @@
   }
 }
 
-bool Field::valueAsString(IJS_Context* cc,
+bool Field::valueAsString(IJS_EventContext* cc,
                           CJS_PropValue& vp,
                           CFX_WideString& sError) {
   if (!vp.IsGetting())
@@ -2815,7 +2765,7 @@
   return true;
 }
 
-bool Field::browseForFileToSubmit(IJS_Context* cc,
+bool Field::browseForFileToSubmit(IJS_EventContext* cc,
                                   const std::vector<CJS_Value>& params,
                                   CJS_Value& vRet,
                                   CFX_WideString& sError) {
@@ -2836,11 +2786,11 @@
   return false;
 }
 
-bool Field::buttonGetCaption(IJS_Context* cc,
+bool Field::buttonGetCaption(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
 
   int nface = 0;
   int iSize = params.size();
@@ -2871,11 +2821,11 @@
   return true;
 }
 
-bool Field::buttonGetIcon(IJS_Context* cc,
+bool Field::buttonGetIcon(IJS_EventContext* cc,
                           const std::vector<CJS_Value>& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
   CJS_Runtime* pRuntime = pContext->GetJSRuntime();
 
   int nface = 0;
@@ -2917,28 +2867,28 @@
   return true;
 }
 
-bool Field::buttonImportIcon(IJS_Context* cc,
+bool Field::buttonImportIcon(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
   return true;
 }
 
-bool Field::buttonSetCaption(IJS_Context* cc,
+bool Field::buttonSetCaption(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
   return false;
 }
 
-bool Field::buttonSetIcon(IJS_Context* cc,
+bool Field::buttonSetIcon(IJS_EventContext* cc,
                           const std::vector<CJS_Value>& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
   return false;
 }
 
-bool Field::checkThisBox(IJS_Context* cc,
+bool Field::checkThisBox(IJS_EventContext* cc,
                          const std::vector<CJS_Value>& params,
                          CJS_Value& vRet,
                          CFX_WideString& sError) {
@@ -2949,7 +2899,7 @@
   if (!m_bCanSet)
     return false;
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int nWidget = params[0].ToInt(pRuntime);
 
   bool bCheckit = true;
@@ -2977,14 +2927,14 @@
   return true;
 }
 
-bool Field::clearItems(IJS_Context* cc,
+bool Field::clearItems(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
   return true;
 }
 
-bool Field::defaultIsChecked(IJS_Context* cc,
+bool Field::defaultIsChecked(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
@@ -2995,7 +2945,7 @@
   if (iSize < 1)
     return false;
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int nWidget = params[0].ToInt(pRuntime);
 
   std::vector<CPDF_FormField*> FieldArray = GetFormFields(m_FieldName);
@@ -3013,14 +2963,14 @@
   return true;
 }
 
-bool Field::deleteItemAt(IJS_Context* cc,
+bool Field::deleteItemAt(IJS_EventContext* cc,
                          const std::vector<CJS_Value>& params,
                          CJS_Value& vRet,
                          CFX_WideString& sError) {
   return true;
 }
 
-bool Field::getArray(IJS_Context* cc,
+bool Field::getArray(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError) {
@@ -3039,7 +2989,7 @@
       [](const std::unique_ptr<CFX_WideString>& p1,
          const std::unique_ptr<CFX_WideString>& p2) { return *p1 < *p2; });
 
-  CJS_Context* pContext = (CJS_Context*)cc;
+  CJS_EventContext* pContext = (CJS_EventContext*)cc;
   CJS_Runtime* pRuntime = pContext->GetJSRuntime();
   CJS_Array FormFieldArray;
 
@@ -3060,11 +3010,11 @@
   return true;
 }
 
-bool Field::getItemAt(IJS_Context* cc,
+bool Field::getItemAt(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
 
   int iSize = params.size();
   int nIdx = -1;
@@ -3100,25 +3050,25 @@
   return true;
 }
 
-bool Field::getLock(IJS_Context* cc,
+bool Field::getLock(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError) {
   return false;
 }
 
-bool Field::insertItemAt(IJS_Context* cc,
+bool Field::insertItemAt(IJS_EventContext* cc,
                          const std::vector<CJS_Value>& params,
                          CJS_Value& vRet,
                          CFX_WideString& sError) {
   return true;
 }
 
-bool Field::isBoxChecked(IJS_Context* cc,
+bool Field::isBoxChecked(IJS_EventContext* cc,
                          const std::vector<CJS_Value>& params,
                          CJS_Value& vRet,
                          CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
 
   int nIndex = -1;
   if (params.size() >= 1)
@@ -3140,11 +3090,11 @@
   return true;
 }
 
-bool Field::isDefaultChecked(IJS_Context* cc,
+bool Field::isDefaultChecked(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
 
   int nIndex = -1;
   if (params.size() >= 1)
@@ -3165,14 +3115,14 @@
   return true;
 }
 
-bool Field::setAction(IJS_Context* cc,
+bool Field::setAction(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError) {
   return true;
 }
 
-bool Field::setFocus(IJS_Context* cc,
+bool Field::setFocus(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError) {
@@ -3217,63 +3167,65 @@
   return true;
 }
 
-bool Field::setItems(IJS_Context* cc,
+bool Field::setItems(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError) {
   return true;
 }
 
-bool Field::setLock(IJS_Context* cc,
+bool Field::setLock(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError) {
   return false;
 }
 
-bool Field::signatureGetModifications(IJS_Context* cc,
+bool Field::signatureGetModifications(IJS_EventContext* cc,
                                       const std::vector<CJS_Value>& params,
                                       CJS_Value& vRet,
                                       CFX_WideString& sError) {
   return false;
 }
 
-bool Field::signatureGetSeedValue(IJS_Context* cc,
+bool Field::signatureGetSeedValue(IJS_EventContext* cc,
                                   const std::vector<CJS_Value>& params,
                                   CJS_Value& vRet,
                                   CFX_WideString& sError) {
   return false;
 }
 
-bool Field::signatureInfo(IJS_Context* cc,
+bool Field::signatureInfo(IJS_EventContext* cc,
                           const std::vector<CJS_Value>& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
   return false;
 }
 
-bool Field::signatureSetSeedValue(IJS_Context* cc,
+bool Field::signatureSetSeedValue(IJS_EventContext* cc,
                                   const std::vector<CJS_Value>& params,
                                   CJS_Value& vRet,
                                   CFX_WideString& sError) {
   return false;
 }
 
-bool Field::signatureSign(IJS_Context* cc,
+bool Field::signatureSign(IJS_EventContext* cc,
                           const std::vector<CJS_Value>& params,
                           CJS_Value& vRet,
                           CFX_WideString& sError) {
   return false;
 }
 
-bool Field::signatureValidate(IJS_Context* cc,
+bool Field::signatureValidate(IJS_EventContext* cc,
                               const std::vector<CJS_Value>& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError) {
   return false;
 }
 
-bool Field::source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Field::source(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
   if (vp.IsGetting()) {
     vp << (CJS_Object*)nullptr;
   }
diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h
index f3948ff..9087f82 100644
--- a/fpdfsdk/javascript/Field.h
+++ b/fpdfsdk/javascript/Field.h
@@ -77,182 +77,238 @@
   explicit Field(CJS_Object* pJSObject);
   ~Field() override;
 
-  bool alignment(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool borderStyle(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool buttonAlignX(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool buttonAlignY(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool buttonFitBounds(IJS_Context* cc,
+  bool alignment(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool borderStyle(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError);
+  bool buttonAlignX(IJS_EventContext* cc,
+                    CJS_PropValue& vp,
+                    CFX_WideString& sError);
+  bool buttonAlignY(IJS_EventContext* cc,
+                    CJS_PropValue& vp,
+                    CFX_WideString& sError);
+  bool buttonFitBounds(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError);
-  bool buttonPosition(IJS_Context* cc,
+  bool buttonPosition(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError);
-  bool buttonScaleHow(IJS_Context* cc,
+  bool buttonScaleHow(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError);
-  bool buttonScaleWhen(IJS_Context* cc,
+  bool buttonScaleWhen(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError);
-  bool calcOrderIndex(IJS_Context* cc,
+  bool calcOrderIndex(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError);
-  bool charLimit(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool comb(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool commitOnSelChange(IJS_Context* cc,
+  bool charLimit(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool comb(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool commitOnSelChange(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError);
-  bool currentValueIndices(IJS_Context* cc,
+  bool currentValueIndices(IJS_EventContext* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError);
-  bool defaultStyle(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool defaultValue(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool doNotScroll(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool doNotSpellCheck(IJS_Context* cc,
+  bool defaultStyle(IJS_EventContext* cc,
+                    CJS_PropValue& vp,
+                    CFX_WideString& sError);
+  bool defaultValue(IJS_EventContext* cc,
+                    CJS_PropValue& vp,
+                    CFX_WideString& sError);
+  bool doNotScroll(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError);
+  bool doNotSpellCheck(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError);
-  bool delay(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool display(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool doc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool editable(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool exportValues(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool fileSelect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool fillColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool hidden(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool highlight(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool lineWidth(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool multiline(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool multipleSelection(IJS_Context* cc,
+  bool delay(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool display(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool doc(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool editable(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool exportValues(IJS_EventContext* cc,
+                    CJS_PropValue& vp,
+                    CFX_WideString& sError);
+  bool fileSelect(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError);
+  bool fillColor(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool hidden(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool highlight(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool lineWidth(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool multiline(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool multipleSelection(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError);
-  bool name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool numItems(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool page(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool password(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool print(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool radiosInUnison(IJS_Context* cc,
+  bool name(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool numItems(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool page(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool password(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool print(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool radiosInUnison(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError);
-  bool readonly(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool rect(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool required(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool richText(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool richValue(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool rotation(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool strokeColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool style(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool submitName(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool textColor(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool textFont(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool textSize(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool userName(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool valueAsString(IJS_Context* cc,
+  bool readonly(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool rect(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool required(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool richText(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool richValue(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool rotation(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool strokeColor(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError);
+  bool style(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool submitName(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError);
+  bool textColor(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool textFont(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool textSize(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool type(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool userName(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool value(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool valueAsString(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError);
-  bool source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool source(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
 
-  bool browseForFileToSubmit(IJS_Context* cc,
+  bool browseForFileToSubmit(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError);
-  bool buttonGetCaption(IJS_Context* cc,
+  bool buttonGetCaption(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError);
-  bool buttonGetIcon(IJS_Context* cc,
+  bool buttonGetIcon(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
-  bool buttonImportIcon(IJS_Context* cc,
+  bool buttonImportIcon(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError);
-  bool buttonSetCaption(IJS_Context* cc,
+  bool buttonSetCaption(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError);
-  bool buttonSetIcon(IJS_Context* cc,
+  bool buttonSetIcon(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
-  bool checkThisBox(IJS_Context* cc,
+  bool checkThisBox(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool clearItems(IJS_Context* cc,
+  bool clearItems(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError);
-  bool defaultIsChecked(IJS_Context* cc,
+  bool defaultIsChecked(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError);
-  bool deleteItemAt(IJS_Context* cc,
+  bool deleteItemAt(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool getArray(IJS_Context* cc,
+  bool getArray(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool getItemAt(IJS_Context* cc,
+  bool getItemAt(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
-  bool getLock(IJS_Context* cc,
+  bool getLock(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool insertItemAt(IJS_Context* cc,
+  bool insertItemAt(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool isBoxChecked(IJS_Context* cc,
+  bool isBoxChecked(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool isDefaultChecked(IJS_Context* cc,
+  bool isDefaultChecked(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError);
-  bool setAction(IJS_Context* cc,
+  bool setAction(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
-  bool setFocus(IJS_Context* cc,
+  bool setFocus(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool setItems(IJS_Context* cc,
+  bool setItems(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool setLock(IJS_Context* cc,
+  bool setLock(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool signatureGetModifications(IJS_Context* cc,
+  bool signatureGetModifications(IJS_EventContext* cc,
                                  const std::vector<CJS_Value>& params,
                                  CJS_Value& vRet,
                                  CFX_WideString& sError);
-  bool signatureGetSeedValue(IJS_Context* cc,
+  bool signatureGetSeedValue(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError);
-  bool signatureInfo(IJS_Context* cc,
+  bool signatureInfo(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
-  bool signatureSetSeedValue(IJS_Context* cc,
+  bool signatureSetSeedValue(IJS_EventContext* cc,
                              const std::vector<CJS_Value>& params,
                              CJS_Value& vRet,
                              CFX_WideString& sError);
-  bool signatureSign(IJS_Context* cc,
+  bool signatureSign(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
-  bool signatureValidate(IJS_Context* cc,
+  bool signatureValidate(IJS_EventContext* cc,
                          const std::vector<CJS_Value>& params,
                          CJS_Value& vRet,
                          CFX_WideString& sError);
diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp
index 94841ef..cfce52f 100644
--- a/fpdfsdk/javascript/Icon.cpp
+++ b/fpdfsdk/javascript/Icon.cpp
@@ -44,7 +44,9 @@
   return m_swIconName;
 }
 
-bool Icon::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool Icon::name(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
diff --git a/fpdfsdk/javascript/Icon.h b/fpdfsdk/javascript/Icon.h
index 98a479c..76bf8e4 100644
--- a/fpdfsdk/javascript/Icon.h
+++ b/fpdfsdk/javascript/Icon.h
@@ -16,7 +16,7 @@
   explicit Icon(CJS_Object* pJSObject);
   ~Icon() override;
 
-  bool name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool name(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
   void SetStream(CPDF_Stream* pIconStream);
   CPDF_Stream* GetStream();
   void SetIconName(CFX_WideString name);
diff --git a/fpdfsdk/javascript/JS_Define.h b/fpdfsdk/javascript/JS_Define.h
index feab4d1..957f683 100644
--- a/fpdfsdk/javascript/JS_Define.h
+++ b/fpdfsdk/javascript/JS_Define.h
@@ -70,7 +70,8 @@
   }                            \
   ;  // NOLINT
 
-template <class C, bool (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)>
+template <class C,
+          bool (C::*M)(IJS_EventContext*, CJS_PropValue&, CFX_WideString&)>
 void JSPropGetter(const char* prop_name_string,
                   const char* class_name_string,
                   v8::Local<v8::String> property,
@@ -85,7 +86,7 @@
   CFX_WideString sError;
   CJS_PropValue value(pRuntime);
   value.StartGetting();
-  if (!(pObj->*M)(pRuntime->GetCurrentContext(), value, sError)) {
+  if (!(pObj->*M)(pRuntime->GetCurrentEventContext(), value, sError)) {
     pRuntime->Error(
         JSFormatErrorString(class_name_string, prop_name_string, sError));
     return;
@@ -93,7 +94,8 @@
   info.GetReturnValue().Set(value.GetJSValue()->ToV8Value(pRuntime));
 }
 
-template <class C, bool (C::*M)(IJS_Context*, CJS_PropValue&, CFX_WideString&)>
+template <class C,
+          bool (C::*M)(IJS_EventContext*, CJS_PropValue&, CFX_WideString&)>
 void JSPropSetter(const char* prop_name_string,
                   const char* class_name_string,
                   v8::Local<v8::String> property,
@@ -109,7 +111,7 @@
   CFX_WideString sError;
   CJS_PropValue propValue(pRuntime, CJS_Value(pRuntime, value));
   propValue.StartSetting();
-  if (!(pObj->*M)(pRuntime->GetCurrentContext(), propValue, sError)) {
+  if (!(pObj->*M)(pRuntime->GetCurrentEventContext(), propValue, sError)) {
     pRuntime->Error(
         JSFormatErrorString(class_name_string, prop_name_string, sError));
   }
@@ -130,7 +132,7 @@
   }
 
 template <class C,
-          bool (C::*M)(IJS_Context*,
+          bool (C::*M)(IJS_EventContext*,
                        const std::vector<CJS_Value>&,
                        CJS_Value&,
                        CFX_WideString&)>
@@ -150,7 +152,7 @@
   C* pObj = reinterpret_cast<C*>(pJSObj->GetEmbedObject());
   CFX_WideString sError;
   CJS_Value valueRes(pRuntime);
-  if (!(pObj->*M)(pRuntime->GetCurrentContext(), parameters, valueRes,
+  if (!(pObj->*M)(pRuntime->GetCurrentEventContext(), parameters, valueRes,
                   sError)) {
     pRuntime->Error(
         JSFormatErrorString(class_name_string, method_name_string, sError));
@@ -375,8 +377,8 @@
   CFX_WideString sError;
   CJS_PropValue value(pRuntime);
   value.StartGetting();
-  if (!pObj->DoProperty(pRuntime->GetCurrentContext(), propname.c_str(), value,
-                        sError)) {
+  if (!pObj->DoProperty(pRuntime->GetCurrentEventContext(), propname.c_str(),
+                        value, sError)) {
     pRuntime->Error(JSFormatErrorString(class_name, "GetProperty", sError));
     return;
   }
@@ -401,7 +403,7 @@
   CFX_WideString sError;
   CJS_PropValue PropValue(pRuntime, CJS_Value(pRuntime, value));
   PropValue.StartSetting();
-  if (!pObj->DoProperty(pRuntime->GetCurrentContext(), propname.c_str(),
+  if (!pObj->DoProperty(pRuntime->GetCurrentEventContext(), propname.c_str(),
                         PropValue, sError)) {
     pRuntime->Error(JSFormatErrorString(class_name, "PutProperty", sError));
   }
@@ -422,7 +424,7 @@
   CFX_WideString propname = CFX_WideString::FromUTF8(
       CFX_ByteStringC(*utf8_value, utf8_value.length()));
   CFX_WideString sError;
-  if (!pObj->DelProperty(pRuntime->GetCurrentContext(), propname.c_str(),
+  if (!pObj->DelProperty(pRuntime->GetCurrentEventContext(), propname.c_str(),
                          sError)) {
     CFX_ByteString cbName;
     cbName.Format("%s.%s", class_name, "DelProperty");
@@ -430,7 +432,7 @@
   }
 }
 
-template <bool (*F)(IJS_Context*,
+template <bool (*F)(IJS_EventContext*,
                     const std::vector<CJS_Value>&,
                     CJS_Value&,
                     CFX_WideString&)>
@@ -446,7 +448,7 @@
   }
   CJS_Value valueRes(pRuntime);
   CFX_WideString sError;
-  if (!(*F)(pRuntime->GetCurrentContext(), parameters, valueRes, sError)) {
+  if (!(*F)(pRuntime->GetCurrentEventContext(), parameters, valueRes, sError)) {
     pRuntime->Error(JSFormatErrorString(func_name_string, nullptr, sError));
     return;
   }
diff --git a/fpdfsdk/javascript/JS_EventHandler.cpp b/fpdfsdk/javascript/JS_EventHandler.cpp
index 5715cb9..bf40623 100644
--- a/fpdfsdk/javascript/JS_EventHandler.cpp
+++ b/fpdfsdk/javascript/JS_EventHandler.cpp
@@ -11,11 +11,11 @@
 #include "fpdfsdk/javascript/JS_Define.h"
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 #include "fpdfsdk/javascript/cjs_runtime.h"
 
-CJS_EventHandler::CJS_EventHandler(CJS_Context* pContext)
-    : m_pJSContext(pContext),
+CJS_EventHandler::CJS_EventHandler(CJS_EventContext* pContext)
+    : m_pJSEventContext(pContext),
       m_eEventType(JET_UNKNOWN),
       m_bValid(false),
       m_pWideStrChange(nullptr),
@@ -590,7 +590,7 @@
 }
 
 Field* CJS_EventHandler::Source() {
-  CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
   v8::Local<v8::Object> pDocObj =
       pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
   ASSERT(!pDocObj.IsEmpty());
@@ -604,7 +604,7 @@
   Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
   pDocument->SetFormFillEnv(m_pTargetFormFillEnv
                                 ? m_pTargetFormFillEnv
-                                : m_pJSContext->GetFormFillEnv());
+                                : m_pJSEventContext->GetFormFillEnv());
 
   CJS_Field* pJSField =
       static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
@@ -614,7 +614,7 @@
 }
 
 Field* CJS_EventHandler::Target_Field() {
-  CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
+  CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
   v8::Local<v8::Object> pDocObj =
       pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
   ASSERT(!pDocObj.IsEmpty());
@@ -628,7 +628,7 @@
   Document* pDocument = (Document*)pJSDocument->GetEmbedObject();
   pDocument->SetFormFillEnv(m_pTargetFormFillEnv
                                 ? m_pTargetFormFillEnv
-                                : m_pJSContext->GetFormFillEnv());
+                                : m_pJSEventContext->GetFormFillEnv());
 
   CJS_Field* pJSField =
       static_cast<CJS_Field*>(pRuntime->GetObjectPrivate(pFieldObj));
diff --git a/fpdfsdk/javascript/JS_EventHandler.h b/fpdfsdk/javascript/JS_EventHandler.h
index 8cfcfa7..ff8ff9e 100644
--- a/fpdfsdk/javascript/JS_EventHandler.h
+++ b/fpdfsdk/javascript/JS_EventHandler.h
@@ -10,7 +10,7 @@
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/fx_system.h"
 
-class CJS_Context;
+class CJS_EventContext;
 class CPDFSDK_Annot;
 class CPDFSDK_FormFillEnvironment;
 class CPDF_Bookmark;
@@ -60,7 +60,7 @@
 
 class CJS_EventHandler {
  public:
-  explicit CJS_EventHandler(CJS_Context* pContext);
+  explicit CJS_EventHandler(CJS_EventContext* pContext);
   virtual ~CJS_EventHandler();
 
   void OnApp_Init();
@@ -165,7 +165,7 @@
   JS_EVENT_T EventType() { return m_eEventType; }
 
  public:
-  CJS_Context* m_pJSContext;
+  CJS_EventContext* const m_pJSEventContext;  // Not Owned.
   JS_EVENT_T m_eEventType;
   bool m_bValid;
 
diff --git a/fpdfsdk/javascript/JS_Object.cpp b/fpdfsdk/javascript/JS_Object.cpp
index 9ef6cdd..cd86889 100644
--- a/fpdfsdk/javascript/JS_Object.cpp
+++ b/fpdfsdk/javascript/JS_Object.cpp
@@ -7,7 +7,7 @@
 #include "fpdfsdk/javascript/JS_Object.h"
 
 #include "fpdfsdk/javascript/JS_Define.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 
 CJS_EmbedObj::CJS_EmbedObj(CJS_Object* pJSObject) : m_pJSObject(pJSObject) {}
 
diff --git a/fpdfsdk/javascript/JS_Object.h b/fpdfsdk/javascript/JS_Object.h
index 658a5e2..2e5c75c 100644
--- a/fpdfsdk/javascript/JS_Object.h
+++ b/fpdfsdk/javascript/JS_Object.h
@@ -14,7 +14,7 @@
 #include "fpdfsdk/javascript/cjs_runtime.h"
 #include "fxjs/fxjs_v8.h"
 
-class CJS_Context;
+class CJS_EventContext;
 class CJS_Object;
 class CPDFSDK_FormFillEnvironment;
 
diff --git a/fpdfsdk/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/javascript/JS_Runtime_Stub.cpp
index 96148d8..12edc1b 100644
--- a/fpdfsdk/javascript/JS_Runtime_Stub.cpp
+++ b/fpdfsdk/javascript/JS_Runtime_Stub.cpp
@@ -6,16 +6,16 @@
 
 #include <memory>
 
-#include "fpdfsdk/javascript/ijs_context.h"
+#include "fpdfsdk/javascript/ijs_event_context.h"
 #include "fpdfsdk/javascript/ijs_runtime.h"
 #include "third_party/base/ptr_util.h"
 
-class CJS_ContextStub final : public IJS_Context {
+class CJS_EventContextStub final : public IJS_EventContext {
  public:
-  CJS_ContextStub() {}
-  ~CJS_ContextStub() override {}
+  CJS_EventContextStub() {}
+  ~CJS_EventContextStub() override {}
 
-  // IJS_Context:
+  // IJS_EventContext:
   bool RunScript(const CFX_WideString& script, CFX_WideString* info) override {
     return false;
   }
@@ -124,14 +124,16 @@
       : m_pFormFillEnv(pFormFillEnv) {}
   ~CJS_RuntimeStub() override {}
 
-  IJS_Context* NewContext() override {
+  IJS_EventContext* NewEventContext() override {
     if (!m_pContext)
-      m_pContext = pdfium::MakeUnique<CJS_ContextStub>();
-    return GetCurrentContext();
+      m_pContext = pdfium::MakeUnique<CJS_EventContextStub>();
+    return GetCurrentEventContext();
   }
 
-  IJS_Context* GetCurrentContext() override { return m_pContext.get(); }
-  void ReleaseContext(IJS_Context* pContext) override {}
+  IJS_EventContext* GetCurrentEventContext() override {
+    return m_pContext.get();
+  }
+  void ReleaseEventContext(IJS_EventContext* pContext) override {}
 
   CPDFSDK_FormFillEnvironment* GetFormFillEnv() const override {
     return m_pFormFillEnv;
@@ -154,7 +156,7 @@
 
  protected:
   CPDFSDK_FormFillEnvironment* m_pFormFillEnv;
-  std::unique_ptr<CJS_ContextStub> m_pContext;
+  std::unique_ptr<CJS_EventContextStub> m_pContext;
 };
 
 // static
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index c0ea84c..32484d4 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -22,7 +22,7 @@
 #include "fpdfsdk/javascript/JS_EventHandler.h"
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 #include "fpdfsdk/javascript/cjs_runtime.h"
 #include "fpdfsdk/javascript/color.h"
 #include "fpdfsdk/javascript/resource.h"
@@ -82,7 +82,7 @@
   return result;
 }
 
-void AlertIfPossible(CJS_Context* pContext, const FX_WCHAR* swMsg) {
+void AlertIfPossible(CJS_EventContext* pContext, const FX_WCHAR* swMsg) {
   CPDFSDK_FormFillEnvironment* pFormFillEnv = pContext->GetFormFillEnv();
   if (pFormFillEnv)
     pFormFillEnv->JS_appAlert(swMsg, nullptr, 0, 3);
@@ -750,7 +750,7 @@
 
 // function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency,
 // bCurrencyPrepend)
-bool CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
+bool CJS_PublicMethods::AFNumber_Format(IJS_EventContext* cc,
                                         const std::vector<CJS_Value>& params,
                                         CJS_Value& vRet,
                                         CFX_WideString& sError) {
@@ -760,7 +760,7 @@
     return false;
   }
 
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
   CJS_Runtime* pRuntime = pContext->GetJSRuntime();
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
   if (!pEvent->m_pValue)
@@ -898,11 +898,11 @@
 
 // function AFNumber_Keystroke(nDec, sepStyle, negStyle, currStyle, strCurrency,
 // bCurrencyPrepend)
-bool CJS_PublicMethods::AFNumber_Keystroke(IJS_Context* cc,
+bool CJS_PublicMethods::AFNumber_Keystroke(IJS_EventContext* cc,
                                            const std::vector<CJS_Value>& params,
                                            CJS_Value& vRet,
                                            CFX_WideString& sError) {
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
 
   if (params.size() < 2)
@@ -945,7 +945,7 @@
     }
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int iSepStyle = params[1].ToInt(pRuntime);
   if (iSepStyle < 0 || iSepStyle > 3)
     iSepStyle = 0;
@@ -999,13 +999,13 @@
 }
 
 // function AFPercent_Format(nDec, sepStyle)
-bool CJS_PublicMethods::AFPercent_Format(IJS_Context* cc,
+bool CJS_PublicMethods::AFPercent_Format(IJS_EventContext* cc,
                                          const std::vector<CJS_Value>& params,
                                          CJS_Value& vRet,
                                          CFX_WideString& sError) {
 #if _FX_OS_ != _FX_ANDROID_
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
 
   if (params.size() != 2) {
@@ -1092,7 +1092,7 @@
 }
 // AFPercent_Keystroke(nDec, sepStyle)
 bool CJS_PublicMethods::AFPercent_Keystroke(
-    IJS_Context* cc,
+    IJS_EventContext* cc,
     const std::vector<CJS_Value>& params,
     CJS_Value& vRet,
     CFX_WideString& sError) {
@@ -1100,12 +1100,12 @@
 }
 
 // function AFDate_FormatEx(cFormat)
-bool CJS_PublicMethods::AFDate_FormatEx(IJS_Context* cc,
+bool CJS_PublicMethods::AFDate_FormatEx(IJS_EventContext* cc,
                                         const std::vector<CJS_Value>& params,
                                         CJS_Value& vRet,
                                         CFX_WideString& sError) {
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
 
   if (params.size() != 1) {
@@ -1200,12 +1200,12 @@
 }
 
 // AFDate_KeystrokeEx(cFormat)
-bool CJS_PublicMethods::AFDate_KeystrokeEx(IJS_Context* cc,
+bool CJS_PublicMethods::AFDate_KeystrokeEx(IJS_EventContext* cc,
                                            const std::vector<CJS_Value>& params,
                                            CJS_Value& vRet,
                                            CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_EventContext* pContext = (CJS_EventContext*)cc;
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
 
   if (params.size() != 1) {
@@ -1235,7 +1235,7 @@
   return true;
 }
 
-bool CJS_PublicMethods::AFDate_Format(IJS_Context* cc,
+bool CJS_PublicMethods::AFDate_Format(IJS_EventContext* cc,
                                       const std::vector<CJS_Value>& params,
                                       CJS_Value& vRet,
                                       CFX_WideString& sError) {
@@ -1244,7 +1244,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int iIndex = params[0].ToInt(pRuntime);
   const FX_WCHAR* cFormats[] = {L"m/d",
                                 L"m/d/yy",
@@ -1266,12 +1266,12 @@
 
   std::vector<CJS_Value> newParams;
   newParams.push_back(
-      CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
+      CJS_Value(CJS_Runtime::FromEventContext(cc), cFormats[iIndex]));
   return AFDate_FormatEx(cc, newParams, vRet, sError);
 }
 
 // AFDate_KeystrokeEx(cFormat)
-bool CJS_PublicMethods::AFDate_Keystroke(IJS_Context* cc,
+bool CJS_PublicMethods::AFDate_Keystroke(IJS_EventContext* cc,
                                          const std::vector<CJS_Value>& params,
                                          CJS_Value& vRet,
                                          CFX_WideString& sError) {
@@ -1280,7 +1280,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int iIndex = params[0].ToInt(pRuntime);
   const FX_WCHAR* cFormats[] = {L"m/d",
                                 L"m/d/yy",
@@ -1302,12 +1302,12 @@
 
   std::vector<CJS_Value> newParams;
   newParams.push_back(
-      CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
+      CJS_Value(CJS_Runtime::FromEventContext(cc), cFormats[iIndex]));
   return AFDate_KeystrokeEx(cc, newParams, vRet, sError);
 }
 
 // function AFTime_Format(ptf)
-bool CJS_PublicMethods::AFTime_Format(IJS_Context* cc,
+bool CJS_PublicMethods::AFTime_Format(IJS_EventContext* cc,
                                       const std::vector<CJS_Value>& params,
                                       CJS_Value& vRet,
                                       CFX_WideString& sError) {
@@ -1316,7 +1316,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int iIndex = params[0].ToInt(pRuntime);
   const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
                                 L"h:MM:ss tt"};
@@ -1326,11 +1326,11 @@
 
   std::vector<CJS_Value> newParams;
   newParams.push_back(
-      CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
+      CJS_Value(CJS_Runtime::FromEventContext(cc), cFormats[iIndex]));
   return AFDate_FormatEx(cc, newParams, vRet, sError);
 }
 
-bool CJS_PublicMethods::AFTime_Keystroke(IJS_Context* cc,
+bool CJS_PublicMethods::AFTime_Keystroke(IJS_EventContext* cc,
                                          const std::vector<CJS_Value>& params,
                                          CJS_Value& vRet,
                                          CFX_WideString& sError) {
@@ -1339,7 +1339,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int iIndex = params[0].ToInt(pRuntime);
   const FX_WCHAR* cFormats[] = {L"HH:MM", L"h:MM tt", L"HH:MM:ss",
                                 L"h:MM:ss tt"};
@@ -1349,18 +1349,18 @@
 
   std::vector<CJS_Value> newParams;
   newParams.push_back(
-      CJS_Value(CJS_Runtime::FromContext(cc), cFormats[iIndex]));
+      CJS_Value(CJS_Runtime::FromEventContext(cc), cFormats[iIndex]));
   return AFDate_KeystrokeEx(cc, newParams, vRet, sError);
 }
 
-bool CJS_PublicMethods::AFTime_FormatEx(IJS_Context* cc,
+bool CJS_PublicMethods::AFTime_FormatEx(IJS_EventContext* cc,
                                         const std::vector<CJS_Value>& params,
                                         CJS_Value& vRet,
                                         CFX_WideString& sError) {
   return AFDate_FormatEx(cc, params, vRet, sError);
 }
 
-bool CJS_PublicMethods::AFTime_KeystrokeEx(IJS_Context* cc,
+bool CJS_PublicMethods::AFTime_KeystrokeEx(IJS_EventContext* cc,
                                            const std::vector<CJS_Value>& params,
                                            CJS_Value& vRet,
                                            CFX_WideString& sError) {
@@ -1368,7 +1368,7 @@
 }
 
 // function AFSpecial_Format(psf)
-bool CJS_PublicMethods::AFSpecial_Format(IJS_Context* cc,
+bool CJS_PublicMethods::AFSpecial_Format(IJS_EventContext* cc,
                                          const std::vector<CJS_Value>& params,
                                          CJS_Value& vRet,
                                          CFX_WideString& sError) {
@@ -1377,12 +1377,12 @@
     return false;
   }
 
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
   if (!pEvent->m_pValue)
     return false;
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString wsSource = pEvent->Value();
   CFX_WideString wsFormat;
   switch (params[0].ToInt(pRuntime)) {
@@ -1409,12 +1409,12 @@
 
 // function AFSpecial_KeystrokeEx(mask)
 bool CJS_PublicMethods::AFSpecial_KeystrokeEx(
-    IJS_Context* cc,
+    IJS_EventContext* cc,
     const std::vector<CJS_Value>& params,
     CJS_Value& vRet,
     CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_EventContext* pContext = (CJS_EventContext*)cc;
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
 
   if (params.size() < 1) {
@@ -1494,7 +1494,7 @@
 
 // function AFSpecial_Keystroke(psf)
 bool CJS_PublicMethods::AFSpecial_Keystroke(
-    IJS_Context* cc,
+    IJS_EventContext* cc,
     const std::vector<CJS_Value>& params,
     CJS_Value& vRet,
     CFX_WideString& sError) {
@@ -1503,13 +1503,13 @@
     return false;
   }
 
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
   if (!pEvent->m_pValue)
     return false;
 
   const char* cFormat = "";
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   switch (params[0].ToInt(pRuntime)) {
     case 0:
       cFormat = "99999";
@@ -1529,11 +1529,11 @@
   }
 
   std::vector<CJS_Value> params2;
-  params2.push_back(CJS_Value(CJS_Runtime::FromContext(cc), cFormat));
+  params2.push_back(CJS_Value(CJS_Runtime::FromEventContext(cc), cFormat));
   return AFSpecial_KeystrokeEx(cc, params2, vRet, sError);
 }
 
-bool CJS_PublicMethods::AFMergeChange(IJS_Context* cc,
+bool CJS_PublicMethods::AFMergeChange(IJS_EventContext* cc,
                                       const std::vector<CJS_Value>& params,
                                       CJS_Value& vRet,
                                       CFX_WideString& sError) {
@@ -1542,8 +1542,8 @@
     return false;
   }
 
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_EventHandler* pEventHandler = pContext->GetEventHandler();
 
   CFX_WideString swValue;
@@ -1574,7 +1574,7 @@
   return true;
 }
 
-bool CJS_PublicMethods::AFParseDateEx(IJS_Context* cc,
+bool CJS_PublicMethods::AFParseDateEx(IJS_EventContext* cc,
                                       const std::vector<CJS_Value>& params,
                                       CJS_Value& vRet,
                                       CFX_WideString& sError) {
@@ -1583,17 +1583,16 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
+  CJS_Runtime* pRuntime = pContext->GetJSRuntime();
   CFX_WideString sValue = params[0].ToCFXWideString(pRuntime);
   CFX_WideString sFormat = params[1].ToCFXWideString(pRuntime);
-
   double dDate = MakeRegularDate(sValue, sFormat, nullptr);
-
   if (JS_PortIsNan(dDate)) {
     CFX_WideString swMsg;
     swMsg.Format(JSGetStringFromID(IDS_STRING_JSPARSEDATE).c_str(),
                  sFormat.c_str());
-    AlertIfPossible((CJS_Context*)cc, swMsg.c_str());
+    AlertIfPossible(pContext, swMsg.c_str());
     return false;
   }
 
@@ -1601,7 +1600,7 @@
   return true;
 }
 
-bool CJS_PublicMethods::AFSimple(IJS_Context* cc,
+bool CJS_PublicMethods::AFSimple(IJS_EventContext* cc,
                                  const std::vector<CJS_Value>& params,
                                  CJS_Value& vRet,
                                  CFX_WideString& sError) {
@@ -1610,7 +1609,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   vRet = CJS_Value(pRuntime, static_cast<double>(AF_Simple(
                                  params[0].ToCFXWideString(pRuntime).c_str(),
                                  params[1].ToDouble(pRuntime),
@@ -1619,7 +1618,7 @@
   return true;
 }
 
-bool CJS_PublicMethods::AFMakeNumber(IJS_Context* cc,
+bool CJS_PublicMethods::AFMakeNumber(IJS_EventContext* cc,
                                      const std::vector<CJS_Value>& params,
                                      CJS_Value& vRet,
                                      CFX_WideString& sError) {
@@ -1628,7 +1627,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString ws = params[0].ToCFXWideString(pRuntime);
   ws.Replace(L",", L".");
   vRet = CJS_Value(pRuntime, ws.c_str());
@@ -1638,7 +1637,7 @@
   return true;
 }
 
-bool CJS_PublicMethods::AFSimple_Calculate(IJS_Context* cc,
+bool CJS_PublicMethods::AFSimple_Calculate(IJS_EventContext* cc,
                                            const std::vector<CJS_Value>& params,
                                            CJS_Value& vRet,
                                            CFX_WideString& sError) {
@@ -1653,8 +1652,8 @@
     return false;
   }
 
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CPDFSDK_InterForm* pReaderInterForm =
       pContext->GetFormFillEnv()->GetInterForm();
   CPDF_InterForm* pInterForm = pReaderInterForm->GetInterForm();
@@ -1737,7 +1736,7 @@
 /* This function validates the current event to ensure that its value is
 ** within the specified range. */
 
-bool CJS_PublicMethods::AFRange_Validate(IJS_Context* cc,
+bool CJS_PublicMethods::AFRange_Validate(IJS_EventContext* cc,
                                          const std::vector<CJS_Value>& params,
                                          CJS_Value& vRet,
                                          CFX_WideString& sError) {
@@ -1745,8 +1744,8 @@
     sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);
     return false;
   }
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
   if (!pEvent->m_pValue)
     return false;
@@ -1784,7 +1783,7 @@
   return true;
 }
 
-bool CJS_PublicMethods::AFExtractNums(IJS_Context* cc,
+bool CJS_PublicMethods::AFExtractNums(IJS_EventContext* cc,
                                       const std::vector<CJS_Value>& params,
                                       CJS_Value& vRet,
                                       CFX_WideString& sError) {
@@ -1793,7 +1792,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString str = params[0].ToCFXWideString(pRuntime);
   CFX_WideString sPart;
   CJS_Array nums;
diff --git a/fpdfsdk/javascript/PublicMethods.h b/fpdfsdk/javascript/PublicMethods.h
index 0820c40..bb01ea3 100644
--- a/fpdfsdk/javascript/PublicMethods.h
+++ b/fpdfsdk/javascript/PublicMethods.h
@@ -18,91 +18,91 @@
       : CJS_Object(pObject) {}
   ~CJS_PublicMethods() override {}
 
-  static bool AFNumber_Format(IJS_Context* cc,
+  static bool AFNumber_Format(IJS_EventContext* cc,
                               const std::vector<CJS_Value>& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError);
-  static bool AFNumber_Keystroke(IJS_Context* cc,
+  static bool AFNumber_Keystroke(IJS_EventContext* cc,
                                  const std::vector<CJS_Value>& params,
                                  CJS_Value& vRet,
                                  CFX_WideString& sError);
-  static bool AFPercent_Format(IJS_Context* cc,
+  static bool AFPercent_Format(IJS_EventContext* cc,
                                const std::vector<CJS_Value>& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError);
-  static bool AFPercent_Keystroke(IJS_Context* cc,
+  static bool AFPercent_Keystroke(IJS_EventContext* cc,
                                   const std::vector<CJS_Value>& params,
                                   CJS_Value& vRet,
                                   CFX_WideString& sError);
-  static bool AFDate_FormatEx(IJS_Context* cc,
+  static bool AFDate_FormatEx(IJS_EventContext* cc,
                               const std::vector<CJS_Value>& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError);
-  static bool AFDate_KeystrokeEx(IJS_Context* cc,
+  static bool AFDate_KeystrokeEx(IJS_EventContext* cc,
                                  const std::vector<CJS_Value>& params,
                                  CJS_Value& vRet,
                                  CFX_WideString& sError);
-  static bool AFDate_Format(IJS_Context* cc,
+  static bool AFDate_Format(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError);
-  static bool AFDate_Keystroke(IJS_Context* cc,
+  static bool AFDate_Keystroke(IJS_EventContext* cc,
                                const std::vector<CJS_Value>& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError);
-  static bool AFTime_FormatEx(IJS_Context* cc,
+  static bool AFTime_FormatEx(IJS_EventContext* cc,
                               const std::vector<CJS_Value>& params,
                               CJS_Value& vRet,
                               CFX_WideString& sError);  //
-  static bool AFTime_KeystrokeEx(IJS_Context* cc,
+  static bool AFTime_KeystrokeEx(IJS_EventContext* cc,
                                  const std::vector<CJS_Value>& params,
                                  CJS_Value& vRet,
                                  CFX_WideString& sError);
-  static bool AFTime_Format(IJS_Context* cc,
+  static bool AFTime_Format(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError);
-  static bool AFTime_Keystroke(IJS_Context* cc,
+  static bool AFTime_Keystroke(IJS_EventContext* cc,
                                const std::vector<CJS_Value>& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError);
-  static bool AFSpecial_Format(IJS_Context* cc,
+  static bool AFSpecial_Format(IJS_EventContext* cc,
                                const std::vector<CJS_Value>& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError);
-  static bool AFSpecial_Keystroke(IJS_Context* cc,
+  static bool AFSpecial_Keystroke(IJS_EventContext* cc,
                                   const std::vector<CJS_Value>& params,
                                   CJS_Value& vRet,
                                   CFX_WideString& sError);
-  static bool AFSpecial_KeystrokeEx(IJS_Context* cc,
+  static bool AFSpecial_KeystrokeEx(IJS_EventContext* cc,
                                     const std::vector<CJS_Value>& params,
                                     CJS_Value& vRet,
                                     CFX_WideString& sError);  //
-  static bool AFSimple(IJS_Context* cc,
+  static bool AFSimple(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError);
-  static bool AFMakeNumber(IJS_Context* cc,
+  static bool AFMakeNumber(IJS_EventContext* cc,
                            const std::vector<CJS_Value>& params,
                            CJS_Value& vRet,
                            CFX_WideString& sError);
-  static bool AFSimple_Calculate(IJS_Context* cc,
+  static bool AFSimple_Calculate(IJS_EventContext* cc,
                                  const std::vector<CJS_Value>& params,
                                  CJS_Value& vRet,
                                  CFX_WideString& sError);
-  static bool AFRange_Validate(IJS_Context* cc,
+  static bool AFRange_Validate(IJS_EventContext* cc,
                                const std::vector<CJS_Value>& params,
                                CJS_Value& vRet,
                                CFX_WideString& sError);
-  static bool AFMergeChange(IJS_Context* cc,
+  static bool AFMergeChange(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError);
-  static bool AFParseDateEx(IJS_Context* cc,
+  static bool AFParseDateEx(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError);
-  static bool AFExtractNums(IJS_Context* cc,
+  static bool AFExtractNums(IJS_EventContext* cc,
                             const std::vector<CJS_Value>& params,
                             CJS_Value& vRet,
                             CFX_WideString& sError);
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 6562d1b..6de4d20 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -17,7 +17,7 @@
 #include "fpdfsdk/javascript/JS_EventHandler.h"
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 #include "fpdfsdk/javascript/cjs_runtime.h"
 #include "fpdfsdk/javascript/resource.h"
 #include "third_party/base/stl_util.h"
@@ -211,13 +211,13 @@
 app::~app() {
 }
 
-bool app::activeDocs(IJS_Context* cc,
+bool app::activeDocs(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
   CJS_Runtime* pRuntime = pContext->GetJSRuntime();
   CJS_Document* pJSDocument = nullptr;
   v8::Local<v8::Object> pObj = pRuntime->GetThisObj();
@@ -236,7 +236,7 @@
   return true;
 }
 
-bool app::calculate(IJS_Context* cc,
+bool app::calculate(IJS_EventContext* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -244,7 +244,7 @@
     vp >> bVP;
     m_bCalculate = (bool)bVP;
 
-    CJS_Context* pContext = (CJS_Context*)cc;
+    CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
     pContext->GetFormFillEnv()->GetInterForm()->EnableCalculate(
         (bool)m_bCalculate);
   } else {
@@ -253,7 +253,7 @@
   return true;
 }
 
-bool app::formsVersion(IJS_Context* cc,
+bool app::formsVersion(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   if (vp.IsGetting()) {
@@ -264,7 +264,7 @@
   return false;
 }
 
-bool app::viewerType(IJS_Context* cc,
+bool app::viewerType(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (vp.IsGetting()) {
@@ -275,7 +275,7 @@
   return false;
 }
 
-bool app::viewerVariation(IJS_Context* cc,
+bool app::viewerVariation(IJS_EventContext* cc,
                           CJS_PropValue& vp,
                           CFX_WideString& sError) {
   if (vp.IsGetting()) {
@@ -286,13 +286,13 @@
   return false;
 }
 
-bool app::viewerVersion(IJS_Context* cc,
+bool app::viewerVersion(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 #ifdef PDF_ENABLE_XFA
-  CJS_Context* pJSContext = static_cast<CJS_Context*>(cc);
+  CJS_EventContext* pJSContext = static_cast<CJS_EventContext*>(cc);
   CPDFXFA_Context* pXFAContext = pJSContext->GetFormFillEnv()->GetXFAContext();
   if (pXFAContext->GetDocType() == 1 || pXFAContext->GetDocType() == 2) {
     vp << JS_NUM_VIEWERVERSION_XFA;
@@ -303,12 +303,14 @@
   return true;
 }
 
-bool app::platform(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool app::platform(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 #ifdef PDF_ENABLE_XFA
   CPDFSDK_FormFillEnvironment* pFormFillEnv =
-      static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetFormFillEnv();
+      CJS_Runtime::FromEventContext(cc)->GetFormFillEnv();
   if (!pFormFillEnv)
     return false;
   CFX_WideString platfrom = pFormFillEnv->GetPlatform();
@@ -321,12 +323,14 @@
   return true;
 }
 
-bool app::language(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool app::language(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 #ifdef PDF_ENABLE_XFA
   CPDFSDK_FormFillEnvironment* pFormFillEnv =
-      static_cast<CJS_Context*>(cc)->GetJSRuntime()->GetFormFillEnv();
+      CJS_Runtime::FromEventContext(cc)->GetFormFillEnv();
   if (!pFormFillEnv)
     return false;
   CFX_WideString language = pFormFillEnv->GetLanguage();
@@ -343,7 +347,7 @@
 // comment: need reader support
 // note:
 // CFDF_Document * CPDFSDK_FormFillEnvironment::NewFDF();
-bool app::newFDF(IJS_Context* cc,
+bool app::newFDF(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError) {
@@ -356,18 +360,18 @@
 // CFDF_Document * CPDFSDK_FormFillEnvironment::OpenFDF(string strPath,bool
 // bUserConv);
 
-bool app::openFDF(IJS_Context* cc,
+bool app::openFDF(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError) {
   return true;
 }
 
-bool app::alert(IJS_Context* cc,
+bool app::alert(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   std::vector<CJS_Value> newParams = JS_ExpandKeywordParams(
       pRuntime, params, 4, L"cMsg", L"nIcon", L"nType", L"cTitle");
 
@@ -425,12 +429,12 @@
   return true;
 }
 
-bool app::beep(IJS_Context* cc,
+bool app::beep(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError) {
   if (params.size() == 1) {
-    CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+    CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
     pRuntime->GetFormFillEnv()->JS_appBeep(params[0].ToInt(pRuntime));
     return true;
   }
@@ -439,25 +443,25 @@
   return false;
 }
 
-bool app::findComponent(IJS_Context* cc,
+bool app::findComponent(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
   return true;
 }
 
-bool app::popUpMenuEx(IJS_Context* cc,
+bool app::popUpMenuEx(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError) {
   return false;
 }
 
-bool app::fs(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool app::fs(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError) {
   return false;
 }
 
-bool app::setInterval(IJS_Context* cc,
+bool app::setInterval(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError) {
@@ -466,7 +470,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString script =
       params.size() > 0 ? params[0].ToCFXWideString(pRuntime) : L"";
   if (script.IsEmpty()) {
@@ -491,7 +495,7 @@
   return true;
 }
 
-bool app::setTimeOut(IJS_Context* cc,
+bool app::setTimeOut(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError) {
@@ -500,7 +504,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CFX_WideString script = params[0].ToCFXWideString(pRuntime);
   if (script.IsEmpty()) {
     sError = JSGetStringFromID(IDS_STRING_JSAFNUMBER_KEYSTROKE);
@@ -526,7 +530,7 @@
   return true;
 }
 
-bool app::clearTimeOut(IJS_Context* cc,
+bool app::clearTimeOut(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
@@ -535,11 +539,11 @@
     return false;
   }
 
-  app::ClearTimerCommon(CJS_Runtime::FromContext(cc), params[0]);
+  app::ClearTimerCommon(CJS_Runtime::FromEventContext(cc), params[0]);
   return true;
 }
 
-bool app::clearInterval(IJS_Context* cc,
+bool app::clearInterval(IJS_EventContext* cc,
                         const std::vector<CJS_Value>& params,
                         CJS_Value& vRet,
                         CFX_WideString& sError) {
@@ -548,7 +552,7 @@
     return false;
   }
 
-  app::ClearTimerCommon(CJS_Runtime::FromContext(cc), params[0]);
+  app::ClearTimerCommon(CJS_Runtime::FromEventContext(cc), params[0]);
   return true;
 }
 
@@ -571,7 +575,7 @@
   GlobalTimer::Cancel(pTimerObj->GetTimerID());
 }
 
-bool app::execMenuItem(IJS_Context* cc,
+bool app::execMenuItem(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
@@ -590,15 +594,15 @@
 
 void app::RunJsScript(CJS_Runtime* pRuntime, const CFX_WideString& wsScript) {
   if (!pRuntime->IsBlocking()) {
-    IJS_Context* pContext = pRuntime->NewContext();
+    IJS_EventContext* pContext = pRuntime->NewEventContext();
     pContext->OnExternal_Exec();
     CFX_WideString wtInfo;
     pContext->RunScript(wsScript, &wtInfo);
-    pRuntime->ReleaseContext(pContext);
+    pRuntime->ReleaseEventContext(pContext);
   }
 }
 
-bool app::goBack(IJS_Context* cc,
+bool app::goBack(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError) {
@@ -606,7 +610,7 @@
   return true;
 }
 
-bool app::goForward(IJS_Context* cc,
+bool app::goForward(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError) {
@@ -614,11 +618,11 @@
   return true;
 }
 
-bool app::mailMsg(IJS_Context* cc,
+bool app::mailMsg(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   std::vector<CJS_Value> newParams =
       JS_ExpandKeywordParams(pRuntime, params, 6, L"bUI", L"cTo", L"cCc",
                              L"cBcc", L"cSubject", L"cMsg");
@@ -657,7 +661,7 @@
     cMsg = newParams[5].ToCFXWideString(pRuntime);
 
   pRuntime->BeginBlock();
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
   pContext->GetFormFillEnv()->JS_docmailForm(nullptr, 0, bUI, cTo.c_str(),
                                              cSubject.c_str(), cCc.c_str(),
                                              cBcc.c_str(), cMsg.c_str());
@@ -665,7 +669,7 @@
   return true;
 }
 
-bool app::launchURL(IJS_Context* cc,
+bool app::launchURL(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError) {
@@ -673,7 +677,7 @@
   return true;
 }
 
-bool app::runtimeHighlight(IJS_Context* cc,
+bool app::runtimeHighlight(IJS_EventContext* cc,
                            CJS_PropValue& vp,
                            CFX_WideString& sError) {
   if (vp.IsSetting()) {
@@ -684,20 +688,20 @@
   return true;
 }
 
-bool app::fullscreen(IJS_Context* cc,
+bool app::fullscreen(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   return false;
 }
 
-bool app::popUpMenu(IJS_Context* cc,
+bool app::popUpMenu(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError) {
   return false;
 }
 
-bool app::browseForDoc(IJS_Context* cc,
+bool app::browseForDoc(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
@@ -723,25 +727,25 @@
   return sRet;
 }
 
-bool app::newDoc(IJS_Context* cc,
+bool app::newDoc(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError) {
   return false;
 }
 
-bool app::openDoc(IJS_Context* cc,
+bool app::openDoc(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError) {
   return false;
 }
 
-bool app::response(IJS_Context* cc,
+bool app::response(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   std::vector<CJS_Value> newParams =
       JS_ExpandKeywordParams(pRuntime, params, 5, L"cQuestion", L"cTitle",
                              L"cDefault", L"bPassword", L"cLabel");
@@ -772,7 +776,7 @@
   std::unique_ptr<char[]> pBuff(new char[MAX_INPUT_BYTES + 2]);
   memset(pBuff.get(), 0, MAX_INPUT_BYTES + 2);
 
-  CJS_Context* pContext = static_cast<CJS_Context*>(cc);
+  CJS_EventContext* pContext = static_cast<CJS_EventContext*>(cc);
   int nLengthBytes = pContext->GetFormFillEnv()->JS_appResponse(
       swQuestion.c_str(), swTitle.c_str(), swDefault.c_str(), swLabel.c_str(),
       bPassword, pBuff.get(), MAX_INPUT_BYTES);
@@ -790,11 +794,13 @@
   return true;
 }
 
-bool app::media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool app::media(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError) {
   return false;
 }
 
-bool app::execDialog(IJS_Context* cc,
+bool app::execDialog(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError) {
diff --git a/fpdfsdk/javascript/app.h b/fpdfsdk/javascript/app.h
index e8c7241..6cd68d3 100644
--- a/fpdfsdk/javascript/app.h
+++ b/fpdfsdk/javascript/app.h
@@ -41,106 +41,120 @@
   explicit app(CJS_Object* pJSObject);
   ~app() override;
 
-  bool activeDocs(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool calculate(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool formsVersion(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool fs(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool fullscreen(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool language(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool media(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool platform(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool runtimeHighlight(IJS_Context* cc,
+  bool activeDocs(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError);
+  bool calculate(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool formsVersion(IJS_EventContext* cc,
+                    CJS_PropValue& vp,
+                    CFX_WideString& sError);
+  bool fs(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool fullscreen(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError);
+  bool language(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool media(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool platform(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool runtimeHighlight(IJS_EventContext* cc,
                         CJS_PropValue& vp,
                         CFX_WideString& sError);
-  bool viewerType(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool viewerVariation(IJS_Context* cc,
+  bool viewerType(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError);
+  bool viewerVariation(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError);
-  bool viewerVersion(IJS_Context* cc,
+  bool viewerVersion(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError);
 
-  bool alert(IJS_Context* cc,
+  bool alert(IJS_EventContext* cc,
              const std::vector<CJS_Value>& params,
              CJS_Value& vRet,
              CFX_WideString& sError);
-  bool beep(IJS_Context* cc,
+  bool beep(IJS_EventContext* cc,
             const std::vector<CJS_Value>& params,
             CJS_Value& vRet,
             CFX_WideString& sError);
-  bool browseForDoc(IJS_Context* cc,
+  bool browseForDoc(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool clearInterval(IJS_Context* cc,
+  bool clearInterval(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
-  bool clearTimeOut(IJS_Context* cc,
+  bool clearTimeOut(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool execDialog(IJS_Context* cc,
+  bool execDialog(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError);
-  bool execMenuItem(IJS_Context* cc,
+  bool execMenuItem(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError);
-  bool findComponent(IJS_Context* cc,
+  bool findComponent(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
-  bool goBack(IJS_Context* cc,
+  bool goBack(IJS_EventContext* cc,
               const std::vector<CJS_Value>& params,
               CJS_Value& vRet,
               CFX_WideString& sError);
-  bool goForward(IJS_Context* cc,
+  bool goForward(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
-  bool launchURL(IJS_Context* cc,
+  bool launchURL(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
-  bool mailMsg(IJS_Context* cc,
+  bool mailMsg(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool newFDF(IJS_Context* cc,
+  bool newFDF(IJS_EventContext* cc,
               const std::vector<CJS_Value>& params,
               CJS_Value& vRet,
               CFX_WideString& sError);
-  bool newDoc(IJS_Context* cc,
+  bool newDoc(IJS_EventContext* cc,
               const std::vector<CJS_Value>& params,
               CJS_Value& vRet,
               CFX_WideString& sError);
-  bool openDoc(IJS_Context* cc,
+  bool openDoc(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool openFDF(IJS_Context* cc,
+  bool openFDF(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool popUpMenuEx(IJS_Context* cc,
+  bool popUpMenuEx(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
-  bool popUpMenu(IJS_Context* cc,
+  bool popUpMenu(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
-  bool response(IJS_Context* cc,
+  bool response(IJS_EventContext* cc,
                 const std::vector<CJS_Value>& params,
                 CJS_Value& vRet,
                 CFX_WideString& sError);
-  bool setInterval(IJS_Context* cc,
+  bool setInterval(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError);
-  bool setTimeOut(IJS_Context* cc,
+  bool setTimeOut(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError);
diff --git a/fpdfsdk/javascript/cjs_context.cpp b/fpdfsdk/javascript/cjs_context.cpp
deleted file mode 100644
index e356bdd..0000000
--- a/fpdfsdk/javascript/cjs_context.cpp
+++ /dev/null
@@ -1,272 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "fpdfsdk/javascript/cjs_context.h"
-
-#include "fpdfsdk/javascript/JS_EventHandler.h"
-#include "fpdfsdk/javascript/cjs_runtime.h"
-#include "fpdfsdk/javascript/resource.h"
-
-CJS_Context::CJS_Context(CJS_Runtime* pRuntime)
-    : m_pRuntime(pRuntime),
-      m_pEventHandler(new CJS_EventHandler(this)),
-      m_bBusy(false) {}
-
-CJS_Context::~CJS_Context() {}
-
-CPDFSDK_FormFillEnvironment* CJS_Context::GetFormFillEnv() {
-  return m_pRuntime->GetFormFillEnv();
-}
-
-bool CJS_Context::RunScript(const CFX_WideString& script,
-                            CFX_WideString* info) {
-  v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());
-  v8::HandleScope handle_scope(m_pRuntime->GetIsolate());
-  v8::Local<v8::Context> context = m_pRuntime->NewLocalContext();
-  v8::Context::Scope context_scope(context);
-
-  if (m_bBusy) {
-    *info = JSGetStringFromID(IDS_STRING_JSBUSY);
-    return false;
-  }
-  m_bBusy = true;
-
-  ASSERT(m_pEventHandler->IsValid());
-  CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(),
-                                m_pEventHandler->EventType());
-  if (!m_pRuntime->AddEventToSet(event)) {
-    *info = JSGetStringFromID(IDS_STRING_JSEVENT);
-    return false;
-  }
-
-  CFX_WideString sErrorMessage;
-  int nRet = 0;
-  if (script.GetLength() > 0) {
-    nRet = m_pRuntime->ExecuteScript(script.c_str(), &sErrorMessage);
-  }
-
-  if (nRet < 0) {
-    *info += sErrorMessage;
-  } else {
-    *info = JSGetStringFromID(IDS_STRING_RUN);
-  }
-
-  m_pRuntime->RemoveEventFromSet(event);
-  m_pEventHandler->Destroy();
-  m_bBusy = false;
-
-  return nRet >= 0;
-}
-
-void CJS_Context::OnApp_Init() {
-  m_pEventHandler->OnApp_Init();
-}
-
-void CJS_Context::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                             const CFX_WideString& strTargetName) {
-  m_pEventHandler->OnDoc_Open(pFormFillEnv, strTargetName);
-}
-
-void CJS_Context::OnDoc_WillPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnDoc_WillPrint(pFormFillEnv);
-}
-
-void CJS_Context::OnDoc_DidPrint(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnDoc_DidPrint(pFormFillEnv);
-}
-
-void CJS_Context::OnDoc_WillSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnDoc_WillSave(pFormFillEnv);
-}
-
-void CJS_Context::OnDoc_DidSave(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnDoc_DidSave(pFormFillEnv);
-}
-
-void CJS_Context::OnDoc_WillClose(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnDoc_WillClose(pFormFillEnv);
-}
-
-void CJS_Context::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnPage_Open(pFormFillEnv);
-}
-
-void CJS_Context::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnPage_Close(pFormFillEnv);
-}
-
-void CJS_Context::OnPage_InView(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnPage_InView(pFormFillEnv);
-}
-
-void CJS_Context::OnPage_OutView(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnPage_OutView(pFormFillEnv);
-}
-
-void CJS_Context::OnField_MouseDown(bool bModifier,
-                                    bool bShift,
-                                    CPDF_FormField* pTarget) {
-  m_pEventHandler->OnField_MouseDown(bModifier, bShift, pTarget);
-}
-
-void CJS_Context::OnField_MouseEnter(bool bModifier,
-                                     bool bShift,
-                                     CPDF_FormField* pTarget) {
-  m_pEventHandler->OnField_MouseEnter(bModifier, bShift, pTarget);
-}
-
-void CJS_Context::OnField_MouseExit(bool bModifier,
-                                    bool bShift,
-                                    CPDF_FormField* pTarget) {
-  m_pEventHandler->OnField_MouseExit(bModifier, bShift, pTarget);
-}
-
-void CJS_Context::OnField_MouseUp(bool bModifier,
-                                  bool bShift,
-                                  CPDF_FormField* pTarget) {
-  m_pEventHandler->OnField_MouseUp(bModifier, bShift, pTarget);
-}
-
-void CJS_Context::OnField_Focus(bool bModifier,
-                                bool bShift,
-                                CPDF_FormField* pTarget,
-                                const CFX_WideString& Value) {
-  m_pEventHandler->OnField_Focus(bModifier, bShift, pTarget, Value);
-}
-
-void CJS_Context::OnField_Blur(bool bModifier,
-                               bool bShift,
-                               CPDF_FormField* pTarget,
-                               const CFX_WideString& Value) {
-  m_pEventHandler->OnField_Blur(bModifier, bShift, pTarget, Value);
-}
-
-void CJS_Context::OnField_Calculate(CPDF_FormField* pSource,
-                                    CPDF_FormField* pTarget,
-                                    CFX_WideString& Value,
-                                    bool& bRc) {
-  m_pEventHandler->OnField_Calculate(pSource, pTarget, Value, bRc);
-}
-
-void CJS_Context::OnField_Format(CPDF_FormField* pTarget,
-                                 CFX_WideString& Value,
-                                 bool bWillCommit) {
-  m_pEventHandler->OnField_Format(pTarget, Value, bWillCommit);
-}
-
-void CJS_Context::OnField_Keystroke(CFX_WideString& strChange,
-                                    const CFX_WideString& strChangeEx,
-                                    bool bKeyDown,
-                                    bool bModifier,
-                                    int& nSelEnd,
-                                    int& nSelStart,
-                                    bool bShift,
-                                    CPDF_FormField* pTarget,
-                                    CFX_WideString& Value,
-                                    bool bWillCommit,
-                                    bool bFieldFull,
-                                    bool& bRc) {
-  m_pEventHandler->OnField_Keystroke(
-      strChange, strChangeEx, bKeyDown, bModifier, nSelEnd, nSelStart, bShift,
-      pTarget, Value, bWillCommit, bFieldFull, bRc);
-}
-
-void CJS_Context::OnField_Validate(CFX_WideString& strChange,
-                                   const CFX_WideString& strChangeEx,
-                                   bool bKeyDown,
-                                   bool bModifier,
-                                   bool bShift,
-                                   CPDF_FormField* pTarget,
-                                   CFX_WideString& Value,
-                                   bool& bRc) {
-  m_pEventHandler->OnField_Validate(strChange, strChangeEx, bKeyDown, bModifier,
-                                    bShift, pTarget, Value, bRc);
-}
-
-void CJS_Context::OnScreen_Focus(bool bModifier,
-                                 bool bShift,
-                                 CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_Focus(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnScreen_Blur(bool bModifier,
-                                bool bShift,
-                                CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_Blur(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnScreen_Open(bool bModifier,
-                                bool bShift,
-                                CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_Open(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnScreen_Close(bool bModifier,
-                                 bool bShift,
-                                 CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_Close(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnScreen_MouseDown(bool bModifier,
-                                     bool bShift,
-                                     CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_MouseDown(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnScreen_MouseUp(bool bModifier,
-                                   bool bShift,
-                                   CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_MouseUp(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnScreen_MouseEnter(bool bModifier,
-                                      bool bShift,
-                                      CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_MouseEnter(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnScreen_MouseExit(bool bModifier,
-                                     bool bShift,
-                                     CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_MouseExit(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnScreen_InView(bool bModifier,
-                                  bool bShift,
-                                  CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_InView(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnScreen_OutView(bool bModifier,
-                                   bool bShift,
-                                   CPDFSDK_Annot* pScreen) {
-  m_pEventHandler->OnScreen_OutView(bModifier, bShift, pScreen);
-}
-
-void CJS_Context::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
-  m_pEventHandler->OnBookmark_MouseUp(pBookMark);
-}
-
-void CJS_Context::OnLink_MouseUp(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnLink_MouseUp(pFormFillEnv);
-}
-
-void CJS_Context::OnConsole_Exec() {
-  m_pEventHandler->OnConsole_Exec();
-}
-
-void CJS_Context::OnExternal_Exec() {
-  m_pEventHandler->OnExternal_Exec();
-}
-
-void CJS_Context::OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
-  m_pEventHandler->OnBatchExec(pFormFillEnv);
-}
-
-void CJS_Context::OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv,
-                              const CFX_WideString& strTargetName) {
-  m_pEventHandler->OnMenu_Exec(pFormFillEnv, strTargetName);
-}
diff --git a/fpdfsdk/javascript/cjs_event_context.cpp b/fpdfsdk/javascript/cjs_event_context.cpp
new file mode 100644
index 0000000..abfb6da
--- /dev/null
+++ b/fpdfsdk/javascript/cjs_event_context.cpp
@@ -0,0 +1,280 @@
+// Copyright 2017 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "fpdfsdk/javascript/cjs_event_context.h"
+
+#include "fpdfsdk/javascript/JS_EventHandler.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
+#include "fpdfsdk/javascript/resource.h"
+
+CJS_EventContext::CJS_EventContext(CJS_Runtime* pRuntime)
+    : m_pRuntime(pRuntime),
+      m_pEventHandler(new CJS_EventHandler(this)),
+      m_bBusy(false) {
+  ASSERT(pRuntime);
+}
+
+CJS_EventContext::~CJS_EventContext() {}
+
+CPDFSDK_FormFillEnvironment* CJS_EventContext::GetFormFillEnv() {
+  return m_pRuntime->GetFormFillEnv();
+}
+
+bool CJS_EventContext::RunScript(const CFX_WideString& script,
+                                 CFX_WideString* info) {
+  v8::Isolate::Scope isolate_scope(m_pRuntime->GetIsolate());
+  v8::HandleScope handle_scope(m_pRuntime->GetIsolate());
+  v8::Local<v8::Context> context = m_pRuntime->NewLocalContext();
+  v8::Context::Scope context_scope(context);
+
+  if (m_bBusy) {
+    *info = JSGetStringFromID(IDS_STRING_JSBUSY);
+    return false;
+  }
+
+  CFX_AutoRestorer<bool> restorer(&m_bBusy);
+  m_bBusy = true;
+
+  ASSERT(m_pEventHandler->IsValid());
+  CJS_Runtime::FieldEvent event(m_pEventHandler->TargetName(),
+                                m_pEventHandler->EventType());
+  if (!m_pRuntime->AddEventToSet(event)) {
+    *info = JSGetStringFromID(IDS_STRING_JSEVENT);
+    return false;
+  }
+
+  CFX_WideString sErrorMessage;
+  int nRet = 0;
+  if (script.GetLength() > 0)
+    nRet = m_pRuntime->ExecuteScript(script.c_str(), &sErrorMessage);
+
+  if (nRet < 0)
+    *info += sErrorMessage;
+  else
+    *info = JSGetStringFromID(IDS_STRING_RUN);
+
+  m_pRuntime->RemoveEventFromSet(event);
+  m_pEventHandler->Destroy();
+  return nRet >= 0;
+}
+
+void CJS_EventContext::OnApp_Init() {
+  m_pEventHandler->OnApp_Init();
+}
+
+void CJS_EventContext::OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+                                  const CFX_WideString& strTargetName) {
+  m_pEventHandler->OnDoc_Open(pFormFillEnv, strTargetName);
+}
+
+void CJS_EventContext::OnDoc_WillPrint(
+    CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnDoc_WillPrint(pFormFillEnv);
+}
+
+void CJS_EventContext::OnDoc_DidPrint(
+    CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnDoc_DidPrint(pFormFillEnv);
+}
+
+void CJS_EventContext::OnDoc_WillSave(
+    CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnDoc_WillSave(pFormFillEnv);
+}
+
+void CJS_EventContext::OnDoc_DidSave(
+    CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnDoc_DidSave(pFormFillEnv);
+}
+
+void CJS_EventContext::OnDoc_WillClose(
+    CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnDoc_WillClose(pFormFillEnv);
+}
+
+void CJS_EventContext::OnPage_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnPage_Open(pFormFillEnv);
+}
+
+void CJS_EventContext::OnPage_Close(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnPage_Close(pFormFillEnv);
+}
+
+void CJS_EventContext::OnPage_InView(
+    CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnPage_InView(pFormFillEnv);
+}
+
+void CJS_EventContext::OnPage_OutView(
+    CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnPage_OutView(pFormFillEnv);
+}
+
+void CJS_EventContext::OnField_MouseDown(bool bModifier,
+                                         bool bShift,
+                                         CPDF_FormField* pTarget) {
+  m_pEventHandler->OnField_MouseDown(bModifier, bShift, pTarget);
+}
+
+void CJS_EventContext::OnField_MouseEnter(bool bModifier,
+                                          bool bShift,
+                                          CPDF_FormField* pTarget) {
+  m_pEventHandler->OnField_MouseEnter(bModifier, bShift, pTarget);
+}
+
+void CJS_EventContext::OnField_MouseExit(bool bModifier,
+                                         bool bShift,
+                                         CPDF_FormField* pTarget) {
+  m_pEventHandler->OnField_MouseExit(bModifier, bShift, pTarget);
+}
+
+void CJS_EventContext::OnField_MouseUp(bool bModifier,
+                                       bool bShift,
+                                       CPDF_FormField* pTarget) {
+  m_pEventHandler->OnField_MouseUp(bModifier, bShift, pTarget);
+}
+
+void CJS_EventContext::OnField_Focus(bool bModifier,
+                                     bool bShift,
+                                     CPDF_FormField* pTarget,
+                                     const CFX_WideString& Value) {
+  m_pEventHandler->OnField_Focus(bModifier, bShift, pTarget, Value);
+}
+
+void CJS_EventContext::OnField_Blur(bool bModifier,
+                                    bool bShift,
+                                    CPDF_FormField* pTarget,
+                                    const CFX_WideString& Value) {
+  m_pEventHandler->OnField_Blur(bModifier, bShift, pTarget, Value);
+}
+
+void CJS_EventContext::OnField_Calculate(CPDF_FormField* pSource,
+                                         CPDF_FormField* pTarget,
+                                         CFX_WideString& Value,
+                                         bool& bRc) {
+  m_pEventHandler->OnField_Calculate(pSource, pTarget, Value, bRc);
+}
+
+void CJS_EventContext::OnField_Format(CPDF_FormField* pTarget,
+                                      CFX_WideString& Value,
+                                      bool bWillCommit) {
+  m_pEventHandler->OnField_Format(pTarget, Value, bWillCommit);
+}
+
+void CJS_EventContext::OnField_Keystroke(CFX_WideString& strChange,
+                                         const CFX_WideString& strChangeEx,
+                                         bool bKeyDown,
+                                         bool bModifier,
+                                         int& nSelEnd,
+                                         int& nSelStart,
+                                         bool bShift,
+                                         CPDF_FormField* pTarget,
+                                         CFX_WideString& Value,
+                                         bool bWillCommit,
+                                         bool bFieldFull,
+                                         bool& bRc) {
+  m_pEventHandler->OnField_Keystroke(
+      strChange, strChangeEx, bKeyDown, bModifier, nSelEnd, nSelStart, bShift,
+      pTarget, Value, bWillCommit, bFieldFull, bRc);
+}
+
+void CJS_EventContext::OnField_Validate(CFX_WideString& strChange,
+                                        const CFX_WideString& strChangeEx,
+                                        bool bKeyDown,
+                                        bool bModifier,
+                                        bool bShift,
+                                        CPDF_FormField* pTarget,
+                                        CFX_WideString& Value,
+                                        bool& bRc) {
+  m_pEventHandler->OnField_Validate(strChange, strChangeEx, bKeyDown, bModifier,
+                                    bShift, pTarget, Value, bRc);
+}
+
+void CJS_EventContext::OnScreen_Focus(bool bModifier,
+                                      bool bShift,
+                                      CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_Focus(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnScreen_Blur(bool bModifier,
+                                     bool bShift,
+                                     CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_Blur(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnScreen_Open(bool bModifier,
+                                     bool bShift,
+                                     CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_Open(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnScreen_Close(bool bModifier,
+                                      bool bShift,
+                                      CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_Close(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnScreen_MouseDown(bool bModifier,
+                                          bool bShift,
+                                          CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_MouseDown(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnScreen_MouseUp(bool bModifier,
+                                        bool bShift,
+                                        CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_MouseUp(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnScreen_MouseEnter(bool bModifier,
+                                           bool bShift,
+                                           CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_MouseEnter(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnScreen_MouseExit(bool bModifier,
+                                          bool bShift,
+                                          CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_MouseExit(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnScreen_InView(bool bModifier,
+                                       bool bShift,
+                                       CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_InView(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnScreen_OutView(bool bModifier,
+                                        bool bShift,
+                                        CPDFSDK_Annot* pScreen) {
+  m_pEventHandler->OnScreen_OutView(bModifier, bShift, pScreen);
+}
+
+void CJS_EventContext::OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) {
+  m_pEventHandler->OnBookmark_MouseUp(pBookMark);
+}
+
+void CJS_EventContext::OnLink_MouseUp(
+    CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnLink_MouseUp(pFormFillEnv);
+}
+
+void CJS_EventContext::OnConsole_Exec() {
+  m_pEventHandler->OnConsole_Exec();
+}
+
+void CJS_EventContext::OnExternal_Exec() {
+  m_pEventHandler->OnExternal_Exec();
+}
+
+void CJS_EventContext::OnBatchExec(CPDFSDK_FormFillEnvironment* pFormFillEnv) {
+  m_pEventHandler->OnBatchExec(pFormFillEnv);
+}
+
+void CJS_EventContext::OnMenu_Exec(CPDFSDK_FormFillEnvironment* pFormFillEnv,
+                                   const CFX_WideString& strTargetName) {
+  m_pEventHandler->OnMenu_Exec(pFormFillEnv, strTargetName);
+}
diff --git a/fpdfsdk/javascript/cjs_context.h b/fpdfsdk/javascript/cjs_event_context.h
similarity index 92%
rename from fpdfsdk/javascript/cjs_context.h
rename to fpdfsdk/javascript/cjs_event_context.h
index 95a63ad..7bfe528 100644
--- a/fpdfsdk/javascript/cjs_context.h
+++ b/fpdfsdk/javascript/cjs_event_context.h
@@ -1,28 +1,28 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
+// Copyright 2017 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_
-#define FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_
+#ifndef FPDFSDK_JAVASCRIPT_CJS_EVENT_CONTEXT_H_
+#define FPDFSDK_JAVASCRIPT_CJS_EVENT_CONTEXT_H_
 
 #include <memory>
 
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/fx_system.h"
-#include "fpdfsdk/javascript/ijs_context.h"
+#include "fpdfsdk/javascript/ijs_event_context.h"
 
 class CJS_EventHandler;
 class CJS_Runtime;
 class CPDFSDK_FormFillEnvironment;
 
-class CJS_Context : public IJS_Context {
+class CJS_EventContext : public IJS_EventContext {
  public:
-  explicit CJS_Context(CJS_Runtime* pRuntime);
-  ~CJS_Context() override;
+  explicit CJS_EventContext(CJS_Runtime* pRuntime);
+  ~CJS_EventContext() override;
 
-  // IJS_Context
+  // IJS_EventContext
   bool RunScript(const CFX_WideString& script, CFX_WideString* info) override;
   void OnApp_Init() override;
   void OnDoc_Open(CPDFSDK_FormFillEnvironment* pFormFillEnv,
@@ -132,4 +132,4 @@
   bool m_bBusy;
 };
 
-#endif  // FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_
+#endif  // FPDFSDK_JAVASCRIPT_CJS_EVENT_CONTEXT_H_
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() {
diff --git a/fpdfsdk/javascript/cjs_runtime.h b/fpdfsdk/javascript/cjs_runtime.h
index 66f0877..96b171b 100644
--- a/fpdfsdk/javascript/cjs_runtime.h
+++ b/fpdfsdk/javascript/cjs_runtime.h
@@ -19,7 +19,7 @@
 #include "fpdfsdk/javascript/ijs_runtime.h"
 #include "fxjs/fxjs_v8.h"
 
-class CJS_Context;
+class CJS_EventContext;
 
 class CJS_Runtime : public IJS_Runtime,
                     public CFXJS_Engine,
@@ -27,19 +27,17 @@
  public:
   using FieldEvent = std::pair<CFX_WideString, JS_EVENT_T>;
 
-  static CJS_Runtime* FromContext(const IJS_Context* cc);
+  static CJS_Runtime* FromEventContext(const IJS_EventContext* cc);
   static CJS_Runtime* CurrentRuntimeFromIsolate(v8::Isolate* pIsolate);
 
   explicit CJS_Runtime(CPDFSDK_FormFillEnvironment* pFormFillEnv);
   ~CJS_Runtime() override;
 
   // IJS_Runtime
-  IJS_Context* NewContext() override;
-  void ReleaseContext(IJS_Context* pContext) override;
-  IJS_Context* GetCurrentContext() override;
-
+  IJS_EventContext* NewEventContext() override;
+  void ReleaseEventContext(IJS_EventContext* pContext) override;
+  IJS_EventContext* GetCurrentEventContext() override;
   CPDFSDK_FormFillEnvironment* GetFormFillEnv() const override;
-
   int ExecuteScript(const CFX_WideString& script,
                     CFX_WideString* info) override;
 
@@ -62,7 +60,7 @@
   void DefineJSObjects();
   void SetFormFillEnvToDocument();
 
-  std::vector<std::unique_ptr<CJS_Context>> m_ContextArray;
+  std::vector<std::unique_ptr<CJS_EventContext>> m_EventContextArray;
   CPDFSDK_FormFillEnvironment* const m_pFormFillEnv;
   bool m_bBlocking;
   bool m_isolateManaged;
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 882a903..be26987 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -12,7 +12,7 @@
 #include "fpdfsdk/javascript/JS_EventHandler.h"
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 #include "fpdfsdk/javascript/cjs_runtime.h"
 
 BEGIN_JS_STATIC_CONST(CJS_Color)
@@ -133,20 +133,20 @@
   }
 }
 
-#define JS_IMPLEMENT_COLORPROP(prop, var)                    \
-  bool color::prop(IJS_Context* cc, CJS_PropValue& vp,       \
-                   CFX_WideString& sError) {                 \
-    CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);    \
-    CJS_Array array;                                         \
-    if (vp.IsGetting()) {                                    \
-      ConvertPWLColorToArray(pRuntime, var, &array);         \
-      vp << array;                                           \
-    } else {                                                 \
-      if (!vp.GetJSValue()->ConvertToArray(pRuntime, array)) \
-        return false;                                        \
-      ConvertArrayToPWLColor(pRuntime, array, &var);         \
-    }                                                        \
-    return true;                                             \
+#define JS_IMPLEMENT_COLORPROP(prop, var)                      \
+  bool color::prop(IJS_EventContext* cc, CJS_PropValue& vp,    \
+                   CFX_WideString& sError) {                   \
+    CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc); \
+    CJS_Array array;                                           \
+    if (vp.IsGetting()) {                                      \
+      ConvertPWLColorToArray(pRuntime, var, &array);           \
+      vp << array;                                             \
+    } else {                                                   \
+      if (!vp.GetJSValue()->ConvertToArray(pRuntime, array))   \
+        return false;                                          \
+      ConvertArrayToPWLColor(pRuntime, array, &var);           \
+    }                                                          \
+    return true;                                               \
   }
 
 JS_IMPLEMENT_COLORPROP(transparent, m_crTransparent)
@@ -162,7 +162,7 @@
 JS_IMPLEMENT_COLORPROP(gray, m_crGray)
 JS_IMPLEMENT_COLORPROP(ltGray, m_crLTGray)
 
-bool color::convert(IJS_Context* cc,
+bool color::convert(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError) {
@@ -170,7 +170,7 @@
   if (iSize < 2)
     return false;
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_Array aSource;
   if (!params[0].ConvertToArray(pRuntime, aSource))
     return false;
@@ -200,14 +200,14 @@
   return true;
 }
 
-bool color::equal(IJS_Context* cc,
+bool color::equal(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError) {
   if (params.size() < 2)
     return false;
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_Array array1;
   CJS_Array array2;
   if (!params[0].ConvertToArray(pRuntime, array1))
diff --git a/fpdfsdk/javascript/color.h b/fpdfsdk/javascript/color.h
index 9ea4d63..df53b4a 100644
--- a/fpdfsdk/javascript/color.h
+++ b/fpdfsdk/javascript/color.h
@@ -17,24 +17,26 @@
   explicit color(CJS_Object* pJSObject);
   ~color() override;
 
-  bool black(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool blue(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool cyan(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool dkGray(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool gray(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool green(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool ltGray(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool magenta(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool red(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool transparent(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool white(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool yellow(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool black(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool blue(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool cyan(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool dkGray(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool gray(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool green(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool ltGray(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool magenta(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool red(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool transparent(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError);
+  bool white(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool yellow(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
 
-  bool convert(IJS_Context* cc,
+  bool convert(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool equal(IJS_Context* cc,
+  bool equal(IJS_EventContext* cc,
              const std::vector<CJS_Value>& params,
              CJS_Value& vRet,
              CFX_WideString& sError);
diff --git a/fpdfsdk/javascript/console.cpp b/fpdfsdk/javascript/console.cpp
index 0a8c1e0..538a4ef 100644
--- a/fpdfsdk/javascript/console.cpp
+++ b/fpdfsdk/javascript/console.cpp
@@ -12,7 +12,7 @@
 #include "fpdfsdk/javascript/JS_EventHandler.h"
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 
 BEGIN_JS_STATIC_CONST(CJS_Console)
 END_JS_STATIC_CONST()
@@ -33,21 +33,21 @@
 
 console::~console() {}
 
-bool console::clear(IJS_Context* cc,
+bool console::clear(IJS_EventContext* cc,
                     const std::vector<CJS_Value>& params,
                     CJS_Value& vRet,
                     CFX_WideString& sError) {
   return true;
 }
 
-bool console::hide(IJS_Context* cc,
+bool console::hide(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError) {
   return true;
 }
 
-bool console::println(IJS_Context* cc,
+bool console::println(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError) {
@@ -57,7 +57,7 @@
   return true;
 }
 
-bool console::show(IJS_Context* cc,
+bool console::show(IJS_EventContext* cc,
                    const std::vector<CJS_Value>& params,
                    CJS_Value& vRet,
                    CFX_WideString& sError) {
diff --git a/fpdfsdk/javascript/console.h b/fpdfsdk/javascript/console.h
index 069a81d..1b6e9dd 100644
--- a/fpdfsdk/javascript/console.h
+++ b/fpdfsdk/javascript/console.h
@@ -17,19 +17,19 @@
   ~console() override;
 
  public:
-  bool clear(IJS_Context* cc,
+  bool clear(IJS_EventContext* cc,
              const std::vector<CJS_Value>& params,
              CJS_Value& vRet,
              CFX_WideString& sError);
-  bool hide(IJS_Context* cc,
+  bool hide(IJS_EventContext* cc,
             const std::vector<CJS_Value>& params,
             CJS_Value& vRet,
             CFX_WideString& sError);
-  bool println(IJS_Context* cc,
+  bool println(IJS_EventContext* cc,
                const std::vector<CJS_Value>& params,
                CJS_Value& vRet,
                CFX_WideString& sError);
-  bool show(IJS_Context* cc,
+  bool show(IJS_EventContext* cc,
             const std::vector<CJS_Value>& params,
             CJS_Value& vRet,
             CFX_WideString& sError);
diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp
index b4fb951..48f3ce8 100644
--- a/fpdfsdk/javascript/event.cpp
+++ b/fpdfsdk/javascript/event.cpp
@@ -11,7 +11,7 @@
 #include "fpdfsdk/javascript/JS_EventHandler.h"
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 
 BEGIN_JS_STATIC_CONST(CJS_Event)
 END_JS_STATIC_CONST()
@@ -48,50 +48,52 @@
 
 event::~event() {}
 
-bool event::change(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+bool event::change(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
   CFX_WideString& wChange = pEvent->Change();
   if (vp.IsSetting()) {
     if (vp.GetJSValue()->GetType() == CJS_Value::VT_string)
       vp >> wChange;
-  } else {
-    vp << wChange;
+    return true;
   }
+  vp << wChange;
   return true;
 }
 
-bool event::changeEx(IJS_Context* cc,
+bool event::changeEx(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   vp << pEvent->ChangeEx();
   return true;
 }
 
-bool event::commitKey(IJS_Context* cc,
+bool event::commitKey(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   vp << pEvent->CommitKey();
   return true;
 }
 
-bool event::fieldFull(IJS_Context* cc,
+bool event::fieldFull(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   if (!vp.IsGetting() &&
       wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
@@ -104,14 +106,14 @@
   return true;
 }
 
-bool event::keyDown(IJS_Context* cc,
+bool event::keyDown(IJS_EventContext* cc,
                     CJS_PropValue& vp,
                     CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   if (pEvent->KeyDown())
     vp << true;
@@ -120,14 +122,14 @@
   return true;
 }
 
-bool event::modifier(IJS_Context* cc,
+bool event::modifier(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   if (pEvent->Modifier())
     vp << true;
@@ -136,89 +138,96 @@
   return true;
 }
 
-bool event::name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool event::name(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   vp << pEvent->Name();
   return true;
 }
 
-bool event::rc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+bool event::rc(IJS_EventContext* cc,
+               CJS_PropValue& vp,
+               CFX_WideString& sError) {
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   bool& bRc = pEvent->Rc();
-  if (vp.IsSetting()) {
+  if (vp.IsSetting())
     vp >> bRc;
-  } else {
+  else
     vp << bRc;
-  }
+
   return true;
 }
 
-bool event::richChange(IJS_Context* cc,
+bool event::richChange(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   return true;
 }
 
-bool event::richChangeEx(IJS_Context* cc,
+bool event::richChangeEx(IJS_EventContext* cc,
                          CJS_PropValue& vp,
                          CFX_WideString& sError) {
   return true;
 }
 
-bool event::richValue(IJS_Context* cc,
+bool event::richValue(IJS_EventContext* cc,
                       CJS_PropValue& vp,
                       CFX_WideString& sError) {
   return true;
 }
 
-bool event::selEnd(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+bool event::selEnd(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
-  if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) {
+  if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
     return true;
-  }
 
   int& iSelEnd = pEvent->SelEnd();
-  if (vp.IsSetting()) {
+  if (vp.IsSetting())
     vp >> iSelEnd;
-  } else {
+  else
     vp << iSelEnd;
-  }
+
   return true;
 }
 
-bool event::selStart(IJS_Context* cc,
+bool event::selStart(IJS_EventContext* cc,
                      CJS_PropValue& vp,
                      CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
-  if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0) {
+  if (wcscmp((const wchar_t*)pEvent->Name(), L"Keystroke") != 0)
     return true;
-  }
+
   int& iSelStart = pEvent->SelStart();
-  if (vp.IsSetting()) {
+  if (vp.IsSetting())
     vp >> iSelStart;
-  } else {
+  else
     vp << iSelStart;
-  }
+
   return true;
 }
 
-bool event::shift(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool event::shift(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   if (pEvent->Shift())
     vp << true;
@@ -227,81 +236,92 @@
   return true;
 }
 
-bool event::source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool event::source(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   vp << pEvent->Source()->GetJSObject();
   return true;
 }
 
-bool event::target(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool event::target(IJS_EventContext* cc,
+                   CJS_PropValue& vp,
+                   CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   vp << pEvent->Target_Field()->GetJSObject();
   return true;
 }
 
-bool event::targetName(IJS_Context* cc,
+bool event::targetName(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
+  CJS_EventContext* pContext = (CJS_EventContext*)cc;
   CJS_EventHandler* pEvent = pContext->GetEventHandler();
 
   vp << pEvent->TargetName();
   return true;
 }
 
-bool event::type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
+bool event::type(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   vp << pEvent->Type();
   return true;
 }
 
-bool event::value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError) {
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+bool event::value(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError) {
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   if (wcscmp((const wchar_t*)pEvent->Type(), L"Field") != 0)
     return false;
+
   if (!pEvent->m_pValue)
     return false;
+
   CFX_WideString& val = pEvent->Value();
-  if (vp.IsSetting()) {
+  if (vp.IsSetting())
     vp >> val;
-  } else {
+  else
     vp << val;
-  }
+
   return true;
 }
 
-bool event::willCommit(IJS_Context* cc,
+bool event::willCommit(IJS_EventContext* cc,
                        CJS_PropValue& vp,
                        CFX_WideString& sError) {
   if (!vp.IsGetting())
     return false;
 
-  CJS_Context* pContext = (CJS_Context*)cc;
-  CJS_EventHandler* pEvent = pContext->GetEventHandler();
+  CJS_EventHandler* pEvent =
+      static_cast<CJS_EventContext*>(cc)->GetEventHandler();
 
   if (pEvent->WillCommit())
     vp << true;
   else
     vp << false;
+
   return true;
 }
diff --git a/fpdfsdk/javascript/event.h b/fpdfsdk/javascript/event.h
index 6719494..54ba3f0 100644
--- a/fpdfsdk/javascript/event.h
+++ b/fpdfsdk/javascript/event.h
@@ -15,26 +15,46 @@
   ~event() override;
 
  public:
-  bool change(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool changeEx(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool commitKey(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool fieldFull(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool keyDown(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool modifier(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool name(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool rc(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool richChange(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool richChangeEx(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool richValue(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool selEnd(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool selStart(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool shift(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool source(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool target(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool targetName(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool type(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool value(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
-  bool willCommit(IJS_Context* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool change(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool changeEx(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool commitKey(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool fieldFull(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool keyDown(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool modifier(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool name(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool rc(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool richChange(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError);
+  bool richChangeEx(IJS_EventContext* cc,
+                    CJS_PropValue& vp,
+                    CFX_WideString& sError);
+  bool richValue(IJS_EventContext* cc,
+                 CJS_PropValue& vp,
+                 CFX_WideString& sError);
+  bool selEnd(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool selStart(IJS_EventContext* cc,
+                CJS_PropValue& vp,
+                CFX_WideString& sError);
+  bool shift(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool source(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool target(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool targetName(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError);
+  bool type(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool value(IJS_EventContext* cc, CJS_PropValue& vp, CFX_WideString& sError);
+  bool willCommit(IJS_EventContext* cc,
+                  CJS_PropValue& vp,
+                  CFX_WideString& sError);
 };
 
 class CJS_Event : public CJS_Object {
diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp
index aca8697..06b9d67 100644
--- a/fpdfsdk/javascript/global.cpp
+++ b/fpdfsdk/javascript/global.cpp
@@ -14,7 +14,7 @@
 #include "fpdfsdk/javascript/JS_GlobalData.h"
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 #include "fpdfsdk/javascript/resource.h"
 
 BEGIN_JS_STATIC_CONST(CJS_Global)
@@ -66,7 +66,7 @@
   return CFX_WideString(propname) != L"setPersistent";
 }
 
-bool JSGlobalAlternate::DelProperty(IJS_Context* cc,
+bool JSGlobalAlternate::DelProperty(IJS_EventContext* cc,
                                     const FX_WCHAR* propname,
                                     CFX_WideString& sError) {
   auto it = m_mapGlobal.find(CFX_ByteString::FromUnicode(propname));
@@ -77,11 +77,11 @@
   return true;
 }
 
-bool JSGlobalAlternate::DoProperty(IJS_Context* cc,
+bool JSGlobalAlternate::DoProperty(IJS_EventContext* cc,
                                    const FX_WCHAR* propname,
                                    CJS_PropValue& vp,
                                    CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   if (vp.IsSetting()) {
     CFX_ByteString sPropName = CFX_ByteString::FromUnicode(propname);
     switch (vp.GetJSValue()->GetType()) {
@@ -157,7 +157,7 @@
   return false;
 }
 
-bool JSGlobalAlternate::setPersistent(IJS_Context* cc,
+bool JSGlobalAlternate::setPersistent(IJS_EventContext* cc,
                                       const std::vector<CJS_Value>& params,
                                       CJS_Value& vRet,
                                       CFX_WideString& sError) {
@@ -166,7 +166,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   auto it = m_mapGlobal.find(params[0].ToCFXByteString(pRuntime));
   if (it != m_mapGlobal.end()) {
     JSGlobalData* pData = it->second;
@@ -232,7 +232,7 @@
   }
 }
 
-void JSGlobalAlternate::CommitGlobalPersisitentVariables(IJS_Context* cc) {
+void JSGlobalAlternate::CommitGlobalPersisitentVariables(IJS_EventContext* cc) {
   for (auto it = m_mapGlobal.begin(); it != m_mapGlobal.end(); ++it) {
     CFX_ByteString name = it->first;
     JSGlobalData* pData = it->second;
@@ -269,10 +269,10 @@
   }
 }
 
-void JSGlobalAlternate::ObjectToArray(IJS_Context* cc,
+void JSGlobalAlternate::ObjectToArray(IJS_EventContext* cc,
                                       v8::Local<v8::Object> pObj,
                                       CJS_GlobalVariableArray& array) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   std::vector<CFX_WideString> pKeyList = pRuntime->GetObjectPropertyNames(pObj);
   for (const auto& ws : pKeyList) {
     CFX_ByteString sKey = ws.UTF8Encode();
diff --git a/fpdfsdk/javascript/global.h b/fpdfsdk/javascript/global.h
index 9a6568b..cc5601c 100644
--- a/fpdfsdk/javascript/global.h
+++ b/fpdfsdk/javascript/global.h
@@ -35,23 +35,23 @@
   explicit JSGlobalAlternate(CJS_Object* pJSObject);
   ~JSGlobalAlternate() override;
 
-  bool setPersistent(IJS_Context* cc,
+  bool setPersistent(IJS_EventContext* cc,
                      const std::vector<CJS_Value>& params,
                      CJS_Value& vRet,
                      CFX_WideString& sError);
   bool QueryProperty(const FX_WCHAR* propname);
-  bool DoProperty(IJS_Context* cc,
+  bool DoProperty(IJS_EventContext* cc,
                   const FX_WCHAR* propname,
                   CJS_PropValue& vp,
                   CFX_WideString& sError);
-  bool DelProperty(IJS_Context* cc,
+  bool DelProperty(IJS_EventContext* cc,
                    const FX_WCHAR* propname,
                    CFX_WideString& sError);
   void Initial(CPDFSDK_FormFillEnvironment* pFormFillEnv);
 
  private:
   void UpdateGlobalPersistentVariables();
-  void CommitGlobalPersisitentVariables(IJS_Context* cc);
+  void CommitGlobalPersisitentVariables(IJS_EventContext* cc);
   void DestroyGlobalPersisitentVariables();
   bool SetGlobalVariables(const CFX_ByteString& propname,
                           JS_GlobalDataType nType,
@@ -60,7 +60,7 @@
                           const CFX_ByteString& sData,
                           v8::Local<v8::Object> pData,
                           bool bDefaultPersistent);
-  void ObjectToArray(IJS_Context* cc,
+  void ObjectToArray(IJS_EventContext* cc,
                      v8::Local<v8::Object> pObj,
                      CJS_GlobalVariableArray& array);
   void PutObjectProperty(v8::Local<v8::Object> obj, CJS_KeyValue* pData);
diff --git a/fpdfsdk/javascript/ijs_context.h b/fpdfsdk/javascript/ijs_event_context.h
similarity index 94%
rename from fpdfsdk/javascript/ijs_context.h
rename to fpdfsdk/javascript/ijs_event_context.h
index 2d2248f..8428072 100644
--- a/fpdfsdk/javascript/ijs_context.h
+++ b/fpdfsdk/javascript/ijs_event_context.h
@@ -4,8 +4,8 @@
 
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_
-#define FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_
+#ifndef FPDFSDK_JAVASCRIPT_IJS_EVENT_CONTEXT_H_
+#define FPDFSDK_JAVASCRIPT_IJS_EVENT_CONTEXT_H_
 
 #include "core/fxcrt/fx_string.h"
 #include "core/fxcrt/fx_system.h"
@@ -15,8 +15,10 @@
 class CPDFSDK_Annot;
 class CPDFSDK_FormFillEnvironment;
 
-// Records the details of an event and triggers JS execution for it.
-class IJS_Context {
+// Records the details of an event and triggers JS execution for it. There
+// can be more than one of these at any given time, as JS callbacks to C++
+// may trigger new events on top of one another.
+class IJS_EventContext {
  public:
   virtual bool RunScript(const CFX_WideString& script,
                          CFX_WideString* info) = 0;
@@ -126,7 +128,7 @@
   virtual void OnExternal_Exec() = 0;
 
  protected:
-  virtual ~IJS_Context() {}
+  virtual ~IJS_EventContext() {}
 };
 
-#endif  // FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_
+#endif  // FPDFSDK_JAVASCRIPT_IJS_EVENT_CONTEXT_H_
diff --git a/fpdfsdk/javascript/ijs_runtime.h b/fpdfsdk/javascript/ijs_runtime.h
index 027c500..a0e69d8 100644
--- a/fpdfsdk/javascript/ijs_runtime.h
+++ b/fpdfsdk/javascript/ijs_runtime.h
@@ -15,7 +15,7 @@
 #endif  // PDF_ENABLE_XFA
 
 class CPDFSDK_FormFillEnvironment;
-class IJS_Context;
+class IJS_EventContext;
 
 // Owns the FJXS objects needed to actually execute JS.
 class IJS_Runtime {
@@ -25,12 +25,10 @@
   static IJS_Runtime* Create(CPDFSDK_FormFillEnvironment* pFormFillEnv);
   virtual ~IJS_Runtime() {}
 
-  virtual IJS_Context* NewContext() = 0;
-  virtual void ReleaseContext(IJS_Context* pContext) = 0;
-  virtual IJS_Context* GetCurrentContext() = 0;
-
+  virtual IJS_EventContext* NewEventContext() = 0;
+  virtual void ReleaseEventContext(IJS_EventContext* pContext) = 0;
+  virtual IJS_EventContext* GetCurrentEventContext() = 0;
   virtual CPDFSDK_FormFillEnvironment* GetFormFillEnv() const = 0;
-
   virtual int ExecuteScript(const CFX_WideString& script,
                             CFX_WideString* info) = 0;
 
diff --git a/fpdfsdk/javascript/report.cpp b/fpdfsdk/javascript/report.cpp
index ba6e97d..87ed416 100644
--- a/fpdfsdk/javascript/report.cpp
+++ b/fpdfsdk/javascript/report.cpp
@@ -29,7 +29,7 @@
 
 Report::~Report() {}
 
-bool Report::writeText(IJS_Context* cc,
+bool Report::writeText(IJS_EventContext* cc,
                        const std::vector<CJS_Value>& params,
                        CJS_Value& vRet,
                        CFX_WideString& sError) {
@@ -37,7 +37,7 @@
   return true;
 }
 
-bool Report::save(IJS_Context* cc,
+bool Report::save(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError) {
diff --git a/fpdfsdk/javascript/report.h b/fpdfsdk/javascript/report.h
index fef2369..566b2e8 100644
--- a/fpdfsdk/javascript/report.h
+++ b/fpdfsdk/javascript/report.h
@@ -17,11 +17,11 @@
   ~Report() override;
 
  public:
-  bool save(IJS_Context* cc,
+  bool save(IJS_EventContext* cc,
             const std::vector<CJS_Value>& params,
             CJS_Value& vRet,
             CFX_WideString& sError);
-  bool writeText(IJS_Context* cc,
+  bool writeText(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError);
diff --git a/fpdfsdk/javascript/resource.h b/fpdfsdk/javascript/resource.h
index 663cf3b..af7788f 100644
--- a/fpdfsdk/javascript/resource.h
+++ b/fpdfsdk/javascript/resource.h
@@ -9,7 +9,7 @@
 
 #include "core/fxcrt/fx_string.h"
 
-class CJS_Context;
+class CJS_EventContext;
 
 #define IDS_STRING_JSALERT 25613
 #define IDS_STRING_JSPARAMERROR 25614
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 3967ceb..0baca53 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -18,7 +18,7 @@
 #include "fpdfsdk/javascript/JS_Object.h"
 #include "fpdfsdk/javascript/JS_Value.h"
 #include "fpdfsdk/javascript/PublicMethods.h"
-#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_event_context.h"
 #include "fpdfsdk/javascript/cjs_runtime.h"
 #include "fpdfsdk/javascript/resource.h"
 
@@ -114,11 +114,11 @@
 
 util::~util() {}
 
-bool util::printf(IJS_Context* cc,
+bool util::printf(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int iSize = params.size();
   if (iSize < 1)
     return false;
@@ -177,7 +177,7 @@
   return true;
 }
 
-bool util::printd(IJS_Context* cc,
+bool util::printd(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError) {
@@ -185,7 +185,7 @@
   if (iSize < 2)
     return false;
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   CJS_Value p1 = params[0];
   CJS_Value p2 = params[1];
   CJS_Date jsDate;
@@ -307,7 +307,7 @@
   return false;
 }
 
-bool util::printx(IJS_Context* cc,
+bool util::printx(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError) {
@@ -316,7 +316,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   vRet = CJS_Value(pRuntime, printx(params[0].ToCFXWideString(pRuntime),
                                     params[1].ToCFXWideString(pRuntime))
                                  .c_str());
@@ -425,11 +425,11 @@
   return wsResult;
 }
 
-bool util::scand(IJS_Context* cc,
+bool util::scand(IJS_EventContext* cc,
                  const std::vector<CJS_Value>& params,
                  CJS_Value& vRet,
                  CFX_WideString& sError) {
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int iSize = params.size();
   if (iSize < 2)
     return false;
@@ -450,7 +450,7 @@
   return true;
 }
 
-bool util::byteToChar(IJS_Context* cc,
+bool util::byteToChar(IJS_EventContext* cc,
                       const std::vector<CJS_Value>& params,
                       CJS_Value& vRet,
                       CFX_WideString& sError) {
@@ -459,7 +459,7 @@
     return false;
   }
 
-  CJS_Runtime* pRuntime = CJS_Runtime::FromContext(cc);
+  CJS_Runtime* pRuntime = CJS_Runtime::FromEventContext(cc);
   int arg = params[0].ToInt(pRuntime);
   if (arg < 0 || arg > 255) {
     sError = JSGetStringFromID(IDS_STRING_JSVALUEERROR);
diff --git a/fpdfsdk/javascript/util.h b/fpdfsdk/javascript/util.h
index 80763d1..e7adb20 100644
--- a/fpdfsdk/javascript/util.h
+++ b/fpdfsdk/javascript/util.h
@@ -17,23 +17,23 @@
   explicit util(CJS_Object* pJSObject);
   ~util() override;
 
-  bool printd(IJS_Context* cc,
+  bool printd(IJS_EventContext* cc,
               const std::vector<CJS_Value>& params,
               CJS_Value& vRet,
               CFX_WideString& sError);
-  bool printf(IJS_Context* cc,
+  bool printf(IJS_EventContext* cc,
               const std::vector<CJS_Value>& params,
               CJS_Value& vRet,
               CFX_WideString& sError);
-  bool printx(IJS_Context* cc,
+  bool printx(IJS_EventContext* cc,
               const std::vector<CJS_Value>& params,
               CJS_Value& vRet,
               CFX_WideString& sError);
-  bool scand(IJS_Context* cc,
+  bool scand(IJS_EventContext* cc,
              const std::vector<CJS_Value>& params,
              CJS_Value& vRet,
              CFX_WideString& sError);
-  bool byteToChar(IJS_Context* cc,
+  bool byteToChar(IJS_EventContext* cc,
                   const std::vector<CJS_Value>& params,
                   CJS_Value& vRet,
                   CFX_WideString& sError);