diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-07-03 20:49:46 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-03 20:49:46 +0000 |
commit | 57e594f047f86bfa4d26864e993ce330ad66bfcd (patch) | |
tree | 095991c67b21c764e7249ef6263031f4728ed3de /xfa/fxfa/parser | |
parent | 82dafa4f1dd607561f6852c50c15b03977389dc2 (diff) | |
download | pdfium-57e594f047f86bfa4d26864e993ce330ad66bfcd.tar.xz |
Use UnownedPtr<> in cxfa_nodeiteratortemplate.h
Change-Id: I48c20a56ca25a6821bc9b51aa59c037fe2341194
Reviewed-on: https://pdfium-review.googlesource.com/36972
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r-- | xfa/fxfa/parser/cxfa_nodeiteratortemplate.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/xfa/fxfa/parser/cxfa_nodeiteratortemplate.h b/xfa/fxfa/parser/cxfa_nodeiteratortemplate.h index 214f38e501..10543fdbcf 100644 --- a/xfa/fxfa/parser/cxfa_nodeiteratortemplate.h +++ b/xfa/fxfa/parser/cxfa_nodeiteratortemplate.h @@ -7,14 +7,16 @@ #ifndef XFA_FXFA_PARSER_CXFA_NODEITERATORTEMPLATE_H_ #define XFA_FXFA_PARSER_CXFA_NODEITERATORTEMPLATE_H_ +#include "core/fxcrt/unowned_ptr.h" + template <class NodeType, class TraverseStrategy> class CXFA_NodeIteratorTemplate { public: explicit CXFA_NodeIteratorTemplate(NodeType* pRoot) : m_pRoot(pRoot), m_pCurrent(pRoot) {} - NodeType* GetRoot() const { return m_pRoot; } - NodeType* GetCurrent() const { return m_pCurrent; } + NodeType* GetRoot() const { return m_pRoot.Get(); } + NodeType* GetCurrent() const { return m_pCurrent.Get(); } void Reset() { m_pCurrent = m_pRoot; } bool SetCurrent(NodeType* pNode) { @@ -30,18 +32,18 @@ class CXFA_NodeIteratorTemplate { if (!m_pRoot) return nullptr; if (!m_pCurrent) { - m_pCurrent = LastDescendant(m_pRoot); - return m_pCurrent; + m_pCurrent = LastDescendant(m_pRoot.Get()); + return m_pCurrent.Get(); } - NodeType* pSibling = PreviousSiblingWithinSubtree(m_pCurrent); + NodeType* pSibling = PreviousSiblingWithinSubtree(m_pCurrent.Get()); if (pSibling) { m_pCurrent = LastDescendant(pSibling); - return m_pCurrent; + return m_pCurrent.Get(); } - NodeType* pParent = ParentWithinSubtree(m_pCurrent); + NodeType* pParent = ParentWithinSubtree(m_pCurrent.Get()); if (pParent) { m_pCurrent = pParent; - return m_pCurrent; + return pParent; } return nullptr; } @@ -49,10 +51,10 @@ class CXFA_NodeIteratorTemplate { NodeType* MoveToNext() { if (!m_pRoot || !m_pCurrent) return nullptr; - NodeType* pChild = TraverseStrategy::GetFirstChild(m_pCurrent); + NodeType* pChild = TraverseStrategy::GetFirstChild(m_pCurrent.Get()); if (pChild) { m_pCurrent = pChild; - return m_pCurrent; + return pChild; } return SkipChildrenAndMoveToNext(); } @@ -60,17 +62,17 @@ class CXFA_NodeIteratorTemplate { NodeType* SkipChildrenAndMoveToNext() { if (!m_pRoot) return nullptr; - NodeType* pNode = m_pCurrent; + NodeType* pNode = m_pCurrent.Get(); while (pNode) { NodeType* pSibling = NextSiblingWithinSubtree(pNode); if (pSibling) { m_pCurrent = pSibling; - return m_pCurrent; + return pSibling; } pNode = ParentWithinSubtree(pNode); } m_pCurrent = nullptr; - return m_pCurrent; + return nullptr; } private: @@ -122,8 +124,8 @@ class CXFA_NodeIteratorTemplate { return pChild ? LastDescendant(pChild) : pNode; } - NodeType* m_pRoot; - NodeType* m_pCurrent; + UnownedPtr<NodeType> m_pRoot; + UnownedPtr<NodeType> m_pCurrent; }; #endif // XFA_FXFA_PARSER_CXFA_NODEITERATORTEMPLATE_H_ |