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::Local<v8::Value> pDefault) { | 290 v8::FunctionCallback pConstGetter) { |
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)->Set( | 294 GetGlobalObjectTemplate(pIsolate) |
295 v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), | 295 ->SetAccessorProperty(v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), |
296 v8::NewStringType::kNormal).ToLocalChecked(), | 296 v8::NewStringType::kNormal) |
297 pDefault, v8::ReadOnly); | 297 .ToLocalChecked(), |
| 298 v8::FunctionTemplate::New(pIsolate, pConstGetter)); |
298 } | 299 } |
299 | 300 |
300 void FXJS_InitializeRuntime( | 301 void FXJS_InitializeRuntime( |
301 v8::Isolate* pIsolate, | 302 v8::Isolate* pIsolate, |
302 IJS_Runtime* pIRuntime, | 303 IJS_Runtime* pIRuntime, |
303 v8::Global<v8::Context>* pV8PersistentContext, | 304 v8::Global<v8::Context>* pV8PersistentContext, |
304 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { | 305 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { |
305 if (pIsolate == g_isolate) | 306 if (pIsolate == g_isolate) |
306 ++g_isolate_ref_count; | 307 ++g_isolate_ref_count; |
307 | 308 |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 return v8::Local<v8::Array>(); | 802 return v8::Local<v8::Array>(); |
802 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); | 803 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); |
803 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); | 804 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); |
804 } | 805 } |
805 | 806 |
806 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { | 807 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { |
807 pTo = pFrom; | 808 pTo = pFrom; |
808 } | 809 } |
809 | 810 |
810 | 811 |
OLD | NEW |