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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | fpdfsdk/javascript/Document.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/javascript/Consts.h" 7 #include "fpdfsdk/javascript/Consts.h"
8 8
9 #include "fpdfsdk/javascript/JS_Define.h" 9 #include "fpdfsdk/javascript/JS_Define.h"
10 #include "fpdfsdk/javascript/JS_Object.h" 10 #include "fpdfsdk/javascript/JS_Object.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 JS_STATIC_CONST_ENTRY_STRING(L"none", L"NoVary") 92 JS_STATIC_CONST_ENTRY_STRING(L"none", L"NoVary")
93 JS_STATIC_CONST_ENTRY_STRING(L"fitP", L"FitPage") 93 JS_STATIC_CONST_ENTRY_STRING(L"fitP", L"FitPage")
94 JS_STATIC_CONST_ENTRY_STRING(L"fitW", L"FitWidth") 94 JS_STATIC_CONST_ENTRY_STRING(L"fitW", L"FitWidth")
95 JS_STATIC_CONST_ENTRY_STRING(L"fitH", L"FitHeight") 95 JS_STATIC_CONST_ENTRY_STRING(L"fitH", L"FitHeight")
96 JS_STATIC_CONST_ENTRY_STRING(L"fitV", L"FitVisibleWidth") 96 JS_STATIC_CONST_ENTRY_STRING(L"fitV", L"FitVisibleWidth")
97 JS_STATIC_CONST_ENTRY_STRING(L"pref", L"Preferred") 97 JS_STATIC_CONST_ENTRY_STRING(L"pref", L"Preferred")
98 JS_STATIC_CONST_ENTRY_STRING(L"refW", L"ReflowWidth") 98 JS_STATIC_CONST_ENTRY_STRING(L"refW", L"ReflowWidth")
99 END_JS_STATIC_CONST() 99 END_JS_STATIC_CONST()
100 IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype) 100 IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype)
101 101
102 #define GLOBAL_STRING(rt, name, value) \ 102 #define GLOBAL_STRING(rt, name, value) \
103 FXJS_DefineGlobalConst( \ 103 (rt)->DefineGlobalConst( \
104 (rt)->GetIsolate(), (name), \ 104 (name), [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
105 [](const v8::FunctionCallbackInfo<v8::Value>& info) { \ 105 info.GetReturnValue().Set( \
106 info.GetReturnValue().Set(FXJS_NewString(info.GetIsolate(), (value))); \ 106 CFXJS_Engine::CurrentEngineFromIsolate(info.GetIsolate()) \
107 ->NewString(value)); \
107 }) 108 })
108 109
109 void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) { 110 void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) {
110 GLOBAL_STRING(pRuntime, L"IDS_GREATER_THAN", 111 GLOBAL_STRING(pRuntime, L"IDS_GREATER_THAN",
111 L"Invalid value: must be greater than or equal to % s."); 112 L"Invalid value: must be greater than or equal to % s.");
112 113
113 GLOBAL_STRING(pRuntime, L"IDS_GT_AND_LT", 114 GLOBAL_STRING(pRuntime, L"IDS_GT_AND_LT",
114 L"Invalid value: must be greater than or equal to % s " 115 L"Invalid value: must be greater than or equal to % s "
115 L"and less than or equal to % s."); 116 L"and less than or equal to % s.");
116 117
(...skipping 13 matching lines...) Expand all
130 GLOBAL_STRING(pRuntime, L"IDS_MONTH_INFO", 131 GLOBAL_STRING(pRuntime, L"IDS_MONTH_INFO",
131 L"January[1] February[2] March[3] April[4] May[5] " 132 L"January[1] February[2] March[3] April[4] May[5] "
132 L"June[6] July[7] August[8] September[9] October[10] " 133 L"June[6] July[7] August[8] September[9] October[10] "
133 L"November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] " 134 L"November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] "
134 L"Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] " 135 L"Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] "
135 L"Dec[12]"); 136 L"Dec[12]");
136 137
137 GLOBAL_STRING(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **"); 138 GLOBAL_STRING(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **");
138 } 139 }
139 140
140 #define GLOBAL_ARRAY(rt, name, ...) \ 141 #define GLOBAL_ARRAY(rt, name, ...) \
141 { \ 142 { \
142 const FX_WCHAR* values[] = {__VA_ARGS__}; \ 143 const FX_WCHAR* values[] = {__VA_ARGS__}; \
143 v8::Local<v8::Array> array = FXJS_NewArray((rt)->GetIsolate()); \ 144 v8::Local<v8::Array> array = (rt)->NewArray(); \
144 for (size_t i = 0; i < FX_ArraySize(values); ++i) \ 145 for (size_t i = 0; i < FX_ArraySize(values); ++i) \
145 array->Set(i, FXJS_NewString((rt)->GetIsolate(), values[i])); \ 146 array->Set(i, (rt)->NewString(values[i])); \
146 rt->SetConstArray(name, array); \ 147 (rt)->SetConstArray((name), array); \
147 FXJS_DefineGlobalConst( \ 148 (rt)->DefineGlobalConst( \
148 (rt)->GetIsolate(), (name), \ 149 (name), [](const v8::FunctionCallbackInfo<v8::Value>& info) { \
149 [](const v8::FunctionCallbackInfo<v8::Value>& info) { \ 150 CJS_Runtime* pCurrentRuntime = \
150 CJS_Runtime* pLocalRuntime = static_cast<CJS_Runtime*>( \ 151 CJS_Runtime::CurrentRuntimeFromIsolate(info.GetIsolate()); \
151 FXJS_GetCurrentEngineFromIsolate(info.GetIsolate())); \ 152 if (pCurrentRuntime) \
152 if (pLocalRuntime) \ 153 info.GetReturnValue().Set(pCurrentRuntime->GetConstArray(name)); \
153 info.GetReturnValue().Set(pLocalRuntime->GetConstArray(name)); \ 154 }); \
154 }); \
155 } 155 }
156 156
157 void CJS_GlobalArrays::DefineJSObjects(CJS_Runtime* pRuntime) { 157 void CJS_GlobalArrays::DefineJSObjects(CJS_Runtime* pRuntime) {
158 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_ENTRY_DOT_SEP", L"[+-]?\\d*\\.?\\d*"); 158 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_ENTRY_DOT_SEP", L"[+-]?\\d*\\.?\\d*");
159 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_COMMIT_DOT_SEP", 159 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_COMMIT_DOT_SEP",
160 L"[+-]?\\d+(\\.\\d+)?", // -1.0 or -1 160 L"[+-]?\\d+(\\.\\d+)?", // -1.0 or -1
161 L"[+-]?\\.\\d+", // -.1 161 L"[+-]?\\.\\d+", // -.1
162 L"[+-]?\\d+\\."); // -1. 162 L"[+-]?\\d+\\."); // -1.
163 163
164 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_ENTRY_COMMA_SEP", L"[+-]?\\d*,?\\d*"); 164 GLOBAL_ARRAY(pRuntime, L"RE_NUMBER_ENTRY_COMMA_SEP", L"[+-]?\\d*,?\\d*");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 L"\\d{3}(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // 408 555-1234 196 L"\\d{3}(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // 408 555-1234
197 L"\\(\\d{3}\\)(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // (408) 555-1234 197 L"\\(\\d{3}\\)(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", // (408) 555-1234
198 L"011(\\.|[- \\d])*"); // international 198 L"011(\\.|[- \\d])*"); // international
199 199
200 GLOBAL_ARRAY(pRuntime, L"RE_SSN_ENTRY", 200 GLOBAL_ARRAY(pRuntime, L"RE_SSN_ENTRY",
201 L"\\d{0,3}(\\.|[- ])?\\d{0,2}(\\.|[- ])?\\d{0,4}"); 201 L"\\d{0,3}(\\.|[- ])?\\d{0,2}(\\.|[- ])?\\d{0,4}");
202 202
203 GLOBAL_ARRAY(pRuntime, L"RE_SSN_COMMIT", 203 GLOBAL_ARRAY(pRuntime, L"RE_SSN_COMMIT",
204 L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"); 204 L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}");
205 } 205 }
OLDNEW
« 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