From aeb5246e6293a5d25973405f5602c46aa81f7dfd Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 4 Dec 2017 19:02:16 +0000 Subject: Remove CXFA_ValueArray This CL removes the CXFA_ValueArray. Some of the code in XFA_RESOLVENODE_RS is duplicated, but the duplication makes the code clearer. Change-Id: I7495bb8c614a3d8919bfca858866932774f13fd8 Reviewed-on: https://pdfium-review.googlesource.com/20350 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- fxjs/cfxjse_formcalc_context.cpp | 22 +++++++++++++--------- fxjs/cjx_node.cpp | 17 ++++++++++++----- 2 files changed, 25 insertions(+), 14 deletions(-) (limited to 'fxjs') diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp index 4bfe7d8b8b..e7d44d179f 100644 --- a/fxjs/cfxjse_formcalc_context.cpp +++ b/fxjs/cfxjse_formcalc_context.cpp @@ -10,6 +10,7 @@ #include #include +#include #include "core/fxcrt/cfx_decimal.h" #include "core/fxcrt/cfx_widetextbuf.h" @@ -5999,18 +6000,21 @@ void CFXJSE_FormCalcContext::ParseResolveResult( return; } - CXFA_ValueArray objectProperties(pIsolate); - int32_t iRet = resolveNodeRS.GetAttributeResult(&objectProperties); *bAttribute = true; - if (iRet != 0) { - *bAttribute = false; - for (int32_t i = 0; i < iRet; i++) { - resultValues->push_back(pdfium::MakeUnique(pIsolate)); - resultValues->back()->Assign(objectProperties.m_Values[i].get()); + if (resolveNodeRS.pScriptAttribute && + resolveNodeRS.pScriptAttribute->eValueType == XFA_ScriptType::Object) { + for (CXFA_Object* pObject : resolveNodeRS.objects) { + auto pValue = pdfium::MakeUnique(pIsolate); + CJX_Object* jsObject = pObject->JSObject(); + (jsObject->*(resolveNodeRS.pScriptAttribute->callback))( + pValue.get(), false, resolveNodeRS.pScriptAttribute->attribute); + + resultValues->push_back(std::move(pValue)); + *bAttribute = false; } - return; } - + if (!*bAttribute) + return; if (!pParentValue || !pParentValue->IsObject()) return; diff --git a/fxjs/cjx_node.cpp b/fxjs/cjx_node.cpp index 8bf00f585f..9f0a0de998 100644 --- a/fxjs/cjx_node.cpp +++ b/fxjs/cjx_node.cpp @@ -481,11 +481,18 @@ void CJX_Node::ResolveNodeList(CFXJSE_Value* pValue, pNodeList->Append(pObject->AsNode()); } } else { - CXFA_ValueArray valueArray(pScriptContext->GetRuntime()); - if (resolveNodeRS.GetAttributeResult(&valueArray) > 0) { - for (CXFA_Object* pObject : valueArray.GetAttributeObject()) { - if (pObject->IsNode()) - pNodeList->Append(pObject->AsNode()); + if (resolveNodeRS.pScriptAttribute && + resolveNodeRS.pScriptAttribute->eValueType == XFA_ScriptType::Object) { + for (CXFA_Object* pObject : resolveNodeRS.objects) { + auto pValue = + pdfium::MakeUnique(pScriptContext->GetRuntime()); + CJX_Object* jsObject = pObject->JSObject(); + (jsObject->*(resolveNodeRS.pScriptAttribute->callback))( + pValue.get(), false, resolveNodeRS.pScriptAttribute->attribute); + + CXFA_Object* obj = CFXJSE_Engine::ToObject(pValue.get(), nullptr); + if (obj->IsNode()) + pNodeList->Append(obj->AsNode()); } } } -- cgit v1.2.3