From c0c32b0a3af11624a1f3eaeb9d940d525b54cd4d Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 7 Feb 2018 17:10:22 +0000 Subject: Remove unused return values from CXFA_Node This CL removes the unused return values from InsertChild and RemoveChild methods in CXFA_Node. Bug: chromium:807863 Change-Id: Iac468afc5c48f51e7df3ea12d11b128a0ac124ea Reviewed-on: https://pdfium-review.googlesource.com/25670 Commit-Queue: dsinclair Reviewed-by: Henrique Nakashima Reviewed-by: Ryan Harrison --- xfa/fxfa/parser/cxfa_arraynodelist.cpp | 9 +++----- xfa/fxfa/parser/cxfa_arraynodelist.h | 6 ++--- xfa/fxfa/parser/cxfa_attachnodelist.cpp | 12 +++++----- xfa/fxfa/parser/cxfa_attachnodelist.h | 6 ++--- xfa/fxfa/parser/cxfa_list.h | 6 ++--- xfa/fxfa/parser/cxfa_node.cpp | 41 ++++++++++++++++++--------------- xfa/fxfa/parser/cxfa_node.h | 6 ++--- 7 files changed, 43 insertions(+), 43 deletions(-) (limited to 'xfa') diff --git a/xfa/fxfa/parser/cxfa_arraynodelist.cpp b/xfa/fxfa/parser/cxfa_arraynodelist.cpp index 9eaf9a6c33..8bb200e1b2 100644 --- a/xfa/fxfa/parser/cxfa_arraynodelist.cpp +++ b/xfa/fxfa/parser/cxfa_arraynodelist.cpp @@ -25,12 +25,11 @@ size_t CXFA_ArrayNodeList::GetLength() { return m_array.size(); } -bool CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { +void CXFA_ArrayNodeList::Append(CXFA_Node* pNode) { m_array.push_back(pNode); - return true; } -bool CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) { +void CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) { if (!pBeforeNode) { m_array.push_back(pNewNode); } else { @@ -38,14 +37,12 @@ bool CXFA_ArrayNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) { if (it != m_array.end()) m_array.insert(it, pNewNode); } - return true; } -bool CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) { +void CXFA_ArrayNodeList::Remove(CXFA_Node* pNode) { auto it = std::find(m_array.begin(), m_array.end(), pNode); if (it != m_array.end()) m_array.erase(it); - return true; } CXFA_Node* CXFA_ArrayNodeList::Item(size_t index) { diff --git a/xfa/fxfa/parser/cxfa_arraynodelist.h b/xfa/fxfa/parser/cxfa_arraynodelist.h index 346b206f20..dc798bcd59 100644 --- a/xfa/fxfa/parser/cxfa_arraynodelist.h +++ b/xfa/fxfa/parser/cxfa_arraynodelist.h @@ -21,9 +21,9 @@ class CXFA_ArrayNodeList : public CXFA_TreeList { // From CXFA_TreeList. size_t GetLength() override; - bool Append(CXFA_Node* pNode) override; - bool Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) override; - bool Remove(CXFA_Node* pNode) override; + void Append(CXFA_Node* pNode) override; + void Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) override; + void Remove(CXFA_Node* pNode) override; CXFA_Node* Item(size_t iIndex) override; void SetArrayNodeList(const std::vector& srcArray); diff --git a/xfa/fxfa/parser/cxfa_attachnodelist.cpp b/xfa/fxfa/parser/cxfa_attachnodelist.cpp index f1fbfa784b..4e6a678162 100644 --- a/xfa/fxfa/parser/cxfa_attachnodelist.cpp +++ b/xfa/fxfa/parser/cxfa_attachnodelist.cpp @@ -21,24 +21,24 @@ size_t CXFA_AttachNodeList::GetLength() { m_pAttachNode->GetElementType() == XFA_Element::Subform); } -bool CXFA_AttachNodeList::Append(CXFA_Node* pNode) { +void CXFA_AttachNodeList::Append(CXFA_Node* pNode) { CXFA_Node* pParent = pNode->GetParent(); if (pParent) pParent->RemoveChild(pNode, true); - return m_pAttachNode->InsertChild(pNode, nullptr); + m_pAttachNode->InsertChild(pNode, nullptr); } -bool CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) { +void CXFA_AttachNodeList::Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) { CXFA_Node* pParent = pNewNode->GetParent(); if (pParent) pParent->RemoveChild(pNewNode, true); - return m_pAttachNode->InsertChild(pNewNode, pBeforeNode); + m_pAttachNode->InsertChild(pNewNode, pBeforeNode); } -bool CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { - return m_pAttachNode->RemoveChild(pNode, true); +void CXFA_AttachNodeList::Remove(CXFA_Node* pNode) { + m_pAttachNode->RemoveChild(pNode, true); } CXFA_Node* CXFA_AttachNodeList::Item(size_t index) { diff --git a/xfa/fxfa/parser/cxfa_attachnodelist.h b/xfa/fxfa/parser/cxfa_attachnodelist.h index f0df2bb4d8..cb41b73797 100644 --- a/xfa/fxfa/parser/cxfa_attachnodelist.h +++ b/xfa/fxfa/parser/cxfa_attachnodelist.h @@ -18,9 +18,9 @@ class CXFA_AttachNodeList : public CXFA_TreeList { // From CXFA_TreeList. size_t GetLength() override; - bool Append(CXFA_Node* pNode) override; - bool Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) override; - bool Remove(CXFA_Node* pNode) override; + void Append(CXFA_Node* pNode) override; + void Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) override; + void Remove(CXFA_Node* pNode) override; CXFA_Node* Item(size_t iIndex) override; private: diff --git a/xfa/fxfa/parser/cxfa_list.h b/xfa/fxfa/parser/cxfa_list.h index de9406dd06..6618286317 100644 --- a/xfa/fxfa/parser/cxfa_list.h +++ b/xfa/fxfa/parser/cxfa_list.h @@ -18,9 +18,9 @@ class CXFA_List : public CXFA_Object { ~CXFA_List() override; virtual size_t GetLength() = 0; - virtual bool Append(CXFA_Node* pNode) = 0; - virtual bool Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) = 0; - virtual bool Remove(CXFA_Node* pNode) = 0; + virtual void Append(CXFA_Node* pNode) = 0; + virtual void Insert(CXFA_Node* pNewNode, CXFA_Node* pBeforeNode) = 0; + virtual void Remove(CXFA_Node* pNode) = 0; virtual CXFA_Node* Item(size_t iIndex) = 0; protected: diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index be56b413b6..9af2b2e75a 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -1118,8 +1118,8 @@ CXFA_Node* CXFA_Node::GetChildInternal(size_t index, return nullptr; } -int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { - ASSERT(!pNode->m_pNext); +void CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { + ASSERT(!pNode->parent_); pNode->parent_ = this; bool ret = m_pDocument->RemovePurgeNode(pNode); @@ -1127,9 +1127,9 @@ int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { (void)ret; // Avoid unused variable warning. if (!m_pChild || index == 0) { - if (index > 0) { - return -1; - } + if (index > 0) + return; + pNode->m_pNext = m_pChild; m_pChild = pNode; index = 0; @@ -1138,21 +1138,22 @@ int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { } else { CXFA_Node* pPrev = m_pChild; int32_t iCount = 0; - while (++iCount != index && pPrev->m_pNext) { + while (++iCount != index && pPrev->m_pNext) pPrev = pPrev->m_pNext; - } - if (index > 0 && index != iCount) { - return -1; - } + + if (index > 0 && index != iCount) + return; + pNode->m_pNext = pPrev->m_pNext; pPrev->m_pNext = pNode; index = iCount; } - if (!pNode->m_pNext) { + if (!pNode->m_pNext) m_pLastChild = pNode; - } + ASSERT(m_pLastChild); ASSERT(!m_pLastChild->m_pNext); + pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren); CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); if (pNotify) @@ -1160,18 +1161,19 @@ int32_t CXFA_Node::InsertChild(int32_t index, CXFA_Node* pNode) { if (IsNeedSavingXMLNode() && pNode->m_pXMLNode) { ASSERT(!pNode->m_pXMLNode->GetNodeItem(CFX_XMLNode::Parent)); + m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, index); pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); } - return index; } -bool CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { +void CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { if (!pNode || pNode->parent_ || (pBeforeNode && pBeforeNode->parent_ != this)) { NOTREACHED(); - return false; + return; } + bool ret = m_pDocument->RemovePurgeNode(pNode); ASSERT(ret); (void)ret; // Avoid unused variable warning. @@ -1198,8 +1200,10 @@ bool CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { if (!pNode->m_pNext) { m_pLastChild = pNode; } + ASSERT(m_pLastChild); ASSERT(!m_pLastChild->m_pNext); + pNode->ClearFlag(XFA_NodeFlag_HasRemovedChildren); CXFA_FFNotify* pNotify = m_pDocument->GetNotify(); if (pNotify) @@ -1210,7 +1214,6 @@ bool CXFA_Node::InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode) { m_pXMLNode->InsertChildNode(pNode->m_pXMLNode, nIndex); pNode->ClearFlag(XFA_NodeFlag_OwnXMLNode); } - return true; } CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { @@ -1226,10 +1229,10 @@ CXFA_Node* CXFA_Node::Deprecated_GetPrevSibling() { return nullptr; } -bool CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { +void CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { if (!pNode || pNode->parent_ != this) { NOTREACHED(); - return false; + return; } if (m_pChild == pNode) { @@ -1246,6 +1249,7 @@ bool CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { pNode->parent_ = nullptr; ASSERT(!m_pLastChild || !m_pLastChild->m_pNext); + OnRemoved(bNotify); pNode->SetFlag(XFA_NodeFlag_HasRemovedChildren, true); m_pDocument->AddPurgeNode(pNode); @@ -1277,7 +1281,6 @@ bool CXFA_Node::RemoveChild(CXFA_Node* pNode, bool bNotify) { } pNode->SetFlag(XFA_NodeFlag_OwnXMLNode, false); } - return true; } CXFA_Node* CXFA_Node::GetFirstChildByName(const WideStringView& wsName) const { diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 27bdab0195..c3b2fd1b84 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -172,9 +172,9 @@ class CXFA_Node : public CXFA_Object { return static_cast(GetChildInternal(index, eType, bOnlyChild)); } - int32_t InsertChild(int32_t index, CXFA_Node* pNode); - bool InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode); - bool RemoveChild(CXFA_Node* pNode, bool bNotify); + void InsertChild(int32_t index, CXFA_Node* pNode); + void InsertChild(CXFA_Node* pNode, CXFA_Node* pBeforeNode); + void RemoveChild(CXFA_Node* pNode, bool bNotify); CXFA_Node* Clone(bool bRecursive); -- cgit v1.2.3