summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fxcrt/xml/cfx_xmlelement.cpp10
-rw-r--r--core/fxcrt/xml/cfx_xmlnode.cpp104
-rw-r--r--core/fxcrt/xml/cfx_xmlnode.h23
-rw-r--r--fxjs/xfa/cjx_node.cpp9
-rw-r--r--testing/libfuzzer/pdf_xml_fuzzer.cc38
-rw-r--r--xfa/fxfa/cxfa_ffdoc.cpp10
-rw-r--r--xfa/fxfa/cxfa_textlayout.cpp24
-rw-r--r--xfa/fxfa/cxfa_textparser.cpp7
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_dataimporter.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp2
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp75
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp7
13 files changed, 120 insertions, 197 deletions
diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp
index bba6fe6187..39233190b1 100644
--- a/core/fxcrt/xml/cfx_xmlelement.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement.cpp
@@ -29,7 +29,7 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLElement::Clone() {
pClone->SetAttributes(GetAttributes());
WideString wsText;
- CFX_XMLNode* pChild = m_pChild;
+ CFX_XMLNode* pChild = GetFirstChild();
while (pChild) {
switch (pChild->GetType()) {
case FX_XMLNODE_Text:
@@ -38,7 +38,7 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLElement::Clone() {
default:
break;
}
- pChild = pChild->m_pNext;
+ pChild = pChild->GetNextSibling();
}
pClone->SetTextData(wsText);
return std::move(pClone);
@@ -71,7 +71,7 @@ WideString CFX_XMLElement::GetNamespaceURI() const {
auto* pElement = static_cast<const CFX_XMLElement*>(pNode);
if (!pElement->HasAttribute(wsAttri)) {
- pNode = pNode->GetNodeItem(CFX_XMLNode::Parent);
+ pNode = pNode->GetParent();
continue;
}
return pElement->GetString(wsAttri);
@@ -81,7 +81,7 @@ WideString CFX_XMLElement::GetNamespaceURI() const {
WideString CFX_XMLElement::GetTextData() const {
CFX_WideTextBuf buffer;
- CFX_XMLNode* pChild = m_pChild;
+ CFX_XMLNode* pChild = GetFirstChild();
while (pChild) {
switch (pChild->GetType()) {
case FX_XMLNODE_Text:
@@ -91,7 +91,7 @@ WideString CFX_XMLElement::GetTextData() const {
default:
break;
}
- pChild = pChild->m_pNext;
+ pChild = pChild->GetNextSibling();
}
return buffer.MakeString();
}
diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp
index 19f397deb2..7cc506af9f 100644
--- a/core/fxcrt/xml/cfx_xmlnode.cpp
+++ b/core/fxcrt/xml/cfx_xmlnode.cpp
@@ -15,28 +15,25 @@
#include "core/fxcrt/xml/cfx_xmltext.h"
#include "third_party/base/stl_util.h"
-CFX_XMLNode::CFX_XMLNode()
- : m_pParent(nullptr),
- m_pChild(nullptr),
- m_pPrior(nullptr),
- m_pNext(nullptr) {}
-
-FX_XMLNODETYPE CFX_XMLNode::GetType() const {
- return FX_XMLNODE_Unknown;
-}
+CFX_XMLNode::CFX_XMLNode() = default;
CFX_XMLNode::~CFX_XMLNode() {
DeleteChildren();
}
+FX_XMLNODETYPE CFX_XMLNode::GetType() const {
+ return FX_XMLNODE_Unknown;
+}
+
void CFX_XMLNode::DeleteChildren() {
- CFX_XMLNode* pChild = m_pChild;
+ CFX_XMLNode* pChild = first_child_;
+ first_child_ = nullptr;
+
while (pChild) {
- CFX_XMLNode* pNext = pChild->m_pNext;
+ CFX_XMLNode* pNext = pChild->next_sibling_;
delete pChild;
pChild = pNext;
}
- m_pChild = nullptr;
}
void CFX_XMLNode::AppendChild(CFX_XMLNode* pNode) {
@@ -44,68 +41,57 @@ void CFX_XMLNode::AppendChild(CFX_XMLNode* pNode) {
}
void CFX_XMLNode::InsertChildNode(CFX_XMLNode* pNode, int32_t index) {
- ASSERT(!pNode->m_pParent);
+ ASSERT(!pNode->parent_);
- pNode->m_pParent = this;
- if (!m_pChild) {
- m_pChild = pNode;
- pNode->m_pPrior = nullptr;
- pNode->m_pNext = nullptr;
+ pNode->parent_ = this;
+ if (!first_child_) {
+ first_child_ = pNode;
+ pNode->prev_sibling_ = nullptr;
+ pNode->next_sibling_ = nullptr;
return;
}
if (index == 0) {
- pNode->m_pNext = m_pChild;
- pNode->m_pPrior = nullptr;
- m_pChild->m_pPrior = pNode;
- m_pChild = pNode;
+ pNode->next_sibling_ = first_child_;
+ pNode->prev_sibling_ = nullptr;
+ first_child_->prev_sibling_ = pNode;
+ first_child_ = pNode;
return;
}
int32_t iCount = 0;
- CFX_XMLNode* pFind = m_pChild;
- while (++iCount != index && pFind->m_pNext)
- pFind = pFind->m_pNext;
-
- pNode->m_pPrior = pFind;
- pNode->m_pNext = pFind->m_pNext;
- if (pFind->m_pNext)
- pFind->m_pNext->m_pPrior = pNode;
- pFind->m_pNext = pNode;
+ CFX_XMLNode* pFind = first_child_;
+ while (++iCount != index && pFind->next_sibling_)
+ pFind = pFind->next_sibling_;
+
+ pNode->prev_sibling_ = pFind;
+ pNode->next_sibling_ = pFind->next_sibling_;
+ if (pFind->next_sibling_)
+ pFind->next_sibling_->prev_sibling_ = pNode;
+ pFind->next_sibling_ = pNode;
}
void CFX_XMLNode::RemoveChildNode(CFX_XMLNode* pNode) {
- ASSERT(m_pChild && pNode);
+ ASSERT(first_child_ && pNode);
- if (m_pChild == pNode)
- m_pChild = pNode->m_pNext;
+ if (first_child_ == pNode)
+ first_child_ = pNode->next_sibling_;
else
- pNode->m_pPrior->m_pNext = pNode->m_pNext;
+ pNode->prev_sibling_->next_sibling_ = pNode->next_sibling_;
- if (pNode->m_pNext)
- pNode->m_pNext->m_pPrior = pNode->m_pPrior;
+ if (pNode->next_sibling_)
+ pNode->next_sibling_->prev_sibling_ = pNode->prev_sibling_;
- pNode->m_pParent = nullptr;
- pNode->m_pNext = nullptr;
- pNode->m_pPrior = nullptr;
+ pNode->parent_ = nullptr;
+ pNode->next_sibling_ = nullptr;
+ pNode->prev_sibling_ = nullptr;
}
-CFX_XMLNode* CFX_XMLNode::GetNodeItem(CFX_XMLNode::NodeItem eItem) const {
- switch (eItem) {
- case CFX_XMLNode::Root: {
- CFX_XMLNode* pParent = (CFX_XMLNode*)this;
- while (pParent->m_pParent)
- pParent = pParent->m_pParent;
+CFX_XMLNode* CFX_XMLNode::GetRoot() {
+ CFX_XMLNode* pParent = this;
+ while (pParent->parent_)
+ pParent = pParent->parent_;
- return pParent;
- }
- case CFX_XMLNode::Parent:
- return m_pParent;
- case CFX_XMLNode::NextSibling:
- return m_pNext;
- case CFX_XMLNode::FirstChild:
- return m_pChild;
- }
- return nullptr;
+ return pParent;
}
std::unique_ptr<CFX_XMLNode> CFX_XMLNode::Clone() {
@@ -183,13 +169,13 @@ void CFX_XMLNode::SaveXMLNode(
ws += L"\"";
pXMLStream->WriteString(ws.AsStringView());
}
- if (pNode->m_pChild) {
+ if (pNode->first_child_) {
ws = L"\n>";
pXMLStream->WriteString(ws.AsStringView());
- CFX_XMLNode* pChild = pNode->m_pChild;
+ CFX_XMLNode* pChild = pNode->first_child_;
while (pChild) {
pChild->SaveXMLNode(pXMLStream);
- pChild = pChild->m_pNext;
+ pChild = pChild->next_sibling_;
}
ws = L"</";
ws += static_cast<CFX_XMLElement*>(pNode)->GetName();
diff --git a/core/fxcrt/xml/cfx_xmlnode.h b/core/fxcrt/xml/cfx_xmlnode.h
index dc3152f19a..55c79dcfe0 100644
--- a/core/fxcrt/xml/cfx_xmlnode.h
+++ b/core/fxcrt/xml/cfx_xmlnode.h
@@ -27,32 +27,29 @@ struct FX_XMLNODE {
class CFX_XMLNode {
public:
- enum NodeItem {
- Root = 0,
- Parent,
- NextSibling,
- FirstChild,
- };
-
CFX_XMLNode();
virtual ~CFX_XMLNode();
virtual FX_XMLNODETYPE GetType() const;
virtual std::unique_ptr<CFX_XMLNode> Clone();
+ CFX_XMLNode* GetRoot();
+ CFX_XMLNode* GetParent() const { return parent_; }
+ CFX_XMLNode* GetFirstChild() const { return first_child_; }
+ CFX_XMLNode* GetNextSibling() const { return next_sibling_; }
+
void AppendChild(CFX_XMLNode* pNode);
void InsertChildNode(CFX_XMLNode* pNode, int32_t index);
void RemoveChildNode(CFX_XMLNode* pNode);
void DeleteChildren();
- CFX_XMLNode* GetNodeItem(CFX_XMLNode::NodeItem eItem) const;
-
void SaveXMLNode(const RetainPtr<CFX_SeekableStreamProxy>& pXMLStream);
- CFX_XMLNode* m_pParent;
- CFX_XMLNode* m_pChild;
- CFX_XMLNode* m_pPrior;
- CFX_XMLNode* m_pNext;
+ private:
+ CFX_XMLNode* parent_ = nullptr;
+ CFX_XMLNode* first_child_ = nullptr;
+ CFX_XMLNode* prev_sibling_ = nullptr;
+ CFX_XMLNode* next_sibling_ = nullptr;
};
#endif // CORE_FXCRT_XML_CFX_XMLNODE_H_
diff --git a/fxjs/xfa/cjx_node.cpp b/fxjs/xfa/cjx_node.cpp
index e5396b7c90..8009208561 100644
--- a/fxjs/xfa/cjx_node.cpp
+++ b/fxjs/xfa/cjx_node.cpp
@@ -246,16 +246,15 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime,
}
if (bIgnoreRoot) {
- CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
+ CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild();
while (pXMLChild) {
- CFX_XMLNode* pXMLSibling =
- pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling);
+ CFX_XMLNode* pXMLSibling = pXMLChild->GetNextSibling();
pXMLNode->RemoveChildNode(pXMLChild);
pFakeXMLRoot->AppendChild(pXMLChild);
pXMLChild = pXMLSibling;
}
} else {
- CFX_XMLNode* pXMLParent = pXMLNode->GetNodeItem(CFX_XMLNode::Parent);
+ CFX_XMLNode* pXMLParent = pXMLNode->GetParent();
if (pXMLParent)
pXMLParent->RemoveChildNode(pXMLNode);
@@ -291,7 +290,7 @@ CJS_Return CJX_Node::loadXML(CFX_V8* runtime,
CFX_XMLNode* pTempXMLNode = GetXFANode()->GetXMLMappingNode();
GetXFANode()->SetXMLMappingNode(pFakeXMLRoot.release());
GetXFANode()->SetFlag(XFA_NodeFlag_OwnXMLNode, false);
- if (pTempXMLNode && !pTempXMLNode->GetNodeItem(CFX_XMLNode::Parent))
+ if (pTempXMLNode && !pTempXMLNode->GetParent())
pFakeXMLRoot.reset(pTempXMLNode);
else
pFakeXMLRoot = nullptr;
diff --git a/testing/libfuzzer/pdf_xml_fuzzer.cc b/testing/libfuzzer/pdf_xml_fuzzer.cc
index d8010f90f8..3a2889421f 100644
--- a/testing/libfuzzer/pdf_xml_fuzzer.cc
+++ b/testing/libfuzzer/pdf_xml_fuzzer.cc
@@ -14,37 +14,6 @@
#include "core/fxcrt/xml/cfx_xmlparser.h"
#include "third_party/base/ptr_util.h"
-namespace {
-
-CFX_XMLNode* XFA_FDEExtension_GetDocumentNode(
- CFX_XMLDoc* pXMLDoc,
- bool bVerifyWellFormness = false) {
- if (!pXMLDoc) {
- return nullptr;
- }
- CFX_XMLNode* pXMLFakeRoot = pXMLDoc->GetRoot();
- for (CFX_XMLNode* pXMLNode =
- pXMLFakeRoot->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
- if (pXMLNode->GetType() == FX_XMLNODE_Element) {
- if (bVerifyWellFormness) {
- for (CFX_XMLNode* pNextNode =
- pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling);
- pNextNode;
- pNextNode = pNextNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
- if (pNextNode->GetType() == FX_XMLNODE_Element) {
- return nullptr;
- }
- }
- }
- return pXMLNode;
- }
- }
- return nullptr;
-}
-
-} // namespace
-
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
FX_SAFE_SIZE_T safe_size = size;
if (!safe_size.IsValid())
@@ -60,6 +29,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
if (doc->DoLoad() < 100)
return 0;
- (void)XFA_FDEExtension_GetDocumentNode(doc.get());
+ CFX_XMLNode* pXMLFakeRoot = doc->GetRoot();
+ for (CFX_XMLNode* pXMLNode = pXMLFakeRoot->GetFirstChild(); pXMLNode;
+ pXMLNode = pXMLNode->GetNextSibling()) {
+ if (pXMLNode->GetType() == FX_XMLNODE_Element)
+ break;
+ }
return 0;
}
diff --git a/xfa/fxfa/cxfa_ffdoc.cpp b/xfa/fxfa/cxfa_ffdoc.cpp
index 4dfa78edb1..52ad5f692d 100644
--- a/xfa/fxfa/cxfa_ffdoc.cpp
+++ b/xfa/fxfa/cxfa_ffdoc.cpp
@@ -175,9 +175,8 @@ bool XFA_GetPDFContentsFromPDFXML(CFX_XMLNode* pPDFElement,
uint8_t*& pByteBuffer,
int32_t& iBufferSize) {
CFX_XMLElement* pDocumentElement = nullptr;
- for (CFX_XMLNode* pXMLNode =
- pPDFElement->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLNode = pPDFElement->GetFirstChild(); pXMLNode;
+ pXMLNode = pXMLNode->GetNextSibling()) {
if (pXMLNode->GetType() == FX_XMLNODE_Element) {
CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
WideString wsTagName = pXMLElement->GetName();
@@ -191,9 +190,8 @@ bool XFA_GetPDFContentsFromPDFXML(CFX_XMLNode* pPDFElement,
return false;
}
CFX_XMLElement* pChunkElement = nullptr;
- for (CFX_XMLNode* pXMLNode =
- pDocumentElement->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLNode = pDocumentElement->GetFirstChild(); pXMLNode;
+ pXMLNode = pXMLNode->GetNextSibling()) {
if (pXMLNode->GetType() == FX_XMLNODE_Element) {
CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLNode);
WideString wsTagName = pXMLElement->GetName();
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index ebb9e8aa2c..41d46f8824 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -78,9 +78,8 @@ CFX_XMLNode* CXFA_TextLayout::GetXMLContainerNode() {
return nullptr;
CFX_XMLNode* pXMLContainer = nullptr;
- for (CFX_XMLNode* pXMLChild = pXMLRoot->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLChild;
- pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLChild = pXMLRoot->GetFirstChild(); pXMLChild;
+ pXMLChild = pXMLChild->GetNextSibling()) {
if (pXMLChild->GetType() == FX_XMLNODE_Element) {
CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLChild);
WideString wsTag = pXMLElement->GetLocalTagName();
@@ -463,15 +462,14 @@ bool CXFA_TextLayout::Layout(int32_t iBlock) {
return true;
CFX_XMLNode* pSaveXMLNode = m_pLoader->m_pXMLNode;
- for (; pXMLNode;
- pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (; pXMLNode; pXMLNode = pXMLNode->GetNextSibling()) {
if (!LoadRichText(pXMLNode, szText.width, fLinePos,
m_pLoader->m_pParentStyle, true, nullptr)) {
break;
}
}
while (!pXMLNode) {
- pXMLNode = pSaveXMLNode->GetNodeItem(CFX_XMLNode::Parent);
+ pXMLNode = pSaveXMLNode->GetParent();
if (pXMLNode == pContainerNode)
break;
if (!LoadRichText(pXMLNode, szText.width, fLinePos,
@@ -479,11 +477,10 @@ bool CXFA_TextLayout::Layout(int32_t iBlock) {
break;
}
pSaveXMLNode = pXMLNode;
- pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling);
+ pXMLNode = pXMLNode->GetNextSibling();
if (!pXMLNode)
continue;
- for (; pXMLNode;
- pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (; pXMLNode; pXMLNode = pXMLNode->GetNextSibling()) {
if (!LoadRichText(pXMLNode, szText.width, fLinePos,
m_pLoader->m_pParentStyle, true, nullptr)) {
break;
@@ -824,10 +821,8 @@ bool CXFA_TextLayout::LoadRichText(
}
}
- for (CFX_XMLNode* pChildNode =
- pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pChildNode;
- pChildNode = pChildNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pChildNode = pXMLNode->GetFirstChild(); pChildNode;
+ pChildNode = pChildNode->GetNextSibling()) {
if (bCurOl)
iLiCount++;
@@ -861,8 +856,7 @@ bool CXFA_TextLayout::LoadRichText(
}
if (IsEnd(bSavePieces)) {
if (m_pLoader && m_pLoader->m_iTotalLines > -1) {
- m_pLoader->m_pXMLNode =
- pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling);
+ m_pLoader->m_pXMLNode = pXMLNode->GetNextSibling();
m_pLoader->m_pParentStyle = pParentStyle;
}
return false;
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 07ba896843..bcadbea5c0 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -245,9 +245,8 @@ void CXFA_TextParser::ParseRichText(CFX_XMLNode* pXMLNode,
m_mapXMLNodeToParseContext[pXMLNode] = std::move(pTextContext);
}
- for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLChild;
- pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
+ pXMLChild = pXMLChild->GetNextSibling()) {
ParseRichText(pXMLChild, pNewStyle.Get());
}
}
@@ -382,7 +381,7 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider,
return wsValue.GetInteger();
}
}
- pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::Parent);
+ pXMLNode = pXMLNode->GetParent();
}
}
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index cbb01a9ea7..60c52942ed 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -62,10 +62,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
CXFA_Node* pBind = m_pNode->GetBindData();
CFX_XMLNode* pXMLNode = pBind->GetXMLMappingNode();
ASSERT(pXMLNode);
- for (CFX_XMLNode* pXMLChild =
- pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLChild;
- pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
+ pXMLChild = pXMLChild->GetNextSibling()) {
if (pXMLChild->GetType() == FX_XMLNODE_Element) {
CFX_XMLElement* pElement = static_cast<CFX_XMLElement*>(pXMLChild);
if (XFA_RecognizeRichText(pElement))
diff --git a/xfa/fxfa/parser/cxfa_dataimporter.cpp b/xfa/fxfa/parser/cxfa_dataimporter.cpp
index 9171b00750..7c6e0ec12d 100644
--- a/xfa/fxfa/parser/cxfa_dataimporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataimporter.cpp
@@ -55,7 +55,7 @@ bool CXFA_DataImporter::ImportData(
}
} else {
CFX_XMLNode* pXMLNode = pImportDataRoot->GetXMLMappingNode();
- CFX_XMLNode* pParentXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::Parent);
+ CFX_XMLNode* pParentXMLNode = pXMLNode->GetParent();
if (pParentXMLNode)
pParentXMLNode->RemoveChildNode(pXMLNode);
pDataModel->InsertChild(pImportDataRoot, nullptr);
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 9159f020da..58b14cdf8a 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1154,7 +1154,7 @@ void CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) {
if (!IsNeedSavingXMLNode() || !pNode->m_pXMLNode)
return;
- ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFX_XMLNode::Parent));
+ ASSERT(!pNode->m_pXMLNode->GetParent());
m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index);
pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode);
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index f21506d557..eee5cb3d83 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -106,19 +106,16 @@ CFX_XMLNode* GetDocumentNode(CFX_XMLDoc* pXMLDoc,
if (!pXMLDoc)
return nullptr;
- for (CFX_XMLNode* pXMLNode =
- pXMLDoc->GetRoot()->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLNode; pXMLNode = pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLNode = pXMLDoc->GetRoot()->GetFirstChild(); pXMLNode;
+ pXMLNode = pXMLNode->GetNextSibling()) {
if (pXMLNode->GetType() != FX_XMLNODE_Element)
continue;
if (!bVerifyWellFormness)
return pXMLNode;
- for (CFX_XMLNode* pNextNode =
- pXMLNode->GetNodeItem(CFX_XMLNode::NextSibling);
- pNextNode;
- pNextNode = pNextNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pNextNode = pXMLNode->GetNextSibling(); pNextNode;
+ pNextNode = pNextNode->GetNextSibling()) {
if (pNextNode->GetType() == FX_XMLNODE_Element)
return nullptr;
}
@@ -249,10 +246,8 @@ CFX_XMLNode* GetDataSetsFromXDP(CFX_XMLNode* pXMLDocumentNode) {
return nullptr;
}
- for (CFX_XMLNode* pDatasetsNode =
- pXMLDocumentNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pDatasetsNode;
- pDatasetsNode = pDatasetsNode->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pDatasetsNode = pXMLDocumentNode->GetFirstChild();
+ pDatasetsNode; pDatasetsNode = pDatasetsNode->GetNextSibling()) {
if (MatchNodeName(pDatasetsNode, datasets_packet->name,
datasets_packet->uri, datasets_packet->flags)) {
return pDatasetsNode;
@@ -267,10 +262,8 @@ bool IsStringAllWhitespace(WideString wsText) {
}
void ConvertXMLToPlainText(CFX_XMLElement* pRootXMLNode, WideString& wsOutput) {
- for (CFX_XMLNode* pXMLChild =
- pRootXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLChild;
- pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLChild = pRootXMLNode->GetFirstChild(); pXMLChild;
+ pXMLChild = pXMLChild->GetNextSibling()) {
switch (pXMLChild->GetType()) {
case FX_XMLNODE_Element: {
WideString wsTextData =
@@ -328,9 +321,8 @@ WideString GetPlainTextFromRichText(CFX_XMLNode* pXMLNode) {
default:
break;
}
- for (CFX_XMLNode* pChildXML = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pChildXML;
- pChildXML = pChildXML->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pChildXML = pXMLNode->GetFirstChild(); pChildXML;
+ pChildXML = pChildXML->GetNextSibling()) {
wsPlainText += GetPlainTextFromRichText(pChildXML);
}
@@ -423,10 +415,8 @@ void CXFA_SimpleParser::ConstructXFANode(CXFA_Node* pXFANode,
XFA_PacketType ePacketID = pXFANode->GetPacketType();
if (ePacketID == XFA_PacketType::Datasets) {
if (pXFANode->GetElementType() == XFA_Element::DataValue) {
- for (CFX_XMLNode* pXMLChild =
- pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLChild;
- pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
+ pXMLChild = pXMLChild->GetNextSibling()) {
FX_XMLNODETYPE eNodeType = pXMLChild->GetType();
if (eNodeType == FX_XMLNODE_Instruction)
continue;
@@ -526,10 +516,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
CFX_XMLNode* pXMLConfigDOMRoot = nullptr;
CXFA_Node* pXFAConfigDOMRoot = nullptr;
- for (CFX_XMLNode* pChildItem =
- pXMLDocumentNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pChildItem;
- pChildItem = pChildItem->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pChildItem = pXMLDocumentNode->GetFirstChild(); pChildItem;
+ pChildItem = pChildItem->GetNextSibling()) {
const PacketInfo* pPacketInfo = GetPacketByIndex(XFA_PacketType::Config);
if (!MatchNodeName(pChildItem, pPacketInfo->name, pPacketInfo->uri,
pPacketInfo->flags)) {
@@ -547,10 +535,8 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_XDP(
CFX_XMLNode* pXMLDatasetsDOMRoot = nullptr;
CFX_XMLNode* pXMLFormDOMRoot = nullptr;
CFX_XMLNode* pXMLTemplateDOMRoot = nullptr;
- for (CFX_XMLNode* pChildItem =
- pXMLDocumentNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pChildItem;
- pChildItem = pChildItem->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pChildItem = pXMLDocumentNode->GetFirstChild(); pChildItem;
+ pChildItem = pChildItem->GetNextSibling()) {
if (!pChildItem || pChildItem->GetType() != FX_XMLNODE_Element)
continue;
if (pChildItem == pXMLConfigDOMRoot)
@@ -754,8 +740,7 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
pDataXMLNode = pXMLDocumentNode;
} else {
CFX_XMLElement* pDataElement = new CFX_XMLElement(L"xfa:data");
- CFX_XMLNode* pParentXMLNode =
- pXMLDocumentNode->GetNodeItem(CFX_XMLNode::Parent);
+ CFX_XMLNode* pParentXMLNode = pXMLDocumentNode->GetParent();
if (pParentXMLNode)
pParentXMLNode->RemoveChildNode(pXMLDocumentNode);
@@ -863,9 +848,8 @@ CXFA_Node* CXFA_SimpleParser::NormalLoader(CXFA_Node* pXFANode,
XFA_PacketType ePacketID,
bool bUseAttribute) {
bool bOneOfPropertyFound = false;
- for (CFX_XMLNode* pXMLChild = pXMLDoc->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLChild;
- pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLChild = pXMLDoc->GetFirstChild(); pXMLChild;
+ pXMLChild = pXMLChild->GetNextSibling()) {
switch (pXMLChild->GetType()) {
case FX_XMLNODE_Element: {
CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLChild);
@@ -958,9 +942,8 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode,
pXFANode->SetXMLMappingNode(pXMLNode);
WideString wsValue;
- for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLChild;
- pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
+ pXMLChild = pXMLChild->GetNextSibling()) {
FX_XMLNODETYPE eNodeType = pXMLChild->GetType();
if (eNodeType == FX_XMLNODE_Instruction)
continue;
@@ -1003,9 +986,8 @@ void CXFA_SimpleParser::ParseContentNode(CXFA_Node* pXFANode,
void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
CFX_XMLNode* pXMLNode,
XFA_PacketType ePacketID) {
- for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLChild;
- pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
+ pXMLChild = pXMLChild->GetNextSibling()) {
switch (pXMLChild->GetType()) {
case FX_XMLNODE_Element: {
CFX_XMLElement* pXMLElement = static_cast<CFX_XMLElement*>(pXMLChild);
@@ -1040,10 +1022,8 @@ void CXFA_SimpleParser::ParseDataGroup(CXFA_Node* pXFANode,
}
}
if (eNodeType == XFA_Element::DataModel) {
- for (CFX_XMLNode* pXMLDataChild =
- pXMLElement->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLDataChild; pXMLDataChild = pXMLDataChild->GetNodeItem(
- CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLDataChild = pXMLElement->GetFirstChild();
+ pXMLDataChild; pXMLDataChild = pXMLDataChild->GetNextSibling()) {
if (pXMLDataChild->GetType() == FX_XMLNODE_Element) {
if (!XFA_RecognizeRichText(
static_cast<CFX_XMLElement*>(pXMLDataChild))) {
@@ -1145,9 +1125,8 @@ void CXFA_SimpleParser::ParseDataValue(CXFA_Node* pXFANode,
CFX_WideTextBuf wsCurValueTextBuf;
bool bMarkAsCompound = false;
CFX_XMLNode* pXMLCurValueNode = nullptr;
- for (CFX_XMLNode* pXMLChild = pXMLNode->GetNodeItem(CFX_XMLNode::FirstChild);
- pXMLChild;
- pXMLChild = pXMLChild->GetNodeItem(CFX_XMLNode::NextSibling)) {
+ for (CFX_XMLNode* pXMLChild = pXMLNode->GetFirstChild(); pXMLChild;
+ pXMLChild = pXMLChild->GetNextSibling()) {
FX_XMLNODETYPE eNodeType = pXMLChild->GetType();
if (eNodeType == FX_XMLNODE_Instruction)
continue;
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index f0d2afdbcc..66b4e9d561 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -211,8 +211,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
if (!pExDataXML)
break;
- CFX_XMLNode* pRichTextXML =
- pExDataXML->GetNodeItem(CFX_XMLNode::FirstChild);
+ CFX_XMLNode* pRichTextXML = pExDataXML->GetFirstChild();
if (!pRichTextXML)
break;
@@ -464,7 +463,7 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier(CFX_XMLElement* pNode,
if (!pNode)
return false;
- CFX_XMLNode* pFakeRoot = pNode->GetNodeItem(CFX_XMLNode::Root);
+ CFX_XMLNode* pFakeRoot = pNode->GetRoot();
WideString wsNSAttribute;
bool bRet = false;
if (wsQualifier.IsEmpty()) {
@@ -474,7 +473,7 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier(CFX_XMLElement* pNode,
wsNSAttribute = L"xmlns:" + wsQualifier;
}
for (CFX_XMLNode* pParent = pNode; pParent != pFakeRoot;
- pParent = pParent->GetNodeItem(CFX_XMLNode::Parent)) {
+ pParent = pParent->GetParent()) {
if (pParent->GetType() != FX_XMLNODE_Element)
continue;