| 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/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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 v8::HandleScope handle_scope(pIsolate); | 280 v8::HandleScope handle_scope(pIsolate); |
| 281 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); | 281 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); |
| 282 GetGlobalObjectTemplate(pIsolate)->Set( | 282 GetGlobalObjectTemplate(pIsolate)->Set( |
| 283 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), | 283 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), |
| 284 v8::NewStringType::kNormal).ToLocalChecked(), | 284 v8::NewStringType::kNormal).ToLocalChecked(), |
| 285 v8::FunctionTemplate::New(pIsolate, pMethodCall), v8::ReadOnly); | 285 v8::FunctionTemplate::New(pIsolate, pMethodCall), v8::ReadOnly); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, | 288 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, |
| 289 const wchar_t* sConstName, | 289 const wchar_t* sConstName, |
| 290 v8::FunctionCallback pConstGetter) { | 290 v8::Local<v8::Value> pDefault) { |
| 291 v8::Isolate::Scope isolate_scope(pIsolate); | 291 v8::Isolate::Scope isolate_scope(pIsolate); |
| 292 v8::HandleScope handle_scope(pIsolate); | 292 v8::HandleScope handle_scope(pIsolate); |
| 293 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode(); | 293 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode(); |
| 294 GetGlobalObjectTemplate(pIsolate) | 294 GetGlobalObjectTemplate(pIsolate)->Set( |
| 295 ->SetAccessorProperty(v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), | 295 v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), |
| 296 v8::NewStringType::kNormal) | 296 v8::NewStringType::kNormal).ToLocalChecked(), |
| 297 .ToLocalChecked(), | 297 pDefault, v8::ReadOnly); |
| 298 v8::FunctionTemplate::New(pIsolate, pConstGetter)); | |
| 299 } | 298 } |
| 300 | 299 |
| 301 void FXJS_InitializeRuntime( | 300 void FXJS_InitializeRuntime( |
| 302 v8::Isolate* pIsolate, | 301 v8::Isolate* pIsolate, |
| 303 IJS_Runtime* pIRuntime, | 302 IJS_Runtime* pIRuntime, |
| 304 v8::Global<v8::Context>* pV8PersistentContext, | 303 v8::Global<v8::Context>* pV8PersistentContext, |
| 305 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { | 304 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { |
| 306 if (pIsolate == g_isolate) | 305 if (pIsolate == g_isolate) |
| 307 ++g_isolate_ref_count; | 306 ++g_isolate_ref_count; |
| 308 | 307 |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 return v8::Local<v8::Array>(); | 801 return v8::Local<v8::Array>(); |
| 803 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 802 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
| 804 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 803 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); |
| 805 } | 804 } |
| 806 | 805 |
| 807 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 806 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { |
| 808 pTo = pFrom; | 807 pTo = pFrom; |
| 809 } | 808 } |
| 810 | 809 |
| 811 | 810 |
| OLD | NEW |