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

Unified Diff: xfa/fxjse/class.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fpdfsdk/jsapi/fxjs_v8.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/fxjse/class.cpp
diff --git a/xfa/fxjse/class.cpp b/xfa/fxjse/class.cpp
index d6744a611262b367a689a9125927e6d8e611cd7b..b3862076c82dcabd33bfd48c19fcb23e8a4934e6 100644
--- a/xfa/fxjse/class.cpp
+++ b/xfa/fxjse/class.cpp
@@ -127,6 +127,9 @@ static void FXJSE_V8SetterCallback_Wrapper(
static void FXJSE_V8ConstructorCallback_Wrapper(
const v8::FunctionCallbackInfo<v8::Value>& info) {
+ if (!info.IsConstructCall()) {
+ return;
+ }
const FXJSE_CLASS* lpClassDefinition =
static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
if (!lpClassDefinition) {
@@ -267,12 +270,14 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext,
}
if (lpClassDefinition->methNum) {
for (int32_t i = 0; i < lpClassDefinition->methNum; i++) {
+ v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
+ pIsolate, FXJSE_V8FunctionCallback_Wrapper,
+ v8::External::New(pIsolate, const_cast<FXJSE_FUNCTION*>(
+ lpClassDefinition->methods + i)));
+ fun->RemovePrototype();
hObjectTemplate->Set(
v8::String::NewFromUtf8(pIsolate, lpClassDefinition->methods[i].name),
- v8::FunctionTemplate::New(
- pIsolate, FXJSE_V8FunctionCallback_Wrapper,
- v8::External::New(pIsolate, const_cast<FXJSE_FUNCTION*>(
- lpClassDefinition->methods + i))),
+ fun,
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete));
}
}
@@ -297,12 +302,12 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext,
}
}
if (bIsJSGlobal) {
- hObjectTemplate->Set(
- v8::String::NewFromUtf8(pIsolate, "toString"),
- v8::FunctionTemplate::New(
- pIsolate, FXJSE_Context_GlobalObjToString,
- v8::External::New(pIsolate,
- const_cast<FXJSE_CLASS*>(lpClassDefinition))));
+ v8::Local<v8::FunctionTemplate> fun = v8::FunctionTemplate::New(
+ pIsolate, FXJSE_Context_GlobalObjToString,
+ v8::External::New(pIsolate,
+ const_cast<FXJSE_CLASS*>(lpClassDefinition)));
+ fun->RemovePrototype();
+ hObjectTemplate->Set(v8::String::NewFromUtf8(pIsolate, "toString"), fun);
}
pClass->m_hTemplate.Reset(lpContext->m_pIsolate, hFunctionTemplate);
lpContext->m_rgClasses.Add(pClass);
« no previous file with comments | « fpdfsdk/jsapi/fxjs_v8.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698