Rename CXFA_NodeHelper to CFXJSE_NodeHelper and move to fxjs/
When viewed through the lens of a GCed world, |m_pCreateParent| and
|m_pAllStartParent| are Persistent<> roots into the heap. Ideally,
there would be no persistents under xfa/, with all those objects
inside the heap itself.
Change-Id: I426ea0f2b2bc8e9bced619ad2e1f499a8e339c73
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/72470
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/fxjs/BUILD.gn b/fxjs/BUILD.gn
index 7a8f961..731374e 100644
--- a/fxjs/BUILD.gn
+++ b/fxjs/BUILD.gn
@@ -128,6 +128,8 @@
"xfa/cfxjse_formcalc_context.h",
"xfa/cfxjse_isolatetracker.cpp",
"xfa/cfxjse_isolatetracker.h",
+ "xfa/cfxjse_nodehelper.cpp",
+ "xfa/cfxjse_nodehelper.h",
"xfa/cfxjse_resolveprocessor.cpp",
"xfa/cfxjse_resolveprocessor.h",
"xfa/cfxjse_runtimedata.cpp",
diff --git a/fxjs/xfa/cfxjse_engine.cpp b/fxjs/xfa/cfxjse_engine.cpp
index 44836c9..e25676f 100644
--- a/fxjs/xfa/cfxjse_engine.cpp
+++ b/fxjs/xfa/cfxjse_engine.cpp
@@ -15,6 +15,7 @@
#include "fxjs/xfa/cfxjse_class.h"
#include "fxjs/xfa/cfxjse_context.h"
#include "fxjs/xfa/cfxjse_formcalc_context.h"
+#include "fxjs/xfa/cfxjse_nodehelper.h"
#include "fxjs/xfa/cfxjse_resolveprocessor.h"
#include "fxjs/xfa/cfxjse_value.h"
#include "fxjs/xfa/cjx_object.h"
@@ -25,7 +26,6 @@
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
-#include "xfa/fxfa/parser/cxfa_nodehelper.h"
#include "xfa/fxfa/parser/cxfa_object.h"
#include "xfa/fxfa/parser/cxfa_thisproxy.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
@@ -620,7 +620,7 @@
}
bool bNextCreate = false;
- CXFA_NodeHelper* pNodeHelper = m_ResolveProcessor->GetNodeHelper();
+ CFXJSE_NodeHelper* pNodeHelper = m_ResolveProcessor->GetNodeHelper();
if (dwStyles & XFA_RESOLVENODE_CreateNode)
pNodeHelper->SetCreateNodeType(bindNode);
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.cpp b/fxjs/xfa/cfxjse_nodehelper.cpp
similarity index 86%
rename from xfa/fxfa/parser/cxfa_nodehelper.cpp
rename to fxjs/xfa/cfxjse_nodehelper.cpp
index dde90bc..e2fbb4f 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.cpp
+++ b/fxjs/xfa/cfxjse_nodehelper.cpp
@@ -4,7 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#include "xfa/fxfa/parser/cxfa_nodehelper.h"
+#include "fxjs/xfa/cfxjse_nodehelper.h"
#include <utility>
@@ -18,11 +18,11 @@
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
#include "xfa/fxfa/parser/xfa_utils.h"
-CXFA_NodeHelper::CXFA_NodeHelper() = default;
+CFXJSE_NodeHelper::CFXJSE_NodeHelper() = default;
-CXFA_NodeHelper::~CXFA_NodeHelper() = default;
+CFXJSE_NodeHelper::~CFXJSE_NodeHelper() = default;
-bool CXFA_NodeHelper::CreateNodeForCondition(const WideString& wsCondition) {
+bool CFXJSE_NodeHelper::CreateNodeForCondition(const WideString& wsCondition) {
size_t szLen = wsCondition.GetLength();
WideString wsIndex(L"0");
bool bAll = false;
@@ -58,10 +58,10 @@
return true;
}
-bool CXFA_NodeHelper::CreateNode(const WideString& wsName,
- const WideString& wsCondition,
- bool bLastNode,
- CFXJSE_Engine* pScriptContext) {
+bool CFXJSE_NodeHelper::CreateNode(const WideString& wsName,
+ const WideString& wsCondition,
+ bool bLastNode,
+ CFXJSE_Engine* pScriptContext) {
if (!m_pCreateParent)
return false;
@@ -123,7 +123,7 @@
return bResult;
}
-void CXFA_NodeHelper::SetCreateNodeType(CXFA_Node* refNode) {
+void CFXJSE_NodeHelper::SetCreateNodeType(CXFA_Node* refNode) {
if (!refNode)
return;
diff --git a/xfa/fxfa/parser/cxfa_nodehelper.h b/fxjs/xfa/cfxjse_nodehelper.h
similarity index 82%
rename from xfa/fxfa/parser/cxfa_nodehelper.h
rename to fxjs/xfa/cfxjse_nodehelper.h
index 27407f9..da2cce3 100644
--- a/xfa/fxfa/parser/cxfa_nodehelper.h
+++ b/fxjs/xfa/cfxjse_nodehelper.h
@@ -4,8 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-#ifndef XFA_FXFA_PARSER_CXFA_NODEHELPER_H_
-#define XFA_FXFA_PARSER_CXFA_NODEHELPER_H_
+#ifndef FXJS_XFA_CFXJSE_NODEHELPER_H_
+#define FXJS_XFA_CFXJSE_NODEHELPER_H_
#include "core/fxcrt/fx_string.h"
#include "xfa/fxfa/fxfa_basic.h"
@@ -14,10 +14,10 @@
class CFXJSE_Engine;
class CXFA_Node;
-class CXFA_NodeHelper {
+class CFXJSE_NodeHelper {
public:
- CXFA_NodeHelper();
- ~CXFA_NodeHelper();
+ CFXJSE_NodeHelper();
+ ~CFXJSE_NodeHelper();
bool CreateNode(const WideString& wsName,
const WideString& wsCondition,
@@ -34,4 +34,4 @@
UnownedPtr<CXFA_Node> m_pAllStartParent;
};
-#endif // XFA_FXFA_PARSER_CXFA_NODEHELPER_H_
+#endif // FXJS_XFA_CFXJSE_NODEHELPER_H_
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.cpp b/fxjs/xfa/cfxjse_resolveprocessor.cpp
index a906df9..6605942 100644
--- a/fxjs/xfa/cfxjse_resolveprocessor.cpp
+++ b/fxjs/xfa/cfxjse_resolveprocessor.cpp
@@ -12,13 +12,13 @@
#include "core/fxcrt/fx_extension.h"
#include "fxjs/xfa/cfxjse_engine.h"
+#include "fxjs/xfa/cfxjse_nodehelper.h"
#include "fxjs/xfa/cfxjse_value.h"
#include "fxjs/xfa/cjx_object.h"
#include "third_party/base/stl_util.h"
#include "xfa/fxfa/parser/cxfa_document.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
#include "xfa/fxfa/parser/cxfa_node.h"
-#include "xfa/fxfa/parser/cxfa_nodehelper.h"
#include "xfa/fxfa/parser/cxfa_object.h"
#include "xfa/fxfa/parser/cxfa_occur.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
@@ -53,7 +53,7 @@
} // namespace
CFXJSE_ResolveProcessor::CFXJSE_ResolveProcessor()
- : m_pNodeHelper(std::make_unique<CXFA_NodeHelper>()) {}
+ : m_pNodeHelper(std::make_unique<CFXJSE_NodeHelper>()) {}
CFXJSE_ResolveProcessor::~CFXJSE_ResolveProcessor() = default;
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.h b/fxjs/xfa/cfxjse_resolveprocessor.h
index 6e4fcba..509161f 100644
--- a/fxjs/xfa/cfxjse_resolveprocessor.h
+++ b/fxjs/xfa/cfxjse_resolveprocessor.h
@@ -16,7 +16,7 @@
#include "xfa/fxfa/parser/xfa_basic_data.h"
#include "xfa/fxfa/parser/xfa_resolvenode_rs.h"
-class CXFA_NodeHelper;
+class CFXJSE_NodeHelper;
class CFXJSE_ResolveNodeData {
public:
@@ -49,7 +49,7 @@
int32_t iCount);
void SetCurStart(int32_t start) { m_iCurStart = start; }
- CXFA_NodeHelper* GetNodeHelper() { return m_pNodeHelper.get(); }
+ CFXJSE_NodeHelper* GetNodeHelper() { return m_pNodeHelper.get(); }
private:
bool ResolveForAttributeRs(CXFA_Object* curNode,
@@ -70,7 +70,7 @@
void FilterCondition(WideString wsCondition, CFXJSE_ResolveNodeData* pRnd);
int32_t m_iCurStart = 0;
- std::unique_ptr<CXFA_NodeHelper> const m_pNodeHelper;
+ std::unique_ptr<CFXJSE_NodeHelper> const m_pNodeHelper;
};
#endif // FXJS_XFA_CFXJSE_RESOLVEPROCESSOR_H_
diff --git a/xfa/fxfa/parser/BUILD.gn b/xfa/fxfa/parser/BUILD.gn
index 7878267..4d35b3a 100644
--- a/xfa/fxfa/parser/BUILD.gn
+++ b/xfa/fxfa/parser/BUILD.gn
@@ -379,8 +379,6 @@
"cxfa_neverembed.h",
"cxfa_node.cpp",
"cxfa_node.h",
- "cxfa_nodehelper.cpp",
- "cxfa_nodehelper.h",
"cxfa_nodeiteratortemplate.h",
"cxfa_nodelocale.cpp",
"cxfa_nodelocale.h",