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

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

Issue 1861813002: Merge to M50: Re-land "Only place primitive objects on the V8 global template." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@2661
Patch Set: resolve conflict Created 4 years, 8 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 <vector> 9 #include <vector>
10 10
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); 285 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode();
286 GetGlobalObjectTemplate(pIsolate) 286 GetGlobalObjectTemplate(pIsolate)
287 ->Set(v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), 287 ->Set(v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(),
288 v8::NewStringType::kNormal) 288 v8::NewStringType::kNormal)
289 .ToLocalChecked(), 289 .ToLocalChecked(),
290 v8::FunctionTemplate::New(pIsolate, pMethodCall), v8::ReadOnly); 290 v8::FunctionTemplate::New(pIsolate, pMethodCall), v8::ReadOnly);
291 } 291 }
292 292
293 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, 293 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate,
294 const wchar_t* sConstName, 294 const wchar_t* sConstName,
295 v8::Local<v8::Value> pDefault) { 295 v8::FunctionCallback pConstGetter) {
296 v8::Isolate::Scope isolate_scope(pIsolate); 296 v8::Isolate::Scope isolate_scope(pIsolate);
297 v8::HandleScope handle_scope(pIsolate); 297 v8::HandleScope handle_scope(pIsolate);
298 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode(); 298 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode();
299 GetGlobalObjectTemplate(pIsolate)->Set( 299 GetGlobalObjectTemplate(pIsolate)
300 v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), 300 ->SetAccessorProperty(v8::String::NewFromUtf8(pIsolate, bsConst.c_str(),
301 v8::NewStringType::kNormal).ToLocalChecked(), 301 v8::NewStringType::kNormal)
302 pDefault, v8::ReadOnly); 302 .ToLocalChecked(),
303 v8::FunctionTemplate::New(pIsolate, pConstGetter));
303 } 304 }
304 305
305 void FXJS_InitializeRuntime( 306 void FXJS_InitializeRuntime(
306 v8::Isolate* pIsolate, 307 v8::Isolate* pIsolate,
307 IJS_Runtime* pIRuntime, 308 IJS_Runtime* pIRuntime,
308 v8::Global<v8::Context>* pV8PersistentContext, 309 v8::Global<v8::Context>* pV8PersistentContext,
309 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { 310 std::vector<v8::Global<v8::Object>*>* pStaticObjects) {
310 if (pIsolate == g_isolate) 311 if (pIsolate == g_isolate)
311 ++g_isolate_ref_count; 312 ++g_isolate_ref_count;
312 313
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 v8::Local<v8::Value> pValue) { 814 v8::Local<v8::Value> pValue) {
814 if (pValue.IsEmpty()) 815 if (pValue.IsEmpty())
815 return v8::Local<v8::Array>(); 816 return v8::Local<v8::Array>();
816 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 817 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
817 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 818 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
818 } 819 }
819 820
820 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 821 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
821 pTo = pFrom; 822 pTo = pFrom;
822 } 823 }
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