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

Side by Side Diff: fpdfsdk/javascript/global.cpp

Issue 1799773002: Move fpdfsdk/src up to fpdfsdk/. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Rebase to master Created 4 years, 9 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 | « fpdfsdk/javascript/global.h ('k') | fpdfsdk/javascript/public_methods_embeddertest.cpp » ('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/src/javascript/global.h" 7 #include "fpdfsdk/javascript/global.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "core/include/fxcrt/fx_ext.h" 11 #include "core/include/fxcrt/fx_ext.h"
12 #include "fpdfsdk/include/javascript/IJavaScript.h" 12 #include "fpdfsdk/include/javascript/IJavaScript.h"
13 #include "fpdfsdk/src/javascript/JS_Context.h" 13 #include "fpdfsdk/javascript/JS_Context.h"
14 #include "fpdfsdk/src/javascript/JS_Define.h" 14 #include "fpdfsdk/javascript/JS_Define.h"
15 #include "fpdfsdk/src/javascript/JS_EventHandler.h" 15 #include "fpdfsdk/javascript/JS_EventHandler.h"
16 #include "fpdfsdk/src/javascript/JS_GlobalData.h" 16 #include "fpdfsdk/javascript/JS_GlobalData.h"
17 #include "fpdfsdk/src/javascript/JS_Object.h" 17 #include "fpdfsdk/javascript/JS_Object.h"
18 #include "fpdfsdk/src/javascript/JS_Value.h" 18 #include "fpdfsdk/javascript/JS_Value.h"
19 #include "fpdfsdk/src/javascript/resource.h" 19 #include "fpdfsdk/javascript/resource.h"
20 20
21 /* ---------------------------- global ---------------------------- */ 21 /* ---------------------------- global ---------------------------- */
22 22
23 // Helper class for compile-time calculation of hash values in order to 23 // Helper class for compile-time calculation of hash values in order to
24 // avoid having global object initializers. 24 // avoid having global object initializers.
25 template <unsigned ACC, wchar_t... Ns> 25 template <unsigned ACC, wchar_t... Ns>
26 struct CHash; 26 struct CHash;
27 27
28 // Only needed to hash single-character strings. 28 // Only needed to hash single-character strings.
29 template <wchar_t N> 29 template <wchar_t N>
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, JSGlobalAlternate, global); 90 IMPLEMENT_SPECIAL_JS_CLASS(CJS_Global, JSGlobalAlternate, global);
91 91
92 void CJS_Global::InitInstance(IJS_Runtime* pIRuntime) { 92 void CJS_Global::InitInstance(IJS_Runtime* pIRuntime) {
93 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime); 93 CJS_Runtime* pRuntime = static_cast<CJS_Runtime*>(pIRuntime);
94 JSGlobalAlternate* pGlobal = 94 JSGlobalAlternate* pGlobal =
95 static_cast<JSGlobalAlternate*>(GetEmbedObject()); 95 static_cast<JSGlobalAlternate*>(GetEmbedObject());
96 pGlobal->Initial(pRuntime->GetReaderApp()); 96 pGlobal->Initial(pRuntime->GetReaderApp());
97 } 97 }
98 98
99 JSGlobalAlternate::JSGlobalAlternate(CJS_Object* pJSObject) 99 JSGlobalAlternate::JSGlobalAlternate(CJS_Object* pJSObject)
100 : CJS_EmbedObj(pJSObject), m_pApp(NULL) { 100 : CJS_EmbedObj(pJSObject), m_pApp(NULL) {}
101 }
102 101
103 JSGlobalAlternate::~JSGlobalAlternate() { 102 JSGlobalAlternate::~JSGlobalAlternate() {
104 DestroyGlobalPersisitentVariables(); 103 DestroyGlobalPersisitentVariables();
105 m_pGlobalData->Release(); 104 m_pGlobalData->Release();
106 } 105 }
107 106
108 void JSGlobalAlternate::Initial(CPDFDoc_Environment* pApp) { 107 void JSGlobalAlternate::Initial(CPDFDoc_Environment* pApp) {
109 m_pApp = pApp; 108 m_pApp = pApp;
110 m_pGlobalData = CJS_GlobalData::GetRetainedInstance(pApp); 109 m_pGlobalData = CJS_GlobalData::GetRetainedInstance(pApp);
111 UpdateGlobalPersistentVariables(); 110 UpdateGlobalPersistentVariables();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent); 290 m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
292 break; 291 break;
293 case JS_GLOBALDATA_TYPE_BOOLEAN: 292 case JS_GLOBALDATA_TYPE_BOOLEAN:
294 m_pGlobalData->SetGlobalVariableBoolean(name, pData->bData); 293 m_pGlobalData->SetGlobalVariableBoolean(name, pData->bData);
295 m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent); 294 m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
296 break; 295 break;
297 case JS_GLOBALDATA_TYPE_STRING: 296 case JS_GLOBALDATA_TYPE_STRING:
298 m_pGlobalData->SetGlobalVariableString(name, pData->sData); 297 m_pGlobalData->SetGlobalVariableString(name, pData->sData);
299 m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent); 298 m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
300 break; 299 break;
301 case JS_GLOBALDATA_TYPE_OBJECT: 300 case JS_GLOBALDATA_TYPE_OBJECT: {
302 { 301 CJS_GlobalVariableArray array;
303 CJS_GlobalVariableArray array; 302 v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(
304 v8::Local<v8::Object> obj = v8::Local<v8::Object>::New( 303 GetJSObject()->GetIsolate(), pData->pData);
305 GetJSObject()->GetIsolate(), pData->pData); 304 ObjectToArray(cc, obj, array);
306 ObjectToArray(cc, obj, array); 305 m_pGlobalData->SetGlobalVariableObject(name, array);
307 m_pGlobalData->SetGlobalVariableObject(name, array); 306 m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
308 m_pGlobalData->SetGlobalVariablePersistent(name, 307 } break;
309 pData->bPersistent);
310 }
311 break;
312 case JS_GLOBALDATA_TYPE_NULL: 308 case JS_GLOBALDATA_TYPE_NULL:
313 m_pGlobalData->SetGlobalVariableNull(name); 309 m_pGlobalData->SetGlobalVariableNull(name);
314 m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent); 310 m_pGlobalData->SetGlobalVariablePersistent(name, pData->bPersistent);
315 break; 311 break;
316 } 312 }
317 } 313 }
318 } 314 }
319 } 315 }
320 316
321 void JSGlobalAlternate::ObjectToArray(IJS_Context* cc, 317 void JSGlobalAlternate::ObjectToArray(IJS_Context* cc,
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 return CJS_Value::VT_boolean; 507 return CJS_Value::VT_boolean;
512 if (nHash == JSCONST_nDateHash) 508 if (nHash == JSCONST_nDateHash)
513 return CJS_Value::VT_date; 509 return CJS_Value::VT_date;
514 if (nHash == JSCONST_nObjectHash) 510 if (nHash == JSCONST_nObjectHash)
515 return CJS_Value::VT_object; 511 return CJS_Value::VT_object;
516 if (nHash == JSCONST_nFXobjHash) 512 if (nHash == JSCONST_nFXobjHash)
517 return CJS_Value::VT_fxobject; 513 return CJS_Value::VT_fxobject;
518 514
519 return CJS_Value::VT_unknown; 515 return CJS_Value::VT_unknown;
520 } 516 }
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/global.h ('k') | fpdfsdk/javascript/public_methods_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698