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 "../../include/javascript/JavaScript.h" | |
8 #include "../../include/javascript/IJavaScript.h" | 7 #include "../../include/javascript/IJavaScript.h" |
| 8 #include "../../include/javascript/JS_Context.h" |
9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
| 10 #include "../../include/javascript/JS_EventHandler.h" |
| 11 #include "../../include/javascript/JS_GlobalData.h" |
10 #include "../../include/javascript/JS_Object.h" | 12 #include "../../include/javascript/JS_Object.h" |
11 #include "../../include/javascript/JS_Value.h" | 13 #include "../../include/javascript/JS_Value.h" |
12 #include "../../include/javascript/JS_GlobalData.h" | 14 #include "../../include/javascript/JavaScript.h" |
13 #include "../../include/javascript/global.h" | 15 #include "../../include/javascript/global.h" |
14 #include "../../include/javascript/JS_EventHandler.h" | |
15 #include "../../include/javascript/JS_Context.h" | |
16 #include "../../include/fpdfxfa/fpdfxfa_app.h" | 16 #include "../../include/fpdfxfa/fpdfxfa_app.h" |
| 17 #include "../../include/javascript/resource.h" |
17 | 18 |
18 /* ---------------------------- global ---------------------------- */ | 19 /* ---------------------------- global ---------------------------- */ |
19 | 20 |
20 // Helper class for compile-time calculation of hash values in order to | 21 // Helper class for compile-time calculation of hash values in order to |
21 // avoid having global object initializers. | 22 // avoid having global object initializers. |
22 template <unsigned ACC, wchar_t... Ns> | 23 template <unsigned ACC, wchar_t... Ns> |
23 struct CHash; | 24 struct CHash; |
24 | 25 |
25 // Only needed to hash single-character strings. | 26 // Only needed to hash single-character strings. |
26 template <wchar_t N> | 27 template <wchar_t N> |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 vp.SetNull(); | 265 vp.SetNull(); |
265 return TRUE; | 266 return TRUE; |
266 } | 267 } |
267 } | 268 } |
268 | 269 |
269 return FALSE; | 270 return FALSE; |
270 } | 271 } |
271 | 272 |
272 FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, JS_ErrorString& sError) | 273 FX_BOOL global_alternate::setPersistent(IFXJS_Context* cc, const CJS_Parameters&
params, CJS_Value& vRet, JS_ErrorString& sError) |
273 { | 274 { |
| 275 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
274 if (params.size() != 2) | 276 if (params.size() != 2) |
275 { | 277 { |
276 » » //sError = JSGetStringFromID(IDS_STRING_JSPARAMERROR);» | 278 » » sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
277 return FALSE; | 279 return FALSE; |
278 } | 280 } |
279 | 281 |
280 CFX_ByteString sName = params[0]; | 282 CFX_ByteString sName = params[0]; |
281 | 283 |
282 js_global_data* pData = NULL; | 284 js_global_data* pData = NULL; |
283 if (m_mapGlobal.Lookup(sName, (FX_LPVOID&)pData)) | 285 if (m_mapGlobal.Lookup(sName, (FX_LPVOID&)pData)) |
284 { | 286 { |
285 if (pData && !pData->bDeleted) | 287 if (pData && !pData->bDeleted) |
286 { | 288 { |
287 pData->bPersistent = (bool)params[1]; | 289 pData->bPersistent = (bool)params[1]; |
288 return TRUE; | 290 return TRUE; |
289 } | 291 } |
290 } | 292 } |
291 | 293 |
292 » //sError = JSGetStringFromID(IDS_JSPARAM_INCORRECT);» | 294 » sError = JSGetStringFromID(pContext, IDS_STRING_JSNOGLOBAL); |
293 return FALSE; | 295 return FALSE; |
294 } | 296 } |
295 | 297 |
296 void global_alternate::UpdateGlobalPersistentVariables() | 298 void global_alternate::UpdateGlobalPersistentVariables() |
297 { | 299 { |
298 ASSERT(m_pGlobalData != NULL); | 300 ASSERT(m_pGlobalData != NULL); |
299 | 301 |
300 for (int i=0,sz=m_pGlobalData->GetSize(); i<sz; i++) | 302 for (int i=0,sz=m_pGlobalData->GetSize(); i<sz; i++) |
301 { | 303 { |
302 CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i); | 304 CJS_GlobalData_Element* pData = m_pGlobalData->GetAt(i); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 if (nHash == JSCONST_nDateHash) | 636 if (nHash == JSCONST_nDateHash) |
635 return VT_date; | 637 return VT_date; |
636 if (nHash == JSCONST_nObjectHash) | 638 if (nHash == JSCONST_nObjectHash) |
637 return VT_object; | 639 return VT_object; |
638 if (nHash == JSCONST_nFXobjHash) | 640 if (nHash == JSCONST_nFXobjHash) |
639 return VT_fxobject; | 641 return VT_fxobject; |
640 | 642 |
641 return VT_unknown; | 643 return VT_unknown; |
642 } | 644 } |
643 | 645 |
OLD | NEW |