summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-03-04 12:33:33 -0800
committerTom Sepez <tsepez@chromium.org>2016-03-04 12:33:33 -0800
commit1a35d55dd6b0d1ea1918e2d6a6c25faf599ba168 (patch)
tree9511760e78804772d1035613abfeff71abe61870 /fpdfsdk/src
parent3e44a7bd2b60ace1ee8bc8f48c709056f65c3dc1 (diff)
downloadpdfium-1a35d55dd6b0d1ea1918e2d6a6c25faf599ba168.tar.xz
Revert "Only place primitive objects on the V8 global template."
This reverts commit 3e44a7bd2b60ace1ee8bc8f48c709056f65c3dc1. R=ochang@chromium.org TBR=ochang@chromium.org Review URL: https://codereview.chromium.org/1767793002 .
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/javascript/Consts.cpp273
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.cpp9
-rw-r--r--fpdfsdk/src/javascript/JS_Runtime.h4
-rw-r--r--fpdfsdk/src/jsapi/fxjs_v8.cpp11
4 files changed, 186 insertions, 111 deletions
diff --git a/fpdfsdk/src/javascript/Consts.cpp b/fpdfsdk/src/javascript/Consts.cpp
index b7cc2d0a46..132f214d2d 100644
--- a/fpdfsdk/src/javascript/Consts.cpp
+++ b/fpdfsdk/src/javascript/Consts.cpp
@@ -11,6 +11,8 @@
#include "fpdfsdk/src/javascript/JS_Object.h"
#include "fpdfsdk/src/javascript/JS_Value.h"
+/* ------------------------------ border ------------------------------ */
+
BEGIN_JS_STATIC_CONST(CJS_Border)
JS_STATIC_CONST_ENTRY_STRING(L"s", L"solid")
JS_STATIC_CONST_ENTRY_STRING(L"b", L"beveled")
@@ -18,16 +20,22 @@ JS_STATIC_CONST_ENTRY_STRING(L"d", L"dashed")
JS_STATIC_CONST_ENTRY_STRING(L"i", L"inset")
JS_STATIC_CONST_ENTRY_STRING(L"u", L"underline")
END_JS_STATIC_CONST()
+
IMPLEMENT_JS_CLASS_CONST(CJS_Border, border)
+/* ------------------------------ display ------------------------------ */
+
BEGIN_JS_STATIC_CONST(CJS_Display)
JS_STATIC_CONST_ENTRY_NUMBER(L"visible", 0)
JS_STATIC_CONST_ENTRY_NUMBER(L"hidden", 1)
JS_STATIC_CONST_ENTRY_NUMBER(L"noPrint", 2)
JS_STATIC_CONST_ENTRY_NUMBER(L"noView", 3)
END_JS_STATIC_CONST()
+
IMPLEMENT_JS_CLASS_CONST(CJS_Display, display)
+/* ------------------------------ font ------------------------------ */
+
BEGIN_JS_STATIC_CONST(CJS_Font)
JS_STATIC_CONST_ENTRY_STRING(L"Times", L"Times-Roman")
JS_STATIC_CONST_ENTRY_STRING(L"TimesB", L"Times-Bold")
@@ -44,16 +52,22 @@ JS_STATIC_CONST_ENTRY_STRING(L"CourBI", L"Courier-BoldOblique")
JS_STATIC_CONST_ENTRY_STRING(L"Symbol", L"Symbol")
JS_STATIC_CONST_ENTRY_STRING(L"ZapfD", L"ZapfDingbats")
END_JS_STATIC_CONST()
+
IMPLEMENT_JS_CLASS_CONST(CJS_Font, font)
+/* ------------------------------ highlight ------------------------------ */
+
BEGIN_JS_STATIC_CONST(CJS_Highlight)
JS_STATIC_CONST_ENTRY_STRING(L"n", L"none")
JS_STATIC_CONST_ENTRY_STRING(L"i", L"invert")
JS_STATIC_CONST_ENTRY_STRING(L"p", L"push")
JS_STATIC_CONST_ENTRY_STRING(L"o", L"outline")
END_JS_STATIC_CONST()
+
IMPLEMENT_JS_CLASS_CONST(CJS_Highlight, highlight)
+/* ------------------------------ position ------------------------------ */
+
BEGIN_JS_STATIC_CONST(CJS_Position)
JS_STATIC_CONST_ENTRY_NUMBER(L"textOnly", 0)
JS_STATIC_CONST_ENTRY_NUMBER(L"iconOnly", 1)
@@ -63,22 +77,31 @@ JS_STATIC_CONST_ENTRY_NUMBER(L"iconTextH", 4)
JS_STATIC_CONST_ENTRY_NUMBER(L"textIconH", 5)
JS_STATIC_CONST_ENTRY_NUMBER(L"overlay", 6)
END_JS_STATIC_CONST()
+
IMPLEMENT_JS_CLASS_CONST(CJS_Position, position)
+/* ------------------------------ scaleHow ------------------------------ */
+
BEGIN_JS_STATIC_CONST(CJS_ScaleHow)
JS_STATIC_CONST_ENTRY_NUMBER(L"proportional", 0)
JS_STATIC_CONST_ENTRY_NUMBER(L"anamorphic", 1)
END_JS_STATIC_CONST()
+
IMPLEMENT_JS_CLASS_CONST(CJS_ScaleHow, scaleHow)
+/* ------------------------------ scaleWhen ------------------------------ */
+
BEGIN_JS_STATIC_CONST(CJS_ScaleWhen)
JS_STATIC_CONST_ENTRY_NUMBER(L"always", 0)
JS_STATIC_CONST_ENTRY_NUMBER(L"never", 1)
JS_STATIC_CONST_ENTRY_NUMBER(L"tooBig", 2)
JS_STATIC_CONST_ENTRY_NUMBER(L"tooSmall", 3)
END_JS_STATIC_CONST()
+
IMPLEMENT_JS_CLASS_CONST(CJS_ScaleWhen, scaleWhen)
+/* ------------------------------ style ------------------------------ */
+
BEGIN_JS_STATIC_CONST(CJS_Style)
JS_STATIC_CONST_ENTRY_STRING(L"ch", L"check")
JS_STATIC_CONST_ENTRY_STRING(L"cr", L"cross")
@@ -87,8 +110,11 @@ JS_STATIC_CONST_ENTRY_STRING(L"ci", L"circle")
JS_STATIC_CONST_ENTRY_STRING(L"st", L"star")
JS_STATIC_CONST_ENTRY_STRING(L"sq", L"square")
END_JS_STATIC_CONST()
+
IMPLEMENT_JS_CLASS_CONST(CJS_Style, style)
+/* ------------------------------ zoomtype ------------------------------ */
+
BEGIN_JS_STATIC_CONST(CJS_Zoomtype)
JS_STATIC_CONST_ENTRY_STRING(L"none", L"NoVary")
JS_STATIC_CONST_ENTRY_STRING(L"fitP", L"FitPage")
@@ -98,109 +124,172 @@ JS_STATIC_CONST_ENTRY_STRING(L"fitV", L"FitVisibleWidth")
JS_STATIC_CONST_ENTRY_STRING(L"pref", L"Preferred")
JS_STATIC_CONST_ENTRY_STRING(L"refW", L"ReflowWidth")
END_JS_STATIC_CONST()
+
IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype)
-#define GLOBAL_STRING(rt, name, value) \
- FXJS_DefineGlobalConst( \
- (rt)->GetIsolate(), (name), \
- [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
- info.GetReturnValue().Set(FXJS_NewString(info.GetIsolate(), (value))); \
- })
+/* ------------------------------ CJS_GlobalConsts ------------------------- */
+
+static void DefineGlobalConstString(CJS_Runtime* pRuntime,
+ const wchar_t* pConstName,
+ const wchar_t* pValue) {
+ FXJS_DefineGlobalConst(pRuntime->GetIsolate(), pConstName,
+ FXJS_NewString(pRuntime->GetIsolate(), pValue));
+}
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.");
+ DefineGlobalConstString(
+ pRuntime, L"IDS_GREATER_THAN",
+ L"Invalid value: must be greater than or equal to % s.");
+ DefineGlobalConstString(
+ pRuntime, L"IDS_GT_AND_LT",
+ L"Invalid value: must be greater than or equal to % s "
+ L"and less than or equal to % s.");
+ DefineGlobalConstString(pRuntime, L"IDS_LESS_THAN",
+ L"Invalid value: must be less than or equal to % s.");
+ DefineGlobalConstString(pRuntime, L"IDS_INVALID_MONTH", L"**Invalid**");
+ DefineGlobalConstString(
+ pRuntime, L"IDS_INVALID_DATE",
+ L"Invalid date / time: please ensure that the date / time exists.Field");
+ DefineGlobalConstString(
+ pRuntime, L"IDS_INVALID_VALUE",
+ L"The value entered does not match the format of the field");
+ DefineGlobalConstString(pRuntime, L"IDS_AM", L"am");
+ DefineGlobalConstString(pRuntime, L"IDS_PM", L"pm");
+ DefineGlobalConstString(
+ pRuntime, L"IDS_MONTH_INFO",
+ L"January[1] February[2] March[3] April[4] May[5] "
+ L"June[6] July[7] August[8] September[9] October[10] "
+ L"November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] "
+ L"Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] "
+ L"Dec[12]");
+ DefineGlobalConstString(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **");
+}
+
+/* ------------------------------ CJS_GlobalArrays ------------------------ */
- GLOBAL_STRING(pRuntime, L"IDS_GT_AND_LT",
- L"Invalid value: must be greater than or equal to % s "
- L"and less than or equal to % s.");
+void DefineGlobalConstStringArray(CJS_Runtime* pRuntime,
+ const wchar_t* sConstName,
+ const wchar_t** pValues,
+ size_t nValues) {
+ CJS_Array array(pRuntime);
+ for (size_t i = 0; i < nValues; ++i) {
+ array.SetElement(i, CJS_Value(pRuntime, pValues[i]));
+ }
+ CJS_PropValue prop(pRuntime);
+ prop << array;
+ FXJS_DefineGlobalConst(pRuntime->GetIsolate(), sConstName, prop.ToV8Value());
+}
- GLOBAL_STRING(pRuntime, L"IDS_LESS_THAN",
- L"Invalid value: must be less than or equal to % s.");
+void CJS_GlobalArrays::DefineJSObjects(CJS_Runtime* pRuntime) {
+ {
+ const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP";
+ const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"};
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
- GLOBAL_STRING(pRuntime, L"IDS_INVALID_MONTH", L"**Invalid**");
- GLOBAL_STRING(
- pRuntime, L"IDS_INVALID_DATE",
- L"Invalid date / time: please ensure that the date / time exists.Field");
+ {
+ const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_DOT_SEP";
+ const FX_WCHAR* ArrayContent[] = {
+ L"[+-]?\\d+(\\.\\d+)?", /* -1.0 or -1 */
+ L"[+-]?\\.\\d+", /* -.1 */
+ L"[+-]?\\d+\\." /* -1. */
+ };
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
- GLOBAL_STRING(pRuntime, L"IDS_INVALID_VALUE",
- L"The value entered does not match the format of the field");
+ {
+ const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_COMMA_SEP";
+ const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*,?\\d*"};
- GLOBAL_STRING(pRuntime, L"IDS_AM", L"am");
- GLOBAL_STRING(pRuntime, L"IDS_PM", L"pm");
- GLOBAL_STRING(pRuntime, L"IDS_MONTH_INFO",
- L"January[1] February[2] March[3] April[4] May[5] "
- L"June[6] July[7] August[8] September[9] October[10] "
- L"November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] "
- L"Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] "
- L"Dec[12]");
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
- GLOBAL_STRING(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **");
-}
+ {
+ const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_COMMA_SEP";
+ const FX_WCHAR* ArrayContent[] = {
+ L"[+-]?\\d+([.,]\\d+)?", /* -1,0 or -1 */
+ L"[+-]?[.,]\\d+", /* -,1 */
+ L"[+-]?\\d+[.,]" /* -1, */
+ };
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
-#define GLOBAL_ARRAY(rt, name, ...) \
- { \
- const FX_WCHAR* values[] = {__VA_ARGS__}; \
- v8::Local<v8::Array> array = FXJS_NewArray((rt)->GetIsolate()); \
- for (size_t i = 0; i < FX_ArraySize(values); ++i) \
- array->Set(i, FXJS_NewString((rt)->GetIsolate(), values[i])); \
- rt->SetConstArray(name, array); \
- FXJS_DefineGlobalConst( \
- (rt)->GetIsolate(), (name), \
- [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
- CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>( \
- FXJS_GetRuntimeFromIsolate(info.GetIsolate())); \
- if (pRuntime) \
- info.GetReturnValue().Set(pRuntime->GetConstArray(name)); \
- }); \
+ {
+ const FX_WCHAR* ArrayName = L"RE_ZIP_ENTRY";
+ const FX_WCHAR* ArrayContent[] = {L"\\d{0,5}"};
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
}
-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",
- L"[+-]?\\d+(\\.\\d+)?", // -1.0 or -1
- L"[+-]?\\.\\d+", // -.1
- L"[+-]?\\d+\\."); // -1.
-
- GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_ENTRY_COMMA_SEP", L"[+-]?\\d*,?\\d*");
- GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_COMMIT_COMMA_SEP",
- L"[+-]?\\d+([.,]\\d+)?", // -1,0 or -1
- L"[+-]?[.,]\\d+", // -,1
- L"[+-]?\\d+[.,]"); // -1,
-
- GLOBAL_ARRAY(pRuntime, L"RE_ZIP_ENTRY", L"\\d{0,5}");
- GLOBAL_ARRAY(pRuntime, L"RE_ZIP_COMMIT", L"\\d{5}");
- GLOBAL_ARRAY(pRuntime, L"RE_ZIP4_ENTRY", L"\\d{0,5}(\\.|[- ])?\\d{0,4}");
- GLOBAL_ARRAY(pRuntime, L"RE_ZIP4_COMMIT", L"\\d{5}(\\.|[- ])?\\d{4}");
- GLOBAL_ARRAY(pRuntime, L"RE_PHONE_ENTRY",
- // 555-1234 or 408 555-1234
- L"\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
-
- // (408
- L"\\(\\d{0,3}",
-
- // (408) 555-1234
- // (allow the addition of parens as an afterthought)
- L"\\(\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
-
- // (408 555-1234
- L"\\(\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
-
- // 408) 555-1234
- L"\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}",
-
- // international
- L"011(\\.|[- \\d])*");
-
- GLOBAL_ARRAY(
- pRuntime, L"RE_PHONE_COMMIT", L"\\d{3}(\\.|[- ])?\\d{4}", // 555-1234
- L"\\d{3}(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // 408 555-1234
- L"\\(\\d{3}\\)(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // (408) 555-1234
- L"011(\\.|[- \\d])*"); // international
-
- GLOBAL_ARRAY(pRuntime, L"RE_SSN_ENTRY",
- L"\\d{0,3}(\\.|[- ])?\\d{0,2}(\\.|[- ])?\\d{0,4}");
-
- GLOBAL_ARRAY(pRuntime, L"RE_SSN_COMMIT",
- L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}");
+ {
+ const FX_WCHAR* ArrayName = L"RE_ZIP_COMMIT";
+ const FX_WCHAR* ArrayContent[] = {L"\\d{5}"};
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
+
+ {
+ const FX_WCHAR* ArrayName = L"RE_ZIP4_ENTRY";
+ const FX_WCHAR* ArrayContent[] = {L"\\d{0,5}(\\.|[- ])?\\d{0,4}"};
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
+
+ {
+ const FX_WCHAR* ArrayName = L"RE_ZIP4_COMMIT";
+ const FX_WCHAR* ArrayContent[] = {L"\\d{5}(\\.|[- ])?\\d{4}"};
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
+
+ {
+ const FX_WCHAR* ArrayName = L"RE_PHONE_ENTRY";
+ const FX_WCHAR* ArrayContent[] = {
+ L"\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", // 555-1234 or 408
+ // 555-1234
+ L"\\(\\d{0,3}", // (408
+ L"\\(\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", // (408)
+ // 555-1234
+ // (allow the addition of parens as an afterthought)
+ L"\\(\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", // (408 555-1234
+
+ L"\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", // 408) 555-1234
+
+ L"011(\\.|[- \\d])*" // international
+ };
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
+
+ {
+ const FX_WCHAR* ArrayName = L"RE_PHONE_COMMIT";
+ const FX_WCHAR* ArrayContent[] = {
+ L"\\d{3}(\\.|[- ])?\\d{4}", // 555-1234
+ L"\\d{3}(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // 408 555-1234
+ L"\\(\\d{3}\\)(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // (408) 555-1234
+ L"011(\\.|[- \\d])*" // international
+ };
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
+
+ {
+ const FX_WCHAR* ArrayName = L"RE_SSN_ENTRY";
+ const FX_WCHAR* ArrayContent[] = {
+ L"\\d{0,3}(\\.|[- ])?\\d{0,2}(\\.|[- ])?\\d{0,4}"};
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
+
+ {
+ const FX_WCHAR* ArrayName = L"RE_SSN_COMMIT";
+ const FX_WCHAR* ArrayContent[] = {
+ L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"};
+ DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent,
+ FX_ArraySize(ArrayContent));
+ }
}
diff --git a/fpdfsdk/src/javascript/JS_Runtime.cpp b/fpdfsdk/src/javascript/JS_Runtime.cpp
index 342b43e267..76221db3f2 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.cpp
+++ b/fpdfsdk/src/javascript/JS_Runtime.cpp
@@ -256,15 +256,6 @@ v8::Local<v8::Context> CJS_Runtime::NewJSContext() {
return v8::Local<v8::Context>::New(m_isolate, m_context);
}
-void CJS_Runtime::SetConstArray(const CFX_WideString& name,
- v8::Local<v8::Array> array) {
- m_ConstArrays[name] = v8::Global<v8::Array>(m_isolate, array);
-}
-
-v8::Local<v8::Array> CJS_Runtime::GetConstArray(const CFX_WideString& name) {
- return v8::Local<v8::Array>::New(m_isolate, m_ConstArrays[name]);
-}
-
#ifdef PDF_ENABLE_XFA
CFX_WideString ChangeObjName(const CFX_WideString& str) {
CFX_WideString sRet = str;
diff --git a/fpdfsdk/src/javascript/JS_Runtime.h b/fpdfsdk/src/javascript/JS_Runtime.h
index 8215b88994..6fc3894f44 100644
--- a/fpdfsdk/src/javascript/JS_Runtime.h
+++ b/fpdfsdk/src/javascript/JS_Runtime.h
@@ -58,9 +58,6 @@ class CJS_Runtime : public IJS_Runtime {
v8::Isolate* GetIsolate() const { return m_isolate; }
v8::Local<v8::Context> NewJSContext();
- void SetConstArray(const CFX_WideString& name, v8::Local<v8::Array> array);
- v8::Local<v8::Array> GetConstArray(const CFX_WideString& name);
-
#ifdef PDF_ENABLE_XFA
FX_BOOL GetHValueByName(const CFX_ByteStringC& utf8Name,
FXJSE_HVALUE hValue) override;
@@ -83,7 +80,6 @@ class CJS_Runtime : public IJS_Runtime {
bool m_isolateManaged;
v8::Global<v8::Context> m_context;
std::vector<v8::Global<v8::Object>*> m_StaticObjects;
- std::map<CFX_WideString, v8::Global<v8::Array>> m_ConstArrays;
std::set<Observer*> m_observers;
};
diff --git a/fpdfsdk/src/jsapi/fxjs_v8.cpp b/fpdfsdk/src/jsapi/fxjs_v8.cpp
index 5631ab6258..f015f87136 100644
--- a/fpdfsdk/src/jsapi/fxjs_v8.cpp
+++ b/fpdfsdk/src/jsapi/fxjs_v8.cpp
@@ -287,15 +287,14 @@ void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate,
void FXJS_DefineGlobalConst(v8::Isolate* pIsolate,
const wchar_t* sConstName,
- v8::FunctionCallback pConstGetter) {
+ v8::Local<v8::Value> pDefault) {
v8::Isolate::Scope isolate_scope(pIsolate);
v8::HandleScope handle_scope(pIsolate);
CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode();
- GetGlobalObjectTemplate(pIsolate)
- ->SetAccessorProperty(v8::String::NewFromUtf8(pIsolate, bsConst.c_str(),
- v8::NewStringType::kNormal)
- .ToLocalChecked(),
- v8::FunctionTemplate::New(pIsolate, pConstGetter));
+ GetGlobalObjectTemplate(pIsolate)->Set(
+ v8::String::NewFromUtf8(pIsolate, bsConst.c_str(),
+ v8::NewStringType::kNormal).ToLocalChecked(),
+ pDefault, v8::ReadOnly);
}
void FXJS_InitializeRuntime(