summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn2
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp22
-rw-r--r--fxjs/cjx_node.cpp17
-rw-r--r--xfa/fxfa/parser/cxfa_valuearray.cpp25
-rw-r--r--xfa/fxfa/parser/cxfa_valuearray.h29
-rw-r--r--xfa/fxfa/parser/xfa_resolvenode_rs.h15
6 files changed, 25 insertions, 85 deletions
diff --git a/BUILD.gn b/BUILD.gn
index db82f1b6e2..65683f9646 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -2473,8 +2473,6 @@ if (pdf_enable_xfa) {
"xfa/fxfa/parser/cxfa_validationmessaging.h",
"xfa/fxfa/parser/cxfa_value.cpp",
"xfa/fxfa/parser/cxfa_value.h",
- "xfa/fxfa/parser/cxfa_valuearray.cpp",
- "xfa/fxfa/parser/cxfa_valuearray.h",
"xfa/fxfa/parser/cxfa_valuedata.cpp",
"xfa/fxfa/parser/cxfa_valuedata.h",
"xfa/fxfa/parser/cxfa_variables.cpp",
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 <algorithm>
#include <string>
+#include <utility>
#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<CFXJSE_Value>(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<CFXJSE_Value>(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<CFXJSE_Value>(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());
}
}
}
diff --git a/xfa/fxfa/parser/cxfa_valuearray.cpp b/xfa/fxfa/parser/cxfa_valuearray.cpp
deleted file mode 100644
index 83ffe6b275..0000000000
--- a/xfa/fxfa/parser/cxfa_valuearray.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#include "xfa/fxfa/parser/cxfa_valuearray.h"
-
-#include <algorithm>
-
-#include "fxjs/cfxjse_engine.h"
-
-CXFA_ValueArray::CXFA_ValueArray(v8::Isolate* pIsolate)
- : m_pIsolate(pIsolate) {}
-
-CXFA_ValueArray::~CXFA_ValueArray() {}
-
-std::vector<CXFA_Object*> CXFA_ValueArray::GetAttributeObject() {
- std::vector<CXFA_Object*> result(m_Values.size());
- std::transform(m_Values.begin(), m_Values.end(), result.begin(),
- [](const std::unique_ptr<CFXJSE_Value>& value) {
- return CFXJSE_Engine::ToObject(value.get(), nullptr);
- });
- return result;
-}
diff --git a/xfa/fxfa/parser/cxfa_valuearray.h b/xfa/fxfa/parser/cxfa_valuearray.h
deleted file mode 100644
index c6054e2fbf..0000000000
--- a/xfa/fxfa/parser/cxfa_valuearray.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2016 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
-#define XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
-
-#include <memory>
-#include <vector>
-
-#include "fxjs/cfxjse_value.h"
-#include "xfa/fxfa/fxfa.h"
-
-class CXFA_Object;
-
-class CXFA_ValueArray {
- public:
- explicit CXFA_ValueArray(v8::Isolate* pIsolate);
- ~CXFA_ValueArray();
-
- std::vector<CXFA_Object*> GetAttributeObject();
-
- v8::Isolate* const m_pIsolate;
- std::vector<std::unique_ptr<CFXJSE_Value>> m_Values;
-};
-
-#endif // XFA_FXFA_PARSER_CXFA_VALUEARRAY_H_
diff --git a/xfa/fxfa/parser/xfa_resolvenode_rs.h b/xfa/fxfa/parser/xfa_resolvenode_rs.h
index c5cdeee06f..2eaab5dff4 100644
--- a/xfa/fxfa/parser/xfa_resolvenode_rs.h
+++ b/xfa/fxfa/parser/xfa_resolvenode_rs.h
@@ -15,7 +15,6 @@
#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_object.h"
-#include "xfa/fxfa/parser/cxfa_valuearray.h"
#define XFA_RESOLVENODE_Children 0x0001
#define XFA_RESOLVENODE_Attributes 0x0004
@@ -41,20 +40,6 @@ struct XFA_RESOLVENODE_RS {
XFA_RESOLVENODE_RS();
~XFA_RESOLVENODE_RS();
- size_t GetAttributeResult(CXFA_ValueArray* valueArray) const {
- if (pScriptAttribute &&
- pScriptAttribute->eValueType == XFA_ScriptType::Object) {
- for (CXFA_Object* pObject : objects) {
- auto pValue = pdfium::MakeUnique<CFXJSE_Value>(valueArray->m_pIsolate);
- CJX_Object* jsObject = pObject->JSObject();
- (jsObject->*(pScriptAttribute->callback))(pValue.get(), false,
- pScriptAttribute->attribute);
- valueArray->m_Values.push_back(std::move(pValue));
- }
- }
- return valueArray->m_Values.size();
- }
-
std::vector<CXFA_Object*> objects; // Not owned.
XFA_RESOLVENODE_RSTYPE dwFlags;
const XFA_SCRIPTATTRIBUTEINFO* pScriptAttribute;