summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-06-04 19:19:07 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-04 19:19:07 +0000
commitad978ed196882ce29e6a4e0757770da6cfc44f81 (patch)
tree742f6d2de3d4edc30b56b79553e89c230071cf7a
parentf8cf36b2a385ed17bc34cf394dfe4e379a563820 (diff)
downloadpdfium-ad978ed196882ce29e6a4e0757770da6cfc44f81.tar.xz
cjs_globalconsts.cpp need not use v8::Context slots
Small step towards deprecating FXJS's use of v8::Context slots. Reduces some string constant storage size while were at it by avoiding wide literals for ascii strings. Change-Id: Ibc651cff264302681645fde7c53bf77517b97651 Reviewed-on: https://pdfium-review.googlesource.com/33470 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
-rw-r--r--fxjs/cjs_globalconsts.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/fxjs/cjs_globalconsts.cpp b/fxjs/cjs_globalconsts.cpp
index a07bf60302..cb6bd33c47 100644
--- a/fxjs/cjs_globalconsts.cpp
+++ b/fxjs/cjs_globalconsts.cpp
@@ -6,42 +6,44 @@
#include "fxjs/cjs_globalconsts.h"
-#define GLOBAL_STRING(rt, name, value) \
- (rt)->DefineGlobalConst( \
- (name), [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
- info.GetReturnValue().Set( \
- CFXJS_Engine::EngineFromIsolateCurrentContext(info.GetIsolate()) \
- ->NewString(value)); \
+#define GLOBAL_STRING(rt, name, value) \
+ (rt)->DefineGlobalConst( \
+ (name), [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
+ const char* pStr = (value); \
+ info.GetReturnValue().Set( \
+ v8::String::NewFromUtf8(info.GetIsolate(), pStr, \
+ v8::NewStringType::kNormal, strlen(pStr)) \
+ .ToLocalChecked()); \
})
// 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.");
+ "Invalid value: must be greater than or equal to % s.");
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.");
+ "Invalid value: must be greater than or equal to % s "
+ "and less than or equal to % s.");
GLOBAL_STRING(pRuntime, L"IDS_LESS_THAN",
- L"Invalid value: must be less than or equal to % s.");
+ "Invalid value: must be less than or equal to % s.");
- GLOBAL_STRING(pRuntime, L"IDS_INVALID_MONTH", L"**Invalid**");
+ GLOBAL_STRING(pRuntime, L"IDS_INVALID_MONTH", "**Invalid**");
GLOBAL_STRING(
pRuntime, L"IDS_INVALID_DATE",
- L"Invalid date / time: please ensure that the date / time exists.Field");
+ "Invalid date / time: please ensure that the date / time exists.Field");
GLOBAL_STRING(pRuntime, L"IDS_INVALID_VALUE",
- L"The value entered does not match the format of the field");
+ "The value entered does not match the format of the field");
- GLOBAL_STRING(pRuntime, L"IDS_AM", L"am");
- GLOBAL_STRING(pRuntime, L"IDS_PM", L"pm");
+ GLOBAL_STRING(pRuntime, L"IDS_AM", "am");
+ GLOBAL_STRING(pRuntime, L"IDS_PM", "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]");
+ "January[1] February[2] March[3] April[4] May[5] "
+ "June[6] July[7] August[8] September[9] October[10] "
+ "November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] "
+ "Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] "
+ "Dec[12]");
- GLOBAL_STRING(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **");
+ GLOBAL_STRING(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", "** ^ _ ^ **");
}