Replace CFDE_TxtEdtPage FX_POSITION usage with uint32_t
Change-Id: I8cd68aaeb3c1f7ba92f32bc4846bf2e7d02111e4
Reviewed-on: https://pdfium-review.googlesource.com/3033
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Nicolás Peña <npm@chromium.org>
diff --git a/xfa/fde/cfde_txtedtpage.cpp b/xfa/fde/cfde_txtedtpage.cpp
index 4bf3e9f..c3d2143 100644
--- a/xfa/fde/cfde_txtedtpage.cpp
+++ b/xfa/fde/cfde_txtedtpage.cpp
@@ -412,24 +412,25 @@
return m_rtPageContents;
}
-FX_POSITION CFDE_TxtEdtPage::GetFirstPosition() {
- if (m_Pieces.empty())
- return nullptr;
- return (FX_POSITION)1;
+size_t CFDE_TxtEdtPage::GetFirstPosition() {
+ return m_Pieces.empty() ? 0 : 1;
}
-FDE_TEXTEDITPIECE* CFDE_TxtEdtPage::GetNext(FX_POSITION& pos,
+FDE_TEXTEDITPIECE* CFDE_TxtEdtPage::GetNext(size_t* pos,
IFDE_VisualSet*& pVisualSet) {
+ ASSERT(pos);
+
if (!m_pTextSet) {
- pos = nullptr;
+ *pos = 0;
return nullptr;
}
- int32_t nPos = (int32_t)(uintptr_t)pos;
+
+ size_t nPos = *pos;
pVisualSet = m_pTextSet.get();
- if (nPos + 1 > pdfium::CollectionSize<int32_t>(m_Pieces))
- pos = nullptr;
+ if (nPos + 1 > m_Pieces.size())
+ *pos = 0;
else
- pos = (FX_POSITION)(uintptr_t)(nPos + 1);
+ *pos = nPos + 1;
return &m_Pieces[nPos - 1];
}
diff --git a/xfa/fde/cfde_txtedtpage.h b/xfa/fde/cfde_txtedtpage.h
index d249619..2cae7ce 100644
--- a/xfa/fde/cfde_txtedtpage.h
+++ b/xfa/fde/cfde_txtedtpage.h
@@ -46,8 +46,8 @@
void UnloadPage(const CFX_RectF* pClipBox);
const CFX_RectF& GetContentsBox();
- FX_POSITION GetFirstPosition();
- FDE_TEXTEDITPIECE* GetNext(FX_POSITION& pos, IFDE_VisualSet*& pVisualSet);
+ size_t GetFirstPosition();
+ FDE_TEXTEDITPIECE* GetNext(size_t* pos, IFDE_VisualSet*& pVisualSet);
wchar_t GetChar(const FDE_TEXTEDITPIECE* pIdentity, int32_t index) const;
int32_t GetWidth(const FDE_TEXTEDITPIECE* pIdentity, int32_t index) const;
diff --git a/xfa/fde/fde_iterator.cpp b/xfa/fde/fde_iterator.cpp
index e9a6440..ff4fc0e 100644
--- a/xfa/fde/fde_iterator.cpp
+++ b/xfa/fde/fde_iterator.cpp
@@ -19,8 +19,8 @@
FDE_CANVASITEM canvas;
canvas.hCanvas = nullptr;
canvas.pCanvas = pCanvas;
- canvas.hPos = pCanvas->GetFirstPosition();
- if (!canvas.hPos)
+ canvas.pos = pCanvas->GetFirstPosition();
+ if (canvas.pos == 0)
return false;
m_CanvasStack.push(canvas);
@@ -39,8 +39,8 @@
FDE_CANVASITEM* pCanvas = &m_CanvasStack.top();
ASSERT(pCanvas && pCanvas->pCanvas);
- pCanvas->hPos = pCanvas->pCanvas->GetFirstPosition();
- return !!pCanvas->hPos;
+ pCanvas->pos = pCanvas->pCanvas->GetFirstPosition();
+ return pCanvas->pos != 0;
}
void CFDE_VisualSetIterator::Reset() {
@@ -53,7 +53,7 @@
CFDE_TxtEdtPage** ppCanvasSet) {
while (!m_CanvasStack.empty()) {
FDE_CANVASITEM* pCanvas = &m_CanvasStack.top();
- if (!pCanvas->hPos) {
+ if (pCanvas->pos == 0) {
if (m_CanvasStack.size() == 1)
break;
@@ -62,7 +62,7 @@
}
do {
FDE_TEXTEDITPIECE* pObj =
- pCanvas->pCanvas->GetNext(pCanvas->hPos, pVisualSet);
+ pCanvas->pCanvas->GetNext(&pCanvas->pos, pVisualSet);
ASSERT(pObj);
FDE_VISUALOBJTYPE eType = pVisualSet->GetType();
@@ -70,7 +70,7 @@
FDE_CANVASITEM canvas;
canvas.hCanvas = pObj;
canvas.pCanvas = static_cast<CFDE_TxtEdtPage*>(pVisualSet);
- canvas.hPos = canvas.pCanvas->GetFirstPosition();
+ canvas.pos = canvas.pCanvas->GetFirstPosition();
m_CanvasStack.push(canvas);
break;
}
@@ -82,7 +82,7 @@
*phCanvasObj = pCanvas->hCanvas;
return pObj;
}
- } while (pCanvas->hPos);
+ } while (pCanvas->pos != 0);
}
if (ppCanvasSet)
*ppCanvasSet = nullptr;
diff --git a/xfa/fde/fde_iterator.h b/xfa/fde/fde_iterator.h
index 95785e4..99f9597 100644
--- a/xfa/fde/fde_iterator.h
+++ b/xfa/fde/fde_iterator.h
@@ -16,7 +16,7 @@
struct FDE_CANVASITEM {
CFDE_TxtEdtPage* pCanvas;
FDE_TEXTEDITPIECE* hCanvas;
- FX_POSITION hPos;
+ size_t pos;
};
class CFDE_VisualSetIterator {