summaryrefslogtreecommitdiff
path: root/xfa/fxfa/app/cxfa_textlayout.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2017-03-27 12:44:20 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-27 20:00:37 +0000
commit5c500acc3380d96db0ab5e2e6c2bc448644992de (patch)
tree6d901f2a357095e00965165f94a0e1769f62d326 /xfa/fxfa/app/cxfa_textlayout.cpp
parentd59442b054072dabfcd5c9cb766e7b60c13a1e69 (diff)
downloadpdfium-5c500acc3380d96db0ab5e2e6c2bc448644992de.tar.xz
Return arrays where appropriate in fxfa.
Also, remove some default method arguments along the way. Change-Id: Ifbd157499881ed6a3777f3903dd7f0193753cf59 Reviewed-on: https://pdfium-review.googlesource.com/3219 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/app/cxfa_textlayout.cpp')
-rw-r--r--xfa/fxfa/app/cxfa_textlayout.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp
index fd913c2df5..0fab077812 100644
--- a/xfa/fxfa/app/cxfa_textlayout.cpp
+++ b/xfa/fxfa/app/cxfa_textlayout.cpp
@@ -224,12 +224,9 @@ void CXFA_TextLayout::InitBreak(CFDE_CSSComputedStyle* pStyle,
if (!m_pTabstopContext)
m_pTabstopContext = pdfium::MakeUnique<CXFA_TextTabstopsContext>();
m_textParser.GetTabstops(pStyle, m_pTabstopContext.get());
- for (int32_t i = 0; i < m_pTabstopContext->m_iTabCount; i++) {
- XFA_TABSTOPS* pTab = m_pTabstopContext->m_tabstops.GetDataPtr(i);
- m_pBreak->AddPositionedTab(pTab->fTabstops);
- }
+ for (const auto& stop : m_pTabstopContext->m_tabstops)
+ m_pBreak->AddPositionedTab(stop.fTabstops);
}
-
float fFontSize = m_textParser.GetFontSize(m_pTextProvider, pStyle);
m_pBreak->SetFontSize(fFontSize);
m_pBreak->SetLineBreakTolerance(fFontSize * 0.2f);
@@ -958,11 +955,12 @@ void CXFA_TextLayout::EndBreak(CFX_BreakType dwStatus,
void CXFA_TextLayout::DoTabstops(CFDE_CSSComputedStyle* pStyle,
CXFA_PieceLine* pPieceLine) {
- if (!m_pTabstopContext || m_pTabstopContext->m_iTabCount == 0)
- return;
if (!pStyle || !pPieceLine)
return;
+ if (!m_pTabstopContext || m_pTabstopContext->m_tabstops.empty())
+ return;
+
int32_t iPieces = pdfium::CollectionSize<int32_t>(pPieceLine->m_textPieces);
if (iPieces == 0)
return;
@@ -970,7 +968,7 @@ void CXFA_TextLayout::DoTabstops(CFDE_CSSComputedStyle* pStyle,
XFA_TextPiece* pPiece = pPieceLine->m_textPieces[iPieces - 1].get();
int32_t& iTabstopsIndex = m_pTabstopContext->m_iTabIndex;
int32_t iCount = m_textParser.CountTabs(pStyle);
- if (iTabstopsIndex > m_pTabstopContext->m_iTabCount - 1)
+ if (!pdfium::IndexInBounds(m_pTabstopContext->m_tabstops, iTabstopsIndex))
return;
if (iCount > 0) {
@@ -986,9 +984,7 @@ void CXFA_TextLayout::DoTabstops(CFDE_CSSComputedStyle* pStyle,
} else if (iTabstopsIndex > -1) {
float fLeft = 0;
if (m_pTabstopContext->m_bTabstops) {
- XFA_TABSTOPS* pTabstops =
- m_pTabstopContext->m_tabstops.GetDataPtr(iTabstopsIndex);
- uint32_t dwAlign = pTabstops->dwAlign;
+ uint32_t dwAlign = m_pTabstopContext->m_tabstops[iTabstopsIndex].dwAlign;
if (dwAlign == FX_HashCode_GetW(L"center", false)) {
fLeft = pPiece->rtPiece.width / 2.0f;
} else if (dwAlign == FX_HashCode_GetW(L"right", false) ||