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

Side by Side Diff: fpdfsdk/src/jsapi/fxjs_v8.cpp

Issue 1761073006: Re-land "Only place primitive objects on the V8 global template."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Better solution - destroy handles before runtime. 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/src/javascript/JS_Runtime.cpp ('k') | no next file » | 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 "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
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
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
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698