summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD.gn4
-rw-r--r--fxjs/cfxjse_engine.cpp10
-rw-r--r--fxjs/cfxjse_engine.h4
-rw-r--r--fxjs/cfxjse_resolveprocessor.cpp (renamed from xfa/fxfa/parser/cxfa_resolveprocessor.cpp)81
-rw-r--r--fxjs/cfxjse_resolveprocessor.h (renamed from xfa/fxfa/parser/cxfa_resolveprocessor.h)44
5 files changed, 72 insertions, 71 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 60b5776e43..626727d94e 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1297,6 +1297,8 @@ static_library("fxjs") {
"fxjs/cfxjse_formcalc_context.h",
"fxjs/cfxjse_isolatetracker.cpp",
"fxjs/cfxjse_isolatetracker.h",
+ "fxjs/cfxjse_resolveprocessor.cpp",
+ "fxjs/cfxjse_resolveprocessor.h",
"fxjs/cfxjse_runtimedata.cpp",
"fxjs/cfxjse_runtimedata.h",
"fxjs/cfxjse_value.cpp",
@@ -1863,8 +1865,6 @@ if (pdf_enable_xfa) {
"xfa/fxfa/parser/cxfa_para.cpp",
"xfa/fxfa/parser/cxfa_para.h",
"xfa/fxfa/parser/cxfa_rectangle.h",
- "xfa/fxfa/parser/cxfa_resolveprocessor.cpp",
- "xfa/fxfa/parser/cxfa_resolveprocessor.h",
"xfa/fxfa/parser/cxfa_script.cpp",
"xfa/fxfa/parser/cxfa_script.h",
"xfa/fxfa/parser/cxfa_simple_parser.cpp",
diff --git a/fxjs/cfxjse_engine.cpp b/fxjs/cfxjse_engine.cpp
index fb36c6dba0..6d990f66fb 100644
--- a/fxjs/cfxjse_engine.cpp
+++ b/fxjs/cfxjse_engine.cpp
@@ -13,6 +13,7 @@
#include "core/fxcrt/fx_extension.h"
#include "fxjs/cfxjse_arguments.h"
#include "fxjs/cfxjse_class.h"
+#include "fxjs/cfxjse_resolveprocessor.h"
#include "fxjs/cfxjse_value.h"
#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
@@ -24,7 +25,6 @@
#include "xfa/fxfa/parser/cxfa_nodehelper.h"
#include "xfa/fxfa/parser/cxfa_nodelist.h"
#include "xfa/fxfa/parser/cxfa_object.h"
-#include "xfa/fxfa/parser/cxfa_resolveprocessor.h"
#include "xfa/fxfa/parser/cxfa_thisproxy.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
@@ -142,7 +142,7 @@ void CFXJSE_Engine::Initialize(v8::Isolate* pIsolate) {
m_pIsolate = pIsolate;
DefineJsContext();
DefineJsClass();
- m_ResolveProcessor = pdfium::MakeUnique<CXFA_ResolveProcessor>();
+ m_ResolveProcessor = pdfium::MakeUnique<CFXJSE_ResolveProcessor>();
}
bool CFXJSE_Engine::RunScript(XFA_SCRIPTLANGTYPE eScriptType,
@@ -574,11 +574,11 @@ int32_t CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject,
m_ResolveProcessor->GetNodeHelper()->m_pCreateParent = nullptr;
m_ResolveProcessor->GetNodeHelper()->m_iCurAllStart = -1;
- CXFA_ResolveNodesData rndFind;
+ CFXJSE_ResolveNodeData rndFind(this);
int32_t nStart = 0;
int32_t nLevel = 0;
int32_t nRet = -1;
- rndFind.m_pSC = this;
+
std::vector<CXFA_Object*> findObjects;
findObjects.push_back(refObject ? refObject : m_pDocument->GetRoot());
int32_t nNodes = 0;
@@ -633,7 +633,7 @@ int32_t CFXJSE_Engine::ResolveObjects(CXFA_Object* refObject,
if (((dwStyles & XFA_RESOLVENODE_Bind) ||
(dwStyles & XFA_RESOLVENODE_CreateNode)) &&
nNodes > 1) {
- CXFA_ResolveNodesData rndBind;
+ CFXJSE_ResolveNodeData rndBind(nullptr);
m_ResolveProcessor->GetFilter(wsExpression, nStart, rndBind);
m_ResolveProcessor->SetIndexDataBind(rndBind.m_wsCondition, i, nNodes);
bDataBind = true;
diff --git a/fxjs/cfxjse_engine.h b/fxjs/cfxjse_engine.h
index 34383cac76..f901850203 100644
--- a/fxjs/cfxjse_engine.h
+++ b/fxjs/cfxjse_engine.h
@@ -19,7 +19,7 @@
#define XFA_RESOLVENODE_TagName 0x0002
-class CXFA_ResolveProcessor;
+class CFXJSE_ResolveProcessor;
class CFXJSE_Engine {
public:
@@ -116,7 +116,7 @@ class CFXJSE_Engine {
// CacheList holds the NodeList items so we can clean them up when we're done.
std::vector<std::unique_ptr<CXFA_NodeList>> m_CacheList;
std::vector<CXFA_Node*>* m_pScriptNodeArray;
- std::unique_ptr<CXFA_ResolveProcessor> m_ResolveProcessor;
+ std::unique_ptr<CFXJSE_ResolveProcessor> m_ResolveProcessor;
std::unique_ptr<CFXJSE_FormCalcContext> m_FM2JSContext;
CXFA_Object* m_pThisObject;
uint32_t m_dwBuiltInInFlags;
diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp b/fxjs/cfxjse_resolveprocessor.cpp
index 6656a527d7..de4800119b 100644
--- a/xfa/fxfa/parser/cxfa_resolveprocessor.cpp
+++ b/fxjs/cfxjse_resolveprocessor.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/parser/cxfa_resolveprocessor.h"
+#include "fxjs/cfxjse_resolveprocessor.h"
#include <algorithm>
#include <utility>
@@ -22,12 +22,12 @@
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
#include "xfa/fxfa/parser/xfa_utils.h"
-CXFA_ResolveProcessor::CXFA_ResolveProcessor()
+CFXJSE_ResolveProcessor::CFXJSE_ResolveProcessor()
: m_iCurStart(0), m_pNodeHelper(pdfium::MakeUnique<CXFA_NodeHelper>()) {}
-CXFA_ResolveProcessor::~CXFA_ResolveProcessor() {}
+CFXJSE_ResolveProcessor::~CFXJSE_ResolveProcessor() {}
-int32_t CXFA_ResolveProcessor::Resolve(CXFA_ResolveNodesData& rnd) {
+int32_t CFXJSE_ResolveProcessor::Resolve(CFXJSE_ResolveNodeData& rnd) {
if (!rnd.m_CurObject)
return -1;
@@ -86,7 +86,7 @@ int32_t CXFA_ResolveProcessor::Resolve(CXFA_ResolveNodesData& rnd) {
return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
-int32_t CXFA_ResolveProcessor::ResolveAnyChild(CXFA_ResolveNodesData& rnd) {
+int32_t CFXJSE_ResolveProcessor::ResolveAnyChild(CFXJSE_ResolveNodeData& rnd) {
WideString wsName = rnd.m_wsName;
WideString wsCondition = rnd.m_wsCondition;
CXFA_Node* findNode = nullptr;
@@ -114,7 +114,7 @@ int32_t CXFA_ResolveProcessor::ResolveAnyChild(CXFA_ResolveNodesData& rnd) {
return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
-int32_t CXFA_ResolveProcessor::ResolveDollar(CXFA_ResolveNodesData& rnd) {
+int32_t CFXJSE_ResolveProcessor::ResolveDollar(CFXJSE_ResolveNodeData& rnd) {
WideString wsName = rnd.m_wsName;
WideString wsCondition = rnd.m_wsCondition;
int32_t iNameLen = wsName.GetLength();
@@ -140,7 +140,8 @@ int32_t CXFA_ResolveProcessor::ResolveDollar(CXFA_ResolveNodesData& rnd) {
return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
-int32_t CXFA_ResolveProcessor::ResolveExcalmatory(CXFA_ResolveNodesData& rnd) {
+int32_t CFXJSE_ResolveProcessor::ResolveExcalmatory(
+ CFXJSE_ResolveNodeData& rnd) {
if (rnd.m_nLevel > 0)
return 0;
@@ -149,8 +150,7 @@ int32_t CXFA_ResolveProcessor::ResolveExcalmatory(CXFA_ResolveNodesData& rnd) {
if (!datasets)
return 0;
- CXFA_ResolveNodesData rndFind;
- rndFind.m_pSC = rnd.m_pSC;
+ CFXJSE_ResolveNodeData rndFind(rnd.m_pSC);
rndFind.m_CurObject = datasets;
rndFind.m_wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1);
rndFind.m_uHashName = static_cast<XFA_HashCode>(
@@ -164,15 +164,15 @@ int32_t CXFA_ResolveProcessor::ResolveExcalmatory(CXFA_ResolveNodesData& rnd) {
return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
-int32_t CXFA_ResolveProcessor::ResolveNumberSign(CXFA_ResolveNodesData& rnd) {
+int32_t CFXJSE_ResolveProcessor::ResolveNumberSign(
+ CFXJSE_ResolveNodeData& rnd) {
WideString wsName = rnd.m_wsName.Right(rnd.m_wsName.GetLength() - 1);
WideString wsCondition = rnd.m_wsCondition;
CXFA_Node* curNode = ToNode(rnd.m_CurObject);
if (ResolveForAttributeRs(curNode, rnd, wsName.AsStringView()))
return 1;
- CXFA_ResolveNodesData rndFind;
- rndFind.m_pSC = rnd.m_pSC;
+ CFXJSE_ResolveNodeData rndFind(rnd.m_pSC);
rndFind.m_nLevel = rnd.m_nLevel + 1;
rndFind.m_dwStyles = rnd.m_dwStyles;
rndFind.m_dwStyles |= XFA_RESOLVENODE_TagName;
@@ -196,9 +196,9 @@ int32_t CXFA_ResolveProcessor::ResolveNumberSign(CXFA_ResolveNodesData& rnd) {
return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
-int32_t CXFA_ResolveProcessor::ResolveForAttributeRs(
+int32_t CFXJSE_ResolveProcessor::ResolveForAttributeRs(
CXFA_Object* curNode,
- CXFA_ResolveNodesData& rnd,
+ CFXJSE_ResolveNodeData& rnd,
const WideStringView& strAttr) {
const XFA_SCRIPTATTRIBUTEINFO* lpScriptAttribute =
XFA_GetScriptAttributeByName(curNode->GetElementType(), strAttr);
@@ -211,7 +211,7 @@ int32_t CXFA_ResolveProcessor::ResolveForAttributeRs(
return 1;
}
-int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
+int32_t CFXJSE_ResolveProcessor::ResolveNormal(CFXJSE_ResolveNodeData& rnd) {
if (rnd.m_nLevel > 32 || !rnd.m_CurObject->IsNode())
return 0;
@@ -221,12 +221,13 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
WideString& wsName = rnd.m_wsName;
XFA_HashCode uNameHash = rnd.m_uHashName;
WideString& wsCondition = rnd.m_wsCondition;
- CXFA_ResolveNodesData rndFind;
+
+ CFXJSE_ResolveNodeData rndFind(rnd.m_pSC);
rndFind.m_wsName = rnd.m_wsName;
rndFind.m_wsCondition = rnd.m_wsCondition;
- rndFind.m_pSC = rnd.m_pSC;
rndFind.m_nLevel = rnd.m_nLevel + 1;
rndFind.m_uHashName = uNameHash;
+
std::vector<CXFA_Node*> children;
std::vector<CXFA_Node*> properties;
CXFA_Node* pVariablesNode = nullptr;
@@ -472,7 +473,7 @@ int32_t CXFA_ResolveProcessor::ResolveNormal(CXFA_ResolveNodesData& rnd) {
return 0;
}
-int32_t CXFA_ResolveProcessor::ResolveAsterisk(CXFA_ResolveNodesData& rnd) {
+int32_t CFXJSE_ResolveProcessor::ResolveAsterisk(CFXJSE_ResolveNodeData& rnd) {
CXFA_Node* curNode = ToNode(rnd.m_CurObject);
std::vector<CXFA_Node*> array =
curNode->GetNodeList(XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties,
@@ -481,7 +482,7 @@ int32_t CXFA_ResolveProcessor::ResolveAsterisk(CXFA_ResolveNodesData& rnd) {
return pdfium::CollectionSize<int32_t>(rnd.m_Objects);
}
-int32_t CXFA_ResolveProcessor::ResolvePopStack(std::vector<int32_t>* stack) {
+int32_t CFXJSE_ResolveProcessor::ResolvePopStack(std::vector<int32_t>* stack) {
if (stack->empty())
return -1;
@@ -490,9 +491,9 @@ int32_t CXFA_ResolveProcessor::ResolvePopStack(std::vector<int32_t>* stack) {
return nType;
}
-int32_t CXFA_ResolveProcessor::GetFilter(const WideStringView& wsExpression,
- int32_t nStart,
- CXFA_ResolveNodesData& rnd) {
+int32_t CFXJSE_ResolveProcessor::GetFilter(const WideStringView& wsExpression,
+ int32_t nStart,
+ CFXJSE_ResolveNodeData& rnd) {
ASSERT(nStart > -1);
int32_t iLength = wsExpression.GetLength();
if (nStart >= iLength) {
@@ -590,10 +591,10 @@ int32_t CXFA_ResolveProcessor::GetFilter(const WideStringView& wsExpression,
static_cast<XFA_HashCode>(FX_HashCode_GetW(wsName.AsStringView(), false));
return nStart;
}
-void CXFA_ResolveProcessor::ConditionArray(int32_t iCurIndex,
- WideString wsCondition,
- int32_t iFoundCount,
- CXFA_ResolveNodesData& rnd) {
+void CFXJSE_ResolveProcessor::ConditionArray(int32_t iCurIndex,
+ WideString wsCondition,
+ int32_t iFoundCount,
+ CFXJSE_ResolveNodeData& rnd) {
int32_t iLen = wsCondition.GetLength();
bool bRelative = false;
bool bAll = false;
@@ -656,10 +657,10 @@ void CXFA_ResolveProcessor::ConditionArray(int32_t iCurIndex,
}
}
-void CXFA_ResolveProcessor::DoPredicateFilter(int32_t iCurIndex,
- WideString wsCondition,
- int32_t iFoundCount,
- CXFA_ResolveNodesData& rnd) {
+void CFXJSE_ResolveProcessor::DoPredicateFilter(int32_t iCurIndex,
+ WideString wsCondition,
+ int32_t iFoundCount,
+ CFXJSE_ResolveNodeData& rnd) {
ASSERT(iFoundCount == pdfium::CollectionSize<int32_t>(rnd.m_Objects));
WideString wsExpression;
XFA_SCRIPTLANGTYPE eLangType = XFA_SCRIPTLANGTYPE_Unkown;
@@ -682,8 +683,8 @@ void CXFA_ResolveProcessor::DoPredicateFilter(int32_t iCurIndex,
}
}
-void CXFA_ResolveProcessor::FilterCondition(CXFA_ResolveNodesData& rnd,
- WideString wsCondition) {
+void CFXJSE_ResolveProcessor::FilterCondition(CFXJSE_ResolveNodeData& rnd,
+ WideString wsCondition) {
int32_t iCurrIndex = 0;
const std::vector<CXFA_Node*>* pArray = rnd.m_pSC->GetUpObjectArray();
if (!pArray->empty()) {
@@ -740,8 +741,8 @@ void CXFA_ResolveProcessor::FilterCondition(CXFA_ResolveNodesData& rnd,
return;
}
}
-void CXFA_ResolveProcessor::SetStylesForChild(uint32_t dwParentStyles,
- CXFA_ResolveNodesData& rnd) {
+void CFXJSE_ResolveProcessor::SetStylesForChild(uint32_t dwParentStyles,
+ CFXJSE_ResolveNodeData& rnd) {
uint32_t dwSubStyles = XFA_RESOLVENODE_Children;
if (dwParentStyles & XFA_RESOLVENODE_TagName) {
dwSubStyles |= XFA_RESOLVENODE_TagName;
@@ -753,7 +754,7 @@ void CXFA_ResolveProcessor::SetStylesForChild(uint32_t dwParentStyles,
rnd.m_dwStyles = dwSubStyles;
}
-int32_t CXFA_ResolveProcessor::SetResultCreateNode(
+int32_t CFXJSE_ResolveProcessor::SetResultCreateNode(
XFA_RESOLVENODE_RS& resolveNodeRS,
WideString& wsLastCondition) {
if (m_pNodeHelper->m_pCreateParent)
@@ -769,9 +770,9 @@ int32_t CXFA_ResolveProcessor::SetResultCreateNode(
return pdfium::CollectionSize<int32_t>(resolveNodeRS.objects);
}
-void CXFA_ResolveProcessor::SetIndexDataBind(WideString& wsNextCondition,
- int32_t& iIndex,
- int32_t iCount) {
+void CFXJSE_ResolveProcessor::SetIndexDataBind(WideString& wsNextCondition,
+ int32_t& iIndex,
+ int32_t iCount) {
if (m_pNodeHelper->CreateNode_ForCondition(wsNextCondition)) {
if (m_pNodeHelper->m_eLastCreateType == XFA_Element::DataGroup) {
iIndex = 0;
@@ -783,7 +784,7 @@ void CXFA_ResolveProcessor::SetIndexDataBind(WideString& wsNextCondition,
}
}
-CXFA_ResolveNodesData::CXFA_ResolveNodesData(CFXJSE_Engine* pSC)
+CFXJSE_ResolveNodeData::CFXJSE_ResolveNodeData(CFXJSE_Engine* pSC)
: m_pSC(pSC),
m_CurObject(nullptr),
m_wsName(),
@@ -795,4 +796,4 @@ CXFA_ResolveNodesData::CXFA_ResolveNodesData(CFXJSE_Engine* pSC)
m_pScriptAttribute(nullptr),
m_dwFlag(XFA_RESOVENODE_RSTYPE_Nodes) {}
-CXFA_ResolveNodesData::~CXFA_ResolveNodesData() {}
+CFXJSE_ResolveNodeData::~CFXJSE_ResolveNodeData() {}
diff --git a/xfa/fxfa/parser/cxfa_resolveprocessor.h b/fxjs/cfxjse_resolveprocessor.h
index c12dfdc80d..f376cca4c7 100644
--- a/xfa/fxfa/parser/cxfa_resolveprocessor.h
+++ b/fxjs/cfxjse_resolveprocessor.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_PARSER_CXFA_RESOLVEPROCESSOR_H_
-#define XFA_FXFA_PARSER_CXFA_RESOLVEPROCESSOR_H_
+#ifndef FXJS_CFXJSE_RESOLVEPROCESSOR_H_
+#define FXJS_CFXJSE_RESOLVEPROCESSOR_H_
#include <memory>
#include <vector>
@@ -15,10 +15,10 @@
class CXFA_NodeHelper;
class CFXJSE_Engine;
-class CXFA_ResolveNodesData {
+class CFXJSE_ResolveNodeData {
public:
- explicit CXFA_ResolveNodesData(CFXJSE_Engine* pSC = nullptr);
- ~CXFA_ResolveNodesData();
+ explicit CFXJSE_ResolveNodeData(CFXJSE_Engine* pSC);
+ ~CFXJSE_ResolveNodeData();
CFXJSE_Engine* m_pSC;
CXFA_Object* m_CurObject;
@@ -32,15 +32,15 @@ class CXFA_ResolveNodesData {
XFA_RESOVENODE_RSTYPE m_dwFlag;
};
-class CXFA_ResolveProcessor {
+class CFXJSE_ResolveProcessor {
public:
- CXFA_ResolveProcessor();
- ~CXFA_ResolveProcessor();
+ CFXJSE_ResolveProcessor();
+ ~CFXJSE_ResolveProcessor();
- int32_t Resolve(CXFA_ResolveNodesData& rnd);
+ int32_t Resolve(CFXJSE_ResolveNodeData& rnd);
int32_t GetFilter(const WideStringView& wsExpression,
int32_t nStart,
- CXFA_ResolveNodesData& rnd);
+ CFXJSE_ResolveNodeData& rnd);
int32_t SetResultCreateNode(XFA_RESOLVENODE_RS& resolveNodeRS,
WideString& wsLastCondition);
void SetIndexDataBind(WideString& wsNextCondition,
@@ -52,29 +52,29 @@ class CXFA_ResolveProcessor {
private:
int32_t ResolveForAttributeRs(CXFA_Object* curNode,
- CXFA_ResolveNodesData& rnd,
+ CFXJSE_ResolveNodeData& rnd,
const WideStringView& strAttr);
- int32_t ResolveAnyChild(CXFA_ResolveNodesData& rnd);
- int32_t ResolveDollar(CXFA_ResolveNodesData& rnd);
- int32_t ResolveExcalmatory(CXFA_ResolveNodesData& rnd);
- int32_t ResolveNumberSign(CXFA_ResolveNodesData& rnd);
- int32_t ResolveAsterisk(CXFA_ResolveNodesData& rnd);
- int32_t ResolveNormal(CXFA_ResolveNodesData& rnd);
+ int32_t ResolveAnyChild(CFXJSE_ResolveNodeData& rnd);
+ int32_t ResolveDollar(CFXJSE_ResolveNodeData& rnd);
+ int32_t ResolveExcalmatory(CFXJSE_ResolveNodeData& rnd);
+ int32_t ResolveNumberSign(CFXJSE_ResolveNodeData& rnd);
+ int32_t ResolveAsterisk(CFXJSE_ResolveNodeData& rnd);
+ int32_t ResolveNormal(CFXJSE_ResolveNodeData& rnd);
int32_t ResolvePopStack(std::vector<int32_t>* stack);
- void SetStylesForChild(uint32_t dwParentStyles, CXFA_ResolveNodesData& rnd);
+ void SetStylesForChild(uint32_t dwParentStyles, CFXJSE_ResolveNodeData& rnd);
void ConditionArray(int32_t iCurIndex,
WideString wsCondition,
int32_t iFoundCount,
- CXFA_ResolveNodesData& rnd);
+ CFXJSE_ResolveNodeData& rnd);
void DoPredicateFilter(int32_t iCurIndex,
WideString wsCondition,
int32_t iFoundCount,
- CXFA_ResolveNodesData& rnd);
- void FilterCondition(CXFA_ResolveNodesData& rnd, WideString wsCondition);
+ CFXJSE_ResolveNodeData& rnd);
+ void FilterCondition(CFXJSE_ResolveNodeData& rnd, WideString wsCondition);
int32_t m_iCurStart;
std::unique_ptr<CXFA_NodeHelper> m_pNodeHelper;
};
-#endif // XFA_FXFA_PARSER_CXFA_RESOLVEPROCESSOR_H_
+#endif // FXJS_CFXJSE_RESOLVEPROCESSOR_H_