Rename |CFX_Break::m_Line| to |m_Lines|.
Rename the variable since it is an array of lines and not a single line.
Along the way, decrease nested if-statements in a couple of places that
use |m_Lines| and also put |m_pCurLine| in the initializer list.
Change-Id: I6f775ddab7f624476769b9de0bad37b5aa51b65e
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/59810
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fgas/layout/cfx_break.cpp b/xfa/fgas/layout/cfx_break.cpp
index 640ef1d..46a854d 100644
--- a/xfa/fgas/layout/cfx_break.cpp
+++ b/xfa/fgas/layout/cfx_break.cpp
@@ -17,16 +17,14 @@
const int CFX_Break::kMinimumTabWidth = 160000;
CFX_Break::CFX_Break(uint32_t dwLayoutStyles)
- : m_dwLayoutStyles(dwLayoutStyles) {
- m_pCurLine = &m_Line[0];
-}
+ : m_dwLayoutStyles(dwLayoutStyles), m_pCurLine(&m_Lines[0]) {}
CFX_Break::~CFX_Break() = default;
void CFX_Break::Reset() {
m_eCharType = FX_CHARTYPE::kUnknown;
- m_Line[0].Clear();
- m_Line[1].Clear();
+ for (CFX_BreakLine& line : m_Lines)
+ line.Clear();
}
void CFX_Break::SetLayoutStyles(uint32_t dwLayoutStyles) {
@@ -169,20 +167,20 @@
int32_t CFX_Break::CountBreakPieces() const {
return HasLine() ? pdfium::CollectionSize<int32_t>(
- m_Line[m_iReadyLineIndex].m_LinePieces)
+ m_Lines[m_iReadyLineIndex].m_LinePieces)
: 0;
}
const CFX_BreakPiece* CFX_Break::GetBreakPieceUnstable(int32_t index) const {
if (!HasLine())
return nullptr;
- if (!pdfium::IndexInBounds(m_Line[m_iReadyLineIndex].m_LinePieces, index))
+ if (!pdfium::IndexInBounds(m_Lines[m_iReadyLineIndex].m_LinePieces, index))
return nullptr;
- return &m_Line[m_iReadyLineIndex].m_LinePieces[index];
+ return &m_Lines[m_iReadyLineIndex].m_LinePieces[index];
}
void CFX_Break::ClearBreakPieces() {
if (HasLine())
- m_Line[m_iReadyLineIndex].Clear();
+ m_Lines[m_iReadyLineIndex].Clear();
m_iReadyLineIndex = -1;
}
diff --git a/xfa/fgas/layout/cfx_break.h b/xfa/fgas/layout/cfx_break.h
index 44e5678..c611abf 100644
--- a/xfa/fgas/layout/cfx_break.h
+++ b/xfa/fgas/layout/cfx_break.h
@@ -92,7 +92,7 @@
RetainPtr<CFGAS_GEFont> m_pFont;
UnownedPtr<CFX_BreakLine> m_pCurLine;
int8_t m_iReadyLineIndex = -1;
- CFX_BreakLine m_Line[2];
+ CFX_BreakLine m_Lines[2];
private:
void FontChanged();
diff --git a/xfa/fgas/layout/cfx_rtfbreak.cpp b/xfa/fgas/layout/cfx_rtfbreak.cpp
index ef0d47e..40f5b84 100644
--- a/xfa/fgas/layout/cfx_rtfbreak.cpp
+++ b/xfa/fgas/layout/cfx_rtfbreak.cpp
@@ -313,12 +313,12 @@
}
if (HasLine()) {
- if (!m_Line[m_iReadyLineIndex].m_LinePieces.empty()) {
- if (dwStatus != CFX_BreakType::Piece)
- m_Line[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
- return m_Line[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
- }
- return CFX_BreakType::None;
+ if (m_Lines[m_iReadyLineIndex].m_LinePieces.empty())
+ return CFX_BreakType::None;
+
+ if (dwStatus != CFX_BreakType::Piece)
+ m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
+ return m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
}
if (m_pCurLine->m_LineChars.empty())
@@ -329,8 +329,8 @@
if (dwStatus == CFX_BreakType::Piece)
return dwStatus;
- m_iReadyLineIndex = m_pCurLine == &m_Line[0] ? 0 : 1;
- CFX_BreakLine* pNextLine = &m_Line[1 - m_iReadyLineIndex];
+ m_iReadyLineIndex = m_pCurLine == &m_Lines[0] ? 0 : 1;
+ CFX_BreakLine* pNextLine = &m_Lines[1 - m_iReadyLineIndex];
bool bAllChars = m_iAlignment == CFX_RTFLineAlignment::Justified ||
m_iAlignment == CFX_RTFLineAlignment::Distributed;
diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp
index 5849999..b347ec7 100644
--- a/xfa/fgas/layout/cfx_txtbreak.cpp
+++ b/xfa/fgas/layout/cfx_txtbreak.cpp
@@ -494,12 +494,12 @@
}
if (HasLine()) {
- if (!m_Line[m_iReadyLineIndex].m_LinePieces.empty()) {
- if (dwStatus != CFX_BreakType::Piece)
- m_Line[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
- return m_Line[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
- }
- return CFX_BreakType::None;
+ if (m_Lines[m_iReadyLineIndex].m_LinePieces.empty())
+ return CFX_BreakType::None;
+
+ if (dwStatus != CFX_BreakType::Piece)
+ m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus = dwStatus;
+ return m_Lines[m_iReadyLineIndex].m_LinePieces.back().m_dwStatus;
}
if (m_pCurLine->m_LineChars.empty())
@@ -509,8 +509,8 @@
if (dwStatus == CFX_BreakType::Piece)
return dwStatus;
- m_iReadyLineIndex = m_pCurLine == &m_Line[0] ? 0 : 1;
- CFX_BreakLine* pNextLine = &m_Line[1 - m_iReadyLineIndex];
+ m_iReadyLineIndex = m_pCurLine == &m_Lines[0] ? 0 : 1;
+ CFX_BreakLine* pNextLine = &m_Lines[1 - m_iReadyLineIndex];
bool bAllChars = m_iAlignment > CFX_TxtLineAlignment_Right;
if (!EndBreak_SplitLine(pNextLine, bAllChars)) {
std::deque<FX_TPO> tpos;