summaryrefslogtreecommitdiff
path: root/fpdfsdk/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/javascript')
-rw-r--r--fpdfsdk/javascript/Document.cpp44
-rw-r--r--fpdfsdk/javascript/Document.h22
-rw-r--r--fpdfsdk/javascript/Field.cpp18
-rw-r--r--fpdfsdk/javascript/Field.h14
-rw-r--r--fpdfsdk/javascript/Icon.cpp12
-rw-r--r--fpdfsdk/javascript/Icon.h12
-rw-r--r--fpdfsdk/javascript/app.cpp33
-rw-r--r--fpdfsdk/javascript/app.h21
-rw-r--r--fpdfsdk/javascript/cjs_annot.cpp12
-rw-r--r--fpdfsdk/javascript/cjs_annot.h12
-rw-r--r--fpdfsdk/javascript/cjs_border.cpp7
-rw-r--r--fpdfsdk/javascript/cjs_border.h7
-rw-r--r--fpdfsdk/javascript/cjs_display.cpp7
-rw-r--r--fpdfsdk/javascript/cjs_display.h7
-rw-r--r--fpdfsdk/javascript/cjs_eventhandler.cpp8
-rw-r--r--fpdfsdk/javascript/cjs_font.cpp7
-rw-r--r--fpdfsdk/javascript/cjs_font.h7
-rw-r--r--fpdfsdk/javascript/cjs_global.cpp38
-rw-r--r--fpdfsdk/javascript/cjs_global.h21
-rw-r--r--fpdfsdk/javascript/cjs_globalarrays.cpp1
-rw-r--r--fpdfsdk/javascript/cjs_globalconsts.cpp1
-rw-r--r--fpdfsdk/javascript/cjs_highlight.cpp7
-rw-r--r--fpdfsdk/javascript/cjs_highlight.h7
-rw-r--r--fpdfsdk/javascript/cjs_position.cpp7
-rw-r--r--fpdfsdk/javascript/cjs_position.h7
-rw-r--r--fpdfsdk/javascript/cjs_runtime.cpp2
-rw-r--r--fpdfsdk/javascript/cjs_scalehow.cpp7
-rw-r--r--fpdfsdk/javascript/cjs_scalehow.h8
-rw-r--r--fpdfsdk/javascript/cjs_scalewhen.cpp7
-rw-r--r--fpdfsdk/javascript/cjs_scalewhen.h8
-rw-r--r--fpdfsdk/javascript/cjs_style.cpp7
-rw-r--r--fpdfsdk/javascript/cjs_style.h7
-rw-r--r--fpdfsdk/javascript/cjs_zoomtype.cpp7
-rw-r--r--fpdfsdk/javascript/cjs_zoomtype.h7
-rw-r--r--fpdfsdk/javascript/color.cpp11
-rw-r--r--fpdfsdk/javascript/color.h13
-rw-r--r--fpdfsdk/javascript/console.cpp11
-rw-r--r--fpdfsdk/javascript/console.h11
-rw-r--r--fpdfsdk/javascript/event.cpp7
-rw-r--r--fpdfsdk/javascript/event.h11
-rw-r--r--fpdfsdk/javascript/report.cpp7
-rw-r--r--fpdfsdk/javascript/report.h11
-rw-r--r--fpdfsdk/javascript/util.cpp27
-rw-r--r--fpdfsdk/javascript/util.h11
44 files changed, 298 insertions, 221 deletions
diff --git a/fpdfsdk/javascript/Document.cpp b/fpdfsdk/javascript/Document.cpp
index 232f6dd380..5ff66e9c8d 100644
--- a/fpdfsdk/javascript/Document.cpp
+++ b/fpdfsdk/javascript/Document.cpp
@@ -38,11 +38,17 @@
#include "third_party/base/numerics/safe_math.h"
#include "third_party/base/ptr_util.h"
-int CJS_PrintParamsObj::g_nObjDefnID = -1;
+int CJS_PrintParamsObj::ObjDefnID = -1;
+// static
+int CJS_PrintParamsObj::GetObjDefnID() {
+ return ObjDefnID;
+}
+
+// static
void CJS_PrintParamsObj::DefineJSObjects(CFXJS_Engine* pEngine,
FXJSOBJTYPE eObjType) {
- g_nObjDefnID =
+ ObjDefnID =
pEngine->DefineObj("PrintParamsObj", eObjType,
JSConstructor<CJS_PrintParamsObj, PrintParamsObj>,
JSDestructor<CJS_PrintParamsObj>);
@@ -145,15 +151,21 @@ JSMethodSpec CJS_Document::MethodSpecs[] = {
{"mailDoc", mailDoc_static},
{0, 0}};
-int CJS_Document::g_nObjDefnID = -1;
+int CJS_Document::ObjDefnID = -1;
+
+// static
+int CJS_Document::GetObjDefnID() {
+ return ObjDefnID;
+}
+// static
void CJS_Document::DefineJSObjects(CFXJS_Engine* pEngine,
FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("Document", eObjType,
- JSConstructor<CJS_Document, Document>,
- JSDestructor<CJS_Document>);
- DefineProps(pEngine, g_nObjDefnID, PropertySpecs);
- DefineMethods(pEngine, g_nObjDefnID, MethodSpecs);
+ ObjDefnID = pEngine->DefineObj("Document", eObjType,
+ JSConstructor<CJS_Document, Document>,
+ JSDestructor<CJS_Document>);
+ DefineProps(pEngine, ObjDefnID, PropertySpecs);
+ DefineMethods(pEngine, ObjDefnID, MethodSpecs);
}
void CJS_Document::InitInstance(IJS_Runtime* pIRuntime) {
@@ -283,7 +295,7 @@ CJS_Return Document::getField(CJS_Runtime* pRuntime,
return CJS_Return(pRuntime->NewUndefined());
v8::Local<v8::Object> pFieldObj =
- pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Field::GetObjDefnID());
if (pFieldObj.IsEmpty())
return CJS_Return(false);
@@ -393,7 +405,7 @@ CJS_Return Document::print(CJS_Runtime* pRuntime,
if (params[8]->IsObject()) {
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[8]);
if (CFXJS_Engine::GetObjDefnID(pObj) ==
- CJS_PrintParamsObj::g_nObjDefnID) {
+ CJS_PrintParamsObj::GetObjDefnID()) {
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[8]);
CJS_Object* pJSObj =
static_cast<CJS_Object*>(pRuntime->GetObjectPrivate(pObj));
@@ -1051,7 +1063,7 @@ CJS_Return Document::getAnnot(CJS_Runtime* pRuntime,
return CJS_Return(false);
v8::Local<v8::Object> pObj =
- pRuntime->NewFxDynamicObj(CJS_Annot::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Annot::GetObjDefnID());
if (pObj.IsEmpty())
return CJS_Return(false);
@@ -1088,7 +1100,7 @@ CJS_Return Document::getAnnots(
return CJS_Return(JSGetStringFromID(IDS_STRING_JSBADOBJECT));
v8::Local<v8::Object> pObj =
- pRuntime->NewFxDynamicObj(CJS_Annot::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Annot::GetObjDefnID());
if (pObj.IsEmpty())
return CJS_Return(false);
@@ -1142,7 +1154,7 @@ CJS_Return Document::addIcon(CJS_Runtime* pRuntime,
return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
v8::Local<v8::Object> pJSIcon = pRuntime->ToObject(params[1]);
- if (CFXJS_Engine::GetObjDefnID(pJSIcon) != CJS_Icon::g_nObjDefnID)
+ if (CFXJS_Engine::GetObjDefnID(pJSIcon) != CJS_Icon::GetObjDefnID())
return CJS_Return(JSGetStringFromID(IDS_STRING_JSTYPEERROR));
v8::Local<v8::Object> pObj = pRuntime->ToObject(params[1]);
@@ -1162,7 +1174,7 @@ CJS_Return Document::get_icons(CJS_Runtime* pRuntime) {
int i = 0;
for (const auto& name : m_IconNames) {
v8::Local<v8::Object> pObj =
- pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Icon::GetObjDefnID());
if (pObj.IsEmpty())
return CJS_Return(false);
@@ -1193,7 +1205,7 @@ CJS_Return Document::getIcon(CJS_Runtime* pRuntime,
return CJS_Return(false);
v8::Local<v8::Object> pObj =
- pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Icon::GetObjDefnID());
if (pObj.IsEmpty())
return CJS_Return(false);
@@ -1345,7 +1357,7 @@ CJS_Return Document::getPrintParams(
CJS_Runtime* pRuntime,
const std::vector<v8::Local<v8::Value>>& params) {
v8::Local<v8::Object> pRetObj =
- pRuntime->NewFxDynamicObj(CJS_PrintParamsObj::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_PrintParamsObj::GetObjDefnID());
if (pRetObj.IsEmpty())
return CJS_Return(false);
diff --git a/fpdfsdk/javascript/Document.h b/fpdfsdk/javascript/Document.h
index 0073042f25..6f9acd2cfb 100644
--- a/fpdfsdk/javascript/Document.h
+++ b/fpdfsdk/javascript/Document.h
@@ -34,13 +34,15 @@ class PrintParamsObj : public CJS_EmbedObj {
class CJS_PrintParamsObj : public CJS_Object {
public:
+ static int GetObjDefnID();
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_PrintParamsObj(v8::Local<v8::Object> pObject)
: CJS_Object(pObject) {}
~CJS_PrintParamsObj() override {}
- static int g_nObjDefnID;
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+ private:
+ static int ObjDefnID;
};
struct CJS_AnnotObj;
@@ -265,18 +267,15 @@ class Document : public CJS_EmbedObj {
class CJS_Document : public CJS_Object {
public:
+ static int GetObjDefnID();
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Document(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Document() override {}
// CJS_Object
void InitInstance(IJS_Runtime* pIRuntime) override;
- static int g_nObjDefnID;
- static JSPropertySpec PropertySpecs[];
- static JSMethodSpec MethodSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_PROP(ADBE, ADBE, Document);
JS_STATIC_PROP(author, author, Document);
JS_STATIC_PROP(baseURL, base_URL, Document);
@@ -352,6 +351,11 @@ class CJS_Document : public CJS_Object {
JS_STATIC_METHOD(submitForm, Document);
JS_STATIC_METHOD(syncAnnotScan, Document);
JS_STATIC_METHOD(mailDoc, Document);
+
+ private:
+ static int ObjDefnID;
+ static JSPropertySpec PropertySpecs[];
+ static JSMethodSpec MethodSpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_DOCUMENT_H_
diff --git a/fpdfsdk/javascript/Field.cpp b/fpdfsdk/javascript/Field.cpp
index 0a35bf5dd4..2a1040655e 100644
--- a/fpdfsdk/javascript/Field.cpp
+++ b/fpdfsdk/javascript/Field.cpp
@@ -165,14 +165,20 @@ JSMethodSpec CJS_Field::MethodSpecs[] = {
{"signatureValidate", signatureValidate_static},
{0, 0}};
-int CJS_Field::g_nObjDefnID = -1;
+int CJS_Field::ObjDefnID = -1;
+// static
+int CJS_Field::GetObjDefnID() {
+ return ObjDefnID;
+}
+
+// static
void CJS_Field::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID =
+ ObjDefnID =
pEngine->DefineObj("Field", eObjType, JSConstructor<CJS_Field, Field>,
JSDestructor<CJS_Field>);
- DefineProps(pEngine, g_nObjDefnID, PropertySpecs);
- DefineMethods(pEngine, g_nObjDefnID, MethodSpecs);
+ DefineProps(pEngine, ObjDefnID, PropertySpecs);
+ DefineMethods(pEngine, ObjDefnID, MethodSpecs);
}
CJS_DelayData::CJS_DelayData(FIELD_PROP prop, int idx, const WideString& name)
@@ -2271,7 +2277,7 @@ CJS_Return Field::buttonGetIcon(
return CJS_Return(false);
v8::Local<v8::Object> pObj =
- pRuntime->NewFxDynamicObj(CJS_Icon::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Icon::GetObjDefnID());
if (pObj.IsEmpty())
return CJS_Return(false);
@@ -2391,7 +2397,7 @@ CJS_Return Field::getArray(CJS_Runtime* pRuntime,
int j = 0;
for (const auto& pStr : swSort) {
v8::Local<v8::Object> pObj =
- pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Field::GetObjDefnID());
if (pObj.IsEmpty())
return CJS_Return(false);
diff --git a/fpdfsdk/javascript/Field.h b/fpdfsdk/javascript/Field.h
index 11b6e7e9fe..1bfd44eef1 100644
--- a/fpdfsdk/javascript/Field.h
+++ b/fpdfsdk/javascript/Field.h
@@ -359,17 +359,14 @@ class Field : public CJS_EmbedObj {
class CJS_Field : public CJS_Object {
public:
+ static int GetObjDefnID();
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Field(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Field() override {}
void InitInstance(IJS_Runtime* pIRuntime) override;
- static int g_nObjDefnID;
- static JSPropertySpec PropertySpecs[];
- static JSMethodSpec MethodSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_PROP(alignment, alignment, Field);
JS_STATIC_PROP(borderStyle, border_style, Field);
JS_STATIC_PROP(buttonAlignX, button_align_x, Field);
@@ -449,6 +446,11 @@ class CJS_Field : public CJS_Object {
JS_STATIC_METHOD(signatureSetSeedValue, Field);
JS_STATIC_METHOD(signatureSign, Field);
JS_STATIC_METHOD(signatureValidate, Field);
+
+ private:
+ static int ObjDefnID;
+ static JSPropertySpec PropertySpecs[];
+ static JSMethodSpec MethodSpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_FIELD_H_
diff --git a/fpdfsdk/javascript/Icon.cpp b/fpdfsdk/javascript/Icon.cpp
index 7a0c758d15..ffb9b81011 100644
--- a/fpdfsdk/javascript/Icon.cpp
+++ b/fpdfsdk/javascript/Icon.cpp
@@ -14,12 +14,18 @@ JSPropertySpec CJS_Icon::PropertySpecs[] = {
{"name", get_name_static, set_name_static},
{0, 0, 0}};
-int CJS_Icon::g_nObjDefnID = -1;
+int CJS_Icon::ObjDefnID = -1;
+// static
+int CJS_Icon::GetObjDefnID() {
+ return ObjDefnID;
+}
+
+// static
void CJS_Icon::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj(
+ ObjDefnID = pEngine->DefineObj(
"Icon", eObjType, JSConstructor<CJS_Icon, Icon>, JSDestructor<CJS_Icon>);
- DefineProps(pEngine, g_nObjDefnID, PropertySpecs);
+ DefineProps(pEngine, ObjDefnID, PropertySpecs);
}
Icon::Icon(CJS_Object* pJSObject)
diff --git a/fpdfsdk/javascript/Icon.h b/fpdfsdk/javascript/Icon.h
index 3580183347..33ee554c02 100644
--- a/fpdfsdk/javascript/Icon.h
+++ b/fpdfsdk/javascript/Icon.h
@@ -28,15 +28,17 @@ class Icon : public CJS_EmbedObj {
class CJS_Icon : public CJS_Object {
public:
+ static int GetObjDefnID();
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Icon(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Icon() override {}
- static int g_nObjDefnID;
- static JSPropertySpec PropertySpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_PROP(name, name, Icon);
+
+ private:
+ static int ObjDefnID;
+ static JSPropertySpec PropertySpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_ICON_H_
diff --git a/fpdfsdk/javascript/app.cpp b/fpdfsdk/javascript/app.cpp
index ceafb8fdd8..9cc13ea21d 100644
--- a/fpdfsdk/javascript/app.cpp
+++ b/fpdfsdk/javascript/app.cpp
@@ -142,13 +142,19 @@ GlobalTimer::TimerMap* GlobalTimer::GetGlobalTimerMap() {
return s_TimerMap;
}
-int CJS_TimerObj::g_nObjDefnID = -1;
+int CJS_TimerObj::ObjDefnID = -1;
+// static
+int CJS_TimerObj::GetObjDefnID() {
+ return ObjDefnID;
+}
+
+// static
void CJS_TimerObj::DefineJSObjects(CFXJS_Engine* pEngine,
FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("TimerObj", eObjType,
- JSConstructor<CJS_TimerObj, TimerObj>,
- JSDestructor<CJS_TimerObj>);
+ ObjDefnID = pEngine->DefineObj("TimerObj", eObjType,
+ JSConstructor<CJS_TimerObj, TimerObj>,
+ JSDestructor<CJS_TimerObj>);
}
TimerObj::TimerObj(CJS_Object* pJSObject)
@@ -210,13 +216,14 @@ JSMethodSpec CJS_App::MethodSpecs[] = {{"alert", alert_static},
{"setTimeOut", setTimeOut_static},
{0, 0}};
-int CJS_App::g_nObjDefnID = -1;
+int CJS_App::ObjDefnID = -1;
+// static
void CJS_App::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj(
- "app", eObjType, JSConstructor<CJS_App, app>, JSDestructor<CJS_App>);
- DefineProps(pEngine, g_nObjDefnID, PropertySpecs);
- DefineMethods(pEngine, g_nObjDefnID, MethodSpecs);
+ ObjDefnID = pEngine->DefineObj("app", eObjType, JSConstructor<CJS_App, app>,
+ JSDestructor<CJS_App>);
+ DefineProps(pEngine, ObjDefnID, PropertySpecs);
+ DefineMethods(pEngine, ObjDefnID, MethodSpecs);
}
app::app(CJS_Object* pJSObject)
@@ -227,7 +234,7 @@ app::~app() {}
CJS_Return app::get_active_docs(CJS_Runtime* pRuntime) {
CJS_Document* pJSDocument = nullptr;
v8::Local<v8::Object> pObj = pRuntime->GetThisObj();
- if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID)
+ if (CFXJS_Engine::GetObjDefnID(pObj) == CJS_Document::GetObjDefnID())
pJSDocument = static_cast<CJS_Document*>(pRuntime->GetObjectPrivate(pObj));
v8::Local<v8::Array> aDocs = pRuntime->NewArray();
@@ -445,7 +452,7 @@ CJS_Return app::setInterval(CJS_Runtime* pRuntime,
m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef));
v8::Local<v8::Object> pRetObj =
- pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_TimerObj::GetObjDefnID());
if (pRetObj.IsEmpty())
return CJS_Return(false);
@@ -473,7 +480,7 @@ CJS_Return app::setTimeOut(CJS_Runtime* pRuntime,
m_Timers.insert(std::unique_ptr<GlobalTimer>(timerRef));
v8::Local<v8::Object> pRetObj =
- pRuntime->NewFxDynamicObj(CJS_TimerObj::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_TimerObj::GetObjDefnID());
if (pRetObj.IsEmpty())
return CJS_Return(false);
@@ -508,7 +515,7 @@ void app::ClearTimerCommon(CJS_Runtime* pRuntime, v8::Local<v8::Value> param) {
return;
v8::Local<v8::Object> pObj = pRuntime->ToObject(param);
- if (CFXJS_Engine::GetObjDefnID(pObj) != CJS_TimerObj::g_nObjDefnID)
+ if (CFXJS_Engine::GetObjDefnID(pObj) != CJS_TimerObj::GetObjDefnID())
return;
CJS_Object* pJSObj =
diff --git a/fpdfsdk/javascript/app.h b/fpdfsdk/javascript/app.h
index a0344306d9..53794736f2 100644
--- a/fpdfsdk/javascript/app.h
+++ b/fpdfsdk/javascript/app.h
@@ -30,12 +30,14 @@ class TimerObj : public CJS_EmbedObj {
class CJS_TimerObj : public CJS_Object {
public:
+ static int GetObjDefnID();
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_TimerObj(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_TimerObj() override {}
- static int g_nObjDefnID;
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+ private:
+ static int ObjDefnID;
};
class app : public CJS_EmbedObj {
@@ -142,15 +144,11 @@ class app : public CJS_EmbedObj {
class CJS_App : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_App(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_App() override {}
- static int g_nObjDefnID;
- static JSPropertySpec PropertySpecs[];
- static JSMethodSpec MethodSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_PROP(activeDocs, active_docs, app);
JS_STATIC_PROP(calculate, calculate, app);
JS_STATIC_PROP(formsVersion, forms_version, app);
@@ -185,6 +183,11 @@ class CJS_App : public CJS_Object {
JS_STATIC_METHOD(response, app);
JS_STATIC_METHOD(setInterval, app);
JS_STATIC_METHOD(setTimeOut, app);
+
+ private:
+ static int ObjDefnID;
+ static JSPropertySpec PropertySpecs[];
+ static JSMethodSpec MethodSpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_APP_H_
diff --git a/fpdfsdk/javascript/cjs_annot.cpp b/fpdfsdk/javascript/cjs_annot.cpp
index af0d208a1e..27ce8cddec 100644
--- a/fpdfsdk/javascript/cjs_annot.cpp
+++ b/fpdfsdk/javascript/cjs_annot.cpp
@@ -25,13 +25,19 @@ JSPropertySpec CJS_Annot::PropertySpecs[] = {
{"type", get_type_static, set_type_static},
{0, 0, 0}};
-int CJS_Annot::g_nObjDefnID = -1;
+int CJS_Annot::ObjDefnID = -1;
+// static
+int CJS_Annot::GetObjDefnID() {
+ return ObjDefnID;
+}
+
+// static
void CJS_Annot::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID =
+ ObjDefnID =
pEngine->DefineObj("Annot", eObjType, JSConstructor<CJS_Annot, Annot>,
JSDestructor<CJS_Annot>);
- DefineProps(pEngine, g_nObjDefnID, PropertySpecs);
+ DefineProps(pEngine, ObjDefnID, PropertySpecs);
}
Annot::Annot(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
diff --git a/fpdfsdk/javascript/cjs_annot.h b/fpdfsdk/javascript/cjs_annot.h
index 147642f3c9..810cea155f 100644
--- a/fpdfsdk/javascript/cjs_annot.h
+++ b/fpdfsdk/javascript/cjs_annot.h
@@ -32,17 +32,19 @@ class Annot : public CJS_EmbedObj {
class CJS_Annot : public CJS_Object {
public:
+ static int GetObjDefnID();
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Annot(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Annot() override {}
- static int g_nObjDefnID;
- static JSPropertySpec PropertySpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_PROP(hidden, hidden, Annot);
JS_STATIC_PROP(name, name, Annot);
JS_STATIC_PROP(type, type, Annot);
+
+ private:
+ static int ObjDefnID;
+ static JSPropertySpec PropertySpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_CJS_ANNOT_H_
diff --git a/fpdfsdk/javascript/cjs_border.cpp b/fpdfsdk/javascript/cjs_border.cpp
index 038606fff6..f751fcc0b4 100644
--- a/fpdfsdk/javascript/cjs_border.cpp
+++ b/fpdfsdk/javascript/cjs_border.cpp
@@ -14,9 +14,10 @@ JSConstSpec CJS_Border::ConstSpecs[] = {
{"u", JSConstSpec::String, 0, "underline"},
{0, JSConstSpec::Number, 0, 0}};
-int CJS_Border::g_nObjDefnID = -1;
+int CJS_Border::ObjDefnID = -1;
+// static
void CJS_Border::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("border", eObjType, nullptr, nullptr);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
+ ObjDefnID = pEngine->DefineObj("border", eObjType, nullptr, nullptr);
+ DefineConsts(pEngine, ObjDefnID, ConstSpecs);
}
diff --git a/fpdfsdk/javascript/cjs_border.h b/fpdfsdk/javascript/cjs_border.h
index 733fbc0ded..c9f550d8ff 100644
--- a/fpdfsdk/javascript/cjs_border.h
+++ b/fpdfsdk/javascript/cjs_border.h
@@ -11,13 +11,14 @@
class CJS_Border : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Border(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Border() override {}
- static int g_nObjDefnID;
+ private:
+ static int ObjDefnID;
static JSConstSpec ConstSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
};
#endif // FPDFSDK_JAVASCRIPT_CJS_BORDER_H_
diff --git a/fpdfsdk/javascript/cjs_display.cpp b/fpdfsdk/javascript/cjs_display.cpp
index afb060b2dd..b196623743 100644
--- a/fpdfsdk/javascript/cjs_display.cpp
+++ b/fpdfsdk/javascript/cjs_display.cpp
@@ -12,9 +12,10 @@ JSConstSpec CJS_Display::ConstSpecs[] = {{"visible", JSConstSpec::Number, 0, 0},
{"noView", JSConstSpec::Number, 3, 0},
{0, JSConstSpec::Number, 0, 0}};
-int CJS_Display::g_nObjDefnID = -1;
+int CJS_Display::ObjDefnID = -1;
+// static
void CJS_Display::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("display", eObjType, nullptr, nullptr);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
+ ObjDefnID = pEngine->DefineObj("display", eObjType, nullptr, nullptr);
+ DefineConsts(pEngine, ObjDefnID, ConstSpecs);
}
diff --git a/fpdfsdk/javascript/cjs_display.h b/fpdfsdk/javascript/cjs_display.h
index 439525fd85..faf779dbcb 100644
--- a/fpdfsdk/javascript/cjs_display.h
+++ b/fpdfsdk/javascript/cjs_display.h
@@ -11,13 +11,14 @@
class CJS_Display : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Display(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Display() override {}
- static int g_nObjDefnID;
+ private:
+ static int ObjDefnID;
static JSConstSpec ConstSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
};
#endif // FPDFSDK_JAVASCRIPT_CJS_DISPLAY_H_
diff --git a/fpdfsdk/javascript/cjs_eventhandler.cpp b/fpdfsdk/javascript/cjs_eventhandler.cpp
index 03d181be62..f1d37e2091 100644
--- a/fpdfsdk/javascript/cjs_eventhandler.cpp
+++ b/fpdfsdk/javascript/cjs_eventhandler.cpp
@@ -589,12 +589,12 @@ bool CJS_EventHandler::Shift() {
Field* CJS_EventHandler::Source() {
CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
v8::Local<v8::Object> pDocObj =
- pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Document::GetObjDefnID());
if (pDocObj.IsEmpty())
return nullptr;
v8::Local<v8::Object> pFieldObj =
- pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Field::GetObjDefnID());
if (pFieldObj.IsEmpty())
return nullptr;
@@ -616,12 +616,12 @@ Field* CJS_EventHandler::Source() {
Field* CJS_EventHandler::Target_Field() {
CJS_Runtime* pRuntime = m_pJSEventContext->GetJSRuntime();
v8::Local<v8::Object> pDocObj =
- pRuntime->NewFxDynamicObj(CJS_Document::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Document::GetObjDefnID());
if (pDocObj.IsEmpty())
return nullptr;
v8::Local<v8::Object> pFieldObj =
- pRuntime->NewFxDynamicObj(CJS_Field::g_nObjDefnID);
+ pRuntime->NewFxDynamicObj(CJS_Field::GetObjDefnID());
if (pFieldObj.IsEmpty())
return nullptr;
diff --git a/fpdfsdk/javascript/cjs_font.cpp b/fpdfsdk/javascript/cjs_font.cpp
index 889c0bb8d2..5189666a8f 100644
--- a/fpdfsdk/javascript/cjs_font.cpp
+++ b/fpdfsdk/javascript/cjs_font.cpp
@@ -23,9 +23,10 @@ JSConstSpec CJS_Font::ConstSpecs[] = {
{"ZapfD", JSConstSpec::String, 0, "ZapfDingbats"},
{0, JSConstSpec::Number, 0, 0}};
-int CJS_Font::g_nObjDefnID = -1;
+int CJS_Font::ObjDefnID = -1;
+// static
void CJS_Font::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("font", eObjType, nullptr, nullptr);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
+ ObjDefnID = pEngine->DefineObj("font", eObjType, nullptr, nullptr);
+ DefineConsts(pEngine, ObjDefnID, ConstSpecs);
}
diff --git a/fpdfsdk/javascript/cjs_font.h b/fpdfsdk/javascript/cjs_font.h
index 569e4f10dd..73bca9e104 100644
--- a/fpdfsdk/javascript/cjs_font.h
+++ b/fpdfsdk/javascript/cjs_font.h
@@ -11,13 +11,14 @@
class CJS_Font : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Font(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Font() override {}
- static int g_nObjDefnID;
+ private:
+ static int ObjDefnID;
static JSConstSpec ConstSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
};
#endif // FPDFSDK_JAVASCRIPT_CJS_FONT_H_
diff --git a/fpdfsdk/javascript/cjs_global.cpp b/fpdfsdk/javascript/cjs_global.cpp
index 95782acccf..826d26c638 100644
--- a/fpdfsdk/javascript/cjs_global.cpp
+++ b/fpdfsdk/javascript/cjs_global.cpp
@@ -174,15 +174,11 @@ class JSGlobalAlternate : public CJS_EmbedObj {
} // namespace
-JSConstSpec CJS_Global::ConstSpecs[] = {{0, JSConstSpec::Number, 0, 0}};
-
-JSPropertySpec CJS_Global::PropertySpecs[] = {{0, 0, 0}};
-
JSMethodSpec CJS_Global::MethodSpecs[] = {
{"setPersistent", setPersistent_static},
{0, 0}};
-int CJS_Global::g_nObjDefnID = -1;
+int CJS_Global::ObjDefnID = -1;
// static
void CJS_Global::setPersistent_static(
@@ -191,25 +187,21 @@ void CJS_Global::setPersistent_static(
"setPersistent", "global", info);
}
-void CJS_Global::InitInstance(IJS_Runtime* pIRuntime) {
- CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime);
- JSGlobalAlternate* pGlobal =
- static_cast<JSGlobalAlternate*>(GetEmbedObject());
- pGlobal->Initial(pRuntime->GetFormFillEnv());
-}
-
+// static
void CJS_Global::queryprop_static(
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
JSSpecialPropQuery<JSGlobalAlternate>("global", property, info);
}
+// static
void CJS_Global::getprop_static(
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
JSSpecialPropGet<JSGlobalAlternate>("global", property, info);
}
+// static
void CJS_Global::putprop_static(
v8::Local<v8::String> property,
v8::Local<v8::Value> value,
@@ -217,28 +209,36 @@ void CJS_Global::putprop_static(
JSSpecialPropPut<JSGlobalAlternate>("global", property, value, info);
}
+// static
void CJS_Global::delprop_static(
v8::Local<v8::String> property,
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
JSSpecialPropDel<JSGlobalAlternate>("global", property, info);
}
+// static
void CJS_Global::DefineAllProperties(CFXJS_Engine* pEngine) {
pEngine->DefineObjAllProperties(
- g_nObjDefnID, CJS_Global::queryprop_static, CJS_Global::getprop_static,
+ ObjDefnID, CJS_Global::queryprop_static, CJS_Global::getprop_static,
CJS_Global::putprop_static, CJS_Global::delprop_static);
}
+// static
void CJS_Global::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj(
- "global", eObjType, JSConstructor<CJS_Global, JSGlobalAlternate>,
- JSDestructor<CJS_Global>);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
- DefineProps(pEngine, g_nObjDefnID, PropertySpecs);
- DefineMethods(pEngine, g_nObjDefnID, MethodSpecs);
+ ObjDefnID = pEngine->DefineObj("global", eObjType,
+ JSConstructor<CJS_Global, JSGlobalAlternate>,
+ JSDestructor<CJS_Global>);
+ DefineMethods(pEngine, ObjDefnID, MethodSpecs);
DefineAllProperties(pEngine);
}
+void CJS_Global::InitInstance(IJS_Runtime* pIRuntime) {
+ CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime);
+ JSGlobalAlternate* pGlobal =
+ static_cast<JSGlobalAlternate*>(GetEmbedObject());
+ pGlobal->Initial(pRuntime->GetFormFillEnv());
+}
+
JSGlobalData::JSGlobalData()
: nType(JS_GlobalDataType::NUMBER),
dData(0),
diff --git a/fpdfsdk/javascript/cjs_global.h b/fpdfsdk/javascript/cjs_global.h
index e5eb3aab4b..499a66b7c2 100644
--- a/fpdfsdk/javascript/cjs_global.h
+++ b/fpdfsdk/javascript/cjs_global.h
@@ -11,17 +11,6 @@
class CJS_Global : public CJS_Object {
public:
- explicit CJS_Global(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
- ~CJS_Global() override {}
-
- // CJS_Object
- void InitInstance(IJS_Runtime* pIRuntime) override;
-
- static int g_nObjDefnID;
- static JSConstSpec ConstSpecs[];
- static JSPropertySpec PropertySpecs[];
- static JSMethodSpec MethodSpecs[];
-
static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
static void DefineAllProperties(CFXJS_Engine* pEngine);
@@ -38,6 +27,16 @@ class CJS_Global : public CJS_Object {
static void setPersistent_static(
const v8::FunctionCallbackInfo<v8::Value>& info);
+
+ explicit CJS_Global(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
+ ~CJS_Global() override {}
+
+ // CJS_Object
+ void InitInstance(IJS_Runtime* pIRuntime) override;
+
+ private:
+ static int ObjDefnID;
+ static JSMethodSpec MethodSpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_CJS_GLOBAL_H_
diff --git a/fpdfsdk/javascript/cjs_globalarrays.cpp b/fpdfsdk/javascript/cjs_globalarrays.cpp
index ff0d5e5f71..a68e2fae0d 100644
--- a/fpdfsdk/javascript/cjs_globalarrays.cpp
+++ b/fpdfsdk/javascript/cjs_globalarrays.cpp
@@ -22,6 +22,7 @@
}); \
}
+// static
void CJS_GlobalArrays::DefineJSObjects(CJS_Runtime* pRuntime) {
GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_ENTRY_DOT_SEP", L"[+-]?\\d*\\.?\\d*");
GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_COMMIT_DOT_SEP",
diff --git a/fpdfsdk/javascript/cjs_globalconsts.cpp b/fpdfsdk/javascript/cjs_globalconsts.cpp
index 063d8a1adc..7b7699d146 100644
--- a/fpdfsdk/javascript/cjs_globalconsts.cpp
+++ b/fpdfsdk/javascript/cjs_globalconsts.cpp
@@ -14,6 +14,7 @@
->NewString(value)); \
})
+// static
void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) {
GLOBAL_STRING(pRuntime, L"IDS_GREATER_THAN",
L"Invalid value: must be greater than or equal to % s.");
diff --git a/fpdfsdk/javascript/cjs_highlight.cpp b/fpdfsdk/javascript/cjs_highlight.cpp
index edee548a67..97c561867d 100644
--- a/fpdfsdk/javascript/cjs_highlight.cpp
+++ b/fpdfsdk/javascript/cjs_highlight.cpp
@@ -13,10 +13,11 @@ JSConstSpec CJS_Highlight::ConstSpecs[] = {
{"o", JSConstSpec::String, 0, "outline"},
{0, JSConstSpec::Number, 0, 0}};
-int CJS_Highlight::g_nObjDefnID = -1;
+int CJS_Highlight::ObjDefnID = -1;
+// static
void CJS_Highlight::DefineJSObjects(CFXJS_Engine* pEngine,
FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("highlight", eObjType, nullptr, nullptr);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
+ ObjDefnID = pEngine->DefineObj("highlight", eObjType, nullptr, nullptr);
+ DefineConsts(pEngine, ObjDefnID, ConstSpecs);
}
diff --git a/fpdfsdk/javascript/cjs_highlight.h b/fpdfsdk/javascript/cjs_highlight.h
index cc77660052..1fca9bc9ae 100644
--- a/fpdfsdk/javascript/cjs_highlight.h
+++ b/fpdfsdk/javascript/cjs_highlight.h
@@ -11,13 +11,14 @@
class CJS_Highlight : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Highlight(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Highlight() override {}
- static int g_nObjDefnID;
+ private:
+ static int ObjDefnID;
static JSConstSpec ConstSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
};
#endif // FPDFSDK_JAVASCRIPT_CJS_HIGHLIGHT_H_
diff --git a/fpdfsdk/javascript/cjs_position.cpp b/fpdfsdk/javascript/cjs_position.cpp
index f24c2d95de..f62efc9d6e 100644
--- a/fpdfsdk/javascript/cjs_position.cpp
+++ b/fpdfsdk/javascript/cjs_position.cpp
@@ -16,10 +16,11 @@ JSConstSpec CJS_Position::ConstSpecs[] = {
{"overlay", JSConstSpec::Number, 6, 0},
{0, JSConstSpec::Number, 0, 0}};
-int CJS_Position::g_nObjDefnID = -1;
+int CJS_Position::ObjDefnID = -1;
+// static
void CJS_Position::DefineJSObjects(CFXJS_Engine* pEngine,
FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("position", eObjType, nullptr, nullptr);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
+ ObjDefnID = pEngine->DefineObj("position", eObjType, nullptr, nullptr);
+ DefineConsts(pEngine, ObjDefnID, ConstSpecs);
}
diff --git a/fpdfsdk/javascript/cjs_position.h b/fpdfsdk/javascript/cjs_position.h
index a1850ece7a..8a38cf28bd 100644
--- a/fpdfsdk/javascript/cjs_position.h
+++ b/fpdfsdk/javascript/cjs_position.h
@@ -11,13 +11,14 @@
class CJS_Position : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Position(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Position() override {}
- static int g_nObjDefnID;
+ private:
+ static int ObjDefnID;
static JSConstSpec ConstSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
};
#endif // FPDFSDK_JAVASCRIPT_CJS_POSITION_H_
diff --git a/fpdfsdk/javascript/cjs_runtime.cpp b/fpdfsdk/javascript/cjs_runtime.cpp
index c8c8477500..1b566b121c 100644
--- a/fpdfsdk/javascript/cjs_runtime.cpp
+++ b/fpdfsdk/javascript/cjs_runtime.cpp
@@ -184,7 +184,7 @@ void CJS_Runtime::SetFormFillEnvToDocument() {
if (pThis.IsEmpty())
return;
- if (CFXJS_Engine::GetObjDefnID(pThis) != CJS_Document::g_nObjDefnID)
+ if (CFXJS_Engine::GetObjDefnID(pThis) != CJS_Document::GetObjDefnID())
return;
CJS_Document* pJSDocument =
diff --git a/fpdfsdk/javascript/cjs_scalehow.cpp b/fpdfsdk/javascript/cjs_scalehow.cpp
index 8fafdd473c..b2c04854e9 100644
--- a/fpdfsdk/javascript/cjs_scalehow.cpp
+++ b/fpdfsdk/javascript/cjs_scalehow.cpp
@@ -11,10 +11,11 @@ JSConstSpec CJS_ScaleHow::ConstSpecs[] = {
{"anamorphic", JSConstSpec::Number, 1, 0},
{0, JSConstSpec::Number, 0, 0}};
-int CJS_ScaleHow::g_nObjDefnID = -1;
+int CJS_ScaleHow::ObjDefnID = -1;
+// static
void CJS_ScaleHow::DefineJSObjects(CFXJS_Engine* pEngine,
FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("scaleHow", eObjType, nullptr, nullptr);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
+ ObjDefnID = pEngine->DefineObj("scaleHow", eObjType, nullptr, nullptr);
+ DefineConsts(pEngine, ObjDefnID, ConstSpecs);
}
diff --git a/fpdfsdk/javascript/cjs_scalehow.h b/fpdfsdk/javascript/cjs_scalehow.h
index 36c5fb3ce1..bc3548487e 100644
--- a/fpdfsdk/javascript/cjs_scalehow.h
+++ b/fpdfsdk/javascript/cjs_scalehow.h
@@ -11,14 +11,14 @@
class CJS_ScaleHow : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_ScaleHow(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_ScaleHow() override {}
- static int g_nObjDefnID;
+ private:
+ static int ObjDefnID;
static JSConstSpec ConstSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
};
#endif // FPDFSDK_JAVASCRIPT_CJS_SCALEHOW_H_
diff --git a/fpdfsdk/javascript/cjs_scalewhen.cpp b/fpdfsdk/javascript/cjs_scalewhen.cpp
index 82a4541855..7c45956632 100644
--- a/fpdfsdk/javascript/cjs_scalewhen.cpp
+++ b/fpdfsdk/javascript/cjs_scalewhen.cpp
@@ -13,10 +13,11 @@ JSConstSpec CJS_ScaleWhen::ConstSpecs[] = {
{"tooSmall", JSConstSpec::Number, 3, 0},
{0, JSConstSpec::Number, 0, 0}};
-int CJS_ScaleWhen::g_nObjDefnID = -1;
+int CJS_ScaleWhen::ObjDefnID = -1;
+// static
void CJS_ScaleWhen::DefineJSObjects(CFXJS_Engine* pEngine,
FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("scaleWhen", eObjType, nullptr, nullptr);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
+ ObjDefnID = pEngine->DefineObj("scaleWhen", eObjType, nullptr, nullptr);
+ DefineConsts(pEngine, ObjDefnID, ConstSpecs);
}
diff --git a/fpdfsdk/javascript/cjs_scalewhen.h b/fpdfsdk/javascript/cjs_scalewhen.h
index 1b64c0fea9..7aa97213f5 100644
--- a/fpdfsdk/javascript/cjs_scalewhen.h
+++ b/fpdfsdk/javascript/cjs_scalewhen.h
@@ -11,14 +11,14 @@
class CJS_ScaleWhen : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_ScaleWhen(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_ScaleWhen() override {}
- static int g_nObjDefnID;
+ private:
+ static int ObjDefnID;
static JSConstSpec ConstSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
};
#endif // FPDFSDK_JAVASCRIPT_CJS_SCALEWHEN_H_
diff --git a/fpdfsdk/javascript/cjs_style.cpp b/fpdfsdk/javascript/cjs_style.cpp
index 66342f5649..25bd3524e1 100644
--- a/fpdfsdk/javascript/cjs_style.cpp
+++ b/fpdfsdk/javascript/cjs_style.cpp
@@ -15,9 +15,10 @@ JSConstSpec CJS_Style::ConstSpecs[] = {
{"sq", JSConstSpec::String, 0, "square"},
{0, JSConstSpec::Number, 0, 0}};
-int CJS_Style::g_nObjDefnID = -1;
+int CJS_Style::ObjDefnID = -1;
+// static
void CJS_Style::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("style", eObjType, nullptr, nullptr);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
+ ObjDefnID = pEngine->DefineObj("style", eObjType, nullptr, nullptr);
+ DefineConsts(pEngine, ObjDefnID, ConstSpecs);
}
diff --git a/fpdfsdk/javascript/cjs_style.h b/fpdfsdk/javascript/cjs_style.h
index 0269bfeb9d..1907555027 100644
--- a/fpdfsdk/javascript/cjs_style.h
+++ b/fpdfsdk/javascript/cjs_style.h
@@ -11,13 +11,14 @@
class CJS_Style : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Style(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Style() override {}
- static int g_nObjDefnID;
+ private:
+ static int ObjDefnID;
static JSConstSpec ConstSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
};
#endif // FPDFSDK_JAVASCRIPT_CJS_STYLE_H_
diff --git a/fpdfsdk/javascript/cjs_zoomtype.cpp b/fpdfsdk/javascript/cjs_zoomtype.cpp
index d138381a2e..1069d8e06e 100644
--- a/fpdfsdk/javascript/cjs_zoomtype.cpp
+++ b/fpdfsdk/javascript/cjs_zoomtype.cpp
@@ -16,10 +16,11 @@ JSConstSpec CJS_Zoomtype::ConstSpecs[] = {
{"refW", JSConstSpec::String, 0, "ReflowWidth"},
{0, JSConstSpec::Number, 0, 0}};
-int CJS_Zoomtype::g_nObjDefnID = -1;
+int CJS_Zoomtype::ObjDefnID = -1;
+// static
void CJS_Zoomtype::DefineJSObjects(CFXJS_Engine* pEngine,
FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("zoomtype", eObjType, nullptr, nullptr);
- DefineConsts(pEngine, g_nObjDefnID, ConstSpecs);
+ ObjDefnID = pEngine->DefineObj("zoomtype", eObjType, nullptr, nullptr);
+ DefineConsts(pEngine, ObjDefnID, ConstSpecs);
}
diff --git a/fpdfsdk/javascript/cjs_zoomtype.h b/fpdfsdk/javascript/cjs_zoomtype.h
index e7ba68930e..9387481106 100644
--- a/fpdfsdk/javascript/cjs_zoomtype.h
+++ b/fpdfsdk/javascript/cjs_zoomtype.h
@@ -11,13 +11,14 @@
class CJS_Zoomtype : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Zoomtype(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Zoomtype() override {}
- static int g_nObjDefnID;
+ private:
+ static int ObjDefnID;
static JSConstSpec ConstSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
};
#endif // FPDFSDK_JAVASCRIPT_CJS_ZOOMTYPE_H_
diff --git a/fpdfsdk/javascript/color.cpp b/fpdfsdk/javascript/color.cpp
index adc56d98ce..3c8d3425d9 100644
--- a/fpdfsdk/javascript/color.cpp
+++ b/fpdfsdk/javascript/color.cpp
@@ -30,18 +30,19 @@ JSPropertySpec CJS_Color::PropertySpecs[] = {
{"yellow", get_yellow_static, set_yellow_static},
{0, 0, 0}};
+int CJS_Color::ObjDefnID = -1;
+
JSMethodSpec CJS_Color::MethodSpecs[] = {{"convert", convert_static},
{"equal", equal_static},
{0, 0}};
-int CJS_Color::g_nObjDefnID = -1;
-
+// static
void CJS_Color::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID =
+ ObjDefnID =
pEngine->DefineObj("color", eObjType, JSConstructor<CJS_Color, color>,
JSDestructor<CJS_Color>);
- DefineProps(pEngine, g_nObjDefnID, PropertySpecs);
- DefineMethods(pEngine, g_nObjDefnID, MethodSpecs);
+ DefineProps(pEngine, ObjDefnID, PropertySpecs);
+ DefineMethods(pEngine, ObjDefnID, MethodSpecs);
}
// static
diff --git a/fpdfsdk/javascript/color.h b/fpdfsdk/javascript/color.h
index 0a97de0621..49dec3c5e8 100644
--- a/fpdfsdk/javascript/color.h
+++ b/fpdfsdk/javascript/color.h
@@ -85,15 +85,11 @@ class color : public CJS_EmbedObj {
class CJS_Color : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Color(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Color() override {}
- static int g_nObjDefnID;
- static JSPropertySpec PropertySpecs[];
- static JSMethodSpec MethodSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_PROP(black, black, color);
JS_STATIC_PROP(blue, blue, color);
JS_STATIC_PROP(cyan, cyan, color);
@@ -109,6 +105,11 @@ class CJS_Color : public CJS_Object {
JS_STATIC_METHOD(convert, color);
JS_STATIC_METHOD(equal, color);
+
+ private:
+ static int ObjDefnID;
+ static JSPropertySpec PropertySpecs[];
+ static JSMethodSpec MethodSpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_COLOR_H_
diff --git a/fpdfsdk/javascript/console.cpp b/fpdfsdk/javascript/console.cpp
index 0f5ca4ea1c..720f5f092e 100644
--- a/fpdfsdk/javascript/console.cpp
+++ b/fpdfsdk/javascript/console.cpp
@@ -20,13 +20,14 @@ JSMethodSpec CJS_Console::MethodSpecs[] = {{"clear", clear_static},
{"show", show_static},
{0, 0}};
-int CJS_Console::g_nObjDefnID = -1;
+int CJS_Console::ObjDefnID = -1;
+// static
void CJS_Console::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj("console", eObjType,
- JSConstructor<CJS_Console, console>,
- JSDestructor<CJS_Console>);
- DefineMethods(pEngine, g_nObjDefnID, MethodSpecs);
+ ObjDefnID = pEngine->DefineObj("console", eObjType,
+ JSConstructor<CJS_Console, console>,
+ JSDestructor<CJS_Console>);
+ DefineMethods(pEngine, ObjDefnID, MethodSpecs);
}
console::console(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
diff --git a/fpdfsdk/javascript/console.h b/fpdfsdk/javascript/console.h
index de1a40a30e..96c2daec21 100644
--- a/fpdfsdk/javascript/console.h
+++ b/fpdfsdk/javascript/console.h
@@ -29,18 +29,19 @@ class console : public CJS_EmbedObj {
class CJS_Console : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Console(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Console() override {}
- static int g_nObjDefnID;
- static JSMethodSpec MethodSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_METHOD(clear, console);
JS_STATIC_METHOD(hide, console);
JS_STATIC_METHOD(println, console);
JS_STATIC_METHOD(show, console);
+
+ private:
+ static int ObjDefnID;
+ static JSMethodSpec MethodSpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_CONSOLE_H_
diff --git a/fpdfsdk/javascript/event.cpp b/fpdfsdk/javascript/event.cpp
index 9102bb61cc..a320adaad3 100644
--- a/fpdfsdk/javascript/event.cpp
+++ b/fpdfsdk/javascript/event.cpp
@@ -36,13 +36,14 @@ JSPropertySpec CJS_Event::PropertySpecs[] = {
{"willCommit", get_will_commit_static, set_will_commit_static},
{0, 0, 0}};
-int CJS_Event::g_nObjDefnID = -1;
+int CJS_Event::ObjDefnID = -1;
+// static
void CJS_Event::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID =
+ ObjDefnID =
pEngine->DefineObj("event", eObjType, JSConstructor<CJS_Event, event>,
JSDestructor<CJS_Event>);
- DefineProps(pEngine, g_nObjDefnID, PropertySpecs);
+ DefineProps(pEngine, ObjDefnID, PropertySpecs);
}
event::event(CJS_Object* pJsObject) : CJS_EmbedObj(pJsObject) {}
diff --git a/fpdfsdk/javascript/event.h b/fpdfsdk/javascript/event.h
index 2a3ee3def4..d78902f5e3 100644
--- a/fpdfsdk/javascript/event.h
+++ b/fpdfsdk/javascript/event.h
@@ -77,14 +77,11 @@ class event : public CJS_EmbedObj {
class CJS_Event : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Event(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Event() override {}
- static int g_nObjDefnID;
- static JSPropertySpec PropertySpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_PROP(change, change, event);
JS_STATIC_PROP(changeEx, change_ex, event);
JS_STATIC_PROP(commitKey, commit_key, event);
@@ -105,6 +102,10 @@ class CJS_Event : public CJS_Object {
JS_STATIC_PROP(type, type, event);
JS_STATIC_PROP(value, value, event);
JS_STATIC_PROP(willCommit, will_commit, event);
+
+ private:
+ static int ObjDefnID;
+ static JSPropertySpec PropertySpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_EVENT_H_
diff --git a/fpdfsdk/javascript/report.cpp b/fpdfsdk/javascript/report.cpp
index b702864a22..f52ffc5201 100644
--- a/fpdfsdk/javascript/report.cpp
+++ b/fpdfsdk/javascript/report.cpp
@@ -16,13 +16,14 @@ JSMethodSpec CJS_Report::MethodSpecs[] = {{"save", save_static},
{"writeText", writeText_static},
{0, 0}};
-int CJS_Report::g_nObjDefnID = -1;
+int CJS_Report::ObjDefnID = -1;
+// static
void CJS_Report::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID =
+ ObjDefnID =
pEngine->DefineObj("Report", eObjType, JSConstructor<CJS_Report, Report>,
JSDestructor<CJS_Report>);
- DefineMethods(pEngine, g_nObjDefnID, MethodSpecs);
+ DefineMethods(pEngine, ObjDefnID, MethodSpecs);
}
Report::Report(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
diff --git a/fpdfsdk/javascript/report.h b/fpdfsdk/javascript/report.h
index 51798e6bcb..b9cad59824 100644
--- a/fpdfsdk/javascript/report.h
+++ b/fpdfsdk/javascript/report.h
@@ -25,16 +25,17 @@ class Report : public CJS_EmbedObj {
class CJS_Report : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Report(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Report() override {}
- static int g_nObjDefnID;
- static JSMethodSpec MethodSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_METHOD(save, Report)
JS_STATIC_METHOD(writeText, Report);
+
+ private:
+ static int ObjDefnID;
+ static JSMethodSpec MethodSpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_REPORT_H_
diff --git a/fpdfsdk/javascript/util.cpp b/fpdfsdk/javascript/util.cpp
index 00d7841022..6ff9f05bca 100644
--- a/fpdfsdk/javascript/util.cpp
+++ b/fpdfsdk/javascript/util.cpp
@@ -28,19 +28,6 @@
#include <ctype.h>
#endif
-JSMethodSpec CJS_Util::MethodSpecs[] = {
- {"printd", printd_static}, {"printf", printf_static},
- {"printx", printx_static}, {"scand", scand_static},
- {"byteToChar", byteToChar_static}, {0, 0}};
-
-int CJS_Util::g_nObjDefnID = -1;
-
-void CJS_Util::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
- g_nObjDefnID = pEngine->DefineObj(
- "util", eObjType, JSConstructor<CJS_Util, util>, JSDestructor<CJS_Util>);
- DefineMethods(pEngine, g_nObjDefnID, MethodSpecs);
-}
-
namespace {
// Map PDF-style directives to equivalent wcsftime directives. Not
@@ -71,6 +58,20 @@ const TbConvert TbConvertTable[] = {
} // namespace
+JSMethodSpec CJS_Util::MethodSpecs[] = {
+ {"printd", printd_static}, {"printf", printf_static},
+ {"printx", printx_static}, {"scand", scand_static},
+ {"byteToChar", byteToChar_static}, {0, 0}};
+
+int CJS_Util::ObjDefnID = -1;
+
+// static
+void CJS_Util::DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType) {
+ ObjDefnID = pEngine->DefineObj(
+ "util", eObjType, JSConstructor<CJS_Util, util>, JSDestructor<CJS_Util>);
+ CJS_Object::DefineMethods(pEngine, ObjDefnID, MethodSpecs);
+}
+
util::util(CJS_Object* pJSObject) : CJS_EmbedObj(pJSObject) {}
util::~util() {}
diff --git a/fpdfsdk/javascript/util.h b/fpdfsdk/javascript/util.h
index cf54b159f9..7e1b3886e4 100644
--- a/fpdfsdk/javascript/util.h
+++ b/fpdfsdk/javascript/util.h
@@ -44,19 +44,20 @@ class util : public CJS_EmbedObj {
class CJS_Util : public CJS_Object {
public:
+ static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
+
explicit CJS_Util(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Util() override {}
- static int g_nObjDefnID;
- static JSMethodSpec MethodSpecs[];
-
- static void DefineJSObjects(CFXJS_Engine* pEngine, FXJSOBJTYPE eObjType);
-
JS_STATIC_METHOD(printd, util);
JS_STATIC_METHOD(printf, util);
JS_STATIC_METHOD(printx, util);
JS_STATIC_METHOD(scand, util);
JS_STATIC_METHOD(byteToChar, util);
+
+ private:
+ static int ObjDefnID;
+ static JSMethodSpec MethodSpecs[];
};
#endif // FPDFSDK_JAVASCRIPT_UTIL_H_