diff options
author | jochen <jochen@chromium.org> | 2016-07-06 05:26:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-06 05:26:23 -0700 |
commit | c4dedf32b1f5c71740df5be2a9b1446a01df304c (patch) | |
tree | c435b0a5d64c9827cca9b56b4bb12995342c90c0 /fpdfsdk/jsapi/fxjs_v8.cpp | |
parent | 2798a7a6549ddddaeb8d4d7f7c31b96aa5e6edd3 (diff) | |
download | pdfium-c4dedf32b1f5c71740df5be2a9b1446a01df304c.tar.xz |
Remove prototypes from v8 functions that aren't constructors
BUG=chromium:625823
R=haraken@chromium.org,thestig@chromium.org
Review-Url: https://codereview.chromium.org/2123153002
Diffstat (limited to 'fpdfsdk/jsapi/fxjs_v8.cpp')
-rw-r--r-- | fpdfsdk/jsapi/fxjs_v8.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/fpdfsdk/jsapi/fxjs_v8.cpp b/fpdfsdk/jsapi/fxjs_v8.cpp index 283fac978a..3297b4bd12 100644 --- a/fpdfsdk/jsapi/fxjs_v8.cpp +++ b/fpdfsdk/jsapi/fxjs_v8.cpp @@ -243,13 +243,14 @@ void FXJS_DefineObjMethod(v8::Isolate* pIsolate, CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); CFXJS_ObjDefinition* pObjDef = CFXJS_ObjDefinition::ForID(pIsolate, nObjDefnID); + v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New( + pIsolate, pMethodCall, v8::Local<v8::Value>(), pObjDef->GetSignature()); + fun->RemovePrototype(); pObjDef->GetInstanceTemplate()->Set( v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), v8::NewStringType::kNormal) .ToLocalChecked(), - v8::FunctionTemplate::New(pIsolate, pMethodCall, v8::Local<v8::Value>(), - pObjDef->GetSignature()), - v8::ReadOnly); + fun, v8::ReadOnly); } void FXJS_DefineObjProperty(v8::Isolate* pIsolate, @@ -301,11 +302,14 @@ void FXJS_DefineGlobalMethod(v8::Isolate* pIsolate, v8::Isolate::Scope isolate_scope(pIsolate); v8::HandleScope handle_scope(pIsolate); CFX_ByteString bsMethodName = CFX_WideString(sMethodName).UTF8Encode(); - GetGlobalObjectTemplate(pIsolate) - ->Set(v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), - v8::NewStringType::kNormal) - .ToLocalChecked(), - v8::FunctionTemplate::New(pIsolate, pMethodCall), v8::ReadOnly); + v8::Local<v8::FunctionTemplate> fun = + v8::FunctionTemplate::New(pIsolate, pMethodCall); + fun->RemovePrototype(); + GetGlobalObjectTemplate(pIsolate)->Set( + v8::String::NewFromUtf8(pIsolate, bsMethodName.c_str(), + v8::NewStringType::kNormal) + .ToLocalChecked(), + fun, v8::ReadOnly); } void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, @@ -314,11 +318,14 @@ void FXJS_DefineGlobalConst(v8::Isolate* pIsolate, v8::Isolate::Scope isolate_scope(pIsolate); v8::HandleScope handle_scope(pIsolate); CFX_ByteString bsConst = CFX_WideString(sConstName).UTF8Encode(); - GetGlobalObjectTemplate(pIsolate) - ->SetAccessorProperty(v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), - v8::NewStringType::kNormal) - .ToLocalChecked(), - v8::FunctionTemplate::New(pIsolate, pConstGetter)); + v8::Local<v8::FunctionTemplate> fun = + v8::FunctionTemplate::New(pIsolate, pConstGetter); + fun->RemovePrototype(); + GetGlobalObjectTemplate(pIsolate)->SetAccessorProperty( + v8::String::NewFromUtf8(pIsolate, bsConst.c_str(), + v8::NewStringType::kNormal) + .ToLocalChecked(), + fun); } void FXJS_InitializeRuntime( |