summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_nodeowner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser/cxfa_nodeowner.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_nodeowner.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_nodeowner.cpp b/xfa/fxfa/parser/cxfa_nodeowner.cpp
new file mode 100644
index 0000000000..ae6f589616
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_nodeowner.cpp
@@ -0,0 +1,35 @@
+// Copyright 2018 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_nodeowner.h"
+
+#include <utility>
+
+#include "third_party/base/stl_util.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
+
+CXFA_NodeOwner::CXFA_NodeOwner() = default;
+
+CXFA_NodeOwner::~CXFA_NodeOwner() = default;
+
+CXFA_Node* CXFA_NodeOwner::AddOwnedNode(std::unique_ptr<CXFA_Node> node) {
+ if (!node)
+ return nullptr;
+
+ CXFA_Node* ret = node.get();
+ nodes_.insert(std::move(node));
+ return ret;
+}
+
+void CXFA_NodeOwner::FreeOwnedNode(CXFA_Node* node) {
+ if (!node)
+ return;
+
+ pdfium::FakeUniquePtr<CXFA_Node> search(node);
+ auto it = nodes_.find(search);
+ assert(it != nodes_.end());
+ nodes_.erase(it);
+}