summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-03-31 20:03:24 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-31 20:03:24 -0700
commit64376be4aac4710848b36b823fd98aae75095336 (patch)
treeb616a397d96e05b9e30ccc7de2e4e6a4334a6a59 /fpdfsdk/javascript
parent777b333109db7fceb5f2ca1fc521ced7f863fa18 (diff)
downloadpdfium-64376be4aac4710848b36b823fd98aae75095336.tar.xz
Move the fpdfsdk/include/javascript folder
This CL splits the IJavaScript.h file into the two inner classes and puts them in the fpdfsdk/javascript folder. Review URL: https://codereview.chromium.org/1847583004
Diffstat (limited to 'fpdfsdk/javascript')
-rw-r--r--fpdfsdk/javascript/Consts.cpp1
-rw-r--r--fpdfsdk/javascript/Consts.h22
-rw-r--r--fpdfsdk/javascript/Document.cpp10
-rw-r--r--fpdfsdk/javascript/Field.cpp5
-rw-r--r--fpdfsdk/javascript/Icon.cpp3
-rw-r--r--fpdfsdk/javascript/JS_EventHandler.cpp7
-rw-r--r--fpdfsdk/javascript/JS_GlobalData.cpp5
-rw-r--r--fpdfsdk/javascript/JS_Object.cpp5
-rw-r--r--fpdfsdk/javascript/JS_Object.h4
-rw-r--r--fpdfsdk/javascript/JS_Runtime_Stub.cpp5
-rw-r--r--fpdfsdk/javascript/JS_Value.cpp2
-rw-r--r--fpdfsdk/javascript/PublicMethods.cpp20
-rw-r--r--fpdfsdk/javascript/app.cpp5
-rw-r--r--fpdfsdk/javascript/cjs_context.cpp (renamed from fpdfsdk/javascript/JS_Context.cpp)7
-rw-r--r--fpdfsdk/javascript/cjs_context.h (renamed from fpdfsdk/javascript/JS_Context.h)9
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp (renamed from fpdfsdk/javascript/JS_Runtime.cpp)7
-rw-r--r--fpdfsdk/javascript/cjs_runtime.h (renamed from fpdfsdk/javascript/JS_Runtime.h)8
-rw-r--r--fpdfsdk/javascript/color.cpp7
-rw-r--r--fpdfsdk/javascript/console.cpp5
-rw-r--r--fpdfsdk/javascript/event.cpp5
-rw-r--r--fpdfsdk/javascript/global.cpp5
-rw-r--r--fpdfsdk/javascript/ijs_context.h134
-rw-r--r--fpdfsdk/javascript/ijs_runtime.h48
-rw-r--r--fpdfsdk/javascript/report.cpp3
-rw-r--r--fpdfsdk/javascript/util.cpp5
25 files changed, 224 insertions, 113 deletions
diff --git a/fpdfsdk/javascript/Consts.cpp b/fpdfsdk/javascript/Consts.cpp
index 3fdbb40ccb..8aeb0b9239 100644
--- a/fpdfsdk/javascript/Consts.cpp
+++ b/fpdfsdk/javascript/Consts.cpp
@@ -6,7 +6,6 @@
#include "fpdfsdk/javascript/Consts.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_Object.h"
#include "fpdfsdk/javascript/JS_Value.h"
diff --git a/fpdfsdk/javascript/Consts.h b/fpdfsdk/javascript/Consts.h
index 165e91ffaa..e358cb9341 100644
--- a/fpdfsdk/javascript/Consts.h
+++ b/fpdfsdk/javascript/Consts.h
@@ -9,8 +9,6 @@
#include "fpdfsdk/javascript/JS_Define.h"
-/* ------------------------------ border ------------------------------ */
-
class CJS_Border : public CJS_Object {
public:
explicit CJS_Border(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
@@ -19,8 +17,6 @@ class CJS_Border : public CJS_Object {
DECLARE_JS_CLASS_CONST();
};
-/* ------------------------------ display ------------------------------ */
-
class CJS_Display : public CJS_Object {
public:
explicit CJS_Display(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
@@ -29,8 +25,6 @@ class CJS_Display : public CJS_Object {
DECLARE_JS_CLASS_CONST();
};
-/* ------------------------------ font ------------------------------ */
-
class CJS_Font : public CJS_Object {
public:
explicit CJS_Font(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
@@ -39,8 +33,6 @@ class CJS_Font : public CJS_Object {
DECLARE_JS_CLASS_CONST();
};
-/* ------------------------------ highlight ------------------------------ */
-
class CJS_Highlight : public CJS_Object {
public:
explicit CJS_Highlight(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
@@ -49,8 +41,6 @@ class CJS_Highlight : public CJS_Object {
DECLARE_JS_CLASS_CONST();
};
-/* ------------------------------ position ------------------------------ */
-
class CJS_Position : public CJS_Object {
public:
explicit CJS_Position(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
@@ -59,8 +49,6 @@ class CJS_Position : public CJS_Object {
DECLARE_JS_CLASS_CONST();
};
-/* ------------------------------ scaleHow ------------------------------ */
-
class CJS_ScaleHow : public CJS_Object {
public:
explicit CJS_ScaleHow(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
@@ -69,8 +57,6 @@ class CJS_ScaleHow : public CJS_Object {
DECLARE_JS_CLASS_CONST();
};
-/* ------------------------------ scaleWhen ------------------------------ */
-
class CJS_ScaleWhen : public CJS_Object {
public:
explicit CJS_ScaleWhen(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
@@ -79,8 +65,6 @@ class CJS_ScaleWhen : public CJS_Object {
DECLARE_JS_CLASS_CONST();
};
-/* ------------------------------ style ------------------------------ */
-
class CJS_Style : public CJS_Object {
public:
explicit CJS_Style(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
@@ -89,8 +73,6 @@ class CJS_Style : public CJS_Object {
DECLARE_JS_CLASS_CONST();
};
-/* ------------------------------ zoomtype ------------------------------ */
-
class CJS_Zoomtype : public CJS_Object {
public:
explicit CJS_Zoomtype(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
@@ -99,15 +81,11 @@ class CJS_Zoomtype : public CJS_Object {
DECLARE_JS_CLASS_CONST();
};
-/* ------------------------------ CJS_GlobalConsts -------------------------- */
-
class CJS_GlobalConsts : public CJS_Object {
public:
static void DefineJSObjects(CJS_Runtime* pRuntime);
};
-/* ------------------------------ CJS_GlobalArrays -------------------------- */
-
class CJS_GlobalArrays : public CJS_Object {
public:
static void DefineJSObjects(CJS_Runtime* pRuntmie);
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 70b4ef7e03..762ba71cf2 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -12,16 +12,15 @@
#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
#include "fpdfsdk/include/fsdk_mgr.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/javascript/Field.h"
#include "fpdfsdk/javascript/Icon.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_Object.h"
-#include "fpdfsdk/javascript/JS_Runtime.h"
#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/app.h"
+#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
#include "fpdfsdk/javascript/resource.h"
#include "third_party/base/numerics/safe_math.h"
@@ -54,8 +53,6 @@ PrintParamsObj::PrintParamsObj(CJS_Object* pJSObject)
bAnnotations = TRUE;
}
-/* ---------------------- Document ---------------------- */
-
#define MINWIDTH 5.0f
#define MINHEIGHT 5.0f
@@ -148,9 +145,6 @@ void CJS_Document::InitInstance(IJS_Runtime* pIRuntime) {
pDoc->SetIsolate(pRuntime->GetIsolate());
}
-/* --------------------------------- Document ---------------------------------
- */
-
Document::Document(CJS_Object* pJSObject)
: CJS_EmbedObj(pJSObject),
m_isolate(NULL),
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 5b8750d88e..158d4d6a7f 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -14,16 +14,15 @@
#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
#include "fpdfsdk/include/fsdk_mgr.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/javascript/Document.h"
#include "fpdfsdk/javascript/Icon.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_Object.h"
-#include "fpdfsdk/javascript/JS_Runtime.h"
#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/PublicMethods.h"
+#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
#include "fpdfsdk/javascript/color.h"
BEGIN_JS_STATIC_CONST(CJS_Field)
diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp
index d3c2ba8039..7dde8bf0b5 100644
--- a/fpdfsdk/javascript/Icon.cpp
+++ b/fpdfsdk/javascript/Icon.cpp
@@ -6,13 +6,10 @@
#include "fpdfsdk/javascript/Icon.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_Object.h"
#include "fpdfsdk/javascript/JS_Value.h"
-/* ---------------------- Icon ---------------------- */
-
BEGIN_JS_STATIC_CONST(CJS_Icon)
END_JS_STATIC_CONST()
diff --git a/fpdfsdk/javascript/JS_EventHandler.cpp b/fpdfsdk/javascript/JS_EventHandler.cpp
index 0dffa7de54..5984946f6d 100644
--- a/fpdfsdk/javascript/JS_EventHandler.cpp
+++ b/fpdfsdk/javascript/JS_EventHandler.cpp
@@ -6,16 +6,13 @@
#include "fpdfsdk/javascript/JS_EventHandler.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/javascript/Document.h"
#include "fpdfsdk/javascript/Field.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_Object.h"
-#include "fpdfsdk/javascript/JS_Runtime.h"
#include "fpdfsdk/javascript/JS_Value.h"
-
-/* ---------------------------- CJS_EventHandler ---------------------------- */
+#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
CJS_EventHandler::CJS_EventHandler(CJS_Context* pContext)
: m_pJSContext(pContext),
diff --git a/fpdfsdk/javascript/JS_GlobalData.cpp b/fpdfsdk/javascript/JS_GlobalData.cpp
index 3a9e52175a..fe3475c2b1 100644
--- a/fpdfsdk/javascript/JS_GlobalData.cpp
+++ b/fpdfsdk/javascript/JS_GlobalData.cpp
@@ -7,13 +7,10 @@
#include "fpdfsdk/javascript/JS_GlobalData.h"
#include "core/fdrm/crypto/include/fx_crypt.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "third_party/base/stl_util.h"
#define JS_MAXGLOBALDATA (1024 * 4 - 8)
-/* --------------------- CJS_GlobalVariableArray --------------------- */
-
CJS_GlobalVariableArray::CJS_GlobalVariableArray() {}
CJS_GlobalVariableArray::~CJS_GlobalVariableArray() {
@@ -81,8 +78,6 @@ void CJS_GlobalVariableArray::Empty() {
array.RemoveAll();
}
-/* -------------------------- CJS_GlobalData -------------------------- */
-
#define READER_JS_GLOBALDATA_FILENAME L"Reader_JsGlobal.Data"
#define PHANTOM_JS_GLOBALDATA_FILENAME L"Phantom_JsGlobal.Data"
#define SDK_JS_GLOBALDATA_FILENAME L"SDK_JsGlobal.Data"
diff --git a/fpdfsdk/javascript/JS_Object.cpp b/fpdfsdk/javascript/JS_Object.cpp
index 9bfa857cb9..d85cc1dbe4 100644
--- a/fpdfsdk/javascript/JS_Object.cpp
+++ b/fpdfsdk/javascript/JS_Object.cpp
@@ -6,10 +6,9 @@
#include "fpdfsdk/javascript/JS_Object.h"
-#include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment.
-#include "fpdfsdk/include/javascript/IJavaScript.h"
-#include "fpdfsdk/javascript/JS_Context.h"
+#include "fpdfsdk/include/fsdk_mgr.h"
#include "fpdfsdk/javascript/JS_Define.h"
+#include "fpdfsdk/javascript/cjs_context.h"
namespace {
diff --git a/fpdfsdk/javascript/JS_Object.h b/fpdfsdk/javascript/JS_Object.h
index da15199e34..e0ec23e79a 100644
--- a/fpdfsdk/javascript/JS_Object.h
+++ b/fpdfsdk/javascript/JS_Object.h
@@ -10,9 +10,9 @@
#include <map>
#include <memory>
-#include "fpdfsdk/include/fsdk_define.h" // For FX_UINT
+#include "fpdfsdk/include/fsdk_define.h"
#include "fpdfsdk/include/jsapi/fxjs_v8.h"
-#include "fpdfsdk/javascript/JS_Runtime.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
class CJS_Context;
class CJS_Object;
diff --git a/fpdfsdk/javascript/JS_Runtime_Stub.cpp b/fpdfsdk/javascript/JS_Runtime_Stub.cpp
index d7962807c9..7d201d1b56 100644
--- a/fpdfsdk/javascript/JS_Runtime_Stub.cpp
+++ b/fpdfsdk/javascript/JS_Runtime_Stub.cpp
@@ -6,8 +6,9 @@
#include <memory>
-#include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment.
-#include "fpdfsdk/include/javascript/IJavaScript.h"
+#include "fpdfsdk/include/fsdk_mgr.h"
+#include "fpdfsdk/javascript/ijs_context.h"
+#include "fpdfsdk/javascript/ijs_runtime.h"
class CJS_ContextStub final : public IJS_Context {
public:
diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp
index 4d2a1d44a8..0b31494b75 100644
--- a/fpdfsdk/javascript/JS_Value.cpp
+++ b/fpdfsdk/javascript/JS_Value.cpp
@@ -282,8 +282,6 @@ FX_BOOL CJS_Value::ConvertToDate(CJS_Date& date) const {
return FALSE;
}
-/* ---------------------------- CJS_PropValue ---------------------------- */
-
CJS_PropValue::CJS_PropValue(const CJS_Value& value)
: CJS_Value(value), m_bIsSetting(0) {}
diff --git a/fpdfsdk/javascript/PublicMethods.cpp b/fpdfsdk/javascript/PublicMethods.cpp
index 62659e4163..b928aab31d 100644
--- a/fpdfsdk/javascript/PublicMethods.cpp
+++ b/fpdfsdk/javascript/PublicMethods.cpp
@@ -11,15 +11,14 @@
#include <vector>
#include "core/fxcrt/include/fx_ext.h"
-#include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment.
-#include "fpdfsdk/include/javascript/IJavaScript.h"
+#include "fpdfsdk/include/fsdk_mgr.h"
#include "fpdfsdk/javascript/Field.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_Object.h"
-#include "fpdfsdk/javascript/JS_Runtime.h"
#include "fpdfsdk/javascript/JS_Value.h"
+#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
#include "fpdfsdk/javascript/color.h"
#include "fpdfsdk/javascript/resource.h"
#include "fpdfsdk/javascript/util.h"
@@ -739,8 +738,6 @@ CFX_WideString CJS_PublicMethods::MakeFormatDate(double dDate,
return sRet;
}
-/* -------------------------------------------------------------------------- */
-
// function AFNumber_Format(nDec, sepStyle, negStyle, currStyle, strCurrency,
// bCurrencyPrepend)
FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
@@ -780,7 +777,6 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
if (iNegStyle < 0 || iNegStyle > 3)
iNegStyle = 0;
- //////////////////////////////////////////////////////
// for processing decimal places
strValue.Replace(",", ".");
double dValue = atof(strValue);
@@ -813,7 +809,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
}
iMax = iDec2 + 1;
}
- ///////////////////////////////////////////////////////
+
// for processing seperator style
if (iDec2 < iMax) {
if (iSepStyle == 0 || iSepStyle == 1) {
@@ -840,9 +836,7 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
}
}
- //////////////////////////////////////////////////////////////////////
// for processing currency string
-
Value = CFX_WideString::FromLocal(strValue);
std::wstring strValue2 = Value.c_str();
@@ -851,7 +845,6 @@ FX_BOOL CJS_PublicMethods::AFNumber_Format(IJS_Context* cc,
else
strValue2 = strValue2 + wstrCurrency;
- /////////////////////////////////////////////////////////////////////////
// for processing negative style
if (iNegative) {
if (iNegStyle == 0) {
@@ -1069,7 +1062,6 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(
if (iSepStyle < 0 || iSepStyle > 3)
iSepStyle = 0;
- //////////////////////////////////////////////////////
// for processing decimal places
double dValue = atof(strValue);
dValue *= 100;
@@ -1097,7 +1089,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(
}
iMax = iDec2 + 1;
}
- ///////////////////////////////////////////////////////
+
// for processing seperator style
if (iDec2 < iMax) {
if (iSepStyle == 0 || iSepStyle == 1) {
@@ -1123,7 +1115,7 @@ FX_BOOL CJS_PublicMethods::AFPercent_Format(
iMax++;
}
}
- ////////////////////////////////////////////////////////////////////
+
// negative mark
if (iNegative)
strValue = "-" + strValue;
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index 83836759d7..dd706ebd8c 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -10,14 +10,13 @@
#include <vector>
#include "fpdfsdk/include/fsdk_mgr.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/javascript/Document.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_Object.h"
-#include "fpdfsdk/javascript/JS_Runtime.h"
#include "fpdfsdk/javascript/JS_Value.h"
+#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
#include "fpdfsdk/javascript/resource.h"
BEGIN_JS_STATIC_CONST(CJS_TimerObj)
diff --git a/fpdfsdk/javascript/JS_Context.cpp b/fpdfsdk/javascript/cjs_context.cpp
index c382b07b8b..66a3e0783d 100644
--- a/fpdfsdk/javascript/JS_Context.cpp
+++ b/fpdfsdk/javascript/cjs_context.cpp
@@ -4,15 +4,12 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/javascript/JS_Context.h"
+#include "fpdfsdk/javascript/cjs_context.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
-#include "fpdfsdk/javascript/JS_Runtime.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
#include "fpdfsdk/javascript/resource.h"
-/* -------------------------- CJS_Context -------------------------- */
-
CJS_Context::CJS_Context(CJS_Runtime* pRuntime)
: m_pRuntime(pRuntime), m_bBusy(FALSE), m_bMsgBoxEnable(TRUE) {
m_pEventHandler = new CJS_EventHandler(this);
diff --git a/fpdfsdk/javascript/JS_Context.h b/fpdfsdk/javascript/cjs_context.h
index 5aeba27fca..64b97d616e 100644
--- a/fpdfsdk/javascript/JS_Context.h
+++ b/fpdfsdk/javascript/cjs_context.h
@@ -4,15 +4,16 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FPDFSDK_JAVASCRIPT_JS_CONTEXT_H_
-#define FPDFSDK_JAVASCRIPT_JS_CONTEXT_H_
+#ifndef FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_
+#define FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_
#include "core/fxcrt/include/fx_string.h"
#include "core/fxcrt/include/fx_system.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
+#include "fpdfsdk/javascript/ijs_context.h"
class CJS_EventHandler;
class CJS_Runtime;
+class CPDFDoc_Environment;
class CJS_Context : public IJS_Context {
public:
@@ -134,4 +135,4 @@ class CJS_Context : public IJS_Context {
FX_BOOL m_bMsgBoxEnable;
};
-#endif // FPDFSDK_JAVASCRIPT_JS_CONTEXT_H_
+#endif // FPDFSDK_JAVASCRIPT_CJS_CONTEXT_H_
diff --git a/fpdfsdk/javascript/JS_Runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index 44fb340f2d..9c616e6c0e 100644
--- a/fpdfsdk/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -4,17 +4,16 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "fpdfsdk/javascript/JS_Runtime.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
#include <algorithm>
-#include "fpdfsdk/include/fsdk_mgr.h" // For CPDFDoc_Environment.
-#include "fpdfsdk/include/javascript/IJavaScript.h"
+#include "fpdfsdk/include/fsdk_mgr.h"
#include "fpdfsdk/javascript/Consts.h"
#include "fpdfsdk/javascript/Document.h"
#include "fpdfsdk/javascript/Field.h"
#include "fpdfsdk/javascript/Icon.h"
-#include "fpdfsdk/javascript/JS_Context.h"
+#include "fpdfsdk/javascript/cjs_context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_GlobalData.h"
diff --git a/fpdfsdk/javascript/JS_Runtime.h b/fpdfsdk/javascript/cjs_runtime.h
index 68dfb5b973..97e30e7eee 100644
--- a/fpdfsdk/javascript/JS_Runtime.h
+++ b/fpdfsdk/javascript/cjs_runtime.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef FPDFSDK_JAVASCRIPT_JS_RUNTIME_H_
-#define FPDFSDK_JAVASCRIPT_JS_RUNTIME_H_
+#ifndef FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_
+#define FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_
#include <map>
#include <memory>
@@ -14,9 +14,9 @@
#include <vector>
#include "core/fxcrt/include/fx_basic.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/include/jsapi/fxjs_v8.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
+#include "fpdfsdk/javascript/ijs_runtime.h"
class CJS_Context;
@@ -89,4 +89,4 @@ class CJS_Runtime : public IJS_Runtime {
std::set<Observer*> m_observers;
};
-#endif // FPDFSDK_JAVASCRIPT_JS_RUNTIME_H_
+#endif // FPDFSDK_JAVASCRIPT_CJS_RUNTIME_H_
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index 2681a8693e..74c885b682 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -8,15 +8,12 @@
#include <vector>
-#include "fpdfsdk/include/javascript/IJavaScript.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_Object.h"
-#include "fpdfsdk/javascript/JS_Runtime.h"
#include "fpdfsdk/javascript/JS_Value.h"
-
-/* -------------------------- color -------------------------- */
+#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
BEGIN_JS_STATIC_CONST(CJS_Color)
END_JS_STATIC_CONST()
diff --git a/fpdfsdk/javascript/console.cpp b/fpdfsdk/javascript/console.cpp
index 4cce32d54a..a09fe4db17 100644
--- a/fpdfsdk/javascript/console.cpp
+++ b/fpdfsdk/javascript/console.cpp
@@ -8,14 +8,11 @@
#include <vector>
-#include "fpdfsdk/include/javascript/IJavaScript.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_Object.h"
#include "fpdfsdk/javascript/JS_Value.h"
-
-/* ------------------------ console ------------------------ */
+#include "fpdfsdk/javascript/cjs_context.h"
BEGIN_JS_STATIC_CONST(CJS_Console)
END_JS_STATIC_CONST()
diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp
index 7549451e6c..253a802c8f 100644
--- a/fpdfsdk/javascript/event.cpp
+++ b/fpdfsdk/javascript/event.cpp
@@ -6,15 +6,12 @@
#include "fpdfsdk/javascript/event.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/javascript/Field.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_Object.h"
#include "fpdfsdk/javascript/JS_Value.h"
-
-/* -------------------------- event -------------------------- */
+#include "fpdfsdk/javascript/cjs_context.h"
BEGIN_JS_STATIC_CONST(CJS_Event)
END_JS_STATIC_CONST()
diff --git a/fpdfsdk/javascript/global.cpp b/fpdfsdk/javascript/global.cpp
index 251e95bd48..fe974c7af2 100644
--- a/fpdfsdk/javascript/global.cpp
+++ b/fpdfsdk/javascript/global.cpp
@@ -9,17 +9,14 @@
#include <vector>
#include "core/fxcrt/include/fx_ext.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#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/resource.h"
-/* ---------------------------- global ---------------------------- */
-
// Helper class for compile-time calculation of hash values in order to
// avoid having global object initializers.
template <unsigned ACC, wchar_t... Ns>
diff --git a/fpdfsdk/javascript/ijs_context.h b/fpdfsdk/javascript/ijs_context.h
new file mode 100644
index 0000000000..365533c091
--- /dev/null
+++ b/fpdfsdk/javascript/ijs_context.h
@@ -0,0 +1,134 @@
+// Copyright 2016 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_IJS_CONTEXT_H_
+#define FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_Bookmark;
+class CPDF_FormField;
+class CPDFSDK_Annot;
+class CPDFSDK_Document;
+
+// Records the details of an event and triggers JS execution for it.
+class IJS_Context {
+ public:
+ virtual FX_BOOL RunScript(const CFX_WideString& script,
+ CFX_WideString* info) = 0;
+
+ virtual void OnApp_Init() = 0;
+
+ virtual void OnDoc_Open(CPDFSDK_Document* pDoc,
+ const CFX_WideString& strTargetName) = 0;
+ virtual void OnDoc_WillPrint(CPDFSDK_Document* pDoc) = 0;
+ virtual void OnDoc_DidPrint(CPDFSDK_Document* pDoc) = 0;
+ virtual void OnDoc_WillSave(CPDFSDK_Document* pDoc) = 0;
+ virtual void OnDoc_DidSave(CPDFSDK_Document* pDoc) = 0;
+ virtual void OnDoc_WillClose(CPDFSDK_Document* pDoc) = 0;
+
+ virtual void OnPage_Open(CPDFSDK_Document* pTarget) = 0;
+ virtual void OnPage_Close(CPDFSDK_Document* pTarget) = 0;
+ virtual void OnPage_InView(CPDFSDK_Document* pTarget) = 0;
+ virtual void OnPage_OutView(CPDFSDK_Document* pTarget) = 0;
+
+ virtual void OnField_MouseDown(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDF_FormField* pTarget) = 0;
+ virtual void OnField_MouseEnter(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDF_FormField* pTarget) = 0;
+ virtual void OnField_MouseExit(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDF_FormField* pTarget) = 0;
+ virtual void OnField_MouseUp(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDF_FormField* pTarget) = 0;
+ virtual void OnField_Focus(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDF_FormField* pTarget,
+ const CFX_WideString& Value) = 0;
+ virtual void OnField_Blur(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDF_FormField* pTarget,
+ const CFX_WideString& Value) = 0;
+
+ virtual void OnField_Calculate(CPDF_FormField* pSource,
+ CPDF_FormField* pTarget,
+ CFX_WideString& Value,
+ FX_BOOL& bRc) = 0;
+ virtual void OnField_Format(CPDF_FormField* pTarget,
+ CFX_WideString& Value,
+ FX_BOOL bWillCommit) = 0;
+ virtual void OnField_Keystroke(CFX_WideString& strChange,
+ const CFX_WideString& strChangeEx,
+ FX_BOOL KeyDown,
+ FX_BOOL bModifier,
+ int& nSelEnd,
+ int& nSelStart,
+ FX_BOOL bShift,
+ CPDF_FormField* pTarget,
+ CFX_WideString& Value,
+ FX_BOOL bWillCommit,
+ FX_BOOL bFieldFull,
+ FX_BOOL& bRc) = 0;
+ virtual void OnField_Validate(CFX_WideString& strChange,
+ const CFX_WideString& strChangeEx,
+ FX_BOOL bKeyDown,
+ FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDF_FormField* pTarget,
+ CFX_WideString& Value,
+ FX_BOOL& bRc) = 0;
+
+ virtual void OnScreen_Focus(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+ virtual void OnScreen_Blur(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+ virtual void OnScreen_Open(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+ virtual void OnScreen_Close(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+ virtual void OnScreen_MouseDown(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+ virtual void OnScreen_MouseUp(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+ virtual void OnScreen_MouseEnter(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+ virtual void OnScreen_MouseExit(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+ virtual void OnScreen_InView(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+ virtual void OnScreen_OutView(FX_BOOL bModifier,
+ FX_BOOL bShift,
+ CPDFSDK_Annot* pScreen) = 0;
+
+ virtual void OnBookmark_MouseUp(CPDF_Bookmark* pBookMark) = 0;
+ virtual void OnLink_MouseUp(CPDFSDK_Document* pTarget) = 0;
+
+ virtual void OnMenu_Exec(CPDFSDK_Document* pTarget,
+ const CFX_WideString&) = 0;
+ virtual void OnBatchExec(CPDFSDK_Document* pTarget) = 0;
+ virtual void OnConsole_Exec() = 0;
+ virtual void OnExternal_Exec() = 0;
+
+ virtual void EnableMessageBox(FX_BOOL bEnable) = 0;
+
+ protected:
+ virtual ~IJS_Context() {}
+};
+
+#endif // FPDFSDK_JAVASCRIPT_IJS_CONTEXT_H_
diff --git a/fpdfsdk/javascript/ijs_runtime.h b/fpdfsdk/javascript/ijs_runtime.h
new file mode 100644
index 0000000000..d4e9000cfd
--- /dev/null
+++ b/fpdfsdk/javascript/ijs_runtime.h
@@ -0,0 +1,48 @@
+// Copyright 2016 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_IJS_RUNTIME_H_
+#define FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+#ifdef PDF_ENABLE_XFA
+#include "xfa/fxjse/include/fxjse.h"
+#endif // PDF_ENABLE_XFA
+
+class CPDFDoc_Environment;
+class CPDFSDK_Document;
+class IJS_Context;
+
+// Owns the FJXS objects needed to actually execute JS.
+class IJS_Runtime {
+ public:
+ static void Initialize(unsigned int slot, void* isolate);
+ static IJS_Runtime* Create(CPDFDoc_Environment* pEnv);
+ virtual ~IJS_Runtime() {}
+
+ virtual IJS_Context* NewContext() = 0;
+ virtual void ReleaseContext(IJS_Context* pContext) = 0;
+ virtual IJS_Context* GetCurrentContext() = 0;
+ virtual void SetReaderDocument(CPDFSDK_Document* pReaderDoc) = 0;
+ virtual CPDFSDK_Document* GetReaderDocument() = 0;
+ virtual int Execute(IJS_Context* cc,
+ const wchar_t* script,
+ CFX_WideString* info) = 0;
+
+#ifdef PDF_ENABLE_XFA
+ virtual FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name,
+ FXJSE_HVALUE hValue) = 0;
+ virtual FX_BOOL SetHValueByName(const CFX_ByteStringC& utf8Name,
+ FXJSE_HVALUE hValue) = 0;
+#endif // PDF_ENABLE_XFA
+
+ protected:
+ IJS_Runtime() {}
+};
+
+#endif // FPDFSDK_JAVASCRIPT_IJS_RUNTIME_H_
diff --git a/fpdfsdk/javascript/report.cpp b/fpdfsdk/javascript/report.cpp
index ca7e199b0f..69cc336003 100644
--- a/fpdfsdk/javascript/report.cpp
+++ b/fpdfsdk/javascript/report.cpp
@@ -8,13 +8,10 @@
#include <vector>
-#include "fpdfsdk/include/javascript/IJavaScript.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_Object.h"
#include "fpdfsdk/javascript/JS_Value.h"
-/* ---------------------- report ---------------------- */
-
BEGIN_JS_STATIC_CONST(CJS_Report)
END_JS_STATIC_CONST()
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 0f50daf38c..adaa9c794b 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -13,14 +13,13 @@
#include <vector>
#include "core/fxcrt/include/fx_ext.h"
-#include "fpdfsdk/include/javascript/IJavaScript.h"
-#include "fpdfsdk/javascript/JS_Context.h"
#include "fpdfsdk/javascript/JS_Define.h"
#include "fpdfsdk/javascript/JS_EventHandler.h"
#include "fpdfsdk/javascript/JS_Object.h"
-#include "fpdfsdk/javascript/JS_Runtime.h"
#include "fpdfsdk/javascript/JS_Value.h"
#include "fpdfsdk/javascript/PublicMethods.h"
+#include "fpdfsdk/javascript/cjs_context.h"
+#include "fpdfsdk/javascript/cjs_runtime.h"
#include "fpdfsdk/javascript/resource.h"
#if _FX_OS_ == _FX_ANDROID_