summaryrefslogtreecommitdiff
path: root/core/fxcrt/xml/cxml_element.cpp
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-12-13 14:36:52 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-12-13 14:36:52 +0000
commit9a3a077e4820efa035eca4aec7e93fbd1298d6cb (patch)
tree682e7861f7d7148e3b0d24646397d226e9262366 /core/fxcrt/xml/cxml_element.cpp
parentaa123edaf307ac238f3aa79d951ea4b991c1f7aa (diff)
downloadpdfium-9a3a077e4820efa035eca4aec7e93fbd1298d6cb.tar.xz
Use size_t in CXML_Element and callers.
Change-Id: I9ebacd18252a837f1f5f13ccaec19b196bacc3ae Reviewed-on: https://pdfium-review.googlesource.com/21072 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/xml/cxml_element.cpp')
-rw-r--r--core/fxcrt/xml/cxml_element.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/core/fxcrt/xml/cxml_element.cpp b/core/fxcrt/xml/cxml_element.cpp
index 9d3e22c8f9..f11fd1fe14 100644
--- a/core/fxcrt/xml/cxml_element.cpp
+++ b/core/fxcrt/xml/cxml_element.cpp
@@ -53,11 +53,11 @@ ByteString CXML_Element::GetNamespaceURI(const ByteString& qName) const {
return pwsSpace ? pwsSpace->UTF8Encode() : ByteString();
}
-void CXML_Element::GetAttrByIndex(int index,
+void CXML_Element::GetAttrByIndex(size_t index,
ByteString* space,
ByteString* name,
WideString* value) const {
- if (index < 0 || index >= m_AttrMap.GetSize())
+ if (index >= static_cast<size_t>(m_AttrMap.GetSize()))
return;
CXML_AttrItem& item = m_AttrMap.GetAt(index);
@@ -89,9 +89,9 @@ int CXML_Element::GetAttrInteger(const ByteStringView& name) const {
return pwsValue ? pwsValue->GetInteger() : 0;
}
-uint32_t CXML_Element::CountElements(const ByteStringView& space,
- const ByteStringView& tag) const {
- int count = 0;
+size_t CXML_Element::CountElements(const ByteStringView& space,
+ const ByteStringView& tag) const {
+ size_t count = 0;
for (const auto& pChild : m_Children) {
const CXML_Element* pKid = pChild->AsElement();
if (pKid && pKid->m_TagName == tag &&
@@ -102,22 +102,20 @@ uint32_t CXML_Element::CountElements(const ByteStringView& space,
return count;
}
-CXML_Object* CXML_Element::GetChild(uint32_t index) const {
+CXML_Object* CXML_Element::GetChild(size_t index) const {
return index < m_Children.size() ? m_Children[index].get() : nullptr;
}
CXML_Element* CXML_Element::GetElement(const ByteStringView& space,
const ByteStringView& tag,
- int nth) const {
- if (nth < 0)
- return nullptr;
-
+ size_t nth) const {
for (const auto& pChild : m_Children) {
CXML_Element* pKid = pChild->AsElement();
if (pKid && pKid->m_TagName == tag &&
(space.IsEmpty() || pKid->m_QSpaceName == space)) {
- if (nth-- == 0)
+ if (nth == 0)
return pKid;
+ --nth;
}
}
return nullptr;