summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_document.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-02 16:02:03 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-02 16:02:03 +0000
commit70180648ffd01dd3716871758411d2031aaaebbe (patch)
tree6cc1d7aa3df8c3e343a1ef6f7e032bae8499f6db /xfa/fxfa/parser/cxfa_document.cpp
parent8ab2b2b2869f769dc169b4a96bb67ec596d5278b (diff)
downloadpdfium-70180648ffd01dd3716871758411d2031aaaebbe.tar.xz
Add a CFX_XMLDocument class.
This CL adds a CFX_XMLDocument to act as the XML node container. All nodes are now owned by the document and the document is returned by the CFX_XMLParser. Classes which parse XML files now store the document instead of the root node. BUG: chromium:835636 Change-Id: I1e07d6115cf14714911d6fd4c3fa920c94fd5faf Reviewed-on: https://pdfium-review.googlesource.com/31313 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_document.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_document.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp
index 9e5143c5a4..15458826ce 100644
--- a/xfa/fxfa/parser/cxfa_document.cpp
+++ b/xfa/fxfa/parser/cxfa_document.cpp
@@ -11,7 +11,9 @@
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/fx_fallthrough.h"
+#include "core/fxcrt/xml/cfx_xmldocument.h"
#include "fxjs/cfxjse_engine.h"
+#include "xfa/fxfa/cxfa_ffdoc.h"
#include "xfa/fxfa/cxfa_ffnotify.h"
#include "xfa/fxfa/parser/cscript_datawindow.h"
#include "xfa/fxfa/parser/cscript_eventpseudomodel.h"
@@ -1628,7 +1630,9 @@ void CXFA_Document::DoDataMerge() {
CXFA_Node* pDatasetsRoot = ToNode(GetXFAObject(XFA_HASHCODE_Datasets));
if (!pDatasetsRoot) {
// Ownership will be passed in the AppendChild below to the XML tree.
- auto pDatasetsXMLNode = pdfium::MakeUnique<CFX_XMLElement>(L"xfa:datasets");
+ auto* pDatasetsXMLNode =
+ notify_->GetHDOC()->GetXMLDocument()->CreateNode<CFX_XMLElement>(
+ L"xfa:datasets");
pDatasetsXMLNode->SetAttribute(L"xmlns:xfa",
L"http://www.xfa.org/schema/xfa-data/1.0/");
pDatasetsRoot =
@@ -1636,10 +1640,10 @@ void CXFA_Document::DoDataMerge() {
pDatasetsRoot->JSObject()->SetCData(XFA_Attribute::Name, L"datasets", false,
false);
- CFX_XMLElement* ref = pDatasetsXMLNode.get();
- m_pRootNode->GetXMLMappingNode()->AppendChild(std::move(pDatasetsXMLNode));
+ m_pRootNode->GetXMLMappingNode()->AppendChild(pDatasetsXMLNode);
m_pRootNode->InsertChild(pDatasetsRoot, nullptr);
- pDatasetsRoot->SetXMLMappingNode(ref);
+
+ pDatasetsRoot->SetXMLMappingNode(pDatasetsXMLNode);
}
CXFA_Node *pDataRoot = nullptr, *pDDRoot = nullptr;
@@ -1672,8 +1676,11 @@ void CXFA_Document::DoDataMerge() {
if (!pDataRoot) {
pDataRoot = CreateNode(XFA_PacketType::Datasets, XFA_Element::DataGroup);
pDataRoot->JSObject()->SetCData(XFA_Attribute::Name, L"data", false, false);
- pDataRoot->SetXMLMappingNode(
- pdfium::MakeUnique<CFX_XMLElement>(L"xfa:data"));
+
+ auto* elem =
+ notify_->GetHDOC()->GetXMLDocument()->CreateNode<CFX_XMLElement>(
+ L"xfa:data");
+ pDataRoot->SetXMLMappingNode(elem);
pDatasetsRoot->InsertChild(pDataRoot, nullptr);
}
@@ -1727,8 +1734,11 @@ void CXFA_Document::DoDataMerge() {
CreateNode(XFA_PacketType::Datasets, XFA_Element::DataGroup));
pDataTopLevel->JSObject()->SetCData(XFA_Attribute::Name, wsDataTopLevelName,
false, false);
- pDataTopLevel->SetXMLMappingNode(
- pdfium::MakeUnique<CFX_XMLElement>(wsDataTopLevelName));
+
+ auto* elem =
+ notify_->GetHDOC()->GetXMLDocument()->CreateNode<CFX_XMLElement>(
+ wsDataTopLevelName);
+ pDataTopLevel->SetXMLMappingNode(elem);
CXFA_Node* pBeforeNode = pDataRoot->GetFirstChild();
pDataRoot->InsertChild(pDataTopLevel, pBeforeNode);