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

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

Issue 2123153002: Remove prototypes from v8 functions that aren't constructors (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: updates Created 4 years, 5 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 | « no previous file | fxjse/class.cpp » ('j') | 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/jsapi/include/fxjs_v8.h" 7 #include "fpdfsdk/jsapi/include/fxjs_v8.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 236
237 void FXJS_DefineObjMethod(v8::Isolate* pIsolate, 237 void FXJS_DefineObjMethod(v8::Isolate* pIsolate,
238 int nObjDefnID, 238 int nObjDefnID,
239 const wchar_t* sMethodName, 239 const wchar_t* sMethodName,
240 v8::FunctionCallback pMethodCall) { 240 v8::FunctionCallback pMethodCall) {
241 v8::Isolate::Scope isolate_scope(pIsolate); 241 v8::Isolate::Scope isolate_scope(pIsolate);
242 v8::HandleScope handle_scope(pIsolate); 242 v8::HandleScope handle_scope(pIsolate);
243 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); 243 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode();
244 CFXJS_ObjDefinition* pObjDef = 244 CFXJS_ObjDefinition* pObjDef =
245 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); 245 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID);
246 v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
247 pIsolate, pMethodCall, v8::Local<v8::Value>(), pObjDef->GetSignature());
248 fun->RemovePrototype();
246 pObjDef->GetInstanceTemplate()->Set( 249 pObjDef->GetInstanceTemplate()->Set(
247 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), 250 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(),
248 v8::NewStringType::kNormal) 251 v8::NewStringType::kNormal)
249 .ToLocalChecked(), 252 .ToLocalChecked(),
250 v8::FunctionTemplate::New(pIsolate, pMethodCall, v8::Local<v8::Value>(), 253 fun, v8::ReadOnly);
251 pObjDef->GetSignature()),
252 v8::ReadOnly);
253 } 254 }
254 255
255 void FXJS_DefineObjProperty(v8::Isolate* pIsolate, 256 void FXJS_DefineObjProperty(v8::Isolate* pIsolate,
256 int nObjDefnID, 257 int nObjDefnID,
257 const wchar_t* sPropName, 258 const wchar_t* sPropName,
258 v8::AccessorGetterCallback pPropGet, 259 v8::AccessorGetterCallback pPropGet,
259 v8::AccessorSetterCallback pPropPut) { 260 v8::AccessorSetterCallback pPropPut) {
260 v8::Isolate::Scope isolate_scope(pIsolate); 261 v8::Isolate::Scope isolate_scope(pIsolate);
261 v8::HandleScope handle_scope(pIsolate); 262 v8::HandleScope handle_scope(pIsolate);
262 CFX_ByteString bsPropertyName = CFX_WideString(sPropName).UTF8Encode(); 263 CFX_ByteString bsPropertyName = CFX_WideString(sPropName).UTF8Encode();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); 295 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID);
295 pObjDef->GetInstanceTemplate()->Set(pIsolate, bsConstName.c_str(), pDefault); 296 pObjDef->GetInstanceTemplate()->Set(pIsolate, bsConstName.c_str(), pDefault);
296 } 297 }
297 298
298 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, 299 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate,
299 const wchar_t* sMethodName, 300 const wchar_t* sMethodName,
300 v8::FunctionCallback pMethodCall) { 301 v8::FunctionCallback pMethodCall) {
301 v8::Isolate::Scope isolate_scope(pIsolate); 302 v8::Isolate::Scope isolate_scope(pIsolate);
302 v8::HandleScope handle_scope(pIsolate); 303 v8::HandleScope handle_scope(pIsolate);
303 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); 304 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode();
304 GetGlobalObjectTemplate(pIsolate) 305 v8::Local<v8::FunctionTemplate> fun =
305 ->Set(v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), 306 v8::FunctionTemplate::New(pIsolate, pMethodCall);
306 v8::NewStringType::kNormal) 307 fun->RemovePrototype();
307 .ToLocalChecked(), 308 GetGlobalObjectTemplate(pIsolate)->Set(
308 v8::FunctionTemplate::New(pIsolate, pMethodCall), v8::ReadOnly); 309 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(),
310 v8::NewStringType::kNormal)
311 .ToLocalChecked(),
312 fun, v8::ReadOnly);
309 } 313 }
310 314
311 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, 315 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate,
312 const wchar_t* sConstName, 316 const wchar_t* sConstName,
313 v8::FunctionCallback pConstGetter) { 317 v8::FunctionCallback pConstGetter) {
314 v8::Isolate::Scope isolate_scope(pIsolate); 318 v8::Isolate::Scope isolate_scope(pIsolate);
315 v8::HandleScope handle_scope(pIsolate); 319 v8::HandleScope handle_scope(pIsolate);
316 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode(); 320 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode();
317 GetGlobalObjectTemplate(pIsolate) 321 v8::Local<v8::FunctionTemplate> fun =
318 ->SetAccessorProperty(v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), 322 v8::FunctionTemplate::New(pIsolate, pConstGetter);
319 v8::NewStringType::kNormal) 323 fun->RemovePrototype();
320 .ToLocalChecked(), 324 GetGlobalObjectTemplate(pIsolate)->SetAccessorProperty(
321 v8::FunctionTemplate::New(pIsolate, pConstGetter)); 325 v8::String::NewFromUtf8(pIsolate, bsConst.c_str(),
326 v8::NewStringType::kNormal)
327 .ToLocalChecked(),
328 fun);
322 } 329 }
323 330
324 void FXJS_InitializeRuntime( 331 void FXJS_InitializeRuntime(
325 v8::Isolate* pIsolate, 332 v8::Isolate* pIsolate,
326 IJS_Runtime* pIRuntime, 333 IJS_Runtime* pIRuntime,
327 v8::Global<v8::Context>* pV8PersistentContext, 334 v8::Global<v8::Context>* pV8PersistentContext,
328 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { 335 std::vector<v8::Global<v8::Object>*>* pStaticObjects) {
329 if (pIsolate == g_isolate) 336 if (pIsolate == g_isolate)
330 ++g_isolate_ref_count; 337 ++g_isolate_ref_count;
331 338
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 v8::Local<v8::Value> pValue) { 836 v8::Local<v8::Value> pValue) {
830 if (pValue.IsEmpty()) 837 if (pValue.IsEmpty())
831 return v8::Local<v8::Array>(); 838 return v8::Local<v8::Array>();
832 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 839 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
833 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 840 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
834 } 841 }
835 842
836 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 843 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
837 pTo = pFrom; 844 pTo = pFrom;
838 } 845 }
OLDNEW
« no previous file with comments | « no previous file | fxjse/class.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698