From 85caeb903c239d0c80aec86241885eabc1de71fb Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 4 Dec 2017 15:14:05 +0000 Subject: Remove unused XFA code Change-Id: Iea75ce6b3a7e06b7977491a89e7a31755f038312 Reviewed-on: https://pdfium-review.googlesource.com/20191 Commit-Queue: Ryan Harrison Reviewed-by: Ryan Harrison --- fxjs/cfxjse_class.cpp | 131 ++------------------------------------------------ 1 file changed, 3 insertions(+), 128 deletions(-) (limited to 'fxjs/cfxjse_class.cpp') diff --git a/fxjs/cfxjse_class.cpp b/fxjs/cfxjse_class.cpp index b2e747b4fd..09976d1aa5 100644 --- a/fxjs/cfxjse_class.cpp +++ b/fxjs/cfxjse_class.cpp @@ -34,57 +34,6 @@ void V8FunctionCallback_Wrapper( info.GetReturnValue().Set(lpRetValue->DirectGetValue()); } -void V8ClassGlobalConstructorCallback_Wrapper( - const v8::FunctionCallbackInfo& info) { - const FXJSE_CLASS_DESCRIPTOR* lpClassDefinition = - static_cast( - info.Data().As()->Value()); - if (!lpClassDefinition) - return; - - ByteStringView szFunctionName(lpClassDefinition->name); - auto lpThisValue = pdfium::MakeUnique(info.GetIsolate()); - lpThisValue->ForceSetValue(info.Holder()); - auto lpRetValue = pdfium::MakeUnique(info.GetIsolate()); - CFXJSE_Arguments impl(&info, lpRetValue.get()); - lpClassDefinition->constructor(lpThisValue.get(), szFunctionName, impl); - if (!lpRetValue->DirectGetValue().IsEmpty()) - info.GetReturnValue().Set(lpRetValue->DirectGetValue()); -} - -void V8GetterCallback_Wrapper(v8::Local property, - const v8::PropertyCallbackInfo& info) { - const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo = - static_cast( - info.Data().As()->Value()); - if (!lpPropertyInfo) - return; - - ByteStringView szPropertyName(lpPropertyInfo->name); - auto lpThisValue = pdfium::MakeUnique(info.GetIsolate()); - auto lpPropValue = pdfium::MakeUnique(info.GetIsolate()); - lpThisValue->ForceSetValue(info.Holder()); - lpPropertyInfo->getProc(lpThisValue.get(), szPropertyName, lpPropValue.get()); - info.GetReturnValue().Set(lpPropValue->DirectGetValue()); -} - -void V8SetterCallback_Wrapper(v8::Local property, - v8::Local value, - const v8::PropertyCallbackInfo& info) { - const FXJSE_PROPERTY_DESCRIPTOR* lpPropertyInfo = - static_cast( - info.Data().As()->Value()); - if (!lpPropertyInfo) - return; - - ByteStringView szPropertyName(lpPropertyInfo->name); - auto lpThisValue = pdfium::MakeUnique(info.GetIsolate()); - auto lpPropValue = pdfium::MakeUnique(info.GetIsolate()); - lpThisValue->ForceSetValue(info.Holder()); - lpPropValue->ForceSetValue(value); - lpPropertyInfo->setProc(lpThisValue.get(), szPropertyName, lpPropValue.get()); -} - void V8ConstructorCallback_Wrapper( const v8::FunctionCallbackInfo& info) { if (!info.IsConstructCall()) @@ -202,22 +151,6 @@ bool DynPropQueryAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass, return nPropType != FXJSE_ClassPropType_None; } -bool DynPropDeleterAdapter(const FXJSE_CLASS_DESCRIPTOR* lpClass, - CFXJSE_Value* pObject, - const ByteStringView& szPropName) { - ASSERT(lpClass); - int32_t nPropType = - lpClass->dynPropTypeGetter == nullptr - ? FXJSE_ClassPropType_Property - : lpClass->dynPropTypeGetter(pObject, szPropName, false); - if (nPropType != FXJSE_ClassPropType_Method) { - if (lpClass->dynPropDeleter) - return lpClass->dynPropDeleter(pObject, szPropName); - return nPropType != FXJSE_ClassPropType_Property; - } - return false; -} - void NamedPropertyQueryCallback( v8::Local property, const v8::PropertyCallbackInfo& info) { @@ -238,22 +171,6 @@ void NamedPropertyQueryCallback( info.GetReturnValue().Set(iV8Absent); } -void NamedPropertyDeleterCallback( - v8::Local property, - const v8::PropertyCallbackInfo& info) { - v8::Local thisObject = info.Holder(); - const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast( - info.Data().As()->Value()); - v8::Isolate* pIsolate = info.GetIsolate(); - v8::HandleScope scope(pIsolate); - v8::String::Utf8Value szPropName(property); - ByteStringView szFxPropName(*szPropName, szPropName.length()); - auto lpThisValue = pdfium::MakeUnique(info.GetIsolate()); - lpThisValue->ForceSetValue(thisObject); - info.GetReturnValue().Set( - !!DynPropDeleterAdapter(lpClass, lpThisValue.get(), szFxPropName)); -} - void NamedPropertyGetterCallback( v8::Local property, const v8::PropertyCallbackInfo& info) { @@ -291,15 +208,7 @@ void NamedPropertySetterCallback( void NamedPropertyEnumeratorCallback( const v8::PropertyCallbackInfo& info) { - const FXJSE_CLASS_DESCRIPTOR* lpClass = static_cast( - info.Data().As()->Value()); - v8::Isolate* pIsolate = info.GetIsolate(); - v8::Local 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); + info.GetReturnValue().Set(v8::Array::New(info.GetIsolate())); } } // namespace @@ -333,20 +242,6 @@ CFXJSE_Class* CFXJSE_Class::Create( hFunctionTemplate->InstanceTemplate(); SetUpNamedPropHandler(pIsolate, hObjectTemplate, lpClassDefinition); - if (lpClassDefinition->propNum) { - for (int32_t i = 0; i < lpClassDefinition->propNum; i++) { - hObjectTemplate->SetNativeDataProperty( - v8::String::NewFromUtf8(pIsolate, - lpClassDefinition->properties[i].name), - lpClassDefinition->properties[i].getProc ? V8GetterCallback_Wrapper - : nullptr, - lpClassDefinition->properties[i].setProc ? V8SetterCallback_Wrapper - : nullptr, - v8::External::New(pIsolate, const_cast( - lpClassDefinition->properties + i)), - static_cast(v8::DontDelete)); - } - } if (lpClassDefinition->methNum) { for (int32_t i = 0; i < lpClassDefinition->methNum; i++) { v8::Local fun = v8::FunctionTemplate::New( @@ -360,26 +255,7 @@ CFXJSE_Class* CFXJSE_Class::Create( static_cast(v8::ReadOnly | v8::DontDelete)); } } - if (lpClassDefinition->constructor) { - if (bIsJSGlobal) { - hObjectTemplate->Set( - v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name), - v8::FunctionTemplate::New( - pIsolate, V8ClassGlobalConstructorCallback_Wrapper, - v8::External::New(pIsolate, const_cast( - lpClassDefinition))), - static_cast(v8::ReadOnly | v8::DontDelete)); - } else { - v8::Local hLocalContext = lpContext->GetContext(); - FXJSE_GetGlobalObjectFromContext(hLocalContext) - ->Set(v8::String::NewFromUtf8(pIsolate, lpClassDefinition->name), - v8::Function::New( - pIsolate, V8ClassGlobalConstructorCallback_Wrapper, - v8::External::New(pIsolate, - const_cast( - lpClassDefinition)))); - } - } + if (bIsJSGlobal) { v8::Local fun = v8::FunctionTemplate::New( pIsolate, Context_GlobalObjToString, @@ -402,8 +278,7 @@ void CFXJSE_Class::SetUpNamedPropHandler( v8::NamedPropertyHandlerConfiguration configuration( lpClassDefinition->dynPropGetter ? NamedPropertyGetterCallback : 0, lpClassDefinition->dynPropSetter ? NamedPropertySetterCallback : 0, - lpClassDefinition->dynPropTypeGetter ? NamedPropertyQueryCallback : 0, - lpClassDefinition->dynPropDeleter ? NamedPropertyDeleterCallback : 0, + lpClassDefinition->dynPropTypeGetter ? NamedPropertyQueryCallback : 0, 0, NamedPropertyEnumeratorCallback, v8::External::New(pIsolate, const_cast(lpClassDefinition)), -- cgit v1.2.3