summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_page
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-04-11 10:02:09 -0700
committerWei Li <weili@chromium.org>2016-04-11 10:02:09 -0700
commite1aebd43b0c75133f94f8b141b33d12e2e715524 (patch)
tree863aded8c706db162eb3f69d6482100f9d61b842 /core/fpdfapi/fpdf_page
parent2d4a4fc372159ac7562abea48498b6ab72c2f321 (diff)
downloadpdfium-e1aebd43b0c75133f94f8b141b33d12e2e715524.tar.xz
Use std::vector as internal storage for CPDF_Array
Replace the usage of CFX_ArrayTemplate inside CPDF_Array, which has non-standard APIs such as GetSize() returns int. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1867183002 .
Diffstat (limited to 'core/fpdfapi/fpdf_page')
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_allstates.cpp5
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp8
-rw-r--r--core/fpdfapi/fpdf_page/cpdf_shadingpattern.h2
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser.cpp14
4 files changed, 14 insertions, 15 deletions
diff --git a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
index f2d637f888..4fe5283251 100644
--- a/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_allstates.cpp
@@ -46,10 +46,9 @@ void CPDF_AllStates::SetLineDash(CPDF_Array* pArray,
FX_FLOAT scale) {
CFX_GraphStateData* pData = m_GraphState.GetModify();
pData->m_DashPhase = phase * scale;
- pData->SetDashCount(pArray->GetCount());
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
+ pData->SetDashCount(static_cast<int>(pArray->GetCount()));
+ for (size_t i = 0; i < pArray->GetCount(); i++)
pData->m_DashArray[i] = pArray->GetNumberAt(i) * scale;
- }
}
void CPDF_AllStates::ProcessExtGS(CPDF_Dictionary* pGS,
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
index f637a4463c..457de9667a 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.cpp
@@ -48,7 +48,7 @@ CPDF_ShadingPattern::CPDF_ShadingPattern(CPDF_Document* pDoc,
}
CPDF_ShadingPattern::~CPDF_ShadingPattern() {
- for (int i = 0; i < m_nFuncs; ++i)
+ for (size_t i = 0; i < m_nFuncs; ++i)
delete m_pFunctions[i];
CPDF_ColorSpace* pCS = m_pCountedCS ? m_pCountedCS->get() : nullptr;
@@ -66,16 +66,16 @@ FX_BOOL CPDF_ShadingPattern::Load() {
return FALSE;
if (m_nFuncs) {
- for (int i = 0; i < m_nFuncs; i++)
+ for (size_t i = 0; i < m_nFuncs; i++)
delete m_pFunctions[i];
m_nFuncs = 0;
}
CPDF_Object* pFunc = pShadingDict->GetDirectObjectBy("Function");
if (pFunc) {
if (CPDF_Array* pArray = pFunc->AsArray()) {
- m_nFuncs = std::min<int>(pArray->GetCount(), 4);
+ m_nFuncs = std::min<size_t>(pArray->GetCount(), 4);
- for (int i = 0; i < m_nFuncs; i++)
+ for (size_t i = 0; i < m_nFuncs; i++)
m_pFunctions[i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i));
} else {
m_pFunctions[0] = CPDF_Function::Load(pFunc);
diff --git a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
index 55a249a1bc..c9bbd07d2e 100644
--- a/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
+++ b/core/fpdfapi/fpdf_page/cpdf_shadingpattern.h
@@ -56,7 +56,7 @@ class CPDF_ShadingPattern : public CPDF_Pattern {
CPDF_CountedColorSpace* m_pCountedCS;
CPDF_Function* m_pFunctions[4];
- int m_nFuncs;
+ size_t m_nFuncs;
};
#endif // CORE_FPDFAPI_FPDF_PAGE_CPDF_SHADINGPATTERN_H_
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 21edc9e0cd..ba2901df24 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -1418,14 +1418,14 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
if (!pArray) {
return;
}
- int n = pArray->GetCount();
- int nsegs = 0;
- for (int i = 0; i < n; i++) {
+ size_t n = pArray->GetCount();
+ size_t nsegs = 0;
+ for (size_t i = 0; i < n; i++) {
if (pArray->GetDirectObjectAt(i)->IsString())
nsegs++;
}
if (nsegs == 0) {
- for (int i = 0; i < n; i++) {
+ for (size_t i = 0; i < n; i++) {
m_pCurStates->m_TextX -=
(pArray->GetNumberAt(i) * m_pCurStates->m_TextState.GetFontSize()) /
1000;
@@ -1434,9 +1434,9 @@ void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
}
CFX_ByteString* pStrs = new CFX_ByteString[nsegs];
FX_FLOAT* pKerning = FX_Alloc(FX_FLOAT, nsegs);
- int iSegment = 0;
+ size_t iSegment = 0;
FX_FLOAT fInitKerning = 0;
- for (int i = 0; i < n; i++) {
+ for (size_t i = 0; i < n; i++) {
CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
if (pObj->IsString()) {
CFX_ByteString str = pObj->GetString();
@@ -1801,7 +1801,7 @@ void PDF_ReplaceAbbr(CPDF_Object* pObj) {
}
case CPDF_Object::ARRAY: {
CPDF_Array* pArray = pObj->AsArray();
- for (uint32_t i = 0; i < pArray->GetCount(); i++) {
+ for (size_t i = 0; i < pArray->GetCount(); i++) {
CPDF_Object* pElement = pArray->GetObjectAt(i);
if (pElement->IsName()) {
CFX_ByteString name = pElement->GetString();