summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_simple_parser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-02-15 18:12:29 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-15 18:12:29 +0000
commite40678ed8a22ecd57421877af39cf7f281f618c4 (patch)
tree50bbf114829ad3b4852b3739f65c6385091c4ba0 /xfa/fxfa/parser/cxfa_simple_parser.cpp
parent625e6fec9ddd1d023116f7bd22d2192ef9bc49c8 (diff)
downloadpdfium-e40678ed8a22ecd57421877af39cf7f281f618c4.tar.xz
Make the CFX_XMLNode a MaybeOwned pointer
This CL removes the HasOwnXML flag from the CXFA_Node objects and instead uses a MaybeOwned pointer to keep track of the XML nodes. Change-Id: Ie678258247ec21ecb15c639647b189e140586d25 Reviewed-on: https://pdfium-review.googlesource.com/26811 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_simple_parser.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp41
1 files changed, 18 insertions, 23 deletions
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 7424913114..f30ab6b631 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -724,13 +724,13 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
return pNode;
}
- CFX_XMLNode* pDataXMLNode = nullptr;
+ MaybeOwned<CFX_XMLNode> pDataXMLNode;
if (MatchNodeName(pXMLDocumentNode, L"data", packet->uri, packet->flags)) {
static_cast<CFX_XMLElement*>(pXMLDocumentNode)
->RemoveAttribute(L"xmlns:xfa");
- pDataXMLNode = pXMLDocumentNode;
+ pDataXMLNode.Reset(pXMLDocumentNode);
} else {
- CFX_XMLElement* pDataElement = new CFX_XMLElement(L"xfa:data");
+ auto pDataElement = pdfium::MakeUnique<CFX_XMLElement>(L"xfa:data");
CFX_XMLNode* pParentXMLNode = pXMLDocumentNode->GetParent();
if (pParentXMLNode)
pParentXMLNode->RemoveChildNode(pXMLDocumentNode);
@@ -741,29 +741,24 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data(
->RemoveAttribute(L"xmlns:xfa");
}
pDataElement->AppendChild(pXMLDocumentNode);
- pDataXMLNode = pDataElement;
+ pDataXMLNode.Reset(std::move(pDataElement));
}
+ if (!pDataXMLNode)
+ return nullptr;
- if (pDataXMLNode) {
- CXFA_Node* pNode = m_pFactory->CreateNode(XFA_PacketType::Datasets,
- XFA_Element::DataGroup);
- if (!pNode) {
- if (pDataXMLNode != pXMLDocumentNode)
- delete pDataXMLNode;
- return nullptr;
- }
- WideString wsLocalName =
- static_cast<CFX_XMLElement*>(pDataXMLNode)->GetLocalTagName();
- pNode->JSObject()->SetCData(XFA_Attribute::Name, wsLocalName, false, false);
- if (!DataLoader(pNode, pDataXMLNode, true))
- return nullptr;
+ CXFA_Node* pNode =
+ m_pFactory->CreateNode(XFA_PacketType::Datasets, XFA_Element::DataGroup);
+ if (!pNode)
+ return nullptr;
- pNode->SetXMLMappingNode(pDataXMLNode);
- if (pDataXMLNode != pXMLDocumentNode)
- pNode->SetFlag(XFA_NodeFlag_OwnXMLNode);
- return pNode;
- }
- return nullptr;
+ WideString wsLocalName =
+ static_cast<CFX_XMLElement*>(pDataXMLNode.Get())->GetLocalTagName();
+ pNode->JSObject()->SetCData(XFA_Attribute::Name, wsLocalName, false, false);
+ if (!DataLoader(pNode, pDataXMLNode.Get(), true))
+ return nullptr;
+
+ pNode->SetXMLMappingNode(std::move(pDataXMLNode));
+ return pNode;
}
CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_LocaleConnectionSourceSet(