From eaba5af84597164281ddd972a5e98631b18d783b Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Tue, 5 Jun 2018 15:54:51 +0000 Subject: Clean up CFX_TxtBreak Removed some unused assignments and now unused variables. Also rewrote a for loop so that its secondary condition is now in the control block. The static analyzer was claiming it was possible for a division by 0, though following the control path it was claiming, I am pretty sure it should have exited early. This reorganizing of the code makes it a bit more readable and eliminates the div by 0 warning from the static analyzer. Issues found with Clang Static Analyzer. Change-Id: I91f1b42374734665b06724e9fafa6490e06bd3da Reviewed-on: https://pdfium-review.googlesource.com/33910 Reviewed-by: Henrique Nakashima Commit-Queue: Ryan Harrison --- xfa/fgas/layout/cfx_txtbreak.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/xfa/fgas/layout/cfx_txtbreak.cpp b/xfa/fgas/layout/cfx_txtbreak.cpp index 76a36c90da..7633c4c91e 100644 --- a/xfa/fgas/layout/cfx_txtbreak.cpp +++ b/xfa/fgas/layout/cfx_txtbreak.cpp @@ -456,7 +456,7 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque& tpos, else ttp.m_iStartPos = iStart; - for (int32_t j = 0; j < ttp.m_iChars; j++) { + for (int32_t j = 0; j < ttp.m_iChars && iGapChars > 0; j++, iGapChars--) { CFX_Char* pTC = ttp.GetChar(j); if (pTC->m_nBreakType != FX_LBT_DIRECT_BRK || pTC->m_iCharWidth < 0) continue; @@ -465,9 +465,6 @@ void CFX_TxtBreak::EndBreak_Alignment(const std::deque& tpos, pTC->m_iCharWidth += k; ttp.m_iWidth += k; iOffset -= k; - iGapChars--; - if (iGapChars < 1) - break; } iStart += ttp.m_iWidth; } @@ -804,7 +801,6 @@ int32_t CFX_TxtBreak::GetDisplayPos(const FX_TXTRUN* pTxtRun, if (chartype < FX_CHARTYPE_ArabicAlef) bLam = false; - dwProps = FX_GetUnicodeProperties(wForm); bool bEmptyChar = (chartype >= FX_CHARTYPE_Tab && chartype <= FX_CHARTYPE_Control); if (wForm == 0xFEFF) @@ -928,7 +924,6 @@ std::vector CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, int32_t iLength = pTxtRun->iLength; CFX_RectF rect(*pTxtRun->pRect); float fFontSize = pTxtRun->fFontSize; - int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); float fScale = fFontSize / 1000.0f; RetainPtr pFont = pTxtRun->pFont; if (!pFont) @@ -964,10 +959,8 @@ std::vector CFX_TxtBreak::GetCharRects(const FX_TXTRUN* pTxtRun, wch == L'\n')) { bRet = false; } - if (bRet) { - iCharSize = iFontSize * 500; + if (bRet) fCharSize = fFontSize / 2.0f; - } rect.left = fStart; if (bRTLPiece) { rect.left -= fCharSize; -- cgit v1.2.3