summaryrefslogtreecommitdiff
path: root/core/fxcrt/xml/cfx_xmlelement.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_xmlelement.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_xmlelement.cpp')
-rw-r--r--core/fxcrt/xml/cfx_xmlelement.cpp36
1 files changed, 13 insertions, 23 deletions
diff --git a/core/fxcrt/xml/cfx_xmlelement.cpp b/core/fxcrt/xml/cfx_xmlelement.cpp
index 4eb3900c2f..530752e1dd 100644
--- a/core/fxcrt/xml/cfx_xmlelement.cpp
+++ b/core/fxcrt/xml/cfx_xmlelement.cpp
@@ -29,16 +29,10 @@ std::unique_ptr<CFX_XMLNode> CFX_XMLElement::Clone() {
pClone->SetAttributes(GetAttributes());
WideString wsText;
- CFX_XMLNode* pChild = GetFirstChild();
- while (pChild) {
- switch (pChild->GetType()) {
- case FX_XMLNODE_Text:
- wsText += static_cast<CFX_XMLText*>(pChild)->GetText();
- break;
- default:
- break;
- }
- pChild = pChild->GetNextSibling();
+ for (CFX_XMLNode* pChild = GetFirstChild(); pChild;
+ pChild = pChild->GetNextSibling()) {
+ if (pChild->GetType() == FX_XMLNODE_Text)
+ wsText += static_cast<CFX_XMLText*>(pChild)->GetText();
}
pClone->SetTextData(wsText);
return std::move(pClone);
@@ -81,17 +75,13 @@ WideString CFX_XMLElement::GetNamespaceURI() const {
WideString CFX_XMLElement::GetTextData() const {
CFX_WideTextBuf buffer;
- CFX_XMLNode* pChild = GetFirstChild();
- while (pChild) {
- switch (pChild->GetType()) {
- case FX_XMLNODE_Text:
- case FX_XMLNODE_CharData:
- buffer << static_cast<CFX_XMLText*>(pChild)->GetText();
- break;
- default:
- break;
+
+ for (CFX_XMLNode* pChild = GetFirstChild(); pChild;
+ pChild = pChild->GetNextSibling()) {
+ if (pChild->GetType() == FX_XMLNODE_Text ||
+ pChild->GetType() == FX_XMLNODE_CharData) {
+ buffer << static_cast<CFX_XMLText*>(pChild)->GetText();
}
- pChild = pChild->GetNextSibling();
}
return buffer.MakeString();
}
@@ -116,10 +106,10 @@ void CFX_XMLElement::Save(
if (GetFirstChild()) {
ws = L"\n>";
pXMLStream->WriteString(ws.AsStringView());
- CFX_XMLNode* pChild = GetFirstChild();
- while (pChild) {
+
+ for (CFX_XMLNode* pChild = GetFirstChild(); pChild;
+ pChild = pChild->GetNextSibling()) {
pChild->Save(pXMLStream);
- pChild = pChild->GetNextSibling();
}
ws = L"</";
ws += GetName();