summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/parser/cxfa_nodeiteratortemplate.h32
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_