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 "fpdfsdk/jsapi/include/fxjs_v8.h" | 7 #include "fpdfsdk/jsapi/include/fxjs_v8.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } | 407 } |
408 | 408 |
409 #ifdef PDF_ENABLE_XFA | 409 #ifdef PDF_ENABLE_XFA |
410 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, | 410 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, |
411 IJS_Runtime* pIRuntime) { | 411 IJS_Runtime* pIRuntime) { |
412 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime); | 412 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime); |
413 } | 413 } |
414 #endif // PDF_ENABLE_XFA | 414 #endif // PDF_ENABLE_XFA |
415 | 415 |
416 int FXJS_Execute(v8::Isolate* pIsolate, | 416 int FXJS_Execute(v8::Isolate* pIsolate, |
417 IJS_Context* pJSContext, | 417 const CFX_WideString& script, |
418 const wchar_t* script, | |
419 FXJSErr* pError) { | 418 FXJSErr* pError) { |
420 v8::Isolate::Scope isolate_scope(pIsolate); | 419 v8::Isolate::Scope isolate_scope(pIsolate); |
421 v8::TryCatch try_catch(pIsolate); | 420 v8::TryCatch try_catch(pIsolate); |
422 CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode(); | 421 CFX_ByteString bsScript = script.UTF8Encode(); |
423 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 422 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
424 v8::Local<v8::Script> compiled_script; | 423 v8::Local<v8::Script> compiled_script; |
425 if (!v8::Script::Compile(context, | 424 if (!v8::Script::Compile(context, |
426 v8::String::NewFromUtf8(pIsolate, bsScript.c_str(), | 425 v8::String::NewFromUtf8(pIsolate, bsScript.c_str(), |
427 v8::NewStringType::kNormal, | 426 v8::NewStringType::kNormal, |
428 bsScript.GetLength()) | 427 bsScript.GetLength()) |
429 .ToLocalChecked()) | 428 .ToLocalChecked()) |
430 .ToLocal(&compiled_script)) { | 429 .ToLocal(&compiled_script)) { |
431 v8::String::Utf8Value error(try_catch.Exception()); | 430 v8::String::Utf8Value error(try_catch.Exception()); |
432 // TODO(tsepez): return error via pError->message. | 431 // TODO(tsepez): return error via pError->message. |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 v8::Local<v8::Value> pValue) { | 807 v8::Local<v8::Value> pValue) { |
809 if (pValue.IsEmpty()) | 808 if (pValue.IsEmpty()) |
810 return v8::Local<v8::Array>(); | 809 return v8::Local<v8::Array>(); |
811 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 810 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
812 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 811 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); |
813 } | 812 } |
814 | 813 |
815 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 814 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { |
816 pTo = pFrom; | 815 pTo = pFrom; |
817 } | 816 } |
OLD | NEW |