Nest FX_XMLNODETYPE inside CFX_XMLNode.

Avoid standalone enum describing state of a class.
Tidy a couple of loops while at it.

Change-Id: Icff82aa76f582137105a1d66564b6fdc50ad4a18
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/52183
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fpdfdoc/cpdf_metadata.cpp b/core/fpdfdoc/cpdf_metadata.cpp
index 19f5791..da8dcb9 100644
--- a/core/fpdfdoc/cpdf_metadata.cpp
+++ b/core/fpdfdoc/cpdf_metadata.cpp
@@ -25,7 +25,7 @@
   if (attr.EqualsASCII("http://ns.adobe.com/AcrobatAdhocWorkflow/1.0/")) {
     for (const auto* child = element->GetFirstChild(); child;
          child = child->GetNextSibling()) {
-      if (child->GetType() != FX_XMLNODE_Element)
+      if (child->GetType() != CFX_XMLNode::Type::kElement)
         continue;
 
       const auto* child_elem = static_cast<const CFX_XMLElement*>(child);
diff --git a/core/fxcrt/xml/cfx_xmlchardata.cpp b/core/fxcrt/xml/cfx_xmlchardata.cpp
index 395435c..1d42bd0 100644
--- a/core/fxcrt/xml/cfx_xmlchardata.cpp
+++ b/core/fxcrt/xml/cfx_xmlchardata.cpp
@@ -13,8 +13,8 @@
 
 CFX_XMLCharData::~CFX_XMLCharData() = default;
 
-FX_XMLNODETYPE CFX_XMLCharData::GetType() const {
-  return FX_XMLNODE_CharData;
+CFX_XMLNode::Type CFX_XMLCharData::GetType() const {
+  return Type::kCharData;
 }
 
 CFX_XMLNode* CFX_XMLCharData::Clone(CFX_XMLDocument* doc) {
diff --git a/core/fxcrt/xml/cfx_xmlchardata.h b/core/fxcrt/xml/cfx_xmlchardata.h
index 4143009..4d3a7f0 100644
--- a/core/fxcrt/xml/cfx_xmlchardata.h
+++ b/core/fxcrt/xml/cfx_xmlchardata.h
@@ -18,13 +18,13 @@
   ~CFX_XMLCharData() override;
 
   // CFX_XMLNode
-  FX_XMLNODETYPE GetType() const override;
+  Type GetType() const override;
   CFX_XMLNode* Clone(CFX_XMLDocument* doc) override;
   void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) override;
 };
 
 inline CFX_XMLCharData* ToXMLCharData(CFX_XMLNode* pNode) {
-  return pNode && pNode->GetType() == FX_XMLNODE_CharData
+  return pNode && pNode->GetType() == CFX_XMLNode::Type::kCharData
              ? static_cast<CFX_XMLCharData*>(pNode)
              : nullptr;
 }
diff --git a/core/fxcrt/xml/cfx_xmlchardata_unittest.cpp b/core/fxcrt/xml/cfx_xmlchardata_unittest.cpp
index 5b2ad85..60798bd 100644
--- a/core/fxcrt/xml/cfx_xmlchardata_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmlchardata_unittest.cpp
@@ -9,7 +9,7 @@
 
 TEST(CFX_XMLCharDataTest, GetType) {
   CFX_XMLCharData data(L"My Data");
-  EXPECT_EQ(FX_XMLNODE_CharData, data.GetType());
+  EXPECT_EQ(CFX_XMLNode::Type::kCharData, data.GetType());
 }
 
 TEST(CFX_XMLCharDataTest, GetText) {
@@ -24,7 +24,7 @@
   CFX_XMLNode* clone = data.Clone(&doc);
   EXPECT_TRUE(clone != nullptr);
   EXPECT_NE(&data, clone);
-  ASSERT_EQ(FX_XMLNODE_CharData, clone->GetType());
+  ASSERT_EQ(CFX_XMLNode::Type::kCharData, clone->GetType());
   EXPECT_EQ(L"My Data", ToXMLCharData(clone)->GetText());
 }
 
diff --git a/core/fxcrt/xml/cfx_xmldocument_unittest.cpp b/core/fxcrt/xml/cfx_xmldocument_unittest.cpp
index 5a33975..8043cc6 100644
--- a/core/fxcrt/xml/cfx_xmldocument_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmldocument_unittest.cpp
@@ -16,6 +16,6 @@
   CFX_XMLDocument doc;
   auto* node = doc.CreateNode<CFX_XMLElement>(L"elem");
 
-  ASSERT_EQ(FX_XMLNODE_Element, node->GetType());
+  ASSERT_EQ(CFX_XMLNode::Type::kElement, node->GetType());
   EXPECT_EQ(L"elem", node->GetName());
 }
diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp
index 6508262..6ea144e 100644
--- a/core/fxcrt/xml/cfx_xmlelement.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement.cpp
@@ -20,8 +20,8 @@
 
 CFX_XMLElement::~CFX_XMLElement() = default;
 
-FX_XMLNODETYPE CFX_XMLElement::GetType() const {
-  return FX_XMLNODE_Element;
+CFX_XMLNode::Type CFX_XMLElement::GetType() const {
+  return Type::kElement;
 }
 
 CFX_XMLNode* CFX_XMLElement::Clone(CFX_XMLDocument* doc) {
@@ -32,7 +32,7 @@
   // text nodes?
   for (CFX_XMLNode* pChild = GetFirstChild(); pChild;
        pChild = pChild->GetNextSibling()) {
-    if (pChild->GetType() == FX_XMLNODE_Text)
+    if (pChild->GetType() == Type::kText)
       node->AppendChild(pChild->Clone(doc));
   }
   return node;
@@ -57,10 +57,7 @@
     attr += wsPrefix;
   }
   const CFX_XMLNode* pNode = this;
-  while (pNode) {
-    if (pNode->GetType() != FX_XMLNODE_Element)
-      break;
-
+  while (pNode && pNode->GetType() == Type::kElement) {
     auto* pElement = static_cast<const CFX_XMLElement*>(pNode);
     if (!pElement->HasAttribute(attr)) {
       pNode = pNode->GetParent();
diff --git a/core/fxcrt/xml/cfx_xmlelement.h b/core/fxcrt/xml/cfx_xmlelement.h
index 7ebd584..efc9fbb 100644
--- a/core/fxcrt/xml/cfx_xmlelement.h
+++ b/core/fxcrt/xml/cfx_xmlelement.h
@@ -20,7 +20,7 @@
   ~CFX_XMLElement() override;
 
   // CFX_XMLNode
-  FX_XMLNODETYPE GetType() const override;
+  Type GetType() const override;
   CFX_XMLNode* Clone(CFX_XMLDocument* doc) override;
   void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) override;
 
@@ -52,13 +52,13 @@
 };
 
 inline CFX_XMLElement* ToXMLElement(CFX_XMLNode* pNode) {
-  return pNode && pNode->GetType() == FX_XMLNODE_Element
+  return pNode && pNode->GetType() == CFX_XMLNode::Type::kElement
              ? static_cast<CFX_XMLElement*>(pNode)
              : nullptr;
 }
 
 inline const CFX_XMLElement* ToXMLElement(const CFX_XMLNode* pNode) {
-  return pNode && pNode->GetType() == FX_XMLNODE_Element
+  return pNode && pNode->GetType() == CFX_XMLNode::Type::kElement
              ? static_cast<const CFX_XMLElement*>(pNode)
              : nullptr;
 }
diff --git a/core/fxcrt/xml/cfx_xmlelement_unittest.cpp b/core/fxcrt/xml/cfx_xmlelement_unittest.cpp
index 45f3c8e..08afc61 100644
--- a/core/fxcrt/xml/cfx_xmlelement_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement_unittest.cpp
@@ -11,7 +11,7 @@
 
 TEST(CFX_XMLElementTest, GetType) {
   CFX_XMLElement node(L"node");
-  EXPECT_EQ(FX_XMLNODE_Element, node.GetType());
+  EXPECT_EQ(CFX_XMLNode::Type::kElement, node.GetType());
 }
 
 TEST(CFX_XMLElementTest, GetName) {
@@ -85,7 +85,7 @@
 
   CFX_XMLNode* clone = node.Clone(&doc);
   EXPECT_TRUE(clone != nullptr);
-  ASSERT_EQ(FX_XMLNODE_Element, clone->GetType());
+  ASSERT_EQ(CFX_XMLNode::Type::kElement, clone->GetType());
 
   CFX_XMLElement* inst = ToXMLElement(clone);
   EXPECT_EQ(L"test:node", inst->GetName());
@@ -102,7 +102,7 @@
   ASSERT_TRUE(inst->GetFirstChild() != nullptr);
   EXPECT_TRUE(inst->GetFirstChild()->GetNextSibling() == nullptr);
 
-  ASSERT_EQ(FX_XMLNODE_Text, inst->GetFirstChild()->GetType());
+  ASSERT_EQ(CFX_XMLNode::Type::kText, inst->GetFirstChild()->GetType());
   auto* text = ToXMLText(inst->GetFirstChild());
   EXPECT_EQ(L"Text Child", text->GetText());
 }
diff --git a/core/fxcrt/xml/cfx_xmlinstruction.cpp b/core/fxcrt/xml/cfx_xmlinstruction.cpp
index 2f8cfef..ac01f4e 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction.cpp
+++ b/core/fxcrt/xml/cfx_xmlinstruction.cpp
@@ -17,8 +17,8 @@
 
 CFX_XMLInstruction::~CFX_XMLInstruction() = default;
 
-FX_XMLNODETYPE CFX_XMLInstruction::GetType() const {
-  return FX_XMLNODE_Instruction;
+CFX_XMLNode::Type CFX_XMLInstruction::GetType() const {
+  return Type::kInstruction;
 }
 
 CFX_XMLNode* CFX_XMLInstruction::Clone(CFX_XMLDocument* doc) {
diff --git a/core/fxcrt/xml/cfx_xmlinstruction.h b/core/fxcrt/xml/cfx_xmlinstruction.h
index 6221da1..f4ba112 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction.h
+++ b/core/fxcrt/xml/cfx_xmlinstruction.h
@@ -20,7 +20,7 @@
   ~CFX_XMLInstruction() override;
 
   // CFX_XMLNode
-  FX_XMLNODETYPE GetType() const override;
+  Type GetType() const override;
   CFX_XMLNode* Clone(CFX_XMLDocument* doc) override;
   void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) override;
 
@@ -36,7 +36,7 @@
 };
 
 inline CFX_XMLInstruction* ToXMLInstruction(CFX_XMLNode* pNode) {
-  return pNode && pNode->GetType() == FX_XMLNODE_Instruction
+  return pNode && pNode->GetType() == CFX_XMLNode::Type::kInstruction
              ? static_cast<CFX_XMLInstruction*>(pNode)
              : nullptr;
 }
diff --git a/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp b/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp
index d4d6aa2..97d9ddf 100644
--- a/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmlinstruction_unittest.cpp
@@ -15,7 +15,7 @@
 
 TEST(CFX_XMLInstructionTest, GetType) {
   CFX_XMLInstruction node(L"acrobat");
-  EXPECT_EQ(FX_XMLNODE_Instruction, node.GetType());
+  EXPECT_EQ(CFX_XMLNode::Type::kInstruction, node.GetType());
 }
 
 TEST(CFX_XMLInstructionTest, AcrobatInstruction) {
@@ -53,7 +53,7 @@
   CFX_XMLNode* clone = node.Clone(&doc);
   EXPECT_TRUE(clone != nullptr);
 
-  ASSERT_EQ(FX_XMLNODE_Instruction, clone->GetType());
+  ASSERT_EQ(CFX_XMLNode::Type::kInstruction, clone->GetType());
   CFX_XMLInstruction* inst = ToXMLInstruction(clone);
   EXPECT_TRUE(inst->IsAcrobat());
 
@@ -96,7 +96,7 @@
 
   CFX_XMLElement* root = doc->GetRoot();
   ASSERT_TRUE(root->GetFirstChild() != nullptr);
-  ASSERT_EQ(FX_XMLNODE_Instruction, root->GetFirstChild()->GetType());
+  ASSERT_EQ(CFX_XMLNode::Type::kInstruction, root->GetFirstChild()->GetType());
 
   CFX_XMLInstruction* node = ToXMLInstruction(root->GetFirstChild());
   ASSERT_TRUE(node != nullptr);
@@ -129,7 +129,7 @@
 
   CFX_XMLElement* root = doc->GetRoot();
   ASSERT_TRUE(root->GetFirstChild() != nullptr);
-  ASSERT_TRUE(root->GetFirstChild()->GetType() == FX_XMLNODE_Element);
+  ASSERT_TRUE(root->GetFirstChild()->GetType() == CFX_XMLNode::Type::kElement);
 
   CFX_XMLElement* node = ToXMLElement(root->GetFirstChild());
   EXPECT_EQ(L"node", node->GetName());
diff --git a/core/fxcrt/xml/cfx_xmlnode.h b/core/fxcrt/xml/cfx_xmlnode.h
index 78578ae..728d9f7 100644
--- a/core/fxcrt/xml/cfx_xmlnode.h
+++ b/core/fxcrt/xml/cfx_xmlnode.h
@@ -10,21 +10,21 @@
 #include "core/fxcrt/fx_stream.h"
 #include "core/fxcrt/retain_ptr.h"
 
-enum FX_XMLNODETYPE {
-  FX_XMLNODE_Instruction = 0,
-  FX_XMLNODE_Element,
-  FX_XMLNODE_Text,
-  FX_XMLNODE_CharData,
-};
-
 class CFX_XMLDocument;
 
 class CFX_XMLNode {
  public:
+  enum class Type {
+    kInstruction = 0,
+    kElement,
+    kText,
+    kCharData,
+  };
+
   CFX_XMLNode();
   virtual ~CFX_XMLNode();
 
-  virtual FX_XMLNODETYPE GetType() const = 0;
+  virtual Type GetType() const = 0;
   virtual CFX_XMLNode* Clone(CFX_XMLDocument* doc) = 0;
   virtual void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) = 0;
 
diff --git a/core/fxcrt/xml/cfx_xmlparser.cpp b/core/fxcrt/xml/cfx_xmlparser.cpp
index e636f10..cba956e 100644
--- a/core/fxcrt/xml/cfx_xmlparser.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser.cpp
@@ -100,7 +100,7 @@
   buffer.resize(pdfium::base::ValueOrDieForType<size_t>(alloc_size_safe));
 
   std::stack<wchar_t> character_to_skip_too_stack;
-  std::stack<FX_XMLNODETYPE> node_type_stack;
+  std::stack<CFX_XMLNode::Type> node_type_stack;
   WideString current_attribute_name;
   FDE_XmlSyntaxState current_parser_state = FDE_XmlSyntaxState::Text;
   int32_t iCount = 0;
@@ -149,11 +149,11 @@
             current_buffer_idx++;
             current_parser_state = FDE_XmlSyntaxState::CloseElement;
           } else if (ch == L'?') {
-            node_type_stack.push(FX_XMLNODE_Instruction);
+            node_type_stack.push(CFX_XMLNode::Type::kInstruction);
             current_buffer_idx++;
             current_parser_state = FDE_XmlSyntaxState::Target;
           } else {
-            node_type_stack.push(FX_XMLNODE_Element);
+            node_type_stack.push(CFX_XMLNode::Type::kElement);
             current_parser_state = FDE_XmlSyntaxState::Tag;
           }
           break;
@@ -198,12 +198,13 @@
           }
           if (!IsXMLNameChar(ch, current_text_.empty())) {
             if (current_text_.empty()) {
-              if (node_type_stack.top() == FX_XMLNODE_Element) {
+              if (node_type_stack.top() == CFX_XMLNode::Type::kElement) {
                 if (ch == L'>' || ch == L'/') {
                   current_parser_state = FDE_XmlSyntaxState::BreakElement;
                   break;
                 }
-              } else if (node_type_stack.top() == FX_XMLNODE_Instruction) {
+              } else if (node_type_stack.top() ==
+                         CFX_XMLNode::Type::kInstruction) {
                 if (ch == L'?') {
                   current_parser_state = FDE_XmlSyntaxState::CloseInstruction;
                   current_buffer_idx++;
@@ -214,7 +215,7 @@
               }
               return false;
             } else {
-              if (node_type_stack.top() == FX_XMLNODE_Instruction) {
+              if (node_type_stack.top() == CFX_XMLNode::Type::kInstruction) {
                 if (ch != '=' && !IsXMLWhiteSpace(ch)) {
                   current_parser_state = FDE_XmlSyntaxState::TargetData;
                   break;
@@ -234,7 +235,7 @@
             break;
           }
           if (ch != L'=') {
-            if (node_type_stack.top() == FX_XMLNODE_Instruction) {
+            if (node_type_stack.top() == CFX_XMLNode::Type::kInstruction) {
               current_parser_state = FDE_XmlSyntaxState::TargetData;
               break;
             }
@@ -291,7 +292,7 @@
             current_parser_state = FDE_XmlSyntaxState::Text;
 
             if (current_node_ &&
-                current_node_->GetType() == FX_XMLNODE_Instruction)
+                current_node_->GetType() == CFX_XMLNode::Type::kInstruction)
               current_node_ = current_node_->GetParent();
           }
           break;
diff --git a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
index e6e5afa..a1fa8f3 100644
--- a/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmlparser_unittest.cpp
@@ -321,7 +321,7 @@
 
   CFX_XMLElement* root = doc->GetRoot();
   ASSERT_TRUE(root->GetFirstChild() != nullptr);
-  ASSERT_EQ(FX_XMLNODE_Instruction, root->GetFirstChild()->GetType());
+  ASSERT_EQ(CFX_XMLNode::Type::kInstruction, root->GetFirstChild()->GetType());
 
   CFX_XMLInstruction* instruction = ToXMLInstruction(root->GetFirstChild());
   EXPECT_TRUE(instruction->IsOriginalXFAVersion());
diff --git a/core/fxcrt/xml/cfx_xmltext.cpp b/core/fxcrt/xml/cfx_xmltext.cpp
index b73316b..67c35a5 100644
--- a/core/fxcrt/xml/cfx_xmltext.cpp
+++ b/core/fxcrt/xml/cfx_xmltext.cpp
@@ -12,8 +12,8 @@
 
 CFX_XMLText::~CFX_XMLText() = default;
 
-FX_XMLNODETYPE CFX_XMLText::GetType() const {
-  return FX_XMLNODE_Text;
+CFX_XMLNode::Type CFX_XMLText::GetType() const {
+  return Type::kText;
 }
 
 CFX_XMLNode* CFX_XMLText::Clone(CFX_XMLDocument* doc) {
diff --git a/core/fxcrt/xml/cfx_xmltext.h b/core/fxcrt/xml/cfx_xmltext.h
index f2c7c88..72ca242 100644
--- a/core/fxcrt/xml/cfx_xmltext.h
+++ b/core/fxcrt/xml/cfx_xmltext.h
@@ -18,7 +18,7 @@
   ~CFX_XMLText() override;
 
   // CFX_XMLNode
-  FX_XMLNODETYPE GetType() const override;
+  Type GetType() const override;
   CFX_XMLNode* Clone(CFX_XMLDocument* doc) override;
   void Save(const RetainPtr<IFX_SeekableWriteStream>& pXMLStream) override;
 
@@ -30,8 +30,9 @@
 };
 
 inline bool IsXMLText(const CFX_XMLNode* pNode) {
-  FX_XMLNODETYPE type = pNode->GetType();
-  return type == FX_XMLNODE_Text || type == FX_XMLNODE_CharData;
+  CFX_XMLNode::Type type = pNode->GetType();
+  return type == CFX_XMLNode::Type::kText ||
+         type == CFX_XMLNode::Type::kCharData;
 }
 
 inline CFX_XMLText* ToXMLText(CFX_XMLNode* pNode) {
diff --git a/core/fxcrt/xml/cfx_xmltext_unittest.cpp b/core/fxcrt/xml/cfx_xmltext_unittest.cpp
index 0326858..0df003a 100644
--- a/core/fxcrt/xml/cfx_xmltext_unittest.cpp
+++ b/core/fxcrt/xml/cfx_xmltext_unittest.cpp
@@ -9,7 +9,7 @@
 
 TEST(CFX_XMLTextTest, GetType) {
   CFX_XMLText text(L"My Text");
-  EXPECT_EQ(FX_XMLNODE_Text, text.GetType());
+  EXPECT_EQ(CFX_XMLNode::Type::kText, text.GetType());
 }
 
 TEST(CFX_XMLTextTest, GetText) {
@@ -23,7 +23,7 @@
   CFX_XMLText data(L"My Data");
   CFX_XMLNode* clone = data.Clone(&doc);
   EXPECT_TRUE(clone != nullptr);
-  ASSERT_EQ(FX_XMLNODE_Text, clone->GetType());
+  ASSERT_EQ(CFX_XMLNode::Type::kText, clone->GetType());
   EXPECT_EQ(L"My Data", ToXMLText(clone)->GetText());
 }
 
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index 53b1804..59c364a 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -282,7 +282,7 @@
   top_xml_doc->AppendNodesFrom(pParser->GetXMLDoc().get());
 
   if (bIgnoreRoot &&
-      (pXMLNode->GetType() != FX_XMLNODE_Element ||
+      (pXMLNode->GetType() != CFX_XMLNode::Type::kElement ||
        XFA_RecognizeRichText(static_cast<CFX_XMLElement*>(pXMLNode)))) {
     bIgnoreRoot = false;
   }
@@ -405,7 +405,7 @@
   CFX_XMLNode* pElement = nullptr;
   if (GetXFANode()->GetPacketType() == XFA_PacketType::Datasets) {
     pElement = GetXFANode()->GetXMLMappingNode();
-    if (!pElement || pElement->GetType() != FX_XMLNODE_Element) {
+    if (!pElement || pElement->GetType() != CFX_XMLNode::Type::kElement) {
       return CJS_Result::Success(
           runtime->NewString(bsXMLHeader.AsStringView()));
     }
diff --git a/testing/fuzzers/pdf_xml_fuzzer.cc b/testing/fuzzers/pdf_xml_fuzzer.cc
index cbf436d..e858f5b 100644
--- a/testing/fuzzers/pdf_xml_fuzzer.cc
+++ b/testing/fuzzers/pdf_xml_fuzzer.cc
@@ -28,7 +28,7 @@
 
   for (CFX_XMLNode* pXMLNode = doc->GetRoot()->GetFirstChild(); pXMLNode;
        pXMLNode = pXMLNode->GetNextSibling()) {
-    if (pXMLNode->GetType() == FX_XMLNODE_Element)
+    if (pXMLNode->GetType() == CFX_XMLNode::Type::kElement)
       break;
   }
   return 0;
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index 1b934c4..a0e9758 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -716,9 +716,9 @@
       if (m_bBlockContinue || (m_pLoader && pXMLNode == m_pLoader->pXMLNode)) {
         m_bBlockContinue = true;
       }
-      if (pXMLNode->GetType() == FX_XMLNODE_Text) {
+      if (pXMLNode->GetType() == CFX_XMLNode::Type::kText) {
         bContentNode = true;
-      } else if (pXMLNode->GetType() == FX_XMLNODE_Element) {
+      } else if (pXMLNode->GetType() == CFX_XMLNode::Type::kElement) {
         pElement = static_cast<const CFX_XMLElement*>(pXMLNode);
         wsName = pElement->GetLocalTagName();
       }
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 3fca792..84ad724 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -304,7 +304,7 @@
 
     return tagProvider;
   }
-  if (pXMLNode->GetType() == FX_XMLNODE_Text) {
+  if (pXMLNode->GetType() == CFX_XMLNode::Type::kText) {
     tagProvider->m_bTagAvailable = true;
     tagProvider->m_bContent = true;
   }
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index ace9bb4..beb99e3 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -37,10 +37,8 @@
 CFX_XMLNode* GetDocumentNode(CFX_XMLNode* pRootNode) {
   for (CFX_XMLNode* pXMLNode = pRootNode->GetFirstChild(); pXMLNode;
        pXMLNode = pXMLNode->GetNextSibling()) {
-    if (pXMLNode->GetType() != FX_XMLNODE_Element)
-      continue;
-
-    return pXMLNode;
+    if (pXMLNode->GetType() == CFX_XMLNode::Type::kElement)
+      return pXMLNode;
   }
   return nullptr;
 }
@@ -159,14 +157,14 @@
   for (CFX_XMLNode* pXMLChild = pRootXMLNode->GetFirstChild(); pXMLChild;
        pXMLChild = pXMLChild->GetNextSibling()) {
     switch (pXMLChild->GetType()) {
-      case FX_XMLNODE_Element: {
+      case CFX_XMLNode::Type::kElement: {
         WideString wsTextData = ToXMLElement(pXMLChild)->GetTextData();
         wsTextData += L"\n";
         wsOutput += wsTextData;
         break;
       }
-      case FX_XMLNODE_Text:
-      case FX_XMLNODE_CharData: {
+      case CFX_XMLNode::Type::kText:
+      case CFX_XMLNode::Type::kCharData: {
         WideString wsText = ToXMLText(pXMLChild)->GetText();
         if (IsStringAllWhitespace(wsText))
           continue;
@@ -186,7 +184,7 @@
 
   WideString wsPlainText;
   switch (pXMLNode->GetType()) {
-    case FX_XMLNODE_Element: {
+    case CFX_XMLNode::Type::kElement: {
       CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
       WideString wsTag = pXMLElement->GetLocalTagName();
       uint32_t uTag = FX_HashCode_GetW(wsTag.AsStringView(), true);
@@ -204,8 +202,8 @@
       }
       break;
     }
-    case FX_XMLNODE_Text:
-    case FX_XMLNODE_CharData: {
+    case CFX_XMLNode::Type::kText:
+    case CFX_XMLNode::Type::kCharData: {
       WideString wsContent = ToXMLText(pXMLNode)->GetText();
       wsPlainText += wsContent;
       break;
@@ -277,11 +275,11 @@
     if (pXFANode->GetElementType() == XFA_Element::DataValue) {
       for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
            pXMLChild = pXMLChild->GetNextSibling()) {
-        FX_XMLNODETYPE eNodeType = pXMLChild->GetType();
-        if (eNodeType == FX_XMLNODE_Instruction)
+        CFX_XMLNode::Type eNodeType = pXMLChild->GetType();
+        if (eNodeType == CFX_XMLNode::Type::kInstruction)
           continue;
 
-        if (eNodeType == FX_XMLNODE_Element) {
+        if (eNodeType == CFX_XMLNode::Type::kElement) {
           CXFA_Node* pXFAChild = m_pFactory->CreateNode(
               XFA_PacketType::Datasets, XFA_Element::DataValue);
           if (!pXFAChild)
@@ -670,7 +668,7 @@
   for (CFX_XMLNode* pXMLChild = pXMLDoc->GetFirstChild(); pXMLChild;
        pXMLChild = pXMLChild->GetNextSibling()) {
     switch (pXMLChild->GetType()) {
-      case FX_XMLNODE_Element: {
+      case CFX_XMLNode::Type::kElement: {
         CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLChild);
         WideString wsTagName = pXMLElement->GetLocalTagName();
         XFA_Element eType = XFA_GetElementByName(wsTagName.AsStringView());
@@ -734,7 +732,7 @@
             break;
         }
       } break;
-      case FX_XMLNODE_Instruction:
+      case CFX_XMLNode::Type::kInstruction:
         ParseInstruction(pXFANode, ToXMLInstruction(pXMLChild), ePacketID);
         break;
       default:
@@ -762,8 +760,8 @@
   WideString wsValue;
   for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
        pXMLChild = pXMLChild->GetNextSibling()) {
-    FX_XMLNODETYPE eNodeType = pXMLChild->GetType();
-    if (eNodeType == FX_XMLNODE_Instruction)
+    CFX_XMLNode::Type eNodeType = pXMLChild->GetType();
+    if (eNodeType == CFX_XMLNode::Type::kInstruction)
       continue;
 
     CFX_XMLElement* pElement = ToXMLElement(pXMLChild);
@@ -806,7 +804,7 @@
   for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
        pXMLChild = pXMLChild->GetNextSibling()) {
     switch (pXMLChild->GetType()) {
-      case FX_XMLNODE_Element: {
+      case CFX_XMLNode::Type::kElement: {
         CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLChild);
         WideString wsNamespaceURI = pXMLElement->GetNamespaceURI();
         if (wsNamespaceURI.EqualsASCII(
@@ -906,8 +904,8 @@
         pXFAChild->SetFlag(XFA_NodeFlag_Initialized);
         continue;
       }
-      case FX_XMLNODE_CharData:
-      case FX_XMLNODE_Text: {
+      case CFX_XMLNode::Type::kCharData:
+      case CFX_XMLNode::Type::kText: {
         CFX_XMLText* pXMLText = ToXMLText(pXMLChild);
         WideString wsText = pXMLText->GetText();
         if (IsStringAllWhitespace(wsText))
@@ -940,8 +938,8 @@
   CFX_XMLNode* pXMLCurValueNode = nullptr;
   for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
        pXMLChild = pXMLChild->GetNextSibling()) {
-    FX_XMLNODETYPE eNodeType = pXMLChild->GetType();
-    if (eNodeType == FX_XMLNODE_Instruction)
+    CFX_XMLNode::Type eNodeType = pXMLChild->GetType();
+    if (eNodeType == CFX_XMLNode::Type::kInstruction)
       continue;
 
     CFX_XMLText* pText = ToXMLText(pXMLChild);
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 8ba7068..4c0d7d0 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -4917,7 +4917,7 @@
 void CXFA_Node::SetToXML(const WideString& value) {
   auto* pNode = GetXMLMappingNode();
   switch (pNode->GetType()) {
-    case FX_XMLNODE_Element: {
+    case CFX_XMLNode::Type::kElement: {
       auto* elem = static_cast<CFX_XMLElement*>(pNode);
       if (IsAttributeInXML()) {
         elem->SetAttribute(JSObject()->GetCData(XFA_Attribute::QualifiedName),
@@ -4946,7 +4946,7 @@
       elem->AppendChild(text);
       break;
     }
-    case FX_XMLNODE_Text:
+    case CFX_XMLNode::Type::kText:
       ToXMLText(GetXMLMappingNode())->SetText(value);
       break;
     default: