diff options
author | dan sinclair <dsinclair@chromium.org> | 2018-04-17 21:34:18 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-17 21:34:18 +0000 |
commit | 13aa65a71294cac6e4bdaab73ddd6f4b9fcd8676 (patch) | |
tree | 478874bff3e2831949884adfe750a4924832eb54 /core/fxcrt/xml/cfx_xmlnode.h | |
parent | 35939f83e45b67de4ccc8c3e70e5e00be40326b6 (diff) | |
download | pdfium-13aa65a71294cac6e4bdaab73ddd6f4b9fcd8676.tar.xz |
Add ownership to CFX_XMLNode children
This CL sets the CFX_XML tree ownership. The pointers set into the tree
must be unique_ptrs and the CFX_XMLNode children are set to be either
unique_ptrs or UnownedPtrs.
Change-Id: Ib0db495c81471e40f5b4533503f7bbe5a784fd77
Reviewed-on: https://pdfium-review.googlesource.com/30711
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cfx_xmlnode.h')
-rw-r--r-- | core/fxcrt/xml/cfx_xmlnode.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/core/fxcrt/xml/cfx_xmlnode.h b/core/fxcrt/xml/cfx_xmlnode.h index 86b5e998e6..d46ab9b29d 100644 --- a/core/fxcrt/xml/cfx_xmlnode.h +++ b/core/fxcrt/xml/cfx_xmlnode.h @@ -35,12 +35,12 @@ class CFX_XMLNode { virtual void Save(const RetainPtr<IFX_SeekableStream>& pXMLStream); CFX_XMLNode* GetRoot(); - CFX_XMLNode* GetParent() const { return parent_; } - CFX_XMLNode* GetFirstChild() const { return first_child_; } - CFX_XMLNode* GetNextSibling() const { return next_sibling_; } + CFX_XMLNode* GetParent() const { return parent_.Get(); } + CFX_XMLNode* GetFirstChild() const { return first_child_.get(); } + CFX_XMLNode* GetNextSibling() const { return next_sibling_.get(); } - void AppendChild(CFX_XMLNode* pNode); - void InsertChildNode(CFX_XMLNode* pNode, int32_t index); + void AppendChild(std::unique_ptr<CFX_XMLNode> pNode); + void InsertChildNode(std::unique_ptr<CFX_XMLNode> pNode, int32_t index); void RemoveChildNode(CFX_XMLNode* pNode); void DeleteChildren(); @@ -48,11 +48,13 @@ class CFX_XMLNode { WideString EncodeEntities(const WideString& value); private: - CFX_XMLNode* parent_ = nullptr; - CFX_XMLNode* next_sibling_ = nullptr; - CFX_XMLNode* prev_sibling_ = nullptr; - CFX_XMLNode* first_child_ = nullptr; - CFX_XMLNode* last_child_ = nullptr; + // A node owns it's first child and it owns it's next sibling. The rest + // are unowned pointers. + UnownedPtr<CFX_XMLNode> parent_; + UnownedPtr<CFX_XMLNode> last_child_; + UnownedPtr<CFX_XMLNode> prev_sibling_; + std::unique_ptr<CFX_XMLNode> first_child_; + std::unique_ptr<CFX_XMLNode> next_sibling_; }; #endif // CORE_FXCRT_XML_CFX_XMLNODE_H_ |