Chromium Code Reviews| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 } | 413 } |
| 414 | 414 |
| 415 #ifdef PDF_ENABLE_XFA | 415 #ifdef PDF_ENABLE_XFA |
| 416 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, | 416 void FXJS_SetRuntimeForV8Context(v8::Local<v8::Context> v8Context, |
| 417 IJS_Runtime* pIRuntime) { | 417 IJS_Runtime* pIRuntime) { |
| 418 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime); | 418 v8Context->SetAlignedPointerInEmbedderData(kPerContextDataIndex, pIRuntime); |
| 419 } | 419 } |
| 420 #endif // PDF_ENABLE_XFA | 420 #endif // PDF_ENABLE_XFA |
| 421 | 421 |
| 422 int FXJS_Execute(v8::Isolate* pIsolate, | 422 int FXJS_Execute(v8::Isolate* pIsolate, |
| 423 IJS_Context* pJSContext, | |
| 424 const wchar_t* script, | 423 const wchar_t* script, |
| 425 FXJSErr* pError) { | 424 FXJSErr* pError) { |
| 426 v8::Isolate::Scope isolate_scope(pIsolate); | 425 v8::Isolate::Scope isolate_scope(pIsolate); |
| 427 v8::TryCatch try_catch(pIsolate); | 426 v8::TryCatch try_catch(pIsolate); |
| 428 CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode(); | 427 CFX_ByteString bsScript = CFX_WideString(script).UTF8Encode(); |
|
Tom Sepez
2016/06/02 18:25:35
this started out as a widestring in the caller, th
dsinclair
2016/06/02 18:57:45
Done.
| |
| 429 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 428 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
| 430 v8::Local<v8::Script> compiled_script; | 429 v8::Local<v8::Script> compiled_script; |
| 431 if (!v8::Script::Compile(context, | 430 if (!v8::Script::Compile(context, |
| 432 v8::String::NewFromUtf8(pIsolate, bsScript.c_str(), | 431 v8::String::NewFromUtf8(pIsolate, bsScript.c_str(), |
| 433 v8::NewStringType::kNormal, | 432 v8::NewStringType::kNormal, |
| 434 bsScript.GetLength()) | 433 bsScript.GetLength()) |
| 435 .ToLocalChecked()) | 434 .ToLocalChecked()) |
| 436 .ToLocal(&compiled_script)) { | 435 .ToLocal(&compiled_script)) { |
| 437 v8::String::Utf8Value error(try_catch.Exception()); | 436 v8::String::Utf8Value error(try_catch.Exception()); |
| 438 // TODO(tsepez): return error via pError->message. | 437 // TODO(tsepez): return error via pError->message. |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 v8::Local<v8::Value> pValue) { | 813 v8::Local<v8::Value> pValue) { |
| 815 if (pValue.IsEmpty()) | 814 if (pValue.IsEmpty()) |
| 816 return v8::Local<v8::Array>(); | 815 return v8::Local<v8::Array>(); |
| 817 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 816 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
| 818 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 817 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); |
| 819 } | 818 } |
| 820 | 819 |
| 821 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 820 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { |
| 822 pTo = pFrom; | 821 pTo = pFrom; |
| 823 } | 822 } |
| OLD | NEW |