diff options
author | tsepez <tsepez@chromium.org> | 2016-08-15 16:44:55 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-15 16:44:55 -0700 |
commit | b4694249b336d1c0bea9222880b49dcf9284791d (patch) | |
tree | 681a503d12000b78296bcacf4fce046922335950 /fpdfsdk/javascript/Consts.cpp | |
parent | 19cdfe4d73370b21709aefd9dce06cf463239fa1 (diff) | |
download | pdfium-b4694249b336d1c0bea9222880b49dcf9284791d.tar.xz |
Push v8::Isolate into CFXJS_Engine classchromium/2831
Nearly all the "loose" functions in FXJS become methods on
the CFJXS_Engine.
This is the "missing link" wrt some layering violatons that
have been around forever. We can stop passing &m_ variables
from CJS_ down into FXJS Initialization as a result.
Review-Url: https://codereview.chromium.org/2245863002
Diffstat (limited to 'fpdfsdk/javascript/Consts.cpp')
-rw-r--r-- | fpdfsdk/javascript/Consts.cpp | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/fpdfsdk/javascript/Consts.cpp b/fpdfsdk/javascript/Consts.cpp index 19988a61ea..c224ad0de8 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) { |