summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-02-13 21:44:33 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-13 21:44:33 +0000
commitfa3765cce4da4c3923e525f0462afd794360d221 (patch)
tree2a246bc47d7584edf5d8dd2c124f6c21c26cd5c8 /xfa/fxfa/parser
parent9c112f92d4c2046d5a4f8538f4d18b74a87649d4 (diff)
downloadpdfium-fa3765cce4da4c3923e525f0462afd794360d221.tar.xz
Cleanup CFX_XMLNode pointers
This CL cleans up hte CFX_XMLNode pointers. Each pointer has been renamed to make the usage clearer, the NodeItems method has been removed in favour of distinct accessors and the node pointers have been made private. Change-Id: I5459a77a0ae93b08741a0cd59266ef9c81ddad75 Reviewed-on: https://pdfium-review.googlesource.com/26550 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-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
4 files changed, 32 insertions, 54 deletions
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;