summaryrefslogtreecommitdiff
path: root/xfa/fgas/layout/cfx_txtbreak.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-05-15 19:50:45 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-15 19:50:45 +0000
commit22b448a7859d21b63172a69a66bf0ef25d3cdeb6 (patch)
tree131941ee19b44614e0c407ff2357425490bd0ee1 /xfa/fgas/layout/cfx_txtbreak.cpp
parent16e9ecf374e22a8ab9b4de2dfa87b048ae37dcbe (diff)
downloadpdfium-22b448a7859d21b63172a69a66bf0ef25d3cdeb6.tar.xz
Remove CFX_BreakLine::CountChars
The CFX_BreakLine::CountChars is a thin wrapper around getting the size of the m_LineChars vector. This CL removes CountChars and uses the vectory directly. Change-Id: I6b172c090aa7acf3282df517a8ae2bbdd55ff15b Reviewed-on: https://pdfium-review.googlesource.com/32590 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fgas/layout/cfx_txtbreak.cpp')
-rw-r--r--xfa/fgas/layout/cfx_txtbreak.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp
index 526fd64c96..76a36c90da 100644
--- a/xfa/fgas/layout/cfx_txtbreak.cpp
+++ b/xfa/fgas/layout/cfx_txtbreak.cpp
@@ -239,9 +239,8 @@ CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) {
m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance && !m_bSingleLine &&
(m_eCharType != FX_CHARTYPE_Space || chartype != FX_CHARTYPE_Control)) {
dwRet1 = EndBreak(CFX_BreakType::Line);
- int32_t iCount = m_pCurLine->CountChars();
- if (iCount > 0)
- pCurChar = &m_pCurLine->m_LineChars[iCount - 1];
+ if (!m_pCurLine->m_LineChars.empty())
+ pCurChar = &m_pCurLine->m_LineChars.back();
}
CFX_BreakType dwRet2 = CFX_BreakType::None;
@@ -284,11 +283,10 @@ CFX_BreakType CFX_TxtBreak::AppendChar(wchar_t wch) {
bool CFX_TxtBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine,
bool bAllChars) {
- int32_t iCount = m_pCurLine->CountChars();
bool bDone = false;
CFX_Char* pTC;
if (!m_bSingleLine && m_pCurLine->m_iWidth > m_iLineWidth + m_iTolerance) {
- pTC = m_pCurLine->GetChar(iCount - 1);
+ pTC = m_pCurLine->GetChar(m_pCurLine->m_LineChars.size() - 1);
switch (pTC->GetCharType()) {
case FX_CHARTYPE_Tab:
case FX_CHARTYPE_Control:
@@ -301,7 +299,6 @@ bool CFX_TxtBreak::EndBreak_SplitLine(CFX_BreakLine* pNextLine,
}
}
- iCount = m_pCurLine->CountChars();
CFX_BreakPiece tp;
if (bAllChars && !bDone) {
int32_t iEndPos = m_pCurLine->m_iWidth;
@@ -316,13 +313,10 @@ void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
FX_TPO tpo;
CFX_Char* pTC;
std::vector<CFX_Char>& chars = m_pCurLine->m_LineChars;
- int32_t iCount = m_pCurLine->CountChars();
bool bDone = m_pCurLine->m_iArabicChars > 0;
if (bDone) {
- ASSERT(iCount >= 0);
-
size_t iBidiNum = 0;
- for (size_t i = 0; i < static_cast<size_t>(iCount); ++i) {
+ for (size_t i = 0; i < m_pCurLine->m_LineChars.size(); ++i) {
pTC = &chars[i];
pTC->m_iBidiPos = static_cast<int32_t>(i);
if (pTC->GetCharType() != FX_CHARTYPE_Control)
@@ -341,6 +335,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
int32_t iCharWidth;
int32_t i = 0;
int32_t j = -1;
+ int32_t iCount = pdfium::CollectionSize<int32_t>(m_pCurLine->m_LineChars);
while (i < iCount) {
pTC = &chars[i];
if (iBidiLevel < 0) {
@@ -405,7 +400,7 @@ void CFX_TxtBreak::EndBreak_BidiLine(std::deque<FX_TPO>* tpos,
tp.m_iStartPos = m_pCurLine->m_iStart;
tp.m_iWidth = m_pCurLine->m_iWidth;
tp.m_iStartChar = 0;
- tp.m_iChars = iCount;
+ tp.m_iChars = m_pCurLine->m_LineChars.size();
tp.m_pChars = &m_pCurLine->m_LineChars;
pTC = &chars[0];
tp.m_dwCharStyles = pTC->m_dwCharStyles;
@@ -507,11 +502,10 @@ CFX_BreakType CFX_TxtBreak::EndBreak(CFX_BreakType dwStatus) {
return CFX_BreakType::None;
}
- int32_t iCount = m_pCurLine->CountChars();
- if (iCount < 1)
+ if (m_pCurLine->m_LineChars.empty())
return CFX_BreakType::None;
- m_pCurLine->GetChar(iCount - 1)->m_dwStatus = dwStatus;
+ m_pCurLine->m_LineChars.back().m_dwStatus = dwStatus;
if (dwStatus == CFX_BreakType::Piece)
return dwStatus;
@@ -623,8 +617,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine,
CFX_BreakLine* pNextLine,
bool bAllChars) {
ASSERT(pCurLine && pNextLine);
- int32_t iCount = pCurLine->CountChars();
- if (iCount < 2)
+ if (pCurLine->m_LineChars.size() < 2)
return;
int32_t iEndPos = pCurLine->m_iWidth;
@@ -634,7 +627,7 @@ void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine,
iCharPos = 0;
iCharPos++;
- if (iCharPos >= iCount) {
+ if (iCharPos >= pdfium::CollectionSize<int32_t>(pCurLine->m_LineChars)) {
pNextLine->Clear();
CFX_Char* pTC = &curChars[iCharPos - 1];
pTC->m_nBreakType = FX_LBT_UNKNOWN;
@@ -647,9 +640,8 @@ void CFX_TxtBreak::SplitTextLine(CFX_BreakLine* pCurLine,
pCurLine->m_iWidth = iEndPos;
CFX_Char* pTC = &curChars[iCharPos - 1];
pTC->m_nBreakType = FX_LBT_UNKNOWN;
- iCount = pdfium::CollectionSize<int>(pNextLine->m_LineChars);
int32_t iWidth = 0;
- for (int32_t i = 0; i < iCount; i++) {
+ for (size_t i = 0; i < pNextLine->m_LineChars.size(); ++i) {
if (pNextLine->m_LineChars[i].GetCharType() >= FX_CHARTYPE_ArabicAlef) {
pCurLine->m_iArabicChars--;
pNextLine->m_iArabicChars++;