summaryrefslogtreecommitdiff
path: root/xfa/src
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-03-04 10:37:34 -0800
committerTom Sepez <tsepez@chromium.org>2016-03-04 10:37:34 -0800
commitce00f4a129899bfc62583c9e3b06654e5bbe17cb (patch)
treee452fc0d5be4431939f499278e010738a6396edb /xfa/src
parent1c91537c9f9669246713a5be628493ae2fc4899a (diff)
downloadpdfium-ce00f4a129899bfc62583c9e3b06654e5bbe17cb.tar.xz
Fix deprecated ObjectTemplate::New() and TryCatch() warnings.
R=jochen@chromium.org Review URL: https://codereview.chromium.org/1762643003 .
Diffstat (limited to 'xfa/src')
-rw-r--r--xfa/src/fxjse/src/class.h3
-rw-r--r--xfa/src/fxjse/src/context.cpp4
-rw-r--r--xfa/src/fxjse/src/dynprop.cpp241
-rw-r--r--xfa/src/fxjse/src/value.cpp2
4 files changed, 4 insertions, 246 deletions
diff --git a/xfa/src/fxjse/src/class.h b/xfa/src/fxjse/src/class.h
index 794a34e7b8..3c1780fc58 100644
--- a/xfa/src/fxjse/src/class.h
+++ b/xfa/src/fxjse/src/class.h
@@ -28,9 +28,6 @@ class CFXJSE_Class {
FX_BOOL bIsJSGlobal = FALSE);
static CFXJSE_Class* GetClassFromContext(CFXJSE_Context* pContext,
const CFX_ByteStringC& szName);
- static void SetUpDynPropHandler(CFXJSE_Context* pContext,
- CFXJSE_Value* pValue,
- const FXJSE_CLASS* lpClassDefinition);
static void SetUpNamedPropHandler(
v8::Isolate* pIsolate,
v8::Local<v8::ObjectTemplate>& hObjectTemplate,
diff --git a/xfa/src/fxjse/src/context.cpp b/xfa/src/fxjse/src/context.cpp
index 54b4f64efc..9d5b699c8b 100644
--- a/xfa/src/fxjse/src/context.cpp
+++ b/xfa/src/fxjse/src/context.cpp
@@ -182,7 +182,7 @@ CFXJSE_Context* CFXJSE_Context::Create(v8::Isolate* pIsolate,
lpGlobalClassObj->m_hTemplate);
hObjectTemplate = hFunctionTemplate->InstanceTemplate();
} else {
- hObjectTemplate = v8::ObjectTemplate::New();
+ hObjectTemplate = v8::ObjectTemplate::New(pIsolate);
hObjectTemplate->SetInternalFieldCount(1);
}
v8::Local<v8::Context> hNewContext =
@@ -220,7 +220,7 @@ FX_BOOL CFXJSE_Context::ExecuteScript(const FX_CHAR* szScript,
CFXJSE_Value* lpRetValue,
CFXJSE_Value* lpNewThisObject) {
CFXJSE_ScopeUtil_IsolateHandleContext scope(this);
- v8::TryCatch trycatch;
+ v8::TryCatch trycatch(m_pIsolate);
v8::Local<v8::String> hScriptString =
v8::String::NewFromUtf8(m_pIsolate, szScript);
if (lpNewThisObject == NULL) {
diff --git a/xfa/src/fxjse/src/dynprop.cpp b/xfa/src/fxjse/src/dynprop.cpp
index 26beb5c283..bc423c03c0 100644
--- a/xfa/src/fxjse/src/dynprop.cpp
+++ b/xfa/src/fxjse/src/dynprop.cpp
@@ -52,7 +52,7 @@ static void FXJSE_DynPropGetterAdapter(const FXJSE_CLASS* lpClass,
v8::Isolate* pIsolate = lpValue->GetIsolate();
v8::HandleScope hscope(pIsolate);
v8::Local<v8::ObjectTemplate> hCallBackInfoTemplate =
- v8::ObjectTemplate::New();
+ v8::ObjectTemplate::New(pIsolate);
hCallBackInfoTemplate->SetInternalFieldCount(2);
v8::Local<v8::Object> hCallBackInfo =
hCallBackInfoTemplate->NewInstance();
@@ -114,184 +114,6 @@ static FX_BOOL FXJSE_DynPropDeleterAdapter(const FXJSE_CLASS* lpClass,
return FALSE;
}
-static void FXJSE_V8ProxyCallback_getOwnPropertyDescriptor_getter(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>();
- FXJSE_CLASS* lpClass = static_cast<FXJSE_CLASS*>(
- hCallBackInfo->GetAlignedPointerFromInternalField(0));
- v8::Local<v8::String> hPropName =
- hCallBackInfo->GetInternalField(1).As<v8::String>();
- ASSERT(lpClass && !hPropName.IsEmpty());
- v8::String::Utf8Value szPropName(hPropName);
- CFX_ByteStringC szFxPropName = *szPropName;
- CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
- CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate());
- lpThisValue->ForceSetValue(info.This());
- FXJSE_DynPropGetterAdapter(
- lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName,
- reinterpret_cast<FXJSE_HVALUE>(lpNewValue));
- info.GetReturnValue().Set(lpNewValue->DirectGetValue());
- delete lpThisValue;
- lpThisValue = nullptr;
- delete lpNewValue;
- lpNewValue = nullptr;
-}
-
-static void FXJSE_V8ProxyCallback_getOwnPropertyDescriptor_setter(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>();
- FXJSE_CLASS* lpClass = static_cast<FXJSE_CLASS*>(
- hCallBackInfo->GetAlignedPointerFromInternalField(0));
- v8::Local<v8::String> hPropName =
- hCallBackInfo->GetInternalField(1).As<v8::String>();
- ASSERT(lpClass && !hPropName.IsEmpty());
- v8::String::Utf8Value szPropName(hPropName);
- CFX_ByteStringC szFxPropName = *szPropName;
- CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
- CFXJSE_Value* lpNewValue = CFXJSE_Value::Create(info.GetIsolate());
- lpThisValue->ForceSetValue(info.This());
- lpNewValue->ForceSetValue(info[0]);
- FXJSE_DynPropSetterAdapter(
- lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName,
- reinterpret_cast<FXJSE_HVALUE>(lpNewValue));
- delete lpThisValue;
- lpThisValue = nullptr;
- delete lpNewValue;
- lpNewValue = nullptr;
-}
-
-static void FXJSE_V8ProxyCallback_getOwnPropertyDescriptor(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- const FXJSE_CLASS* lpClass =
- static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
- if (!lpClass) {
- return;
- }
- v8::Isolate* pIsolate = info.GetIsolate();
- v8::HandleScope scope(pIsolate);
- v8::Local<v8::String> hPropName = info[0]->ToString();
- v8::String::Utf8Value szPropName(hPropName);
- CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- v8::Local<v8::ObjectTemplate> hCallBackInfoTemplate =
- v8::ObjectTemplate::New();
- hCallBackInfoTemplate->SetInternalFieldCount(2);
- v8::Local<v8::Object> hCallBackInfo = hCallBackInfoTemplate->NewInstance();
- hCallBackInfo->SetAlignedPointerInInternalField(
- 0, const_cast<FXJSE_CLASS*>(lpClass));
- hCallBackInfo->SetInternalField(1, hPropName);
- v8::Local<v8::Object> hPropDescriptor = v8::Object::New(pIsolate);
- hPropDescriptor->ForceSet(
- v8::String::NewFromUtf8(pIsolate, "get"),
- v8::Function::New(pIsolate,
- FXJSE_V8ProxyCallback_getOwnPropertyDescriptor_getter,
- hCallBackInfo));
- hPropDescriptor->ForceSet(
- v8::String::NewFromUtf8(pIsolate, "set"),
- v8::Function::New(pIsolate,
- FXJSE_V8ProxyCallback_getOwnPropertyDescriptor_setter,
- hCallBackInfo));
- hPropDescriptor->ForceSet(v8::String::NewFromUtf8(pIsolate, "enumerable"),
- v8::Boolean::New(pIsolate, false));
- hPropDescriptor->ForceSet(v8::String::NewFromUtf8(pIsolate, "configurable"),
- v8::Boolean::New(pIsolate, true));
- info.GetReturnValue().Set(hPropDescriptor);
-}
-
-static void FXJSE_V8ProxyCallback_getPropertyDescriptor(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- v8::Isolate* pIsolate = info.GetIsolate();
- v8::Local<v8::Object> hChainObj =
- info.This()->GetPrototype().As<v8::Object>();
- v8::Local<v8::Script> fnSource = v8::Script::Compile(v8::String::NewFromUtf8(
- pIsolate,
- "(function (o, name) { var fn, x, d; fn = "
- "Object.getOwnPropertyDescriptor; x = o; while(x && !(d = fn(x, "
- "name))){x = x.__proto__;} return d; })"));
- v8::Local<v8::Function> fn = fnSource->Run().As<v8::Function>();
- v8::Local<v8::Value> rgArgs[] = {hChainObj, info[0]};
- v8::Local<v8::Value> hChainDescriptor = fn->Call(info.This(), 2, rgArgs);
- if (!hChainDescriptor.IsEmpty() && hChainDescriptor->IsObject()) {
- info.GetReturnValue().Set(hChainDescriptor);
- } else {
- FXJSE_V8ProxyCallback_getOwnPropertyDescriptor(info);
- }
-}
-
-static void FXJSE_V8ProxyCallback_getOwnPropertyNames(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- v8::Isolate* pIsolate = info.GetIsolate();
- v8::HandleScope scope(pIsolate);
- info.GetReturnValue().Set(v8::Array::New(pIsolate));
-}
-
-static void FXJSE_V8ProxyCallback_getPropertyNames(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- v8::Local<v8::Object> hChainObj =
- info.This()->GetPrototype().As<v8::Object>();
- v8::Local<v8::Value> hChainPropertyNames = hChainObj->GetPropertyNames();
- info.GetReturnValue().Set(hChainPropertyNames);
-}
-
-static void FXJSE_V8ProxyCallback_defineProperty(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- const FXJSE_CLASS* lpClass =
- static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
- if (!lpClass) {
- return;
- }
- v8::Isolate* pIsolate = info.GetIsolate();
- v8::HandleScope scope(pIsolate);
- v8::Local<v8::String> hPropName = info[0]->ToString();
- v8::Local<v8::Object> hPropDescriptor = info[1]->ToObject();
- v8::String::Utf8Value szPropName(hPropName);
- if (!hPropDescriptor->Has(v8::String::NewFromUtf8(pIsolate, "value"))) {
- return;
- }
- v8::Local<v8::Value> hPropValue =
- hPropDescriptor->Get(v8::String::NewFromUtf8(pIsolate, "value"));
- CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
- CFXJSE_Value* lpPropValue = CFXJSE_Value::Create(info.GetIsolate());
- lpThisValue->ForceSetValue(info.This());
- lpPropValue->ForceSetValue(hPropValue);
- FXJSE_DynPropSetterAdapter(
- lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName,
- reinterpret_cast<FXJSE_HVALUE>(lpPropValue));
- delete lpThisValue;
- lpThisValue = nullptr;
- delete lpPropValue;
- lpPropValue = nullptr;
-}
-
-static void FXJSE_V8ProxyCallback_delete(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- info.GetReturnValue().Set(true);
- const FXJSE_CLASS* lpClass =
- static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
- if (!lpClass) {
- return;
- }
- v8::Isolate* pIsolate = info.GetIsolate();
- v8::HandleScope scope(pIsolate);
- v8::Local<v8::String> hPropName = info[0]->ToString();
- v8::String::Utf8Value szPropName(hPropName);
- CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
- CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
- lpThisValue->ForceSetValue(info.This());
- info.GetReturnValue().Set(
- FXJSE_DynPropDeleterAdapter(
- lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName)
- ? true
- : false);
- delete lpThisValue;
- lpThisValue = nullptr;
-}
-
-static void FXJSE_V8ProxyCallback_fix(
- const v8::FunctionCallbackInfo<v8::Value>& info) {
- info.GetReturnValue().SetUndefined();
-}
-
static void FXJSE_V8_GenericNamedPropertyQueryCallback(
v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Integer>& info) {
@@ -390,67 +212,6 @@ static void FXJSE_V8_GenericNamedPropertyEnumeratorCallback(
info.GetReturnValue().Set(newArray);
}
-void CFXJSE_Class::SetUpDynPropHandler(CFXJSE_Context* pContext,
- CFXJSE_Value* pValue,
- const FXJSE_CLASS* lpClassDefinition) {
- v8::Isolate* pIsolate = pValue->GetIsolate();
- CFXJSE_ScopeUtil_IsolateHandleRootOrNormalContext scope(pIsolate, pContext);
- v8::Local<v8::Context> hContext = v8::Local<v8::Context>::New(
- pIsolate, pContext ? pContext->m_hContext
- : CFXJSE_RuntimeData::Get(pIsolate)->m_hRootContext);
- v8::Local<v8::Object> hObject =
- v8::Local<v8::Value>::New(pIsolate, pValue->m_hValue).As<v8::Object>();
- v8::Local<v8::Object> hHarmonyProxyObj =
- hContext->Global()
- ->Get(v8::String::NewFromUtf8(pIsolate, "Proxy"))
- .As<v8::Object>();
- v8::Local<v8::Function> hHarmonyProxyCreateFn =
- hHarmonyProxyObj->Get(v8::String::NewFromUtf8(pIsolate, "create"))
- .As<v8::Function>();
- v8::Local<v8::Value> hOldPrototype = hObject->GetPrototype();
- v8::Local<v8::Object> hTrapper = v8::Object::New(pIsolate);
- hTrapper->ForceSet(
- v8::String::NewFromUtf8(pIsolate, "getOwnPropertyDescriptor"),
- v8::Function::New(
- pIsolate, FXJSE_V8ProxyCallback_getOwnPropertyDescriptor,
- v8::External::New(pIsolate,
- const_cast<FXJSE_CLASS*>(lpClassDefinition))));
- hTrapper->ForceSet(
- v8::String::NewFromUtf8(pIsolate, "getPropertyDescriptor"),
- v8::Function::New(pIsolate, FXJSE_V8ProxyCallback_getPropertyDescriptor,
- v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(
- lpClassDefinition))));
- hTrapper->ForceSet(
- v8::String::NewFromUtf8(pIsolate, "getOwnPropertyNames"),
- v8::Function::New(pIsolate, FXJSE_V8ProxyCallback_getOwnPropertyNames,
- v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(
- lpClassDefinition))));
- hTrapper->ForceSet(
- v8::String::NewFromUtf8(pIsolate, "getPropertyNames"),
- v8::Function::New(pIsolate, FXJSE_V8ProxyCallback_getPropertyNames,
- v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(
- lpClassDefinition))));
- hTrapper->ForceSet(
- v8::String::NewFromUtf8(pIsolate, "delete"),
- v8::Function::New(pIsolate, FXJSE_V8ProxyCallback_delete,
- v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(
- lpClassDefinition))));
- hTrapper->ForceSet(
- v8::String::NewFromUtf8(pIsolate, "defineProperty"),
- v8::Function::New(pIsolate, FXJSE_V8ProxyCallback_defineProperty,
- v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(
- lpClassDefinition))));
- hTrapper->ForceSet(
- v8::String::NewFromUtf8(pIsolate, "fix"),
- v8::Function::New(pIsolate, FXJSE_V8ProxyCallback_fix,
- v8::External::New(pIsolate, const_cast<FXJSE_CLASS*>(
- lpClassDefinition))));
- v8::Local<v8::Value> rgArgs[] = {hTrapper, hOldPrototype};
- v8::Local<v8::Value> hNewPrototype =
- hHarmonyProxyCreateFn->Call(hHarmonyProxyObj, 2, rgArgs);
- hObject->SetPrototype(hNewPrototype);
-}
-
void CFXJSE_Class::SetUpNamedPropHandler(
v8::Isolate* pIsolate,
v8::Local<v8::ObjectTemplate>& hObjectTemplate,
diff --git a/xfa/src/fxjse/src/value.cpp b/xfa/src/fxjse/src/value.cpp
index b3c47b65c0..d4e2c0dbc2 100644
--- a/xfa/src/fxjse/src/value.cpp
+++ b/xfa/src/fxjse/src/value.cpp
@@ -515,7 +515,7 @@ FX_BOOL CFXJSE_Value::Call(CFXJSE_Value* lpReceiver,
? hFunctionValue.As<v8::Object>()
: v8::Local<v8::Object>();
- v8::TryCatch trycatch;
+ v8::TryCatch trycatch(m_pIsolate);
if (hFunctionObject.IsEmpty() || !hFunctionObject->IsCallable()) {
if (lpRetValue)
lpRetValue->ForceSetValue(FXJSE_CreateReturnValue(m_pIsolate, trycatch));