diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-02-13 20:55:03 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-02-13 20:55:03 +0000 |
commit | 80bf582f00adeefae67ae432b74c3b0609e7845e (patch) | |
tree | 18c88bc620fcded6fc39cdfe3a5b0ae04643424d /xfa/fxfa/parser/cxfa_node.cpp | |
parent | 566d0b9486f024f253d1c331866b04529c9a22b3 (diff) | |
download | pdfium-80bf582f00adeefae67ae432b74c3b0609e7845e.tar.xz |
Cleanup CXFA_Node ownership
Currently a CXFA_Node can be owned by the CXFA_Document root pointer,
the CXFA_Document Purge list or as a child of another CXFA_Node. This
makes it hard to know who currently owns what.
This CL moves all ownership of nodes into a CXFA_NodeOwner class which
CXFA_Document subclasses. The node owner always owns all nodes and is
responsible for cleaning them up upon destruction. The destruction order
is not guarenteed to be in tree order as nodes can be inserted and moved
around the tree.
Change-Id: I6b202b8e844999ba835093dcdd1a808938b6d9a8
Reviewed-on: https://pdfium-review.googlesource.com/26434
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 83da3e76df..9159f020da 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -537,16 +537,7 @@ CXFA_Node::CXFA_Node(CXFA_Document* pDoc, pdfium::MakeUnique<CJX_Node>(this)) {} CXFA_Node::~CXFA_Node() { - ASSERT(!parent_); - - CXFA_Node* pNode = first_child_; - while (pNode) { - CXFA_Node* pNext = pNode->next_sibling_; - pNode->parent_ = nullptr; - delete pNode; - pNode = pNext; - } - if (m_pXMLNode && IsOwnXMLNode()) + if (m_pXMLNode && IsOwnedXMLNode()) delete m_pXMLNode; } @@ -1119,10 +1110,6 @@ void CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { pNode->parent_ = this; pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren); - bool ret = m_pDocument->RemovePurgeNode(pNode); - ASSERT(ret); - (void)ret; // Avoid unused variable warning. - if (!first_child_) { ASSERT(!last_child_); @@ -1221,8 +1208,6 @@ void CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { OnRemoved(bNotify); - m_pDocument->AddPurgeNode(pNode); - if (!IsNeedSavingXMLNode() || !pNode->m_pXMLNode) return; |