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

Side by Side Diff: fpdfsdk/src/jsapi/fxjs_v8.cpp

Issue 1484843002: Tidy ifdefs in fpdfsdk. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Fix initialization error warning. Created 5 years 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/src/javascript/app.cpp ('k') | fpdfsdk/src/jsapi/fxjs_v8_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/include/jsapi/fxjs_v8.h" 7 #include "fpdfsdk/include/jsapi/fxjs_v8.h"
8 8
9 #include "core/include/fxcrt/fx_basic.h" 9 #include "core/include/fxcrt/fx_basic.h"
10 10
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 v8::Isolate* pIsolate, 276 v8::Isolate* pIsolate,
277 IJS_Runtime* pIRuntime, 277 IJS_Runtime* pIRuntime,
278 v8::Global<v8::Context>* pV8PersistentContext, 278 v8::Global<v8::Context>* pV8PersistentContext,
279 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { 279 std::vector<v8::Global<v8::Object>*>* pStaticObjects) {
280 if (pIsolate == g_isolate) 280 if (pIsolate == g_isolate)
281 ++g_isolate_ref_count; 281 ++g_isolate_ref_count;
282 282
283 v8::Isolate::Scope isolate_scope(pIsolate); 283 v8::Isolate::Scope isolate_scope(pIsolate);
284 #ifdef PDF_ENABLE_XFA 284 #ifdef PDF_ENABLE_XFA
285 v8::Locker locker(pIsolate); 285 v8::Locker locker(pIsolate);
286 #endif 286 #endif // PDF_ENABLE_XFA
287 v8::HandleScope handle_scope(pIsolate); 287 v8::HandleScope handle_scope(pIsolate);
288 v8::Local<v8::Context> v8Context = 288 v8::Local<v8::Context> v8Context =
289 v8::Context::New(pIsolate, NULL, GetGlobalObjectTemplate(pIsolate)); 289 v8::Context::New(pIsolate, NULL, GetGlobalObjectTemplate(pIsolate));
290 v8::Context::Scope context_scope(v8Context); 290 v8::Context::Scope context_scope(v8Context);
291 291
292 FXJS_PerIsolateData::SetUp(pIsolate); 292 FXJS_PerIsolateData::SetUp(pIsolate);
293 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime); 293 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime);
294 294
295 int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); 295 int maxID = CFXJS_ObjDefinition::MaxID(pIsolate);
296 pStaticObjects->resize(maxID + 1); 296 pStaticObjects->resize(maxID + 1);
(...skipping 25 matching lines...) Expand all
322 } 322 }
323 pV8PersistentContext->Reset(pIsolate, v8Context); 323 pV8PersistentContext->Reset(pIsolate, v8Context);
324 } 324 }
325 325
326 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate, 326 void FXJS_ReleaseRuntime(v8::Isolate* pIsolate,
327 v8::Global<v8::Context>* pV8PersistentContext, 327 v8::Global<v8::Context>* pV8PersistentContext,
328 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { 328 std::vector<v8::Global<v8::Object>*>* pStaticObjects) {
329 v8::Isolate::Scope isolate_scope(pIsolate); 329 v8::Isolate::Scope isolate_scope(pIsolate);
330 #ifdef PDF_ENABLE_XFA 330 #ifdef PDF_ENABLE_XFA
331 v8::Locker locker(pIsolate); 331 v8::Locker locker(pIsolate);
332 #endif 332 #endif // PDF_ENABLE_XFA
333 v8::HandleScope handle_scope(pIsolate); 333 v8::HandleScope handle_scope(pIsolate);
334 v8::Local<v8::Context> context = 334 v8::Local<v8::Context> context =
335 v8::Local<v8::Context>::New(pIsolate, *pV8PersistentContext); 335 v8::Local<v8::Context>::New(pIsolate, *pV8PersistentContext);
336 v8::Context::Scope context_scope(context); 336 v8::Context::Scope context_scope(context);
337 337
338 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate); 338 FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate);
339 if (!pData) 339 if (!pData)
340 return; 340 return;
341 341
342 #ifdef PDF_ENABLE_XFA 342 #ifdef PDF_ENABLE_XFA
343 // XFA, if present, should have already cleaned itself up. 343 // XFA, if present, should have already cleaned itself up.
344 FXSYS_assert(!pData->m_pFXJSERuntimeData); 344 FXSYS_assert(!pData->m_pFXJSERuntimeData);
345 #endif // PDF_ENABLE_XFA
345 346
346 #endif
347 int maxID = CFXJS_ObjDefinition::MaxID(pIsolate); 347 int maxID = CFXJS_ObjDefinition::MaxID(pIsolate);
348 for (int i = 0; i < maxID; ++i) { 348 for (int i = 0; i < maxID; ++i) {
349 CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i); 349 CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, i);
350 v8::Local<v8::Object> pObj; 350 v8::Local<v8::Object> pObj;
351 if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) { 351 if (pObjDef->m_ObjType == FXJSOBJTYPE_GLOBAL) {
352 pObj = 352 pObj =
353 context->Global()->GetPrototype()->ToObject(context).ToLocalChecked(); 353 context->Global()->GetPrototype()->ToObject(context).ToLocalChecked();
354 } else if (pStaticObjects->at(i) && !pStaticObjects->at(i)->IsEmpty()) { 354 } else if (pStaticObjects->at(i) && !pStaticObjects->at(i)->IsEmpty()) {
355 pObj = v8::Local<v8::Object>::New(pIsolate, *pStaticObjects->at(i)); 355 pObj = v8::Local<v8::Object>::New(pIsolate, *pStaticObjects->at(i));
356 delete pStaticObjects->at(i); 356 delete pStaticObjects->at(i);
(...skipping 21 matching lines...) Expand all
378 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 378 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
379 return static_cast<IJS_Runtime*>( 379 return static_cast<IJS_Runtime*>(
380 context->GetAlignedPointerFromEmbedderData(kPerContextDataIndex)); 380 context->GetAlignedPointerFromEmbedderData(kPerContextDataIndex));
381 } 381 }
382 382
383 #ifdef PDF_ENABLE_XFA 383 #ifdef PDF_ENABLE_XFA
384 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, 384 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context,
385 IJS_Runtime* pIRuntime) { 385 IJS_Runtime* pIRuntime) {
386 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime); 386 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime);
387 } 387 }
388 #endif // PDF_ENABLE_XFA
388 389
389 #endif
390 int FXJS_Execute(v8::Isolate* pIsolate, 390 int FXJS_Execute(v8::Isolate* pIsolate,
391 IJS_Context* pJSContext, 391 IJS_Context* pJSContext,
392 const wchar_t* script, 392 const wchar_t* script,
393 FXJSErr* pError) { 393 FXJSErr* pError) {
394 v8::Isolate::Scope isolate_scope(pIsolate); 394 v8::Isolate::Scope isolate_scope(pIsolate);
395 v8::TryCatch try_catch(pIsolate); 395 v8::TryCatch try_catch(pIsolate);
396 CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode(); 396 CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode();
397 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 397 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
398 v8::Local<v8::Script> compiled_script; 398 v8::Local<v8::Script> compiled_script;
399 if (!v8::Script::Compile( 399 if (!v8::Script::Compile(
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 return v8::Local<v8::Array>(); 769 return v8::Local<v8::Array>();
770 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 770 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
771 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 771 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
772 } 772 }
773 773
774 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 774 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
775 pTo = pFrom; 775 pTo = pFrom;
776 } 776 }
777 777
778 778
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/app.cpp ('k') | fpdfsdk/src/jsapi/fxjs_v8_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698