OLD | NEW |
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 "Consts.h" | 7 #include "Consts.h" |
8 | 8 |
9 #include "../../include/javascript/IJavaScript.h" | 9 #include "../../include/javascript/IJavaScript.h" |
10 #include "JS_Define.h" | 10 #include "JS_Define.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 JS_STATIC_CONST_ENTRY_STRING(L"fitH", L"FitHeight") | 122 JS_STATIC_CONST_ENTRY_STRING(L"fitH", L"FitHeight") |
123 JS_STATIC_CONST_ENTRY_STRING(L"fitV", L"FitVisibleWidth") | 123 JS_STATIC_CONST_ENTRY_STRING(L"fitV", L"FitVisibleWidth") |
124 JS_STATIC_CONST_ENTRY_STRING(L"pref", L"Preferred") | 124 JS_STATIC_CONST_ENTRY_STRING(L"pref", L"Preferred") |
125 JS_STATIC_CONST_ENTRY_STRING(L"refW", L"ReflowWidth") | 125 JS_STATIC_CONST_ENTRY_STRING(L"refW", L"ReflowWidth") |
126 END_JS_STATIC_CONST() | 126 END_JS_STATIC_CONST() |
127 | 127 |
128 IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype) | 128 IMPLEMENT_JS_CLASS_CONST(CJS_Zoomtype, zoomtype) |
129 | 129 |
130 /* ------------------------------ CJS_GlobalConsts ------------------------- */ | 130 /* ------------------------------ CJS_GlobalConsts ------------------------- */ |
131 | 131 |
132 static void DefineGlobalConstString(v8::Isolate* pIsolate, | 132 static void DefineGlobalConstString(CJS_Runtime* pRuntime, |
133 const wchar_t* pConstName, | 133 const wchar_t* pConstName, |
134 const wchar_t* pValue) { | 134 const wchar_t* pValue) { |
135 FXJS_DefineGlobalConst(pIsolate, pConstName, | 135 FXJS_DefineGlobalConst(pRuntime->GetIsolate(), pConstName, |
136 FXJS_NewString(pIsolate, pValue)); | 136 FXJS_NewString(pRuntime->GetIsolate(), pValue)); |
137 } | 137 } |
138 | 138 |
139 void CJS_GlobalConsts::DefineJSObjects(v8::Isolate* pIsolate) { | 139 void CJS_GlobalConsts::DefineJSObjects(CJS_Runtime* pRuntime) { |
140 DefineGlobalConstString( | 140 DefineGlobalConstString( |
141 pIsolate, L"IDS_GREATER_THAN", | 141 pRuntime, L"IDS_GREATER_THAN", |
142 L"Invalid value: must be greater than or equal to % s."); | 142 L"Invalid value: must be greater than or equal to % s."); |
143 DefineGlobalConstString( | 143 DefineGlobalConstString( |
144 pIsolate, L"IDS_GT_AND_LT", | 144 pRuntime, L"IDS_GT_AND_LT", |
145 L"Invalid value: must be greater than or equal to % s " | 145 L"Invalid value: must be greater than or equal to % s " |
146 L"and less than or equal to % s."); | 146 L"and less than or equal to % s."); |
147 DefineGlobalConstString(pIsolate, L"IDS_LESS_THAN", | 147 DefineGlobalConstString(pRuntime, L"IDS_LESS_THAN", |
148 L"Invalid value: must be less than or equal to % s."); | 148 L"Invalid value: must be less than or equal to % s."); |
149 DefineGlobalConstString(pIsolate, L"IDS_INVALID_MONTH", L"**Invalid**"); | 149 DefineGlobalConstString(pRuntime, L"IDS_INVALID_MONTH", L"**Invalid**"); |
150 DefineGlobalConstString( | 150 DefineGlobalConstString( |
151 pIsolate, L"IDS_INVALID_DATE", | 151 pRuntime, L"IDS_INVALID_DATE", |
152 L"Invalid date / time: please ensure that the date / time exists.Field"); | 152 L"Invalid date / time: please ensure that the date / time exists.Field"); |
153 DefineGlobalConstString( | 153 DefineGlobalConstString( |
154 pIsolate, L"IDS_INVALID_VALUE", | 154 pRuntime, L"IDS_INVALID_VALUE", |
155 L"The value entered does not match the format of the field"); | 155 L"The value entered does not match the format of the field"); |
156 DefineGlobalConstString(pIsolate, L"IDS_AM", L"am"); | 156 DefineGlobalConstString(pRuntime, L"IDS_AM", L"am"); |
157 DefineGlobalConstString(pIsolate, L"IDS_PM", L"pm"); | 157 DefineGlobalConstString(pRuntime, L"IDS_PM", L"pm"); |
158 DefineGlobalConstString( | 158 DefineGlobalConstString( |
159 pIsolate, L"IDS_MONTH_INFO", | 159 pRuntime, L"IDS_MONTH_INFO", |
160 L"January[1] February[2] March[3] April[4] May[5] " | 160 L"January[1] February[2] March[3] April[4] May[5] " |
161 L"June[6] July[7] August[8] September[9] October[10] " | 161 L"June[6] July[7] August[8] September[9] October[10] " |
162 L"November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] " | 162 L"November[11] December[12] Sept[9] Jan[1] Feb[2] Mar[3] " |
163 L"Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] " | 163 L"Apr[4] Jun[6] Jul[7] Aug[8] Sep[9] Oct[10] Nov[11] " |
164 L"Dec[12]"); | 164 L"Dec[12]"); |
165 DefineGlobalConstString(pIsolate, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **"); | 165 DefineGlobalConstString(pRuntime, L"IDS_STARTUP_CONSOLE_MSG", L"** ^ _ ^ **"); |
166 } | 166 } |
167 | 167 |
168 /* ------------------------------ CJS_GlobalArrays ------------------------ */ | 168 /* ------------------------------ CJS_GlobalArrays ------------------------ */ |
169 | 169 |
170 void DefineGlobalConstStringArray(v8::Isolate* pIsolate, | 170 void DefineGlobalConstStringArray(CJS_Runtime* pRuntime, |
171 const wchar_t* sConstName, | 171 const wchar_t* sConstName, |
172 const wchar_t** pValues, | 172 const wchar_t** pValues, |
173 size_t nValues) { | 173 size_t nValues) { |
174 CJS_Array array(pIsolate); | 174 CJS_Array array(pRuntime); |
175 for (size_t i = 0; i < nValues; ++i) { | 175 for (size_t i = 0; i < nValues; ++i) { |
176 array.SetElement(i, CJS_Value(pIsolate, pValues[i])); | 176 array.SetElement(i, CJS_Value(pRuntime, pValues[i])); |
177 } | 177 } |
178 CJS_PropValue prop(pIsolate); | 178 CJS_PropValue prop(pRuntime); |
179 prop << array; | 179 prop << array; |
180 FXJS_DefineGlobalConst(pIsolate, sConstName, prop.ToV8Value()); | 180 FXJS_DefineGlobalConst(pRuntime->GetIsolate(), sConstName, prop.ToV8Value()); |
181 } | 181 } |
182 | 182 |
183 void CJS_GlobalArrays::DefineJSObjects(v8::Isolate* pIsolate) { | 183 void CJS_GlobalArrays::DefineJSObjects(CJS_Runtime* pRuntime) { |
184 { | 184 { |
185 const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP"; | 185 const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_DOT_SEP"; |
186 const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"}; | 186 const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*\\.?\\d*"}; |
187 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 187 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
188 FX_ArraySize(ArrayContent)); | 188 FX_ArraySize(ArrayContent)); |
189 } | 189 } |
190 | 190 |
191 { | 191 { |
192 const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_DOT_SEP"; | 192 const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_DOT_SEP"; |
193 const FX_WCHAR* ArrayContent[] = { | 193 const FX_WCHAR* ArrayContent[] = { |
194 L"[+-]?\\d+(\\.\\d+)?", /* -1.0 or -1 */ | 194 L"[+-]?\\d+(\\.\\d+)?", /* -1.0 or -1 */ |
195 L"[+-]?\\.\\d+", /* -.1 */ | 195 L"[+-]?\\.\\d+", /* -.1 */ |
196 L"[+-]?\\d+\\." /* -1. */ | 196 L"[+-]?\\d+\\." /* -1. */ |
197 }; | 197 }; |
198 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 198 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
199 FX_ArraySize(ArrayContent)); | 199 FX_ArraySize(ArrayContent)); |
200 } | 200 } |
201 | 201 |
202 { | 202 { |
203 const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_COMMA_SEP"; | 203 const FX_WCHAR* ArrayName = L"RE_NUMBER_ENTRY_COMMA_SEP"; |
204 const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*,?\\d*"}; | 204 const FX_WCHAR* ArrayContent[] = {L"[+-]?\\d*,?\\d*"}; |
205 | 205 |
206 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 206 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
207 FX_ArraySize(ArrayContent)); | 207 FX_ArraySize(ArrayContent)); |
208 } | 208 } |
209 | 209 |
210 { | 210 { |
211 const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_COMMA_SEP"; | 211 const FX_WCHAR* ArrayName = L"RE_NUMBER_COMMIT_COMMA_SEP"; |
212 const FX_WCHAR* ArrayContent[] = { | 212 const FX_WCHAR* ArrayContent[] = { |
213 L"[+-]?\\d+([.,]\\d+)?", /* -1,0 or -1 */ | 213 L"[+-]?\\d+([.,]\\d+)?", /* -1,0 or -1 */ |
214 L"[+-]?[.,]\\d+", /* -,1 */ | 214 L"[+-]?[.,]\\d+", /* -,1 */ |
215 L"[+-]?\\d+[.,]" /* -1, */ | 215 L"[+-]?\\d+[.,]" /* -1, */ |
216 }; | 216 }; |
217 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 217 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
218 FX_ArraySize(ArrayContent)); | 218 FX_ArraySize(ArrayContent)); |
219 } | 219 } |
220 | 220 |
221 { | 221 { |
222 const FX_WCHAR* ArrayName = L"RE_ZIP_ENTRY"; | 222 const FX_WCHAR* ArrayName = L"RE_ZIP_ENTRY"; |
223 const FX_WCHAR* ArrayContent[] = {L"\\d{0,5}"}; | 223 const FX_WCHAR* ArrayContent[] = {L"\\d{0,5}"}; |
224 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 224 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
225 FX_ArraySize(ArrayContent)); | 225 FX_ArraySize(ArrayContent)); |
226 } | 226 } |
227 | 227 |
228 { | 228 { |
229 const FX_WCHAR* ArrayName = L"RE_ZIP_COMMIT"; | 229 const FX_WCHAR* ArrayName = L"RE_ZIP_COMMIT"; |
230 const FX_WCHAR* ArrayContent[] = {L"\\d{5}"}; | 230 const FX_WCHAR* ArrayContent[] = {L"\\d{5}"}; |
231 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 231 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
232 FX_ArraySize(ArrayContent)); | 232 FX_ArraySize(ArrayContent)); |
233 } | 233 } |
234 | 234 |
235 { | 235 { |
236 const FX_WCHAR* ArrayName = L"RE_ZIP4_ENTRY"; | 236 const FX_WCHAR* ArrayName = L"RE_ZIP4_ENTRY"; |
237 const FX_WCHAR* ArrayContent[] = {L"\\d{0,5}(\\.|[- ])?\\d{0,4}"}; | 237 const FX_WCHAR* ArrayContent[] = {L"\\d{0,5}(\\.|[- ])?\\d{0,4}"}; |
238 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 238 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
239 FX_ArraySize(ArrayContent)); | 239 FX_ArraySize(ArrayContent)); |
240 } | 240 } |
241 | 241 |
242 { | 242 { |
243 const FX_WCHAR* ArrayName = L"RE_ZIP4_COMMIT"; | 243 const FX_WCHAR* ArrayName = L"RE_ZIP4_COMMIT"; |
244 const FX_WCHAR* ArrayContent[] = {L"\\d{5}(\\.|[- ])?\\d{4}"}; | 244 const FX_WCHAR* ArrayContent[] = {L"\\d{5}(\\.|[- ])?\\d{4}"}; |
245 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 245 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
246 FX_ArraySize(ArrayContent)); | 246 FX_ArraySize(ArrayContent)); |
247 } | 247 } |
248 | 248 |
249 { | 249 { |
250 const FX_WCHAR* ArrayName = L"RE_PHONE_ENTRY"; | 250 const FX_WCHAR* ArrayName = L"RE_PHONE_ENTRY"; |
251 const FX_WCHAR* ArrayContent[] = { | 251 const FX_WCHAR* ArrayContent[] = { |
252 L"\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", /* 555-1234 or 408 | 252 L"\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", /* 555-1234 or 408 |
253 555-1234 */ | 253 555-1234 */ |
254 L"\\(\\d{0,3}", /* (408 */ | 254 L"\\(\\d{0,3}", /* (408 */ |
255 L"\\(\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", /* (408) | 255 L"\\(\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", /* (408) |
256 555-1234 */ | 256 555-1234 */ |
257 /* (allow the addition of parens as an afterthought) */ | 257 /* (allow the addition of parens as an afterthought) */ |
258 L"\\(\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", /* (408 555-1234 | 258 L"\\(\\d{0,3}(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", /* (408 555-1234 |
259 */ | 259 */ |
260 L"\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", /* 408) 555-1234 | 260 L"\\d{0,3}\\)(\\.|[- ])?\\d{0,3}(\\.|[- ])?\\d{0,4}", /* 408) 555-1234 |
261 */ | 261 */ |
262 L"011(\\.|[- \\d])*" /* international */ | 262 L"011(\\.|[- \\d])*" /* international */ |
263 }; | 263 }; |
264 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 264 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
265 FX_ArraySize(ArrayContent)); | 265 FX_ArraySize(ArrayContent)); |
266 } | 266 } |
267 | 267 |
268 { | 268 { |
269 const FX_WCHAR* ArrayName = L"RE_PHONE_COMMIT"; | 269 const FX_WCHAR* ArrayName = L"RE_PHONE_COMMIT"; |
270 const FX_WCHAR* ArrayContent[] = { | 270 const FX_WCHAR* ArrayContent[] = { |
271 L"\\d{3}(\\.|[- ])?\\d{4}", /* 555-1234 */ | 271 L"\\d{3}(\\.|[- ])?\\d{4}", /* 555-1234 */ |
272 L"\\d{3}(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", /* 408 555-1234 */ | 272 L"\\d{3}(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", /* 408 555-1234 */ |
273 L"\\(\\d{3}\\)(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", /* (408) 555-1234 */ | 273 L"\\(\\d{3}\\)(\\.|[- ])?\\d{3}(\\.|[- ])?\\d{4}", /* (408) 555-1234 */ |
274 L"011(\\.|[- \\d])*" /* international */ | 274 L"011(\\.|[- \\d])*" /* international */ |
275 }; | 275 }; |
276 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 276 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
277 FX_ArraySize(ArrayContent)); | 277 FX_ArraySize(ArrayContent)); |
278 } | 278 } |
279 | 279 |
280 { | 280 { |
281 const FX_WCHAR* ArrayName = L"RE_SSN_ENTRY"; | 281 const FX_WCHAR* ArrayName = L"RE_SSN_ENTRY"; |
282 const FX_WCHAR* ArrayContent[] = { | 282 const FX_WCHAR* ArrayContent[] = { |
283 L"\\d{0,3}(\\.|[- ])?\\d{0,2}(\\.|[- ])?\\d{0,4}"}; | 283 L"\\d{0,3}(\\.|[- ])?\\d{0,2}(\\.|[- ])?\\d{0,4}"}; |
284 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 284 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
285 FX_ArraySize(ArrayContent)); | 285 FX_ArraySize(ArrayContent)); |
286 } | 286 } |
287 | 287 |
288 { | 288 { |
289 const FX_WCHAR* ArrayName = L"RE_SSN_COMMIT"; | 289 const FX_WCHAR* ArrayName = L"RE_SSN_COMMIT"; |
290 const FX_WCHAR* ArrayContent[] = { | 290 const FX_WCHAR* ArrayContent[] = { |
291 L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"}; | 291 L"\\d{3}(\\.|[- ])?\\d{2}(\\.|[- ])?\\d{4}"}; |
292 DefineGlobalConstStringArray(pIsolate, ArrayName, ArrayContent, | 292 DefineGlobalConstStringArray(pRuntime, ArrayName, ArrayContent, |
293 FX_ArraySize(ArrayContent)); | 293 FX_ArraySize(ArrayContent)); |
294 } | 294 } |
295 } | 295 } |
OLD | NEW |