summaryrefslogtreecommitdiff
path: root/core/fxcrt/xml/cfx_xmlnode.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-02-13 22:04:23 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-02-13 22:04:23 +0000
commit9bf1a5efde45cd99be11c530232df349c3eb5295 (patch)
treefc6ae5dfd030cc8bc9d35d5df61ff48f6bf97db0 /core/fxcrt/xml/cfx_xmlnode.cpp
parent815f5eba63db351b6b9b53ec6ad49890802f7fa1 (diff)
downloadpdfium-9bf1a5efde45cd99be11c530232df349c3eb5295.tar.xz
Add last_child to CFX_XMLNode
This CL adds the list_child_ member into CFX_XMLNode to keep it consistent with other tree's in the system. Change-Id: I2e64f11fb9c7df40dd3467edcce177fc492d2cd2 Reviewed-on: https://pdfium-review.googlesource.com/26670 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cfx_xmlnode.cpp')
-rw-r--r--core/fxcrt/xml/cfx_xmlnode.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/core/fxcrt/xml/cfx_xmlnode.cpp b/core/fxcrt/xml/cfx_xmlnode.cpp
index 6135907557..1851a4d81e 100644
--- a/core/fxcrt/xml/cfx_xmlnode.cpp
+++ b/core/fxcrt/xml/cfx_xmlnode.cpp
@@ -27,6 +27,7 @@ FX_XMLNODETYPE CFX_XMLNode::GetType() const {
void CFX_XMLNode::DeleteChildren() {
CFX_XMLNode* pChild = first_child_;
first_child_ = nullptr;
+ last_child_ = nullptr;
while (pChild) {
CFX_XMLNode* pNext = pChild->next_sibling_;
@@ -44,11 +45,15 @@ void CFX_XMLNode::InsertChildNode(CFX_XMLNode* pNode, int32_t index) {
pNode->parent_ = this;
if (!first_child_) {
+ ASSERT(!last_child_);
+
first_child_ = pNode;
+ last_child_ = pNode;
pNode->prev_sibling_ = nullptr;
pNode->next_sibling_ = nullptr;
return;
}
+
if (index == 0) {
pNode->next_sibling_ = first_child_;
pNode->prev_sibling_ = nullptr;
@@ -66,7 +71,10 @@ void CFX_XMLNode::InsertChildNode(CFX_XMLNode* pNode, int32_t index) {
pNode->next_sibling_ = pFind->next_sibling_;
if (pFind->next_sibling_)
pFind->next_sibling_->prev_sibling_ = pNode;
+
pFind->next_sibling_ = pNode;
+ if (pFind == last_child_)
+ last_child_ = pNode;
}
void CFX_XMLNode::RemoveChildNode(CFX_XMLNode* pNode) {
@@ -77,6 +85,9 @@ void CFX_XMLNode::RemoveChildNode(CFX_XMLNode* pNode) {
else
pNode->prev_sibling_->next_sibling_ = pNode->next_sibling_;
+ if (last_child_ == pNode)
+ last_child_ = pNode->prev_sibling_;
+
if (pNode->next_sibling_)
pNode->next_sibling_->prev_sibling_ = pNode->prev_sibling_;