xref: /aosp_15_r20/external/pdfium/core/fxcrt/xml/cfx_xmlnode.cpp (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2017 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "core/fxcrt/xml/cfx_xmlnode.h"
8 
9 CFX_XMLNode::CFX_XMLNode() = default;
10 
11 CFX_XMLNode::~CFX_XMLNode() = default;
12 
InsertChildNode(CFX_XMLNode * pNode,int32_t index)13 void CFX_XMLNode::InsertChildNode(CFX_XMLNode* pNode, int32_t index) {
14   InsertBefore(pNode, GetNthChild(index));
15 }
16 
GetRoot()17 CFX_XMLNode* CFX_XMLNode::GetRoot() {
18   CFX_XMLNode* pParent = this;
19   while (pParent->GetParent())
20     pParent = pParent->GetParent();
21 
22   return pParent;
23 }
24