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

Side by Side Diff: fpdfsdk/jsapi/fxjs_v8.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/util.cpp ('k') | fpdfsdk/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 <vector> 9 #include <vector>
10 10
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 int nObjDefnID, 220 int nObjDefnID,
221 const wchar_t* sMethodName, 221 const wchar_t* sMethodName,
222 v8::FunctionCallback pMethodCall) { 222 v8::FunctionCallback pMethodCall) {
223 v8::Isolate::Scope isolate_scope(pIsolate); 223 v8::Isolate::Scope isolate_scope(pIsolate);
224 v8::HandleScope handle_scope(pIsolate); 224 v8::HandleScope handle_scope(pIsolate);
225 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); 225 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode();
226 CFXJS_ObjDefinition* pObjDef = 226 CFXJS_ObjDefinition* pObjDef =
227 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); 227 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID);
228 pObjDef->GetInstanceTemplate()->Set( 228 pObjDef->GetInstanceTemplate()->Set(
229 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), 229 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(),
230 v8::NewStringType::kNormal).ToLocalChecked(), 230 v8::NewStringType::kNormal)
231 .ToLocalChecked(),
231 v8::FunctionTemplate::New(pIsolate, pMethodCall, v8::Local<v8::Value>(), 232 v8::FunctionTemplate::New(pIsolate, pMethodCall, v8::Local<v8::Value>(),
232 pObjDef->GetSignature()), 233 pObjDef->GetSignature()),
233 v8::ReadOnly); 234 v8::ReadOnly);
234 } 235 }
235 236
236 void FXJS_DefineObjProperty(v8::Isolate* pIsolate, 237 void FXJS_DefineObjProperty(v8::Isolate* pIsolate,
237 int nObjDefnID, 238 int nObjDefnID,
238 const wchar_t* sPropName, 239 const wchar_t* sPropName,
239 v8::AccessorGetterCallback pPropGet, 240 v8::AccessorGetterCallback pPropGet,
240 v8::AccessorSetterCallback pPropPut) { 241 v8::AccessorSetterCallback pPropPut) {
241 v8::Isolate::Scope isolate_scope(pIsolate); 242 v8::Isolate::Scope isolate_scope(pIsolate);
242 v8::HandleScope handle_scope(pIsolate); 243 v8::HandleScope handle_scope(pIsolate);
243 CFX_ByteString bsPropertyName = CFX_WideString(sPropName).UTF8Encode(); 244 CFX_ByteString bsPropertyName = CFX_WideString(sPropName).UTF8Encode();
244 CFXJS_ObjDefinition* pObjDef = 245 CFXJS_ObjDefinition* pObjDef =
245 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); 246 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID);
246 pObjDef->GetInstanceTemplate()->SetAccessor( 247 pObjDef->GetInstanceTemplate()->SetAccessor(
247 v8::String::NewFromUtf8(pIsolate, bsPropertyName.c_str(), 248 v8::String::NewFromUtf8(pIsolate, bsPropertyName.c_str(),
248 v8::NewStringType::kNormal).ToLocalChecked(), 249 v8::NewStringType::kNormal)
250 .ToLocalChecked(),
249 pPropGet, pPropPut); 251 pPropGet, pPropPut);
250 } 252 }
251 253
252 void FXJS_DefineObjAllProperties(v8::Isolate* pIsolate, 254 void FXJS_DefineObjAllProperties(v8::Isolate* pIsolate,
253 int nObjDefnID, 255 int nObjDefnID,
254 v8::NamedPropertyQueryCallback pPropQurey, 256 v8::NamedPropertyQueryCallback pPropQurey,
255 v8::NamedPropertyGetterCallback pPropGet, 257 v8::NamedPropertyGetterCallback pPropGet,
256 v8::NamedPropertySetterCallback pPropPut, 258 v8::NamedPropertySetterCallback pPropPut,
257 v8::NamedPropertyDeleterCallback pPropDel) { 259 v8::NamedPropertyDeleterCallback pPropDel) {
258 v8::Isolate::Scope isolate_scope(pIsolate); 260 v8::Isolate::Scope isolate_scope(pIsolate);
(...skipping 15 matching lines...) Expand all
274 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); 276 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID);
275 pObjDef->GetInstanceTemplate()->Set(pIsolate, bsConstName.c_str(), pDefault); 277 pObjDef->GetInstanceTemplate()->Set(pIsolate, bsConstName.c_str(), pDefault);
276 } 278 }
277 279
278 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, 280 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate,
279 const wchar_t* sMethodName, 281 const wchar_t* sMethodName,
280 v8::FunctionCallback pMethodCall) { 282 v8::FunctionCallback pMethodCall) {
281 v8::Isolate::Scope isolate_scope(pIsolate); 283 v8::Isolate::Scope isolate_scope(pIsolate);
282 v8::HandleScope handle_scope(pIsolate); 284 v8::HandleScope handle_scope(pIsolate);
283 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); 285 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode();
284 GetGlobalObjectTemplate(pIsolate)->Set( 286 GetGlobalObjectTemplate(pIsolate)
285 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), 287 ->Set(v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(),
286 v8::NewStringType::kNormal).ToLocalChecked(), 288 v8::NewStringType::kNormal)
287 v8::FunctionTemplate::New(pIsolate, pMethodCall), v8::ReadOnly); 289 .ToLocalChecked(),
290 v8::FunctionTemplate::New(pIsolate, pMethodCall), v8::ReadOnly);
288 } 291 }
289 292
290 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, 293 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate,
291 const wchar_t* sConstName, 294 const wchar_t* sConstName,
292 v8::FunctionCallback pConstGetter) { 295 v8::FunctionCallback pConstGetter) {
293 v8::Isolate::Scope isolate_scope(pIsolate); 296 v8::Isolate::Scope isolate_scope(pIsolate);
294 v8::HandleScope handle_scope(pIsolate); 297 v8::HandleScope handle_scope(pIsolate);
295 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode(); 298 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode();
296 GetGlobalObjectTemplate(pIsolate) 299 GetGlobalObjectTemplate(pIsolate)
297 ->SetAccessorProperty(v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), 300 ->SetAccessorProperty(v8::String::NewFromUtf8(pIsolate, bsConst.c_str(),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 340
338 if (pObjDef->m_pConstructor) 341 if (pObjDef->m_pConstructor)
339 pObjDef->m_pConstructor(pIRuntime, v8Context->Global() 342 pObjDef->m_pConstructor(pIRuntime, v8Context->Global()
340 ->GetPrototype() 343 ->GetPrototype()
341 ->ToObject(v8Context) 344 ->ToObject(v8Context)
342 .ToLocalChecked()); 345 .ToLocalChecked());
343 } else if (pObjDef->m_ObjType == FXJSOBJTYPE_STATIC) { 346 } else if (pObjDef->m_ObjType == FXJSOBJTYPE_STATIC) {
344 CFX_ByteString bs = CFX_WideString(pObjDef->m_ObjName).UTF8Encode(); 347 CFX_ByteString bs = CFX_WideString(pObjDef->m_ObjName).UTF8Encode();
345 v8::Local<v8::String> m_ObjName = 348 v8::Local<v8::String> m_ObjName =
346 v8::String::NewFromUtf8(pIsolate, bs.c_str(), 349 v8::String::NewFromUtf8(pIsolate, bs.c_str(),
347 v8::NewStringType::kNormal, 350 v8::NewStringType::kNormal, bs.GetLength())
348 bs.GetLength()).ToLocalChecked(); 351 .ToLocalChecked();
349 352
350 v8::Local<v8::Object> obj = 353 v8::Local<v8::Object> obj =
351 FXJS_NewFxDynamicObj(pIsolate, pIRuntime, i, true); 354 FXJS_NewFxDynamicObj(pIsolate, pIRuntime, i, true);
352 v8Context->Global()->Set(v8Context, m_ObjName, obj).FromJust(); 355 v8Context->Global()->Set(v8Context, m_ObjName, obj).FromJust();
353 pStaticObjects->at(i) = new v8::Global<v8::Object>(pIsolate, obj); 356 pStaticObjects->at(i) = new v8::Global<v8::Object>(pIsolate, obj);
354 } 357 }
355 } 358 }
356 pV8PersistentContext->Reset(pIsolate, v8Context); 359 pV8PersistentContext->Reset(pIsolate, v8Context);
357 } 360 }
358 361
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 421
419 int FXJS_Execute(v8::Isolate* pIsolate, 422 int FXJS_Execute(v8::Isolate* pIsolate,
420 IJS_Context* pJSContext, 423 IJS_Context* pJSContext,
421 const wchar_t* script, 424 const wchar_t* script,
422 FXJSErr* pError) { 425 FXJSErr* pError) {
423 v8::Isolate::Scope isolate_scope(pIsolate); 426 v8::Isolate::Scope isolate_scope(pIsolate);
424 v8::TryCatch try_catch(pIsolate); 427 v8::TryCatch try_catch(pIsolate);
425 CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode(); 428 CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode();
426 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 429 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
427 v8::Local<v8::Script> compiled_script; 430 v8::Local<v8::Script> compiled_script;
428 if (!v8::Script::Compile( 431 if (!v8::Script::Compile(context,
429 context, v8::String::NewFromUtf8( 432 v8::String::NewFromUtf8(pIsolate, bsScript.c_str(),
430 pIsolate, bsScript.c_str(), v8::NewStringType::kNormal, 433 v8::NewStringType::kNormal,
431 bsScript.GetLength()).ToLocalChecked()) 434 bsScript.GetLength())
435 .ToLocalChecked())
432 .ToLocal(&compiled_script)) { 436 .ToLocal(&compiled_script)) {
433 v8::String::Utf8Value error(try_catch.Exception()); 437 v8::String::Utf8Value error(try_catch.Exception());
434 // TODO(tsepez): return error via pError->message. 438 // TODO(tsepez): return error via pError->message.
435 return -1; 439 return -1;
436 } 440 }
437 441
438 v8::Local<v8::Value> result; 442 v8::Local<v8::Value> result;
439 if (!compiled_script->Run(context).ToLocal(&result)) { 443 if (!compiled_script->Run(context).ToLocal(&result)) {
440 v8::String::Utf8Value error(try_catch.Exception()); 444 v8::String::Utf8Value error(try_catch.Exception());
441 // TODO(tsepez): return error via pError->message. 445 // TODO(tsepez): return error via pError->message.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 if (pPerObjectData) 505 if (pPerObjectData)
502 return pPerObjectData->m_ObjDefID; 506 return pPerObjectData->m_ObjDefID;
503 return -1; 507 return -1;
504 } 508 }
505 509
506 void FXJS_Error(v8::Isolate* pIsolate, const CFX_WideString& message) { 510 void FXJS_Error(v8::Isolate* pIsolate, const CFX_WideString& message) {
507 // Conversion from pdfium's wchar_t wide-strings to v8's uint16_t 511 // Conversion from pdfium's wchar_t wide-strings to v8's uint16_t
508 // wide-strings isn't handled by v8, so use UTF8 as a common 512 // wide-strings isn't handled by v8, so use UTF8 as a common
509 // intermediate format. 513 // intermediate format.
510 CFX_ByteString utf8_message = message.UTF8Encode(); 514 CFX_ByteString utf8_message = message.UTF8Encode();
511 pIsolate->ThrowException( 515 pIsolate->ThrowException(v8::String::NewFromUtf8(pIsolate,
512 v8::String::NewFromUtf8(pIsolate, utf8_message.c_str(), 516 utf8_message.c_str(),
513 v8::NewStringType::kNormal).ToLocalChecked()); 517 v8::NewStringType::kNormal)
518 .ToLocalChecked());
514 } 519 }
515 520
516 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj) { 521 const wchar_t* FXJS_GetTypeof(v8::Local<v8::Value> pObj) {
517 if (pObj.IsEmpty()) 522 if (pObj.IsEmpty())
518 return NULL; 523 return NULL;
519 if (pObj->IsString()) 524 if (pObj->IsString())
520 return kFXJSValueNameString; 525 return kFXJSValueNameString;
521 if (pObj->IsNumber()) 526 if (pObj->IsNumber())
522 return kFXJSValueNameNumber; 527 return kFXJSValueNameNumber;
523 if (pObj->IsBoolean()) 528 if (pObj->IsBoolean())
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 } 583 }
579 584
580 v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate, 585 v8::Local<v8::String> FXJS_WSToJSString(v8::Isolate* pIsolate,
581 const wchar_t* PropertyName, 586 const wchar_t* PropertyName,
582 int Len) { 587 int Len) {
583 CFX_WideString ws = CFX_WideString(PropertyName, Len); 588 CFX_WideString ws = CFX_WideString(PropertyName, Len);
584 CFX_ByteString bs = ws.UTF8Encode(); 589 CFX_ByteString bs = ws.UTF8Encode();
585 if (!pIsolate) 590 if (!pIsolate)
586 pIsolate = v8::Isolate::GetCurrent(); 591 pIsolate = v8::Isolate::GetCurrent();
587 return v8::String::NewFromUtf8(pIsolate, bs.c_str(), 592 return v8::String::NewFromUtf8(pIsolate, bs.c_str(),
588 v8::NewStringType::kNormal).ToLocalChecked(); 593 v8::NewStringType::kNormal)
594 .ToLocalChecked();
589 } 595 }
590 596
591 v8::Local<v8::Value> FXJS_GetObjectElement(v8::Isolate* pIsolate, 597 v8::Local<v8::Value> FXJS_GetObjectElement(v8::Isolate* pIsolate,
592 v8::Local<v8::Object> pObj, 598 v8::Local<v8::Object> pObj,
593 const wchar_t* PropertyName) { 599 const wchar_t* PropertyName) {
594 if (pObj.IsEmpty()) 600 if (pObj.IsEmpty())
595 return v8::Local<v8::Value>(); 601 return v8::Local<v8::Value>();
596 v8::Local<v8::Value> val; 602 v8::Local<v8::Value> val;
597 if (!pObj->Get(pIsolate->GetCurrentContext(), 603 if (!pObj->Get(pIsolate->GetCurrentContext(),
598 FXJS_WSToJSString(pIsolate, PropertyName)).ToLocal(&val)) 604 FXJS_WSToJSString(pIsolate, PropertyName))
605 .ToLocal(&val))
599 return v8::Local<v8::Value>(); 606 return v8::Local<v8::Value>();
600 return val; 607 return val;
601 } 608 }
602 609
603 v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate, 610 v8::Local<v8::Array> FXJS_GetObjectElementNames(v8::Isolate* pIsolate,
604 v8::Local<v8::Object> pObj) { 611 v8::Local<v8::Object> pObj) {
605 if (pObj.IsEmpty()) 612 if (pObj.IsEmpty())
606 return v8::Local<v8::Array>(); 613 return v8::Local<v8::Array>();
607 v8::Local<v8::Array> val; 614 v8::Local<v8::Array> val;
608 if (!pObj->GetPropertyNames(pIsolate->GetCurrentContext()).ToLocal(&val)) 615 if (!pObj->GetPropertyNames(pIsolate->GetCurrentContext()).ToLocal(&val))
609 return v8::Local<v8::Array>(); 616 return v8::Local<v8::Array>();
610 return val; 617 return val;
611 } 618 }
612 619
613 void FXJS_PutObjectString(v8::Isolate* pIsolate, 620 void FXJS_PutObjectString(v8::Isolate* pIsolate,
614 v8::Local<v8::Object> pObj, 621 v8::Local<v8::Object> pObj,
615 const wchar_t* PropertyName, 622 const wchar_t* PropertyName,
616 const wchar_t* sValue) { 623 const wchar_t* sValue) {
617 if (pObj.IsEmpty()) 624 if (pObj.IsEmpty())
618 return; 625 return;
619 pObj->Set(pIsolate->GetCurrentContext(), 626 pObj->Set(pIsolate->GetCurrentContext(),
620 FXJS_WSToJSString(pIsolate, PropertyName), 627 FXJS_WSToJSString(pIsolate, PropertyName),
621 FXJS_WSToJSString(pIsolate, sValue)).FromJust(); 628 FXJS_WSToJSString(pIsolate, sValue))
629 .FromJust();
622 } 630 }
623 631
624 void FXJS_PutObjectNumber(v8::Isolate* pIsolate, 632 void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
625 v8::Local<v8::Object> pObj, 633 v8::Local<v8::Object> pObj,
626 const wchar_t* PropertyName, 634 const wchar_t* PropertyName,
627 int nValue) { 635 int nValue) {
628 if (pObj.IsEmpty()) 636 if (pObj.IsEmpty())
629 return; 637 return;
630 pObj->Set(pIsolate->GetCurrentContext(), 638 pObj->Set(pIsolate->GetCurrentContext(),
631 FXJS_WSToJSString(pIsolate, PropertyName), 639 FXJS_WSToJSString(pIsolate, PropertyName),
632 v8::Int32::New(pIsolate, nValue)).FromJust(); 640 v8::Int32::New(pIsolate, nValue))
641 .FromJust();
633 } 642 }
634 643
635 void FXJS_PutObjectNumber(v8::Isolate* pIsolate, 644 void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
636 v8::Local<v8::Object> pObj, 645 v8::Local<v8::Object> pObj,
637 const wchar_t* PropertyName, 646 const wchar_t* PropertyName,
638 float fValue) { 647 float fValue) {
639 if (pObj.IsEmpty()) 648 if (pObj.IsEmpty())
640 return; 649 return;
641 pObj->Set(pIsolate->GetCurrentContext(), 650 pObj->Set(pIsolate->GetCurrentContext(),
642 FXJS_WSToJSString(pIsolate, PropertyName), 651 FXJS_WSToJSString(pIsolate, PropertyName),
643 v8::Number::New(pIsolate, (double)fValue)).FromJust(); 652 v8::Number::New(pIsolate, (double)fValue))
653 .FromJust();
644 } 654 }
645 655
646 void FXJS_PutObjectNumber(v8::Isolate* pIsolate, 656 void FXJS_PutObjectNumber(v8::Isolate* pIsolate,
647 v8::Local<v8::Object> pObj, 657 v8::Local<v8::Object> pObj,
648 const wchar_t* PropertyName, 658 const wchar_t* PropertyName,
649 double dValue) { 659 double dValue) {
650 if (pObj.IsEmpty()) 660 if (pObj.IsEmpty())
651 return; 661 return;
652 pObj->Set(pIsolate->GetCurrentContext(), 662 pObj->Set(pIsolate->GetCurrentContext(),
653 FXJS_WSToJSString(pIsolate, PropertyName), 663 FXJS_WSToJSString(pIsolate, PropertyName),
654 v8::Number::New(pIsolate, (double)dValue)).FromJust(); 664 v8::Number::New(pIsolate, (double)dValue))
665 .FromJust();
655 } 666 }
656 667
657 void FXJS_PutObjectBoolean(v8::Isolate* pIsolate, 668 void FXJS_PutObjectBoolean(v8::Isolate* pIsolate,
658 v8::Local<v8::Object> pObj, 669 v8::Local<v8::Object> pObj,
659 const wchar_t* PropertyName, 670 const wchar_t* PropertyName,
660 bool bValue) { 671 bool bValue) {
661 if (pObj.IsEmpty()) 672 if (pObj.IsEmpty())
662 return; 673 return;
663 pObj->Set(pIsolate->GetCurrentContext(), 674 pObj->Set(pIsolate->GetCurrentContext(),
664 FXJS_WSToJSString(pIsolate, PropertyName), 675 FXJS_WSToJSString(pIsolate, PropertyName),
665 v8::Boolean::New(pIsolate, bValue)).FromJust(); 676 v8::Boolean::New(pIsolate, bValue))
677 .FromJust();
666 } 678 }
667 679
668 void FXJS_PutObjectObject(v8::Isolate* pIsolate, 680 void FXJS_PutObjectObject(v8::Isolate* pIsolate,
669 v8::Local<v8::Object> pObj, 681 v8::Local<v8::Object> pObj,
670 const wchar_t* PropertyName, 682 const wchar_t* PropertyName,
671 v8::Local<v8::Object> pPut) { 683 v8::Local<v8::Object> pPut) {
672 if (pObj.IsEmpty()) 684 if (pObj.IsEmpty())
673 return; 685 return;
674 pObj->Set(pIsolate->GetCurrentContext(), 686 pObj->Set(pIsolate->GetCurrentContext(),
675 FXJS_WSToJSString(pIsolate, PropertyName), pPut).FromJust(); 687 FXJS_WSToJSString(pIsolate, PropertyName), pPut)
688 .FromJust();
676 } 689 }
677 690
678 void FXJS_PutObjectNull(v8::Isolate* pIsolate, 691 void FXJS_PutObjectNull(v8::Isolate* pIsolate,
679 v8::Local<v8::Object> pObj, 692 v8::Local<v8::Object> pObj,
680 const wchar_t* PropertyName) { 693 const wchar_t* PropertyName) {
681 if (pObj.IsEmpty()) 694 if (pObj.IsEmpty())
682 return; 695 return;
683 pObj->Set(pIsolate->GetCurrentContext(), 696 pObj->Set(pIsolate->GetCurrentContext(),
684 FXJS_WSToJSString(pIsolate, PropertyName), 697 FXJS_WSToJSString(pIsolate, PropertyName), v8::Local<v8::Object>())
685 v8::Local<v8::Object>()).FromJust(); 698 .FromJust();
686 } 699 }
687 700
688 v8::Local<v8::Array> FXJS_NewArray(v8::Isolate* pIsolate) { 701 v8::Local<v8::Array> FXJS_NewArray(v8::Isolate* pIsolate) {
689 return v8::Array::New(pIsolate); 702 return v8::Array::New(pIsolate);
690 } 703 }
691 704
692 unsigned FXJS_PutArrayElement(v8::Isolate* pIsolate, 705 unsigned FXJS_PutArrayElement(v8::Isolate* pIsolate,
693 v8::Local<v8::Array> pArray, 706 v8::Local<v8::Array> pArray,
694 unsigned index, 707 unsigned index,
695 v8::Local<v8::Value> pValue) { 708 v8::Local<v8::Value> pValue) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 v8::Local<v8::Value> pValue) { 814 v8::Local<v8::Value> pValue) {
802 if (pValue.IsEmpty()) 815 if (pValue.IsEmpty())
803 return v8::Local<v8::Array>(); 816 return v8::Local<v8::Array>();
804 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 817 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
805 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 818 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
806 } 819 }
807 820
808 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 821 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
809 pTo = pFrom; 822 pTo = pFrom;
810 } 823 }
811
812
OLDNEW
« no previous file with comments | « fpdfsdk/javascript/util.cpp ('k') | fpdfsdk/jsapi/fxjs_v8_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698