From 5e2cfb5310c9b25a5ce4c772a6656373309bc956 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 5 Oct 2017 12:11:03 -0400 Subject: Remove friends from CXML_Element This CL removes the friends from CXML_Element and adds accessors as needed. Change-Id: I4f76935caa753a063bef4ff2d043273ae4e14e14 Reviewed-on: https://pdfium-review.googlesource.com/15535 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- core/fxcrt/xml/cxml_element.h | 14 +++++++++++--- core/fxcrt/xml/cxml_parser.cpp | 7 +++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/fxcrt/xml/cxml_element.h b/core/fxcrt/xml/cxml_element.h index 40ebe385b7..a851a86f1c 100644 --- a/core/fxcrt/xml/cxml_element.h +++ b/core/fxcrt/xml/cxml_element.h @@ -8,6 +8,7 @@ #define CORE_FXCRT_XML_CXML_ELEMENT_H_ #include +#include #include #include "core/fxcrt/xml/cxml_attrmap.h" @@ -87,6 +88,10 @@ class CXML_Element : public CXML_Object { return attr; } + void AppendChild(std::unique_ptr child) { + m_Children.push_back(std::move(child)); + } + uint32_t CountChildren() const { return m_Children.size(); } uint32_t CountElements(const ByteStringView& space, const ByteStringView& tag) const; @@ -98,10 +103,13 @@ class CXML_Element : public CXML_Object { void SetTag(const ByteStringView& qTagName); void RemoveChild(uint32_t index); - private: - friend class CXML_Parser; - friend class CXML_Composer; + void SetAttribute(const ByteString& space, + const ByteString& name, + const WideString& value) { + m_AttrMap.SetAt(space, name, value); + } + private: UnownedPtr const m_pParent; ByteString m_QSpaceName; ByteString m_TagName; diff --git a/core/fxcrt/xml/cxml_parser.cpp b/core/fxcrt/xml/cxml_parser.cpp index adf83c7148..062b5bec07 100644 --- a/core/fxcrt/xml/cxml_parser.cpp +++ b/core/fxcrt/xml/cxml_parser.cpp @@ -424,7 +424,7 @@ std::unique_ptr CXML_Parser::ParseElementInternal( WideString attr_value; GetAttrValue(attr_value); - pElement->m_AttrMap.SetAt(attr_space, attr_name, attr_value); + pElement->SetAttribute(attr_space, attr_name, attr_value); } m_nOffset = m_nBufferOffset + static_cast(m_dwIndex); if (m_dwIndex < m_dwBufferSize || IsEOF()) @@ -498,7 +498,7 @@ std::unique_ptr CXML_Parser::ParseElementInternal( if (!pSubElement) break; - pElement->m_Children.push_back(std::move(pSubElement)); + pElement->AppendChild(std::move(pSubElement)); SkipWhiteSpaces(); } break; @@ -541,6 +541,5 @@ void CXML_Parser::InsertContentSegment(bool bCDATA, if (content.IsEmpty()) return; - pElement->m_Children.push_back( - pdfium::MakeUnique(bCDATA, content)); + pElement->AppendChild(pdfium::MakeUnique(bCDATA, content)); } -- cgit v1.2.3