Chromium Code Reviews| Index: core/src/fpdftext/fpdf_text_int.cpp |
| diff --git a/core/src/fpdftext/fpdf_text_int.cpp b/core/src/fpdftext/fpdf_text_int.cpp |
| index 6755939ca2a8f7877d1038a3776434e238c3abb0..52314ed168dcb4b531cf210b69a178be8d634200 100644 |
| --- a/core/src/fpdftext/fpdf_text_int.cpp |
| +++ b/core/src/fpdftext/fpdf_text_int.cpp |
| @@ -42,9 +42,11 @@ FX_FLOAT _NormalizeThreshold(FX_FLOAT threshold) |
| { |
| if (threshold < 300) { |
| return threshold / 2.0f; |
| - } else if (threshold < 500) { |
| + } |
| + if (threshold < 500) { |
| return threshold / 4.0f; |
| - } else if (threshold < 700) { |
| + } |
| + if (threshold < 700) { |
| return threshold / 5.0f; |
| } |
| return threshold / 6.0f; |
| @@ -161,9 +163,6 @@ void CPDF_TextPage::NormalizeObjects(FX_BOOL bNormalize) |
| } |
| FX_BOOL CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo) |
| { |
| - if(!pCharInfo) { |
|
Tom Sepez
2015/07/20 23:59:58
note: always passed as &something so never null.
Lei Zhang
2015/07/21 21:44:46
pointer -> const ref then?
Tom Sepez
2015/07/22 20:38:24
Done.
|
| - return FALSE; |
| - } |
| switch(pCharInfo->m_Unicode) { |
| case 0x2: |
| case 0x3: |
| @@ -173,11 +172,7 @@ FX_BOOL CPDF_TextPage::IsControlChar(PAGECHAR_INFO* pCharInfo) |
| case 0x97: |
| case 0x98: |
| case 0xfffe: |
| - if(pCharInfo->m_Flag == FPDFTEXT_CHAR_HYPHEN) { |
| - return FALSE; |
| - } else { |
| - return TRUE; |
| - } |
| + return pCharInfo->m_Flag != FPDFTEXT_CHAR_HYPHEN; |
|
Lei Zhang
2015/07/21 21:44:47
BTW, wouldn't this return true or false, rather th
Tom Sepez
2015/07/22 20:38:24
Made into |bool| return value.
|
| default: |
| return FALSE; |
| } |
| @@ -561,11 +556,7 @@ int CPDF_TextPage::GetOrderByDirection(int order, int direction) const |
| signflag = -1; |
| } |
| if (signflag * PreXdif < 0) { |
| - if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) { |
| - return index + 1; |
| - } else { |
| - return index; |
| - } |
| + return FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif) ? index + 1 : index; |
| } |
| if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) { |
| minIndex = index; |
| @@ -577,7 +568,8 @@ int CPDF_TextPage::GetOrderByDirection(int order, int direction) const |
| } |
| } |
| return minIndex; |
| - } else if(FPDFTEXT_DOWN) { |
|
Tom Sepez
2015/07/20 23:59:58
note: this must be a bug. Not sure it matters.
Lei Zhang
2015/07/21 21:44:47
It does not matter because GetOrderByDirection() d
Tom Sepez
2015/07/22 20:38:24
Removed this dead code.
|
| + } |
| + if (direction == FPDFTEXT_DOWN) { |
| minIndex = -2; |
| while (1) { |
| if (++index > m_charList.GetSize() - 1) { |
| @@ -605,18 +597,9 @@ int CPDF_TextPage::GetOrderByDirection(int order, int direction) const |
| if (curXdif == 0) { |
| return index; |
| } |
| - int signflag = 0; |
| - if (curXdif > 0) { |
| - signflag = 1; |
| - } else { |
| - signflag = -1; |
| - } |
| + int signflag = curXdif > 0 ? 1 : -1; |
| if (signflag * PreXdif < 0) { |
| - if (FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif)) { |
| - return index - 1; |
| - } else { |
| - return index; |
| - } |
| + return FXSYS_fabs(PreXdif) < FXSYS_fabs(curXdif) ? index - 1 : index; |
| } |
| if (FXSYS_fabs(curXdif) < FXSYS_fabs(minXdif)) { |
| minXdif = curXdif; |
| @@ -626,6 +609,7 @@ int CPDF_TextPage::GetOrderByDirection(int order, int direction) const |
| } |
| return minIndex; |
| } |
| + return minIndex; |
| } |
| void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO & info) const |
| { |
| @@ -952,7 +936,6 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const |
| return breakPos; |
| } |
| } |
| - return breakPos; |
| } else if (direction == FPDFTEXT_RIGHT) { |
| while (++breakPos < m_charList.GetSize()) { |
| charinfo = *(PAGECHAR_INFO*)m_charList.GetAt(breakPos); |
| @@ -960,7 +943,6 @@ int CPDF_TextPage::GetWordBreak(int index, int direction) const |
| return breakPos; |
| } |
| } |
| - return breakPos; |
| } |
| return breakPos; |
| } |
| @@ -1212,9 +1194,8 @@ void CPDF_TextPage::AddCharInfoByRLDirection(CFX_WideString& str, int i) |
| } |
| FX_Free(pDst); |
| return; |
| - } else { |
| - Info.m_Unicode = wChar; |
| } |
| + Info.m_Unicode = wChar; |
| m_TextBuf.AppendChar(Info.m_Unicode); |
| } else { |
| Info.m_Index = -1; |
| @@ -1915,11 +1896,9 @@ int32_t CPDF_TextPage::GetTextObjectWritingMode(const CPDF_TextObject* pTextObj) |
| v.Set(dX, dY); |
| v.Normalize(); |
| if (v.y <= 0.0872f) { |
| - if (v.x <= 0.0872f) { |
| - return m_TextlineDir; |
| - } |
| - return 0; |
| - } else if (v.x <= 0.0872f) { |
| + return v.x <= 0.0872f ? m_TextlineDir : 0; |
| + } |
| + if (v.x <= 0.0872f) { |
| return 1; |
| } |
| return m_TextlineDir; |
| @@ -2698,22 +2677,25 @@ FX_BOOL CPDF_LinkExtract::CheckWebLink(CFX_WideString& strBeCheck) |
| if (str.Find(L"http://www.") != -1) { |
| strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://www.")); |
| return TRUE; |
| - } else if (str.Find(L"http://") != -1) { |
| + } |
| + if (str.Find(L"http://") != -1) { |
| strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"http://")); |
| return TRUE; |
| - } else if (str.Find(L"https://www.") != -1) { |
| + } |
| + if (str.Find(L"https://www.") != -1) { |
| strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://www.")); |
| return TRUE; |
| - } else if (str.Find(L"https://") != -1) { |
| + } |
| + if (str.Find(L"https://") != -1) { |
| strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"https://")); |
| return TRUE; |
| - } else if (str.Find(L"www.") != -1) { |
| + } |
| + if (str.Find(L"www.") != -1) { |
| strBeCheck = strBeCheck.Right(str.GetLength() - str.Find(L"www.")); |
| strBeCheck = L"http://" + strBeCheck; |
| return TRUE; |
| - } else { |
| - return FALSE; |
| } |
| + return FALSE; |
| } |
| FX_BOOL CPDF_LinkExtract::CheckMailLink(CFX_WideString& str) |
| { |