summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-27 18:35:06 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-27 18:35:06 +0000
commit2d950563beb291441c0e1c90cfde8227f7025327 (patch)
treef8b04259830c23510cb79b282b39a14098d32984
parentf351ba03ebf31103c0a6a0c00b1477d39c060139 (diff)
downloadpdfium-2d950563beb291441c0e1c90cfde8227f7025327.tar.xz
Convert CPDF_ClipPath::Get{Path|Text}Count to size_t
This CL updates the various call sites to use size_t instead of other types. Bug: pdfium:774 Change-Id: Id8b75728b61c0ca1b15bc815831c885d33374f7b Reviewed-on: https://pdfium-review.googlesource.com/19410 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
-rw-r--r--core/fpdfapi/page/cpdf_clippath.cpp52
-rw-r--r--core/fpdfapi/page/cpdf_clippath.h4
-rw-r--r--core/fpdfapi/page/cpdf_contentparser.cpp3
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp21
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp6
5 files changed, 40 insertions, 46 deletions
diff --git a/core/fpdfapi/page/cpdf_clippath.cpp b/core/fpdfapi/page/cpdf_clippath.cpp
index 714b56bff3..465a2d3549 100644
--- a/core/fpdfapi/page/cpdf_clippath.cpp
+++ b/core/fpdfapi/page/cpdf_clippath.cpp
@@ -10,7 +10,6 @@
#include "core/fpdfapi/page/cpdf_path.h"
#include "core/fpdfapi/page/cpdf_textobject.h"
-#include "third_party/base/stl_util.h"
#define FPDF_CLIPPATH_MAX_TEXTS 1024
@@ -20,8 +19,8 @@ CPDF_ClipPath::CPDF_ClipPath(const CPDF_ClipPath& that) : m_Ref(that.m_Ref) {}
CPDF_ClipPath::~CPDF_ClipPath() {}
-uint32_t CPDF_ClipPath::GetPathCount() const {
- return pdfium::CollectionSize<uint32_t>(m_Ref.GetObject()->m_PathAndTypeList);
+size_t CPDF_ClipPath::GetPathCount() const {
+ return m_Ref.GetObject()->m_PathAndTypeList.size();
}
CPDF_Path CPDF_ClipPath::GetPath(size_t i) const {
@@ -32,8 +31,8 @@ uint8_t CPDF_ClipPath::GetClipType(size_t i) const {
return m_Ref.GetObject()->m_PathAndTypeList[i].second;
}
-uint32_t CPDF_ClipPath::GetTextCount() const {
- return pdfium::CollectionSize<uint32_t>(m_Ref.GetObject()->m_TextList);
+size_t CPDF_ClipPath::GetTextCount() const {
+ return m_Ref.GetObject()->m_TextList.size();
}
CPDF_TextObject* CPDF_ClipPath::GetText(size_t i) const {
@@ -43,36 +42,33 @@ CPDF_TextObject* CPDF_ClipPath::GetText(size_t i) const {
CFX_FloatRect CPDF_ClipPath::GetClipBox() const {
CFX_FloatRect rect;
bool bStarted = false;
- int count = GetPathCount();
- if (count) {
+ if (GetPathCount() > 0) {
rect = GetPath(0).GetBoundingBox();
- for (int i = 1; i < count; i++) {
+ for (size_t i = 1; i < GetPathCount(); ++i) {
CFX_FloatRect path_rect = GetPath(i).GetBoundingBox();
rect.Intersect(path_rect);
}
bStarted = true;
}
- count = GetTextCount();
- if (count) {
- CFX_FloatRect layer_rect;
- bool bLayerStarted = false;
- for (int i = 0; i < count; i++) {
- CPDF_TextObject* pTextObj = GetText(i);
- if (!pTextObj) {
- if (!bStarted) {
- rect = layer_rect;
- bStarted = true;
- } else {
- rect.Intersect(layer_rect);
- }
- bLayerStarted = false;
+
+ CFX_FloatRect layer_rect;
+ bool bLayerStarted = false;
+ for (size_t i = 0; i < GetTextCount(); ++i) {
+ CPDF_TextObject* pTextObj = GetText(i);
+ if (!pTextObj) {
+ if (!bStarted) {
+ rect = layer_rect;
+ bStarted = true;
+ } else {
+ rect.Intersect(layer_rect);
+ }
+ bLayerStarted = false;
+ } else {
+ if (!bLayerStarted) {
+ layer_rect = CFX_FloatRect(pTextObj->GetBBox(nullptr));
+ bLayerStarted = true;
} else {
- if (!bLayerStarted) {
- layer_rect = CFX_FloatRect(pTextObj->GetBBox(nullptr));
- bLayerStarted = true;
- } else {
- layer_rect.Union(CFX_FloatRect(pTextObj->GetBBox(nullptr)));
- }
+ layer_rect.Union(CFX_FloatRect(pTextObj->GetBBox(nullptr)));
}
}
}
diff --git a/core/fpdfapi/page/cpdf_clippath.h b/core/fpdfapi/page/cpdf_clippath.h
index 740342f14b..89365a2d5a 100644
--- a/core/fpdfapi/page/cpdf_clippath.h
+++ b/core/fpdfapi/page/cpdf_clippath.h
@@ -33,10 +33,10 @@ class CPDF_ClipPath {
}
bool operator!=(const CPDF_ClipPath& that) const { return !(*this == that); }
- uint32_t GetPathCount() const;
+ size_t GetPathCount() const;
CPDF_Path GetPath(size_t i) const;
uint8_t GetClipType(size_t i) const;
- uint32_t GetTextCount() const;
+ size_t GetTextCount() const;
CPDF_TextObject* GetText(size_t i) const;
CFX_FloatRect GetClipBox() const;
void AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge);
diff --git a/core/fpdfapi/page/cpdf_contentparser.cpp b/core/fpdfapi/page/cpdf_contentparser.cpp
index 30701422d2..7095ff596f 100644
--- a/core/fpdfapi/page/cpdf_contentparser.cpp
+++ b/core/fpdfapi/page/cpdf_contentparser.cpp
@@ -190,8 +190,9 @@ bool CPDF_ContentParser::Continue(IFX_PauseIndicator* pPause) {
continue;
if (pObj->m_ClipPath.GetPathCount() != 1)
continue;
- if (pObj->m_ClipPath.GetTextCount())
+ if (pObj->m_ClipPath.GetTextCount() > 0)
continue;
+
CPDF_Path ClipPath = pObj->m_ClipPath.GetPath(0);
if (!ClipPath.IsRect() || pObj->IsShading())
continue;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 5f9a8992d3..e70e813cb4 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -1399,8 +1399,7 @@ void CPDF_RenderStatus::ProcessClipPath(const CPDF_ClipPath& ClipPath,
m_LastClipPath = ClipPath;
m_pDevice->RestoreState(true);
- int nClipPath = ClipPath.GetPathCount();
- for (int i = 0; i < nClipPath; ++i) {
+ for (size_t i = 0; i < ClipPath.GetPathCount(); ++i) {
const CFX_PathData* pPathData = ClipPath.GetPath(i).GetObject();
if (!pPathData)
continue;
@@ -1408,15 +1407,14 @@ void CPDF_RenderStatus::ProcessClipPath(const CPDF_ClipPath& ClipPath,
if (pPathData->GetPoints().empty()) {
CFX_PathData EmptyPath;
EmptyPath.AppendRect(-1, -1, 0, 0);
- int fill_mode = FXFILL_WINDING;
- m_pDevice->SetClip_PathFill(&EmptyPath, nullptr, fill_mode);
+ m_pDevice->SetClip_PathFill(&EmptyPath, nullptr, FXFILL_WINDING);
} else {
- int ClipType = ClipPath.GetClipType(i);
- m_pDevice->SetClip_PathFill(pPathData, pObj2Device, ClipType);
+ m_pDevice->SetClip_PathFill(pPathData, pObj2Device,
+ ClipPath.GetClipType(i));
}
}
- int textcount = ClipPath.GetTextCount();
- if (textcount == 0)
+
+ if (ClipPath.GetTextCount() == 0)
return;
if (m_pDevice->GetDeviceClass() == FXDC_DISPLAY &&
@@ -1425,7 +1423,7 @@ void CPDF_RenderStatus::ProcessClipPath(const CPDF_ClipPath& ClipPath,
}
std::unique_ptr<CFX_PathData> pTextClippingPath;
- for (int i = 0; i < textcount; ++i) {
+ for (size_t i = 0; i < ClipPath.GetTextCount(); ++i) {
CPDF_TextObject* pText = ClipPath.GetText(i);
if (pText) {
if (!pTextClippingPath)
@@ -1496,7 +1494,8 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
pFormResource = pFormDict->GetDictFor("Resources");
}
bool bTextClip =
- (pPageObj->m_ClipPath.HasRef() && pPageObj->m_ClipPath.GetTextCount() &&
+ (pPageObj->m_ClipPath.HasRef() &&
+ pPageObj->m_ClipPath.GetTextCount() > 0 &&
m_pDevice->GetDeviceClass() == FXDC_DISPLAY &&
!(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP));
if ((m_Options.HasFlag(RENDER_OVERPRINT)) && pPageObj->IsImage() &&
@@ -1585,7 +1584,7 @@ bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
pTextMask->Clear(0);
CFX_DefaultRenderDevice text_device;
text_device.Attach(pTextMask, false, nullptr, false);
- for (uint32_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) {
+ for (size_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); ++i) {
CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i);
if (!textobj)
break;
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index 4f29fd69d6..565d90be4c 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -275,16 +275,14 @@ FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page,
std::ostringstream strClip;
CPDF_ClipPath* pClipPath = (CPDF_ClipPath*)clipPath;
- uint32_t i;
- for (i = 0; i < pClipPath->GetPathCount(); i++) {
+ for (size_t i = 0; i < pClipPath->GetPathCount(); ++i) {
CPDF_Path path = pClipPath->GetPath(i);
- int iClipType = pClipPath->GetClipType(i);
if (path.GetPoints().empty()) {
// Empty clipping (totally clipped out)
strClip << "0 0 m W n ";
} else {
OutputPath(strClip, path);
- if (iClipType == FXFILL_WINDING)
+ if (pClipPath->GetClipType(i) == FXFILL_WINDING)
strClip << "W n\n";
else
strClip << "W* n\n";