diff options
author | Lei Zhang <thestig@chromium.org> | 2017-11-22 20:05:32 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-22 20:05:32 +0000 |
commit | a27e55e1c8c04fa85e2132e98e92b42d1a084b1f (patch) | |
tree | 615b1f5d4aa301e37fde3886b3ff1a8d9b2f732c | |
parent | e6dba0dcc2c399e92b2ed7029a5241726f38938f (diff) | |
download | pdfium-a27e55e1c8c04fa85e2132e98e92b42d1a084b1f.tar.xz |
Change CPDF_ContentMark to return size_t for counts.
Change-Id: I45468fa7944290fbbe3d2e67f884164ae8d84160
Reviewed-on: https://pdfium-review.googlesource.com/19171
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r-- | core/fpdfapi/page/cpdf_contentmark.cpp | 11 | ||||
-rw-r--r-- | core/fpdfapi/page/cpdf_contentmark.h | 8 | ||||
-rw-r--r-- | core/fpdfdoc/cpdf_occontext.cpp | 2 | ||||
-rw-r--r-- | core/fpdftext/cpdf_textpage.cpp | 17 |
4 files changed, 19 insertions, 19 deletions
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp index b28d4eaada..1d70edeb51 100644 --- a/core/fpdfapi/page/cpdf_contentmark.cpp +++ b/core/fpdfapi/page/cpdf_contentmark.cpp @@ -9,7 +9,6 @@ #include <utility> #include "core/fpdfapi/parser/cpdf_dictionary.h" -#include "third_party/base/stl_util.h" CPDF_ContentMark::CPDF_ContentMark() {} @@ -18,11 +17,11 @@ CPDF_ContentMark::CPDF_ContentMark(const CPDF_ContentMark& that) CPDF_ContentMark::~CPDF_ContentMark() {} -int CPDF_ContentMark::CountItems() const { +size_t CPDF_ContentMark::CountItems() const { return m_Ref.GetObject()->CountItems(); } -const CPDF_ContentMarkItem& CPDF_ContentMark::GetItem(int i) const { +const CPDF_ContentMarkItem& CPDF_ContentMark::GetItem(size_t i) const { return m_Ref.GetObject()->GetItem(i); } @@ -45,12 +44,12 @@ CPDF_ContentMark::MarkData::MarkData(const MarkData& src) CPDF_ContentMark::MarkData::~MarkData() {} -int CPDF_ContentMark::MarkData::CountItems() const { - return pdfium::CollectionSize<int>(m_Marks); +size_t CPDF_ContentMark::MarkData::CountItems() const { + return m_Marks.size(); } const CPDF_ContentMarkItem& CPDF_ContentMark::MarkData::GetItem( - int index) const { + size_t index) const { return m_Marks[index]; } diff --git a/core/fpdfapi/page/cpdf_contentmark.h b/core/fpdfapi/page/cpdf_contentmark.h index f9a891017e..cb22737ca9 100644 --- a/core/fpdfapi/page/cpdf_contentmark.h +++ b/core/fpdfapi/page/cpdf_contentmark.h @@ -21,8 +21,8 @@ class CPDF_ContentMark { CPDF_ContentMark(const CPDF_ContentMark& that); ~CPDF_ContentMark(); - int CountItems() const; - const CPDF_ContentMarkItem& GetItem(int i) const; + size_t CountItems() const; + const CPDF_ContentMarkItem& GetItem(size_t i) const; void AddMark(const ByteString& name, CPDF_Dictionary* pDict, bool bDirect); void DeleteLastMark(); @@ -36,8 +36,8 @@ class CPDF_ContentMark { MarkData(const MarkData& src); ~MarkData(); - int CountItems() const; - const CPDF_ContentMarkItem& GetItem(int index) const; + size_t CountItems() const; + const CPDF_ContentMarkItem& GetItem(size_t index) const; void AddMark(const ByteString& name, CPDF_Dictionary* pDict, diff --git a/core/fpdfdoc/cpdf_occontext.cpp b/core/fpdfdoc/cpdf_occontext.cpp index 069292c65b..e59690996c 100644 --- a/core/fpdfdoc/cpdf_occontext.cpp +++ b/core/fpdfdoc/cpdf_occontext.cpp @@ -181,7 +181,7 @@ bool CPDF_OCContext::GetOCGVisible(const CPDF_Dictionary* pOCGDict) { } bool CPDF_OCContext::CheckObjectVisible(const CPDF_PageObject* pObj) { - for (int i = 0; i < pObj->m_ContentMark.CountItems(); i++) { + for (size_t i = 0; i < pObj->m_ContentMark.CountItems(); ++i) { const CPDF_ContentMarkItem& item = pObj->m_ContentMark.GetItem(i); if (item.GetName() == "OC" && item.GetParamType() == CPDF_ContentMarkItem::PropertiesDict && diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 485fba24a8..edd5456c1a 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -810,16 +810,15 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { if (!pTextObj->m_ContentMark.HasRef()) return FPDFText_MarkedContent::Pass; - int nContentMark = pTextObj->m_ContentMark.CountItems(); + size_t nContentMark = pTextObj->m_ContentMark.CountItems(); if (nContentMark < 1) return FPDFText_MarkedContent::Pass; WideString actText; bool bExist = false; CPDF_Dictionary* pDict = nullptr; - int n = 0; - for (n = 0; n < nContentMark; n++) { - const CPDF_ContentMarkItem& item = pTextObj->m_ContentMark.GetItem(n); + for (size_t i = 0; i < nContentMark; ++i) { + const CPDF_ContentMarkItem& item = pTextObj->m_ContentMark.GetItem(i); pDict = item.GetParam(); if (!pDict) continue; @@ -832,10 +831,12 @@ FPDFText_MarkedContent CPDF_TextPage::PreMarkedContent(PDFTEXT_Obj Obj) { if (!bExist) return FPDFText_MarkedContent::Pass; - if (m_pPreTextObj && m_pPreTextObj->m_ContentMark.HasRef() && - m_pPreTextObj->m_ContentMark.CountItems() == n && - pDict == m_pPreTextObj->m_ContentMark.GetItem(n - 1).GetParam()) { - return FPDFText_MarkedContent::Done; + if (m_pPreTextObj) { + const CPDF_ContentMark& mark = m_pPreTextObj->m_ContentMark; + if (mark.HasRef() && mark.CountItems() == nContentMark && + mark.GetItem(nContentMark - 1).GetParam() == pDict) { + return FPDFText_MarkedContent::Done; + } } if (actText.IsEmpty()) |