Split CXFA_Node::GetNodeList().

The method tries to do two separate things, so split it into
GetNodeListForType() and GetNodeListWithFilter(). Then callers won't
have to provide dummy arguments.

Change-Id: I31773ec50bac4849cbef6c26929ea2e7b9a73089
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/57933
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/fxjs/xfa/cfxjse_resolveprocessor.cpp b/fxjs/xfa/cfxjse_resolveprocessor.cpp
index 190931c..72dab41 100644
--- a/fxjs/xfa/cfxjse_resolveprocessor.cpp
+++ b/fxjs/xfa/cfxjse_resolveprocessor.cpp
@@ -507,9 +507,8 @@
 
 bool CFXJSE_ResolveProcessor::ResolveAsterisk(CFXJSE_ResolveNodeData& rnd) {
   CXFA_Node* curNode = ToNode(rnd.m_CurObject.Get());
-  std::vector<CXFA_Node*> array =
-      curNode->GetNodeList(XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties,
-                           XFA_Element::Unknown);
+  std::vector<CXFA_Node*> array = curNode->GetNodeListWithFilter(
+      XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties);
   rnd.m_Objects.insert(rnd.m_Objects.end(), array.begin(), array.end());
   return !rnd.m_Objects.empty();
 }
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index d143095..3877f72 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -500,8 +500,8 @@
     return;
   }
 
-  std::vector<CXFA_Node*> properties = GetXFANode()->GetNodeList(
-      XFA_NODEFILTER_OneOfProperty, XFA_Element::Unknown);
+  std::vector<CXFA_Node*> properties =
+      GetXFANode()->GetNodeListWithFilter(XFA_NODEFILTER_OneOfProperty);
   if (!properties.empty()) {
     pValue->Assign(
         GetDocument()->GetScriptContext()->GetOrCreateJSBindingFromMap(
diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp
index a151fba..dd30480 100644
--- a/fxjs/xfa/cjx_object.cpp
+++ b/fxjs/xfa/cjx_object.cpp
@@ -584,8 +584,8 @@
               pBind->RemoveChildAndNotify(pChildNode, true);
             }
           } else {
-            std::vector<CXFA_Node*> valueNodes = pBind->GetNodeList(
-                XFA_NODEFILTER_Children, XFA_Element::DataValue);
+            std::vector<CXFA_Node*> valueNodes =
+                pBind->GetNodeListForType(XFA_Element::DataValue);
             size_t iDatas = valueNodes.size();
             if (iDatas < iSize) {
               size_t iAddNodes = iSize - iDatas;
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 9ad84bd..0626909 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -671,9 +671,8 @@
     }
     case XFA_FFWidgetType::kChoiceList:
       if (pFormNode->IsChoiceListMultiSelect()) {
-        std::vector<CXFA_Node*> items = pDataNode->GetNodeList(
-            XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties,
-            XFA_Element::Unknown);
+        std::vector<CXFA_Node*> items = pDataNode->GetNodeListWithFilter(
+            XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties);
         if (!items.empty()) {
           bool single = items.size() == 1;
           wsNormalizeValue.clear();
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 3f13b05..26a201a 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -703,7 +703,7 @@
 CXFA_Node* FindFirstSiblingNamedInList(CXFA_Node* parent,
                                        uint32_t dwNameHash,
                                        uint32_t dwFilter) {
-  for (CXFA_Node* child : parent->GetNodeList(dwFilter, XFA_Element::Unknown)) {
+  for (CXFA_Node* child : parent->GetNodeListWithFilter(dwFilter)) {
     if (child->GetNameHash() == dwNameHash)
       return child;
 
@@ -727,7 +727,7 @@
 CXFA_Node* FindFirstSiblingOfClassInList(CXFA_Node* parent,
                                          XFA_Element element,
                                          uint32_t dwFilter) {
-  for (CXFA_Node* child : parent->GetNodeList(dwFilter, XFA_Element::Unknown)) {
+  for (CXFA_Node* child : parent->GetNodeListWithFilter(dwFilter)) {
     if (child->GetElementType() == element)
       return child;
 
@@ -768,7 +768,7 @@
 
   if (bIsFindProperty) {
     for (CXFA_Node* child :
-         parent->GetNodeList(XFA_NODEFILTER_Properties, XFA_Element::Unknown)) {
+         parent->GetNodeListWithFilter(XFA_NODEFILTER_Properties)) {
       if (bIsClassName) {
         if (child->GetClassHashCode() == dwNameHash)
           pSiblings->push_back(child);
@@ -790,7 +790,7 @@
       return;
   }
   for (CXFA_Node* child :
-       parent->GetNodeList(XFA_NODEFILTER_Children, XFA_Element::Unknown)) {
+       parent->GetNodeListWithFilter(XFA_NODEFILTER_Children)) {
     if (child->GetElementType() == XFA_Element::Variables)
       continue;
 
@@ -1097,20 +1097,20 @@
   return data ? data->type : XFA_AttributeType::CData;
 }
 
-std::vector<CXFA_Node*> CXFA_Node::GetNodeList(uint32_t dwTypeFilter,
-                                               XFA_Element eTypeFilter) {
-  if (eTypeFilter != XFA_Element::Unknown) {
-    std::vector<CXFA_Node*> nodes;
-    for (CXFA_Node* pChild = GetFirstChild(); pChild;
-         pChild = pChild->GetNextSibling()) {
-      if (pChild->GetElementType() == eTypeFilter)
-        nodes.push_back(pChild);
-    }
-    return nodes;
+std::vector<CXFA_Node*> CXFA_Node::GetNodeListForType(XFA_Element eTypeFilter) {
+  std::vector<CXFA_Node*> nodes;
+  for (CXFA_Node* pChild = GetFirstChild(); pChild;
+       pChild = pChild->GetNextSibling()) {
+    if (pChild->GetElementType() == eTypeFilter)
+      nodes.push_back(pChild);
   }
+  return nodes;
+}
 
+std::vector<CXFA_Node*> CXFA_Node::GetNodeListWithFilter(
+    uint32_t dwTypeFilter) {
+  std::vector<CXFA_Node*> nodes;
   if (dwTypeFilter == (XFA_NODEFILTER_Children | XFA_NODEFILTER_Properties)) {
-    std::vector<CXFA_Node*> nodes;
     for (CXFA_Node* pChild = GetFirstChild(); pChild;
          pChild = pChild->GetNextSibling())
       nodes.push_back(pChild);
@@ -1118,12 +1118,11 @@
   }
 
   if (dwTypeFilter == 0)
-    return std::vector<CXFA_Node*>();
+    return nodes;
 
   bool bFilterChildren = !!(dwTypeFilter & XFA_NODEFILTER_Children);
   bool bFilterProperties = !!(dwTypeFilter & XFA_NODEFILTER_Properties);
   bool bFilterOneOfProperties = !!(dwTypeFilter & XFA_NODEFILTER_OneOfProperty);
-  std::vector<CXFA_Node*> nodes;
   for (CXFA_Node* pChild = GetFirstChild(); pChild;
        pChild = pChild->GetNextSibling()) {
     if (HasProperty(pChild->GetElementType())) {
@@ -2957,7 +2956,7 @@
     XFA_AttributeValue iActivity,
     bool bIsFormReady) {
   std::vector<CXFA_Event*> events;
-  for (CXFA_Node* node : GetNodeList(0, XFA_Element::Event)) {
+  for (CXFA_Node* node : GetNodeListForType(XFA_Element::Event)) {
     auto* event = static_cast<CXFA_Event*>(node);
     if (event->GetActivity() != iActivity)
       continue;
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 0bb2e33..087d0cc 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -173,8 +173,8 @@
   CXFA_Node* GetFirstContainerChild() const;
   CXFA_Node* GetContainerParent() const;
 
-  std::vector<CXFA_Node*> GetNodeList(uint32_t dwTypeFilter,
-                                      XFA_Element eTypeFilter);
+  std::vector<CXFA_Node*> GetNodeListForType(XFA_Element eTypeFilter);
+  std::vector<CXFA_Node*> GetNodeListWithFilter(uint32_t dwTypeFilter);
   CXFA_Node* CreateSamePacketNode(XFA_Element eType);
   CXFA_Node* CloneTemplateToForm(bool bRecursive);
   CXFA_Node* GetTemplateNodeIfExists() const;