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

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

Issue 1767793002: Revert "Only place primitive objects on the V8 global template." (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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::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
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
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