diff options
author | Lei Zhang <thestig@chromium.org> | 2018-08-20 17:14:26 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-08-20 17:14:26 +0000 |
commit | f01e4a5ec03c6b232d41dc878a3640924150f2a7 (patch) | |
tree | 6ad558d5e5688d87f3495413ad21a2c08003e795 /xfa/fgas | |
parent | 5b10a4c713fbc831cc7bed16936b44ff65fd68b1 (diff) | |
download | pdfium-f01e4a5ec03c6b232d41dc878a3640924150f2a7.tar.xz |
Use more consts in CFX_Break.
Change-Id: I57cd74581849a8f434f64c4ec3c4ad3ce1f92546
Reviewed-on: https://pdfium-review.googlesource.com/40630
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa/fgas')
-rw-r--r-- | xfa/fgas/layout/cfx_break.cpp | 18 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_break.h | 3 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_rtfbreak.cpp | 8 | ||||
-rw-r--r-- | xfa/fgas/layout/cfx_txtbreak.cpp | 6 |
4 files changed, 18 insertions, 17 deletions
diff --git a/xfa/fgas/layout/cfx_break.cpp b/xfa/fgas/layout/cfx_break.cpp index 43ef9a3833..35c637a51f 100644 --- a/xfa/fgas/layout/cfx_break.cpp +++ b/xfa/fgas/layout/cfx_break.cpp @@ -12,11 +12,8 @@ #include "third_party/base/stl_util.h" #include "xfa/fgas/font/cfgas_gefont.h" -namespace { - -const int kMinimumTabWidth = 160000; - -} // namespace +const float CFX_Break::kConversionFactor = 20000.0f; +const int CFX_Break::kMinimumTabWidth = 160000; CFX_Break::CFX_Break(uint32_t dwLayoutStyles) : m_dwLayoutStyles(dwLayoutStyles) { @@ -102,7 +99,8 @@ void CFX_Break::SetTabWidth(float fTabWidth) { // Note, the use of max here was only done in the TxtBreak code. Leaving this // in for the RTFBreak code for consistency. If we see issues with tab widths // we may need to fix this. - m_iTabWidth = std::max(FXSYS_round(fTabWidth * 20000.0f), kMinimumTabWidth); + m_iTabWidth = + std::max(FXSYS_round(fTabWidth * kConversionFactor), kMinimumTabWidth); } void CFX_Break::SetDefaultChar(wchar_t wch) { @@ -125,19 +123,19 @@ void CFX_Break::SetParagraphBreakChar(wchar_t wch) { } void CFX_Break::SetLineBreakTolerance(float fTolerance) { - m_iTolerance = FXSYS_round(fTolerance * 20000.0f); + m_iTolerance = FXSYS_round(fTolerance * kConversionFactor); } void CFX_Break::SetCharSpace(float fCharSpace) { - m_iCharSpace = FXSYS_round(fCharSpace * 20000.0f); + m_iCharSpace = FXSYS_round(fCharSpace * kConversionFactor); } void CFX_Break::SetLineBoundary(float fLineStart, float fLineEnd) { if (fLineStart > fLineEnd) return; - m_iLineStart = FXSYS_round(fLineStart * 20000.0f); - m_iLineWidth = FXSYS_round(fLineEnd * 20000.0f); + m_iLineStart = FXSYS_round(fLineStart * kConversionFactor); + m_iLineWidth = FXSYS_round(fLineEnd * kConversionFactor); m_pCurLine->m_iStart = std::min(m_pCurLine->m_iStart, m_iLineWidth); m_pCurLine->m_iStart = std::max(m_pCurLine->m_iStart, m_iLineStart); } diff --git a/xfa/fgas/layout/cfx_break.h b/xfa/fgas/layout/cfx_break.h index 88cef53df1..ee33340e67 100644 --- a/xfa/fgas/layout/cfx_break.h +++ b/xfa/fgas/layout/cfx_break.h @@ -63,6 +63,9 @@ class CFX_Break { } protected: + static const int kMinimumTabWidth; + static const float kConversionFactor; + explicit CFX_Break(uint32_t dwLayoutStyles); void SetBreakStatus(); diff --git a/xfa/fgas/layout/cfx_rtfbreak.cpp b/xfa/fgas/layout/cfx_rtfbreak.cpp index 4dfe8989d1..a50bade98a 100644 --- a/xfa/fgas/layout/cfx_rtfbreak.cpp +++ b/xfa/fgas/layout/cfx_rtfbreak.cpp @@ -27,15 +27,15 @@ CFX_RTFBreak::CFX_RTFBreak(uint32_t dwLayoutStyles) CFX_RTFBreak::~CFX_RTFBreak() {} void CFX_RTFBreak::SetLineStartPos(float fLinePos) { - int32_t iLinePos = FXSYS_round(fLinePos * 20000.0f); + int32_t iLinePos = FXSYS_round(fLinePos * kConversionFactor); iLinePos = std::min(iLinePos, m_iLineWidth); iLinePos = std::max(iLinePos, m_iLineStart); m_pCurLine->m_iStart = iLinePos; } void CFX_RTFBreak::AddPositionedTab(float fTabPos) { - int32_t iTabPos = - std::min(FXSYS_round(fTabPos * 20000.0f) + m_iLineStart, m_iLineWidth); + int32_t iTabPos = std::min( + FXSYS_round(fTabPos * kConversionFactor) + m_iLineStart, m_iLineWidth); auto it = std::lower_bound(m_PositionedTabs.begin(), m_PositionedTabs.end(), iTabPos); if (it != m_PositionedTabs.end() && *it == iTabPos) @@ -158,7 +158,7 @@ void CFX_RTFBreak::AppendChar_Tab(CFX_Char* pCurChar) { iSafeCharWidth = iCharWidth; } else { // Tab width is >= 160000, so this part does not need to be checked. - ASSERT(m_iTabWidth >= 160000); + ASSERT(m_iTabWidth >= kMinimumTabWidth); iSafeCharWidth = iLineWidth / m_iTabWidth + 1; iSafeCharWidth *= m_iTabWidth; } diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp index 490426a221..89d2122494 100644 --- a/xfa/fgas/layout/cfx_txtbreak.cpp +++ b/xfa/fgas/layout/cfx_txtbreak.cpp @@ -33,7 +33,7 @@ CFX_TxtBreak::CFX_TxtBreak() CFX_TxtBreak::~CFX_TxtBreak() {} void CFX_TxtBreak::SetLineWidth(float fLineWidth) { - m_iLineWidth = FXSYS_round(fLineWidth * 20000.0f); + m_iLineWidth = FXSYS_round(fLineWidth * kConversionFactor); ASSERT(m_iLineWidth >= 20000); } @@ -44,7 +44,7 @@ void CFX_TxtBreak::SetAlignment(int32_t iAlignment) { } void CFX_TxtBreak::SetCombWidth(float fCombWidth) { - m_iCombWidth = FXSYS_round(fCombWidth * 20000.0f); + m_iCombWidth = FXSYS_round(fCombWidth * kConversionFactor); } void CFX_TxtBreak::AppendChar_Combination(CFX_Char* pCurChar) { @@ -953,7 +953,7 @@ std::vector<CFX_RectF> CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, wch = *pStr++; iCharSize = *pWidths++; } - fCharSize = static_cast<float>(iCharSize) / 20000.0f; + fCharSize = static_cast<float>(iCharSize) / kConversionFactor; bool bRet = (!bSingleLine && IsCtrlCode(wch)); if (!(wch == L'\v' || wch == L'\f' || wch == 0x2028 || wch == 0x2029 || wch == L'\n')) { |