summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/src/fxjse/src/class.cpp16
-rw-r--r--xfa/src/fxjse/src/class.h4
-rw-r--r--xfa/src/fxjse/src/context.cpp10
-rw-r--r--xfa/src/fxjse/src/dynprop.cpp122
-rw-r--r--xfa/src/fxjse/src/runtime.cpp1
5 files changed, 95 insertions, 58 deletions
diff --git a/xfa/src/fxjse/src/class.cpp b/xfa/src/fxjse/src/class.cpp
index 04b087f37f..a4dc922cf2 100644
--- a/xfa/src/fxjse/src/class.cpp
+++ b/xfa/src/fxjse/src/class.cpp
@@ -151,15 +151,6 @@ static void FXJSE_V8ConstructorCallback_Wrapper(
}
FXSYS_assert(info.This()->InternalFieldCount());
info.This()->SetAlignedPointerInInternalField(0, NULL);
- CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
- lpThisValue->ForceSetValue(info.This());
- if (lpClassDefinition->dynMethodCall || lpClassDefinition->dynPropGetter ||
- lpClassDefinition->dynPropSetter ||
- lpClassDefinition->dynPropTypeGetter) {
- CFXJSE_Class::SetUpDynPropHandler(NULL, lpThisValue, lpClassDefinition);
- }
- delete lpThisValue;
- lpThisValue = NULL;
}
FXJSE_HRUNTIME CFXJSE_Arguments::GetRuntime() const {
const CFXJSE_ArgumentsImpl* lpArguments =
@@ -249,6 +240,7 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext,
v8::Isolate* pIsolate = lpContext->m_pIsolate;
pClass = new CFXJSE_Class(lpContext);
pClass->m_szClassName = lpClassDefinition->name;
+ pClass->m_lpClassDefinition = lpClassDefinition;
CFXJSE_ScopeUtil_IsolateHandleRootContext scope(pIsolate);
v8::Local<v8::FunctionTemplate> hFunctionTemplate = v8::FunctionTemplate::New(
pIsolate, bIsJSGlobal ? 0 : FXJSE_V8ConstructorCallback_Wrapper,
@@ -258,10 +250,8 @@ CFXJSE_Class* CFXJSE_Class::Create(CFXJSE_Context* lpContext,
hFunctionTemplate->InstanceTemplate()->SetInternalFieldCount(1);
v8::Local<v8::ObjectTemplate> hObjectTemplate =
hFunctionTemplate->InstanceTemplate();
- if (lpClassDefinition->dynPropDeleter ||
- lpClassDefinition->dynPropTypeGetter) {
- SetUpNamedPropHandler(pIsolate, hObjectTemplate, lpClassDefinition);
- }
+ SetUpNamedPropHandler(pIsolate, hObjectTemplate, lpClassDefinition);
+
if (lpClassDefinition->propNum) {
for (int32_t i = 0; i < lpClassDefinition->propNum; i++) {
hObjectTemplate->SetNativeDataProperty(
diff --git a/xfa/src/fxjse/src/class.h b/xfa/src/fxjse/src/class.h
index bb2d1b4c0c..4af7c07723 100644
--- a/xfa/src/fxjse/src/class.h
+++ b/xfa/src/fxjse/src/class.h
@@ -10,7 +10,8 @@ class CFXJSE_Context;
class CFXJSE_Value;
class CFXJSE_Class {
protected:
- CFXJSE_Class(CFXJSE_Context* lpContext) : m_pContext(lpContext) {}
+ CFXJSE_Class(CFXJSE_Context* lpContext)
+ : m_pContext(lpContext), m_lpClassDefinition(nullptr) {}
public:
inline CFXJSE_Context* GetContext() { return m_pContext; }
@@ -32,6 +33,7 @@ class CFXJSE_Class {
protected:
CFX_ByteString m_szClassName;
+ const FXJSE_CLASS* m_lpClassDefinition;
CFXJSE_Context* m_pContext;
v8::Global<v8::FunctionTemplate> m_hTemplate;
friend class CFXJSE_Context;
diff --git a/xfa/src/fxjse/src/context.cpp b/xfa/src/fxjse/src/context.cpp
index eab41a93dd..de5e4d5873 100644
--- a/xfa/src/fxjse/src/context.cpp
+++ b/xfa/src/fxjse/src/context.cpp
@@ -169,16 +169,6 @@ CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate,
FXJSE_GetGlobalObjectFromContext(hNewContext);
FXJSE_UpdateObjectBinding(hGlobalObject, lpGlobalObject);
pContext->m_hContext.Reset(pIsolate, hNewContext);
- if (lpGlobalClass) {
- if (lpGlobalClass->dynMethodCall || lpGlobalClass->dynPropGetter ||
- lpGlobalClass->dynPropSetter || lpGlobalClass->dynPropTypeGetter) {
- CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(pIsolate);
- lpThisValue->ForceSetValue(hGlobalObject);
- CFXJSE_Class::SetUpDynPropHandler(pContext, lpThisValue, lpGlobalClass);
- delete lpThisValue;
- lpThisValue = NULL;
- }
- }
return pContext;
}
CFXJSE_Context::~CFXJSE_Context() {
diff --git a/xfa/src/fxjse/src/dynprop.cpp b/xfa/src/fxjse/src/dynprop.cpp
index af3281d724..b9dab225ac 100644
--- a/xfa/src/fxjse/src/dynprop.cpp
+++ b/xfa/src/fxjse/src/dynprop.cpp
@@ -29,9 +29,9 @@ static void FXJSE_DynPropGetterAdapter_MethodCallback(
info.GetReturnValue().Set(lpRetValue->DirectGetValue());
}
delete lpRetValue;
- lpRetValue = NULL;
+ lpRetValue = nullptr;
delete lpThisValue;
- lpThisValue = NULL;
+ lpThisValue = nullptr;
}
static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS* lpClass,
FXJSE_HOBJECT hObject,
@@ -39,7 +39,7 @@ static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS* lpClass,
FXJSE_HVALUE hValue) {
ASSERT(lpClass);
int32_t nPropType =
- lpClass->dynPropTypeGetter == NULL
+ lpClass->dynPropTypeGetter == nullptr
? FXJSE_ClassPropType_Property
: lpClass->dynPropTypeGetter(hObject, szPropName, FALSE);
if (nPropType == FXJSE_ClassPropType_Property) {
@@ -74,7 +74,7 @@ static void FXJSE_DynPropSetterAdapter(const FXJSE_CLASS* lpClass,
FXJSE_HVALUE hValue) {
ASSERT(lpClass);
int32_t nPropType =
- lpClass->dynPropTypeGetter == NULL
+ lpClass->dynPropTypeGetter == nullptr
? FXJSE_ClassPropType_Property
: lpClass->dynPropTypeGetter(hObject, szPropName, FALSE);
if (nPropType != FXJSE_ClassPropType_Method) {
@@ -88,7 +88,7 @@ static FX_BOOL FXJSE_DynPropQueryAdapter(const FXJSE_CLASS* lpClass,
const CFX_ByteStringC& szPropName) {
ASSERT(lpClass);
int32_t nPropType =
- lpClass->dynPropTypeGetter == NULL
+ lpClass->dynPropTypeGetter == nullptr
? FXJSE_ClassPropType_Property
: lpClass->dynPropTypeGetter(hObject, szPropName, TRUE);
return nPropType != FXJSE_ClassPropType_None;
@@ -98,7 +98,7 @@ static FX_BOOL FXJSE_DynPropDeleterAdapter(const FXJSE_CLASS* lpClass,
const CFX_ByteStringC& szPropName) {
ASSERT(lpClass);
int32_t nPropType =
- lpClass->dynPropTypeGetter == NULL
+ lpClass->dynPropTypeGetter == nullptr
? FXJSE_ClassPropType_Property
: lpClass->dynPropTypeGetter(hObject, szPropName, FALSE);
if (nPropType != FXJSE_ClassPropType_Method) {
@@ -128,9 +128,9 @@ static void FXJSE_V8ProxyCallback_getOwnPropertyDescriptor_getter(
reinterpret_cast<FXJSE_HVALUE>(lpNewValue));
info.GetReturnValue().Set(lpNewValue->DirectGetValue());
delete lpThisValue;
- lpThisValue = NULL;
+ lpThisValue = nullptr;
delete lpNewValue;
- lpNewValue = NULL;
+ lpNewValue = nullptr;
}
static void FXJSE_V8ProxyCallback_getOwnPropertyDescriptor_setter(
const v8::FunctionCallbackInfo<v8::Value>& info) {
@@ -150,9 +150,9 @@ static void FXJSE_V8ProxyCallback_getOwnPropertyDescriptor_setter(
lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName,
reinterpret_cast<FXJSE_HVALUE>(lpNewValue));
delete lpThisValue;
- lpThisValue = NULL;
+ lpThisValue = nullptr;
delete lpNewValue;
- lpNewValue = NULL;
+ lpNewValue = nullptr;
}
static void FXJSE_V8ProxyCallback_getOwnPropertyDescriptor(
const v8::FunctionCallbackInfo<v8::Value>& info) {
@@ -248,9 +248,9 @@ static void FXJSE_V8ProxyCallback_defineProperty(
lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName,
reinterpret_cast<FXJSE_HVALUE>(lpPropValue));
delete lpThisValue;
- lpThisValue = NULL;
+ lpThisValue = nullptr;
delete lpPropValue;
- lpPropValue = NULL;
+ lpPropValue = nullptr;
}
static void FXJSE_V8ProxyCallback_delete(
const v8::FunctionCallbackInfo<v8::Value>& info) {
@@ -273,19 +273,16 @@ static void FXJSE_V8ProxyCallback_delete(
? true
: false);
delete lpThisValue;
- lpThisValue = NULL;
+ lpThisValue = nullptr;
}
static void FXJSE_V8ProxyCallback_fix(
const v8::FunctionCallbackInfo<v8::Value>& info) {
info.GetReturnValue().SetUndefined();
}
-static void FXJSE_V8_NamedPropertyQueryCallback(
- v8::Local<v8::String> property,
+static void FXJSE_V8_GenericNamedPropertyQueryCallback(
+ v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
v8::Local<v8::Object> thisObject = info.This();
- if (thisObject->HasRealNamedProperty(property)) {
- return;
- }
const FXJSE_CLASS* lpClass =
static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
v8::Isolate* pIsolate = info.GetIsolate();
@@ -303,15 +300,12 @@ static void FXJSE_V8_NamedPropertyQueryCallback(
info.GetReturnValue().Set(iV8Absent);
}
delete lpThisValue;
- lpThisValue = NULL;
+ lpThisValue = nullptr;
}
-static void FXJSE_V8_NamedPropertyDeleterCallback(
- v8::Local<v8::String> property,
+static void FXJSE_V8_GenericNamedPropertyDeleterCallback(
+ v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Boolean>& info) {
v8::Local<v8::Object> thisObject = info.This();
- if (thisObject->HasRealNamedProperty(property)) {
- return;
- }
const FXJSE_CLASS* lpClass =
static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
v8::Isolate* pIsolate = info.GetIsolate();
@@ -326,8 +320,61 @@ static void FXJSE_V8_NamedPropertyDeleterCallback(
? true
: false);
delete lpThisValue;
- lpThisValue = NULL;
+ lpThisValue = nullptr;
+}
+static void FXJSE_V8_GenericNamedPropertyGetterCallback(
+ v8::Local<v8::Name> property,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS* lpClass =
+ static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
+ lpThisValue->ForceSetValue(thisObject);
+ CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate());
+ FXJSE_DynPropGetterAdapter(
+ lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName,
+ reinterpret_cast<FXJSE_HVALUE>(lpNewValue));
+ info.GetReturnValue().Set(lpNewValue->DirectGetValue());
+ delete lpThisValue;
+ lpThisValue = nullptr;
}
+static void FXJSE_V8_GenericNamedPropertySetterCallback(
+ v8::Local<v8::Name> property,
+ v8::Local<v8::Value> value,
+ const v8::PropertyCallbackInfo<v8::Value>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS* lpClass =
+ static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
+ v8::Isolate* pIsolate = info.GetIsolate();
+ v8::String::Utf8Value szPropName(property);
+ CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
+ CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
+ lpThisValue->ForceSetValue(thisObject);
+ CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate());
+ lpNewValue->ForceSetValue(value);
+ FXJSE_DynPropSetterAdapter(
+ lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName,
+ reinterpret_cast<FXJSE_HVALUE>(lpNewValue));
+ info.GetReturnValue().Set(value);
+ delete lpThisValue;
+ lpThisValue = nullptr;
+}
+static void FXJSE_V8_GenericNamedPropertyEnumeratorCallback(
+ const v8::PropertyCallbackInfo<v8::Array>& info) {
+ v8::Local<v8::Object> thisObject = info.This();
+ const FXJSE_CLASS* lpClass =
+ static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
+ v8::Isolate* pIsolate = info.GetIsolate();
+ v8::Local<v8::Array> newArray = v8::Array::New(pIsolate, lpClass->propNum);
+ for (int i = 0; i < lpClass->propNum; i++) {
+ newArray->Set(
+ i, v8::String::NewFromUtf8(pIsolate, lpClass->properties[i].name));
+ }
+ info.GetReturnValue().Set(newArray);
+}
+
void CFXJSE_Class::SetUpDynPropHandler(CFXJSE_Context* pContext,
CFXJSE_Value* pValue,
const FXJSE_CLASS* lpClassDefinition) {
@@ -392,12 +439,21 @@ void CFXJSE_Class::SetUpNamedPropHandler(
v8::Isolate* pIsolate,
v8::Local<v8::ObjectTemplate>& hObjectTemplate,
const FXJSE_CLASS* lpClassDefinition) {
- hObjectTemplate->SetNamedPropertyHandler(
- 0, 0,
- lpClassDefinition->dynPropTypeGetter ? FXJSE_V8_NamedPropertyQueryCallback
- : 0,
- lpClassDefinition->dynPropDeleter ? FXJSE_V8_NamedPropertyDeleterCallback
- : 0,
- 0,
- v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(lpClassDefinition)));
+ v8::NamedPropertyHandlerConfiguration configuration(
+ lpClassDefinition->dynPropGetter
+ ? FXJSE_V8_GenericNamedPropertyGetterCallback
+ : 0,
+ lpClassDefinition->dynPropSetter
+ ? FXJSE_V8_GenericNamedPropertySetterCallback
+ : 0,
+ lpClassDefinition->dynPropTypeGetter
+ ? FXJSE_V8_GenericNamedPropertyQueryCallback
+ : 0,
+ lpClassDefinition->dynPropDeleter
+ ? FXJSE_V8_GenericNamedPropertyDeleterCallback
+ : 0,
+ FXJSE_V8_GenericNamedPropertyEnumeratorCallback,
+ v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(lpClassDefinition)),
+ v8::PropertyHandlerFlags::kNonMasking);
+ hObjectTemplate->SetHandler(configuration);
}
diff --git a/xfa/src/fxjse/src/runtime.cpp b/xfa/src/fxjse/src/runtime.cpp
index 01836113d0..e2aea644ce 100644
--- a/xfa/src/fxjse/src/runtime.cpp
+++ b/xfa/src/fxjse/src/runtime.cpp
@@ -32,7 +32,6 @@ void FXJSE_Initialize() {
bV8Initialized = TRUE;
atexit(FXJSE_KillV8);
const FX_CHAR* szCmdFlags =
- "--harmony_proxies "
"--block_concurrent_recompilation ";
v8::V8::SetFlagsFromString(szCmdFlags, FXSYS_strlen(szCmdFlags));
}