summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/javascript')
-rw-r--r--fpdfsdk/src/javascript/Document.cpp28
-rw-r--r--fpdfsdk/src/javascript/Document.h4
-rw-r--r--fpdfsdk/src/javascript/Field.cpp10
-rw-r--r--fpdfsdk/src/javascript/Field.h3
-rw-r--r--fpdfsdk/src/javascript/Icon.h4
-rw-r--r--fpdfsdk/src/javascript/JS_Define.h334
-rw-r--r--fpdfsdk/src/javascript/JS_EventHandler.cpp26
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp43
-rw-r--r--fpdfsdk/src/javascript/app.cpp94
-rw-r--r--fpdfsdk/src/javascript/app.h4
-rw-r--r--fpdfsdk/src/javascript/color.h2
-rw-r--r--fpdfsdk/src/javascript/console.h2
-rw-r--r--fpdfsdk/src/javascript/event.h3
-rw-r--r--fpdfsdk/src/javascript/global.h3
-rw-r--r--fpdfsdk/src/javascript/report.h3
-rw-r--r--fpdfsdk/src/javascript/util.h2
16 files changed, 260 insertions, 305 deletions
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index 9a569af859..fe417ce1fc 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -325,9 +325,8 @@ FX_BOOL Document::getField(IFXJS_Context* cc,
}
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- v8::Local<v8::Object> pFieldObj =
- FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
+ v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj(
+ pRuntime->GetIsolate(), pContext, CJS_Field::g_nObjDefnID);
v8::Isolate* isolate = GetIsolate(cc);
CJS_Field* pJSField = (CJS_Field*)FXJS_GetPrivate(isolate, pFieldObj);
@@ -441,11 +440,6 @@ FX_BOOL Document::print(IFXJS_Context* cc,
const CJS_Parameters& params,
CJS_Value& vRet,
CFX_WideString& sError) {
- CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
FX_BOOL bUI = TRUE;
int nStart = 0;
int nEnd = 0;
@@ -460,8 +454,7 @@ FX_BOOL Document::print(IFXJS_Context* cc,
if (params[8].GetType() == CJS_Value::VT_fxobject) {
v8::Local<v8::Object> pObj = params[8].ToV8Object();
{
- if (FXJS_GetObjDefnID(pObj) ==
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj")) {
+ if (FXJS_GetObjDefnID(pObj) == CJS_PrintParamsObj::g_nObjDefnID) {
if (CJS_Object* pJSObj = params[8].ToCJSObject()) {
if (PrintParamsObj* pprintparamsObj =
(PrintParamsObj*)pJSObj->GetEmbedObject()) {
@@ -1410,11 +1403,9 @@ FX_BOOL Document::addIcon(IFXJS_Context* cc,
sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
return FALSE;
}
- v8::Local<v8::Object> pJSIcon = params[1].ToV8Object();
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- if (FXJS_GetObjDefnID(pJSIcon) !=
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon")) {
+ v8::Local<v8::Object> pJSIcon = params[1].ToV8Object();
+ if (FXJS_GetObjDefnID(pJSIcon) != CJS_Icon::g_nObjDefnID) {
sError = JSGetStringFromID(pContext, IDS_STRING_JSTYPEERROR);
return FALSE;
}
@@ -1462,8 +1453,7 @@ FX_BOOL Document::icons(IFXJS_Context* cc,
pIconElement = (*m_pIconTree)[i];
v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon"));
+ pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID);
if (pObj.IsEmpty())
return FALSE;
@@ -1506,8 +1496,7 @@ FX_BOOL Document::getIcon(IFXJS_Context* cc,
Icon* pRetIcon = (*m_pIconTree)[i]->IconStream;
v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon"));
+ pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID);
if (pObj.IsEmpty())
return FALSE;
@@ -1708,8 +1697,7 @@ FX_BOOL Document::getPrintParams(IFXJS_Context* cc,
CJS_Context* pContext = (CJS_Context*)cc;
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"PrintParamsObj"));
+ pRuntime->GetIsolate(), pContext, CJS_PrintParamsObj::g_nObjDefnID);
// Not implemented yet.
diff --git a/fpdfsdk/src/javascript/Document.h b/fpdfsdk/src/javascript/Document.h
index 65b2764d57..cc92b8d399 100644
--- a/fpdfsdk/src/javascript/Document.h
+++ b/fpdfsdk/src/javascript/Document.h
@@ -30,7 +30,7 @@ class CJS_PrintParamsObj : public CJS_Object {
CJS_PrintParamsObj(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_PrintParamsObj() override {}
- DECLARE_JS_CLASS(CJS_PrintParamsObj);
+ DECLARE_JS_CLASS();
};
class Icon;
@@ -328,7 +328,7 @@ class CJS_Document : public CJS_Object {
// CJS_Object
FX_BOOL InitInstance(IFXJS_Context* cc) override;
- DECLARE_JS_CLASS(CJS_Document);
+ DECLARE_JS_CLASS();
JS_STATIC_PROP(ADBE, Document);
JS_STATIC_PROP(author, Document);
diff --git a/fpdfsdk/src/javascript/Field.cpp b/fpdfsdk/src/javascript/Field.cpp
index 2a631dce39..59e3108050 100644
--- a/fpdfsdk/src/javascript/Field.cpp
+++ b/fpdfsdk/src/javascript/Field.cpp
@@ -3310,9 +3310,8 @@ FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc,
CJS_Context* pContext = (CJS_Context*)cc;
CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- v8::Local<v8::Object> pObj =
- FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Icon"));
+ v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
+ pRuntime->GetIsolate(), pContext, CJS_Icon::g_nObjDefnID);
ASSERT(pObj.IsEmpty() == FALSE);
CJS_Icon* pJS_Icon = (CJS_Icon*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
@@ -3521,9 +3520,8 @@ FX_BOOL Field::getArray(IFXJS_Context* cc,
for (int j = 0, jsz = swSort.GetSize(); j < jsz; j++) {
nonstd::unique_ptr<CFX_WideString> pStr(swSort.GetAt(j));
v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
- ASSERT(pObj.IsEmpty() == FALSE);
+ pRuntime->GetIsolate(), pContext, CJS_Field::g_nObjDefnID);
+ ASSERT(!pObj.IsEmpty());
CJS_Field* pJSField =
(CJS_Field*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
diff --git a/fpdfsdk/src/javascript/Field.h b/fpdfsdk/src/javascript/Field.h
index a62bf39a9a..daf47d5c37 100644
--- a/fpdfsdk/src/javascript/Field.h
+++ b/fpdfsdk/src/javascript/Field.h
@@ -539,8 +539,7 @@ class CJS_Field : public CJS_Object {
FX_BOOL InitInstance(IFXJS_Context* cc) override;
- DECLARE_JS_CLASS(CJS_Field);
-
+ DECLARE_JS_CLASS();
JS_STATIC_PROP(alignment, Field);
JS_STATIC_PROP(borderStyle, Field);
JS_STATIC_PROP(buttonAlignX, Field);
diff --git a/fpdfsdk/src/javascript/Icon.h b/fpdfsdk/src/javascript/Icon.h
index b03048b47b..c1880601dc 100644
--- a/fpdfsdk/src/javascript/Icon.h
+++ b/fpdfsdk/src/javascript/Icon.h
@@ -30,9 +30,7 @@ class CJS_Icon : public CJS_Object {
CJS_Icon(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Icon() override {}
- public:
- DECLARE_JS_CLASS(CJS_Icon);
-
+ DECLARE_JS_CLASS();
JS_STATIC_PROP(name, Icon);
};
diff --git a/fpdfsdk/src/javascript/JS_Define.h b/fpdfsdk/src/javascript/JS_Define.h
index 8c00ba593a..cb0986dd3b 100644
--- a/fpdfsdk/src/javascript/JS_Define.h
+++ b/fpdfsdk/src/javascript/JS_Define.h
@@ -30,18 +30,17 @@ struct JSMethodSpec {
v8::FunctionCallback pMethodCall;
};
-/* ====================================== PUBLIC DEFINE SPEC
- * ============================================== */
#define JS_WIDESTRING(widestring) L## #widestring
-
#define BEGIN_JS_STATIC_CONST(js_class_name) \
JSConstSpec js_class_name::JS_Class_Consts[] = {
#define JS_STATIC_CONST_ENTRY_NUMBER(const_name, pValue) \
{ const_name, pValue, L"", 0 } \
,
+
#define JS_STATIC_CONST_ENTRY_STRING(const_name, pValue) \
{ const_name, 0, pValue, 1 } \
,
+
#define END_JS_STATIC_CONST() \
{ 0, 0, 0, 0 } \
} \
@@ -55,6 +54,7 @@ struct JSMethodSpec {
set_##prop_name##_static \
} \
,
+
#define END_JS_STATIC_PROP() \
{ 0, 0, 0 } \
} \
@@ -65,14 +65,12 @@ struct JSMethodSpec {
#define JS_STATIC_METHOD_ENTRY(method_name) \
{ JS_WIDESTRING(method_name), method_name##_static } \
,
+
#define END_JS_STATIC_METHOD() \
{ 0, 0 } \
} \
;
-/* ======================================== PROP CALLBACK
- * ============================================ */
-
template <class C,
FX_BOOL (C::*M)(IFXJS_Context*, CJS_PropValue&, CFX_WideString&)>
void JSPropGetter(const char* prop_name_string,
@@ -134,9 +132,6 @@ void JSPropSetter(const char* prop_name_string,
property, value, info); \
}
-/* ========================================= METHOD CALLBACK
- * =========================================== */
-
template <class C,
FX_BOOL (C::*M)(IFXJS_Context*,
const CJS_Parameters&,
@@ -180,79 +175,175 @@ void JSMethod(const char* method_name_string,
#method_name, #class_name, info); \
}
-/* ===================================== JS CLASS
- * =============================================== */
-
-#define DECLARE_JS_CLASS(js_class_name) \
- static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \
- v8::Local<v8::Object> global); \
- static void JSDestructor(v8::Local<v8::Object> obj); \
- static void DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
- static JSConstSpec JS_Class_Consts[]; \
- static JSPropertySpec JS_Class_Properties[]; \
- static JSMethodSpec JS_Class_Methods[]; \
- static const wchar_t* m_pClassName
-
-#define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \
- const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
- void js_class_name::JSConstructor(IFXJS_Context* cc, \
- v8::Local<v8::Object> obj, \
- v8::Local<v8::Object> global) { \
- CJS_Object* pObj = new js_class_name(obj); \
- pObj->SetEmbedObject(new class_alternate(pObj)); \
- FXJS_SetPrivate(NULL, obj, (void*)pObj); \
- pObj->InitInstance(cc); \
- } \
- \
- void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \
- js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(NULL, obj); \
- pObj->ExitInstance(); \
- delete pObj; \
- } \
- \
- void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
- FXJSOBJTYPE eObjType) { \
- int nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::m_pClassName, \
- eObjType, JSConstructor, JSDestructor); \
- for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \
- FXJS_DefineObjProperty( \
- pIsolate, nObjDefnID, JS_Class_Properties[i].pName, \
- JS_Class_Properties[i].pPropGet, JS_Class_Properties[i].pPropPut); \
- } \
- for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \
- FXJS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \
- JS_Class_Methods[i].pMethodCall); \
- } \
+// All JS classes have a name, an object defintion ID, and the ability to
+// register themselves with FXJS_V8. We never make a BASE class on its own
+// because it can't really do anything.
+#define DECLARE_JS_CLASS_BASE_PART() \
+ static const wchar_t* g_pClassName; \
+ static int g_nObjDefnID; \
+ static void DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType);
+
+#define IMPLEMENT_JS_CLASS_BASE_PART(js_class_name, class_name) \
+ const wchar_t* js_class_name::g_pClassName = JS_WIDESTRING(class_name); \
+ int js_class_name::g_nObjDefnID = -1;
+
+// CONST classes provide constants, but not constructors, methods, or props.
+#define DECLARE_JS_CLASS_CONST() \
+ DECLARE_JS_CLASS_BASE_PART() \
+ DECLARE_JS_CLASS_CONST_PART()
+
+#define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \
+ IMPLEMENT_JS_CLASS_BASE_PART(js_class_name, class_name) \
+ IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \
+ void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
+ FXJSOBJTYPE eObjType) { \
+ g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \
+ eObjType, nullptr, nullptr); \
+ DefineConsts(pIsolate); \
}
+#define DECLARE_JS_CLASS_CONST_PART() \
+ static JSConstSpec JS_Class_Consts[]; \
+ static void DefineConsts(v8::Isolate* pIsolate);
+
+#define IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \
+ void js_class_name::DefineConsts(v8::Isolate* pIsolate) { \
+ for (size_t i = 0; i < FX_ArraySize(JS_Class_Consts) - 1; ++i) { \
+ FXJS_DefineObjConst( \
+ pIsolate, g_nObjDefnID, JS_Class_Consts[i].pName, \
+ JS_Class_Consts[i].t == 0 \
+ ? FXJS_NewNumber(pIsolate, JS_Class_Consts[i].number) \
+ : FXJS_NewString(pIsolate, JS_Class_Consts[i].string)); \
+ } \
+ }
+
+// Convenience macros for declaring classes without an alternate.
+#define DECLARE_JS_CLASS() DECLARE_JS_CLASS_RICH()
#define IMPLEMENT_JS_CLASS(js_class_name, class_name) \
IMPLEMENT_JS_CLASS_RICH(js_class_name, class_name, class_name)
-/* ======================================== CONST CLASS
- * ============================================ */
-
-#define DECLARE_JS_CLASS_CONST() \
- static void DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
- static JSConstSpec JS_Class_Consts[]; \
- static const wchar_t* m_pClassName
-
-#define IMPLEMENT_JS_CLASS_CONST(js_class_name, class_name) \
- const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
- void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
- FXJSOBJTYPE eObjType) { \
- int nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::m_pClassName, \
- eObjType, NULL, NULL); \
- for (int i = 0; i < FX_ArraySize(JS_Class_Consts) - 1; ++i) { \
- FXJS_DefineObjConst( \
- pIsolate, nObjDefnID, JS_Class_Consts[i].pName, \
- JS_Class_Consts[i].t == 0 \
- ? FXJS_NewNumber(pIsolate, JS_Class_Consts[i].number) \
- : FXJS_NewString(pIsolate, JS_Class_Consts[i].string)); \
- } \
+// Rich JS classes provide constants, methods, properties, and the ability
+// to construct native object state.
+#define DECLARE_JS_CLASS_RICH() \
+ DECLARE_JS_CLASS_BASE_PART() \
+ DECLARE_JS_CLASS_CONST_PART() \
+ DECLARE_JS_CLASS_RICH_PART()
+
+#define IMPLEMENT_JS_CLASS_RICH(js_class_name, class_alternate, class_name) \
+ IMPLEMENT_JS_CLASS_BASE_PART(js_class_name, class_name) \
+ IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \
+ IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, class_name) \
+ void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
+ FXJSOBJTYPE eObjType) { \
+ g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \
+ eObjType, JSConstructor, JSDestructor); \
+ DefineConsts(pIsolate); \
+ DefineProps(pIsolate); \
+ DefineMethods(pIsolate); \
}
-/* ===================================== SPECIAL JS CLASS
- * =============================================== */
+#define DECLARE_JS_CLASS_RICH_PART() \
+ static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \
+ v8::Local<v8::Object> global); \
+ static void JSDestructor(v8::Local<v8::Object> obj); \
+ static void DefineProps(v8::Isolate* pIsoalte); \
+ static void DefineMethods(v8::Isolate* pIsoalte); \
+ static JSPropertySpec JS_Class_Properties[]; \
+ static JSMethodSpec JS_Class_Methods[];
+
+#define IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, \
+ class_name) \
+ void js_class_name::JSConstructor(IFXJS_Context* cc, \
+ v8::Local<v8::Object> obj, \
+ v8::Local<v8::Object> global) { \
+ CJS_Object* pObj = new js_class_name(obj); \
+ pObj->SetEmbedObject(new class_alternate(pObj)); \
+ FXJS_SetPrivate(nullptr, obj, (void*)pObj); \
+ pObj->InitInstance(cc); \
+ } \
+ void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \
+ js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(nullptr, obj); \
+ pObj->ExitInstance(); \
+ delete pObj; \
+ } \
+ void js_class_name::DefineProps(v8::Isolate* pIsolate) { \
+ for (size_t i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \
+ FXJS_DefineObjProperty( \
+ pIsolate, g_nObjDefnID, JS_Class_Properties[i].pName, \
+ JS_Class_Properties[i].pPropGet, JS_Class_Properties[i].pPropPut); \
+ } \
+ } \
+ void js_class_name::DefineMethods(v8::Isolate* pIsolate) { \
+ for (size_t i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \
+ FXJS_DefineObjMethod(pIsolate, g_nObjDefnID, JS_Class_Methods[i].pName, \
+ JS_Class_Methods[i].pMethodCall); \
+ } \
+ }
+
+// Special JS classes implement methods, props, and queries, but not consts.
+#define DECLARE_SPECIAL_JS_CLASS() \
+ DECLARE_JS_CLASS_BASE_PART() \
+ DECLARE_JS_CLASS_CONST_PART() \
+ DECLARE_JS_CLASS_RICH_PART() \
+ DECLARE_SPECIAL_JS_CLASS_PART()
+
+#define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \
+ IMPLEMENT_JS_CLASS_BASE_PART(js_class_name, class_name) \
+ IMPLEMENT_JS_CLASS_CONST_PART(js_class_name, class_name) \
+ IMPLEMENT_JS_CLASS_RICH_PART(js_class_name, class_alternate, class_name) \
+ IMPLEMENT_SPECIAL_JS_CLASS_PART(js_class_name, class_alternate, class_name) \
+ void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
+ FXJSOBJTYPE eObjType) { \
+ g_nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::g_pClassName, \
+ eObjType, JSConstructor, JSDestructor); \
+ DefineConsts(pIsolate); \
+ DefineProps(pIsolate); \
+ DefineMethods(pIsolate); \
+ DefineAllProperties(pIsolate); \
+ }
+
+#define DECLARE_SPECIAL_JS_CLASS_PART() \
+ static void queryprop_static( \
+ v8::Local<v8::String> property, \
+ const v8::PropertyCallbackInfo<v8::Integer>& info); \
+ static void getprop_static(v8::Local<v8::String> property, \
+ const v8::PropertyCallbackInfo<v8::Value>& info); \
+ static void putprop_static(v8::Local<v8::String> property, \
+ v8::Local<v8::Value> value, \
+ const v8::PropertyCallbackInfo<v8::Value>& info); \
+ static void delprop_static( \
+ v8::Local<v8::String> property, \
+ const v8::PropertyCallbackInfo<v8::Boolean>& info); \
+ static void DefineAllProperties(v8::Isolate* pIsolate);
+
+#define IMPLEMENT_SPECIAL_JS_CLASS_PART(js_class_name, class_alternate, \
+ class_name) \
+ void js_class_name::queryprop_static( \
+ v8::Local<v8::String> property, \
+ const v8::PropertyCallbackInfo<v8::Integer>& info) { \
+ JSSpecialPropQuery<class_alternate>(#class_name, property, info); \
+ } \
+ void js_class_name::getprop_static( \
+ v8::Local<v8::String> property, \
+ const v8::PropertyCallbackInfo<v8::Value>& info) { \
+ JSSpecialPropGet<class_alternate>(#class_name, property, info); \
+ } \
+ void js_class_name::putprop_static( \
+ v8::Local<v8::String> property, v8::Local<v8::Value> value, \
+ const v8::PropertyCallbackInfo<v8::Value>& info) { \
+ JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \
+ } \
+ void js_class_name::delprop_static( \
+ v8::Local<v8::String> property, \
+ const v8::PropertyCallbackInfo<v8::Boolean>& info) { \
+ JSSpecialPropDel<class_alternate>(#class_name, property, info); \
+ } \
+ void js_class_name::DefineAllProperties(v8::Isolate* pIsolate) { \
+ FXJS_DefineObjAllProperties( \
+ pIsolate, g_nObjDefnID, js_class_name::queryprop_static, \
+ js_class_name::getprop_static, js_class_name::putprop_static, \
+ js_class_name::delprop_static); \
+ }
template <class Alt>
void JSSpecialPropQuery(const char*,
@@ -341,93 +432,10 @@ void JSSpecialPropDel(const char* class_name,
}
}
-#define DECLARE_SPECIAL_JS_CLASS(js_class_name) \
- static void JSConstructor(IFXJS_Context* cc, v8::Local<v8::Object> obj, \
- v8::Local<v8::Object> global); \
- static void JSDestructor(v8::Local<v8::Object> obj); \
- static JSConstSpec JS_Class_Consts[]; \
- static JSPropertySpec JS_Class_Properties[]; \
- static JSMethodSpec JS_Class_Methods[]; \
- static void DefineJSObjects(v8::Isolate* pIsolate, FXJSOBJTYPE eObjType); \
- static const wchar_t* m_pClassName; \
- static void queryprop_##js_class_name##_static( \
- v8::Local<v8::String> property, \
- const v8::PropertyCallbackInfo<v8::Integer>& info); \
- static void getprop_##js_class_name##_static( \
- v8::Local<v8::String> property, \
- const v8::PropertyCallbackInfo<v8::Value>& info); \
- static void putprop_##js_class_name##_static( \
- v8::Local<v8::String> property, v8::Local<v8::Value> value, \
- const v8::PropertyCallbackInfo<v8::Value>& info); \
- static void delprop_##js_class_name##_static( \
- v8::Local<v8::String> property, \
- const v8::PropertyCallbackInfo<v8::Boolean>& info)
-
-#define IMPLEMENT_SPECIAL_JS_CLASS(js_class_name, class_alternate, class_name) \
- const wchar_t* js_class_name::m_pClassName = JS_WIDESTRING(class_name); \
- void js_class_name::queryprop_##js_class_name##_static( \
- v8::Local<v8::String> property, \
- const v8::PropertyCallbackInfo<v8::Integer>& info) { \
- JSSpecialPropQuery<class_alternate>(#class_name, property, info); \
- } \
- void js_class_name::getprop_##js_class_name##_static( \
- v8::Local<v8::String> property, \
- const v8::PropertyCallbackInfo<v8::Value>& info) { \
- JSSpecialPropGet<class_alternate>(#class_name, property, info); \
- } \
- void js_class_name::putprop_##js_class_name##_static( \
- v8::Local<v8::String> property, v8::Local<v8::Value> value, \
- const v8::PropertyCallbackInfo<v8::Value>& info) { \
- JSSpecialPropPut<class_alternate>(#class_name, property, value, info); \
- } \
- void js_class_name::delprop_##js_class_name##_static( \
- v8::Local<v8::String> property, \
- const v8::PropertyCallbackInfo<v8::Boolean>& info) { \
- JSSpecialPropDel<class_alternate>(#class_name, property, info); \
- } \
- void js_class_name::JSConstructor(IFXJS_Context* cc, \
- v8::Local<v8::Object> obj, \
- v8::Local<v8::Object> global) { \
- CJS_Object* pObj = new js_class_name(obj); \
- pObj->SetEmbedObject(new class_alternate(pObj)); \
- FXJS_SetPrivate(NULL, obj, (void*)pObj); \
- pObj->InitInstance(cc); \
- } \
- \
- void js_class_name::JSDestructor(v8::Local<v8::Object> obj) { \
- js_class_name* pObj = (js_class_name*)FXJS_GetPrivate(NULL, obj); \
- ASSERT(pObj != NULL); \
- pObj->ExitInstance(); \
- delete pObj; \
- } \
- \
- void js_class_name::DefineJSObjects(v8::Isolate* pIsolate, \
- FXJSOBJTYPE eObjType) { \
- int nObjDefnID = FXJS_DefineObj(pIsolate, js_class_name::m_pClassName, \
- eObjType, JSConstructor, JSDestructor); \
- for (int i = 0; i < FX_ArraySize(JS_Class_Properties) - 1; ++i) { \
- FXJS_DefineObjProperty( \
- pIsolate, nObjDefnID, JS_Class_Properties[i].pName, \
- JS_Class_Properties[i].pPropGet, JS_Class_Properties[i].pPropPut); \
- } \
- \
- for (int i = 0; i < FX_ArraySize(JS_Class_Methods) - 1; ++i) { \
- FXJS_DefineObjMethod(pIsolate, nObjDefnID, JS_Class_Methods[i].pName, \
- JS_Class_Methods[i].pMethodCall); \
- } \
- FXJS_DefineObjAllProperties( \
- pIsolate, nObjDefnID, \
- js_class_name::queryprop_##js_class_name##_static, \
- js_class_name::getprop_##js_class_name##_static, \
- js_class_name::putprop_##js_class_name##_static, \
- js_class_name::delprop_##js_class_name##_static); \
- }
-
-/* ======================================== GLOBAL METHODS
- * ============================================ */
-
-template <FX_BOOL (
- *F)(IFXJS_Context*, const CJS_Parameters&, CJS_Value&, CFX_WideString&)>
+template <FX_BOOL (*F)(IFXJS_Context* cc,
+ const CJS_Parameters& params,
+ CJS_Value& vRet,
+ CFX_WideString& sError)>
void JSGlobalFunc(const char* func_name_string,
const v8::FunctionCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
@@ -467,7 +475,7 @@ void JSGlobalFunc(const char* func_name_string,
#define IMPLEMENT_JS_STATIC_GLOBAL_FUN(js_class_name) \
void js_class_name::DefineJSObjects(v8::Isolate* pIsolate) { \
- for (int i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \
+ for (size_t i = 0; i < FX_ArraySize(global_methods) - 1; ++i) { \
FXJS_DefineGlobalMethod(pIsolate, \
js_class_name::global_methods[i].pName, \
js_class_name::global_methods[i].pMethodCall); \
diff --git a/fpdfsdk/src/javascript/JS_EventHandler.cpp b/fpdfsdk/src/javascript/JS_EventHandler.cpp
index 42d61f4c1e..dd5c4427ce 100644
--- a/fpdfsdk/src/javascript/JS_EventHandler.cpp
+++ b/fpdfsdk/src/javascript/JS_EventHandler.cpp
@@ -613,13 +613,12 @@ FX_BOOL CJS_EventHandler::Shift() {
Field* CJS_EventHandler::Source() {
CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), m_pJSContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
- ASSERT(pDocObj.IsEmpty() == FALSE);
- v8::Local<v8::Object> pFieldObj =
- FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
- ASSERT(pFieldObj.IsEmpty() == FALSE);
+ pRuntime->GetIsolate(), m_pJSContext, CJS_Document::g_nObjDefnID);
+ ASSERT(!pDocObj.IsEmpty());
+
+ v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj(
+ pRuntime->GetIsolate(), m_pJSContext, CJS_Field::g_nObjDefnID);
+ ASSERT(!pFieldObj.IsEmpty());
CJS_Document* pJSDocument =
(CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj);
@@ -637,13 +636,12 @@ Field* CJS_EventHandler::Source() {
Field* CJS_EventHandler::Target_Field() {
CJS_Runtime* pRuntime = m_pJSContext->GetJSRuntime();
v8::Local<v8::Object> pDocObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), m_pJSContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
- ASSERT(pDocObj.IsEmpty() == FALSE);
- v8::Local<v8::Object> pFieldObj =
- FXJS_NewFxDynamicObj(pRuntime->GetIsolate(), m_pJSContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Field"));
- ASSERT(pFieldObj.IsEmpty() == FALSE);
+ pRuntime->GetIsolate(), m_pJSContext, CJS_Document::g_nObjDefnID);
+ ASSERT(!pDocObj.IsEmpty());
+
+ v8::Local<v8::Object> pFieldObj = FXJS_NewFxDynamicObj(
+ pRuntime->GetIsolate(), m_pJSContext, CJS_Field::g_nObjDefnID);
+ ASSERT(!pFieldObj.IsEmpty());
CJS_Document* pJSDocument =
(CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pDocObj);
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 563576a9d6..f206154029 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -109,34 +109,34 @@ void CJS_Runtime::DefineJSObjects() {
// The call order determines the "ObjDefID" assigned to each class.
// ObjDefIDs 0 - 2
- CJS_Border::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Display::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Font::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_Border::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Display::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Font::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 3 - 5
- CJS_Highlight::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Position::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_Highlight::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Position::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_ScaleHow::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 6 - 8
- CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Style::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_ScaleWhen::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Style::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Zoomtype::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 9 - 11
- CJS_App::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Color::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Console::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_App::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Color::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Console::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 12 - 14
- CJS_Document::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
- CJS_Event::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Field::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
+ CJS_Document::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_GLOBAL);
+ CJS_Event::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Field::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
// ObjDefIDs 15 - 17
- CJS_Global::DefineJSObjects(GetIsolate(), FXJS_STATIC);
- CJS_Icon::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
- CJS_Util::DefineJSObjects(GetIsolate(), FXJS_STATIC);
+ CJS_Global::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
+ CJS_Icon::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
+ CJS_Util::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_STATIC);
// ObjDefIDs 18 - 20 (these can't fail, return void).
CJS_PublicMethods::DefineJSObjects(GetIsolate());
@@ -144,8 +144,8 @@ void CJS_Runtime::DefineJSObjects() {
CJS_GlobalArrays::DefineJSObjects(GetIsolate());
// ObjDefIDs 21 - 22.
- CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
- CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJS_DYNAMIC);
+ CJS_TimerObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
+ CJS_PrintParamsObj::DefineJSObjects(GetIsolate(), FXJSOBJTYPE_DYNAMIC);
}
IFXJS_Context* CJS_Runtime::NewContext() {
@@ -185,8 +185,7 @@ void CJS_Runtime::SetReaderDocument(CPDFSDK_Document* pReaderDoc) {
if (pReaderDoc) {
v8::Local<v8::Object> pThis = FXJS_GetThisObj(GetIsolate());
if (!pThis.IsEmpty()) {
- if (FXJS_GetObjDefnID(pThis) ==
- FXJS_GetObjDefnID(GetIsolate(), L"Document")) {
+ if (FXJS_GetObjDefnID(pThis) == CJS_Document::g_nObjDefnID) {
if (CJS_Document* pJSDocument =
(CJS_Document*)FXJS_GetPrivate(GetIsolate(), pThis)) {
if (Document* pDocument = (Document*)pJSDocument->GetEmbedObject())
diff --git a/fpdfsdk/src/javascript/app.cpp b/fpdfsdk/src/javascript/app.cpp
index 892712243a..ae9001f04c 100644
--- a/fpdfsdk/src/javascript/app.cpp
+++ b/fpdfsdk/src/javascript/app.cpp
@@ -125,14 +125,12 @@ FX_BOOL app::activeDocs(IFXJS_Context* cc,
CJS_Document* pJSDocument = NULL;
if (pDoc == pCurDoc) {
v8::Local<v8::Object> pObj = FXJS_GetThisObj(pRuntime->GetIsolate());
- if (FXJS_GetObjDefnID(pObj) ==
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"))
+ if (FXJS_GetObjDefnID(pObj) == CJS_Document::g_nObjDefnID)
pJSDocument =
(CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
} else {
v8::Local<v8::Object> pObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"Document"));
+ pRuntime->GetIsolate(), pContext, CJS_Document::g_nObjDefnID);
pJSDocument =
(CJS_Document*)FXJS_GetPrivate(pRuntime->GetIsolate(), pObj);
ASSERT(pJSDocument != NULL);
@@ -421,20 +419,13 @@ FX_BOOL app::setInterval(IFXJS_Context* cc,
m_aTimer.Add(pTimer);
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
-
+ pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID);
CJS_TimerObj* pJS_TimerObj =
(CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
- ASSERT(pJS_TimerObj != NULL);
-
TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject();
- ASSERT(pTimerObj != NULL);
-
pTimerObj->SetTimer(pTimer);
vRet = pRetObj;
-
return TRUE;
}
@@ -469,20 +460,13 @@ FX_BOOL app::setTimeOut(IFXJS_Context* cc,
m_aTimer.Add(pTimer);
v8::Local<v8::Object> pRetObj = FXJS_NewFxDynamicObj(
- pRuntime->GetIsolate(), pContext,
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj"));
-
+ pRuntime->GetIsolate(), pContext, CJS_TimerObj::g_nObjDefnID);
CJS_TimerObj* pJS_TimerObj =
(CJS_TimerObj*)FXJS_GetPrivate(pRuntime->GetIsolate(), pRetObj);
- ASSERT(pJS_TimerObj != NULL);
-
TimerObj* pTimerObj = (TimerObj*)pJS_TimerObj->GetEmbedObject();
- ASSERT(pTimerObj != NULL);
-
pTimerObj->SetTimer(pTimer);
vRet = pRetObj;
-
return TRUE;
}
@@ -491,35 +475,28 @@ FX_BOOL app::clearTimeOut(IFXJS_Context* cc,
CJS_Value& vRet,
CFX_WideString& sError) {
CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
if (params.size() != 1) {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
if (params[0].GetType() == CJS_Value::VT_fxobject) {
v8::Local<v8::Object> pObj = params[0].ToV8Object();
- {
- if (FXJS_GetObjDefnID(pObj) ==
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")) {
- if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
- if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
- if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
- pTimer->KillJSTimer();
-
- for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
- if (m_aTimer[i] == pTimer) {
- m_aTimer.RemoveAt(i);
- break;
- }
+ if (FXJS_GetObjDefnID(pObj) == CJS_TimerObj::g_nObjDefnID) {
+ if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
+ if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
+ if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
+ pTimer->KillJSTimer();
+
+ for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
+ if (m_aTimer[i] == pTimer) {
+ m_aTimer.RemoveAt(i);
+ break;
}
-
- delete pTimer;
- pTimerObj->SetTimer(NULL);
}
+
+ delete pTimer;
+ pTimerObj->SetTimer(NULL);
}
}
}
@@ -534,35 +511,28 @@ FX_BOOL app::clearInterval(IFXJS_Context* cc,
CJS_Value& vRet,
CFX_WideString& sError) {
CJS_Context* pContext = (CJS_Context*)cc;
- ASSERT(pContext != NULL);
- CJS_Runtime* pRuntime = pContext->GetJSRuntime();
- ASSERT(pRuntime != NULL);
-
if (params.size() != 1) {
- sError = JSGetStringFromID((CJS_Context*)cc, IDS_STRING_JSPARAMERROR);
+ sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR);
return FALSE;
}
if (params[0].GetType() == CJS_Value::VT_fxobject) {
v8::Local<v8::Object> pObj = params[0].ToV8Object();
- {
- if (FXJS_GetObjDefnID(pObj) ==
- FXJS_GetObjDefnID(pRuntime->GetIsolate(), L"TimerObj")) {
- if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
- if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
- if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
- pTimer->KillJSTimer();
-
- for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
- if (m_aTimer[i] == pTimer) {
- m_aTimer.RemoveAt(i);
- break;
- }
+ if (FXJS_GetObjDefnID(pObj) == CJS_TimerObj::g_nObjDefnID) {
+ if (CJS_Object* pJSObj = params[0].ToCJSObject()) {
+ if (TimerObj* pTimerObj = (TimerObj*)pJSObj->GetEmbedObject()) {
+ if (CJS_Timer* pTimer = pTimerObj->GetTimer()) {
+ pTimer->KillJSTimer();
+
+ for (int i = 0, sz = m_aTimer.GetSize(); i < sz; i++) {
+ if (m_aTimer[i] == pTimer) {
+ m_aTimer.RemoveAt(i);
+ break;
}
-
- delete pTimer;
- pTimerObj->SetTimer(NULL);
}
+
+ delete pTimer;
+ pTimerObj->SetTimer(NULL);
}
}
}
diff --git a/fpdfsdk/src/javascript/app.h b/fpdfsdk/src/javascript/app.h
index 7824a1e99e..4cf1eca1b2 100644
--- a/fpdfsdk/src/javascript/app.h
+++ b/fpdfsdk/src/javascript/app.h
@@ -33,7 +33,7 @@ class CJS_TimerObj : public CJS_Object {
CJS_TimerObj(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_TimerObj() override {}
- DECLARE_JS_CLASS(CJS_TimerObj);
+ DECLARE_JS_CLASS();
};
class app : public CJS_EmbedObj {
@@ -177,7 +177,7 @@ class CJS_App : public CJS_Object {
explicit CJS_App(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_App() override {}
- DECLARE_JS_CLASS(CJS_App);
+ DECLARE_JS_CLASS();
JS_STATIC_PROP(activeDocs, app);
JS_STATIC_PROP(calculate, app);
diff --git a/fpdfsdk/src/javascript/color.h b/fpdfsdk/src/javascript/color.h
index 9dec19174e..12b1f7a01b 100644
--- a/fpdfsdk/src/javascript/color.h
+++ b/fpdfsdk/src/javascript/color.h
@@ -63,7 +63,7 @@ class CJS_Color : public CJS_Object {
CJS_Color(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Color() override {}
- DECLARE_JS_CLASS(CJS_Color);
+ DECLARE_JS_CLASS();
JS_STATIC_PROP(black, color);
JS_STATIC_PROP(blue, color);
diff --git a/fpdfsdk/src/javascript/console.h b/fpdfsdk/src/javascript/console.h
index 747bc15098..b3cdf268c2 100644
--- a/fpdfsdk/src/javascript/console.h
+++ b/fpdfsdk/src/javascript/console.h
@@ -38,7 +38,7 @@ class CJS_Console : public CJS_Object {
CJS_Console(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Console() override {}
- DECLARE_JS_CLASS(CJS_Console);
+ DECLARE_JS_CLASS();
JS_STATIC_METHOD(clear, console);
JS_STATIC_METHOD(hide, console);
diff --git a/fpdfsdk/src/javascript/event.h b/fpdfsdk/src/javascript/event.h
index 29ff3bc290..8efa2dfbb8 100644
--- a/fpdfsdk/src/javascript/event.h
+++ b/fpdfsdk/src/javascript/event.h
@@ -62,8 +62,7 @@ class CJS_Event : public CJS_Object {
CJS_Event(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Event() override {}
- DECLARE_JS_CLASS(CJS_Event);
-
+ DECLARE_JS_CLASS();
JS_STATIC_PROP(change, event);
JS_STATIC_PROP(changeEx, event);
JS_STATIC_PROP(commitKey, event);
diff --git a/fpdfsdk/src/javascript/global.h b/fpdfsdk/src/javascript/global.h
index 03b6e76bc8..ac79ff2f3d 100644
--- a/fpdfsdk/src/javascript/global.h
+++ b/fpdfsdk/src/javascript/global.h
@@ -85,8 +85,7 @@ class CJS_Global : public CJS_Object {
// CJS_Object
FX_BOOL InitInstance(IFXJS_Context* cc) override;
- DECLARE_SPECIAL_JS_CLASS(CJS_Global);
-
+ DECLARE_SPECIAL_JS_CLASS();
JS_SPECIAL_STATIC_METHOD(setPersistent, JSGlobalAlternate, global);
};
diff --git a/fpdfsdk/src/javascript/report.h b/fpdfsdk/src/javascript/report.h
index 0b4be6d6d7..798106bb11 100644
--- a/fpdfsdk/src/javascript/report.h
+++ b/fpdfsdk/src/javascript/report.h
@@ -30,8 +30,7 @@ class CJS_Report : public CJS_Object {
CJS_Report(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Report() override {}
- public:
- DECLARE_JS_CLASS(CJS_Report);
+ DECLARE_JS_CLASS();
JS_STATIC_METHOD(save, Report)
JS_STATIC_METHOD(writeText, Report);
diff --git a/fpdfsdk/src/javascript/util.h b/fpdfsdk/src/javascript/util.h
index c88462c349..8d0d5bd562 100644
--- a/fpdfsdk/src/javascript/util.h
+++ b/fpdfsdk/src/javascript/util.h
@@ -54,7 +54,7 @@ class CJS_Util : public CJS_Object {
CJS_Util(v8::Local<v8::Object> pObject) : CJS_Object(pObject) {}
~CJS_Util() override {}
- DECLARE_JS_CLASS(CJS_Util);
+ DECLARE_JS_CLASS();
JS_STATIC_METHOD(printd, util);
JS_STATIC_METHOD(printf, util);