Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: fpdfsdk/javascript/Consts.cpp

Issue 2245863002: Push v8::Isolate into CFXJS_Engine class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Null isolate before letting CFXJS_Engine dtor invoked Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | fpdfsdk/javascript/Document.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fpdfsdk/javascript/Consts.cpp
diff --git a/fpdfsdk/javascript/Consts.cpp b/fpdfsdk/javascript/Consts.cpp
index 19988a61eaf92ac0c8d393b53d1be5b7779b7e4b..c224ad0de8f4e002bf8e5259d4d9459158a3a69c 100644
--- a/fpdfsdk/javascript/Consts.cpp
+++ b/fpdfsdk/javascript/Consts.cpp
@@ -99,11 +99,12 @@ 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))); \
+#define GLOBAL_STRING(rt, name, value) \
+ (rt)->DefineGlobalConst( \
+ (name), [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
+ info.GetReturnValue().Set( \
+ CFXJS_Engine::CurrentEngineFromIsolate(info.GetIsolate()) \
+ ->NewString(value)); \
})
void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) {
@@ -137,21 +138,20 @@ void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) {
GLOBAL_STRING(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **");
}
-#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* pLocalRuntime = static_cast<CJS_Runtime*>( \
- FXJS_GetCurrentEngineFromIsolate(info.GetIsolate())); \
- if (pLocalRuntime) \
- info.GetReturnValue().Set(pLocalRuntime->GetConstArray(name)); \
- }); \
+#define GLOBAL_ARRAY(rt, name, ...) \
+ { \
+ const FX_WCHAR* values[] = {__VA_ARGS__}; \
+ v8::Local<v8::Array> array = (rt)->NewArray(); \
+ for (size_t i = 0; i < FX_ArraySize(values); ++i) \
+ array->Set(i, (rt)->NewString(values[i])); \
+ (rt)->SetConstArray((name), array); \
+ (rt)->DefineGlobalConst( \
+ (name), [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
+ CJS_Runtime* pCurrentRuntime = \
+ CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate()); \
+ if (pCurrentRuntime) \
+ info.GetReturnValue().Set(pCurrentRuntime->GetConstArray(name)); \
+ }); \
}
void CJS_GlobalArrays::DefineJSObjects(CJS_Runtime* pRuntime) {
« no previous file with comments | « no previous file | fpdfsdk/javascript/Document.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698