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

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

Issue 2144333003: Remove prototypes from v8 functions that aren't constructors (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@2743
Patch Set: 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 | xfa/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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 218
219 void FXJS_DefineObjMethod(v8::Isolate* pIsolate, 219 void FXJS_DefineObjMethod(v8::Isolate* pIsolate,
220 int nObjDefnID, 220 int nObjDefnID,
221 const wchar_t* sMethodName, 221 const wchar_t* sMethodName,
222 v8::FunctionCallback pMethodCall) { 222 v8::FunctionCallback pMethodCall) {
223 v8::Isolate::Scope isolate_scope(pIsolate); 223 v8::Isolate::Scope isolate_scope(pIsolate);
224 v8::HandleScope handle_scope(pIsolate); 224 v8::HandleScope handle_scope(pIsolate);
225 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); 225 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode();
226 CFXJS_ObjDefinition* pObjDef = 226 CFXJS_ObjDefinition* pObjDef =
227 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); 227 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID);
228 v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
229 pIsolate, pMethodCall, v8::Local<v8::Value>(), pObjDef->GetSignature());
230 fun->RemovePrototype();
228 pObjDef->GetInstanceTemplate()->Set( 231 pObjDef->GetInstanceTemplate()->Set(
229 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), 232 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(),
230 v8::NewStringType::kNormal) 233 v8::NewStringType::kNormal)
231 .ToLocalChecked(), 234 .ToLocalChecked(),
232 v8::FunctionTemplate::New(pIsolate, pMethodCall, v8::Local<v8::Value>(), 235 fun, v8::ReadOnly);
233 pObjDef->GetSignature()),
234 v8::ReadOnly);
235 } 236 }
236 237
237 void FXJS_DefineObjProperty(v8::Isolate* pIsolate, 238 void FXJS_DefineObjProperty(v8::Isolate* pIsolate,
238 int nObjDefnID, 239 int nObjDefnID,
239 const wchar_t* sPropName, 240 const wchar_t* sPropName,
240 v8::AccessorGetterCallback pPropGet, 241 v8::AccessorGetterCallback pPropGet,
241 v8::AccessorSetterCallback pPropPut) { 242 v8::AccessorSetterCallback pPropPut) {
242 v8::Isolate::Scope isolate_scope(pIsolate); 243 v8::Isolate::Scope isolate_scope(pIsolate);
243 v8::HandleScope handle_scope(pIsolate); 244 v8::HandleScope handle_scope(pIsolate);
244 CFX_ByteString bsPropertyName = CFX_WideString(sPropName).UTF8Encode(); 245 CFX_ByteString bsPropertyName = CFX_WideString(sPropName).UTF8Encode();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); 277 CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID);
277 pObjDef->GetInstanceTemplate()->Set(pIsolate, bsConstName.c_str(), pDefault); 278 pObjDef->GetInstanceTemplate()->Set(pIsolate, bsConstName.c_str(), pDefault);
278 } 279 }
279 280
280 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, 281 void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate,
281 const wchar_t* sMethodName, 282 const wchar_t* sMethodName,
282 v8::FunctionCallback pMethodCall) { 283 v8::FunctionCallback pMethodCall) {
283 v8::Isolate::Scope isolate_scope(pIsolate); 284 v8::Isolate::Scope isolate_scope(pIsolate);
284 v8::HandleScope handle_scope(pIsolate); 285 v8::HandleScope handle_scope(pIsolate);
285 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); 286 CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode();
286 GetGlobalObjectTemplate(pIsolate) 287 v8::Local<v8::FunctionTemplate> fun =
287 ->Set(v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), 288 v8::FunctionTemplate::New(pIsolate, pMethodCall);
288 v8::NewStringType::kNormal) 289 fun->RemovePrototype();
289 .ToLocalChecked(), 290 GetGlobalObjectTemplate(pIsolate)->Set(
290 v8::FunctionTemplate::New(pIsolate, pMethodCall), v8::ReadOnly); 291 v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(),
292 v8::NewStringType::kNormal)
293 .ToLocalChecked(),
294 fun, v8::ReadOnly);
291 } 295 }
292 296
293 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, 297 void FXJS_DefineGlobalConst(v8::Isolate* pIsolate,
294 const wchar_t* sConstName, 298 const wchar_t* sConstName,
295 v8::FunctionCallback pConstGetter) { 299 v8::FunctionCallback pConstGetter) {
296 v8::Isolate::Scope isolate_scope(pIsolate); 300 v8::Isolate::Scope isolate_scope(pIsolate);
297 v8::HandleScope handle_scope(pIsolate); 301 v8::HandleScope handle_scope(pIsolate);
298 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode(); 302 CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode();
299 GetGlobalObjectTemplate(pIsolate) 303 v8::Local<v8::FunctionTemplate> fun =
300 ->SetAccessorProperty(v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), 304 v8::FunctionTemplate::New(pIsolate, pConstGetter);
301 v8::NewStringType::kNormal) 305 fun->RemovePrototype();
302 .ToLocalChecked(), 306 GetGlobalObjectTemplate(pIsolate)->SetAccessorProperty(
303 v8::FunctionTemplate::New(pIsolate, pConstGetter)); 307 v8::String::NewFromUtf8(pIsolate, bsConst.c_str(),
308 v8::NewStringType::kNormal)
309 .ToLocalChecked(),
310 fun);
304 } 311 }
305 312
306 void FXJS_InitializeRuntime( 313 void FXJS_InitializeRuntime(
307 v8::Isolate* pIsolate, 314 v8::Isolate* pIsolate,
308 IJS_Runtime* pIRuntime, 315 IJS_Runtime* pIRuntime,
309 v8::Global<v8::Context>* pV8PersistentContext, 316 v8::Global<v8::Context>* pV8PersistentContext,
310 std::vector<v8::Global<v8::Object>*>* pStaticObjects) { 317 std::vector<v8::Global<v8::Object>*>* pStaticObjects) {
311 if (pIsolate == g_isolate) 318 if (pIsolate == g_isolate)
312 ++g_isolate_ref_count; 319 ++g_isolate_ref_count;
313 320
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 v8::Local<v8::Value> pValue) { 821 v8::Local<v8::Value> pValue) {
815 if (pValue.IsEmpty()) 822 if (pValue.IsEmpty())
816 return v8::Local<v8::Array>(); 823 return v8::Local<v8::Array>();
817 v8::Local<v8::Context> context = pIsolate->GetCurrentContext(); 824 v8::Local<v8::Context> context = pIsolate->GetCurrentContext();
818 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked()); 825 return v8::Local<v8::Array>::Cast(pValue->ToObject(context).ToLocalChecked());
819 } 826 }
820 827
821 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) { 828 void FXJS_ValueCopy(v8::Local<v8::Value>& pTo, v8::Local<v8::Value> pFrom) {
822 pTo = pFrom; 829 pTo = pFrom;
823 } 830 }
OLDNEW
« no previous file with comments | « no previous file | xfa/fxjse/class.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698