summaryrefslogtreecommitdiff
path: root/fpdfsdk/src
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-02-26 14:31:56 -0800
committerTom Sepez <tsepez@chromium.org>2016-02-26 14:31:56 -0800
commit007e6c0f9559412788b903bcb6a7601e220c3be8 (patch)
treea2c6bb85eaa2b63fd24ed70fd3c6ddad54e219d5 /fpdfsdk/src
parent281a9eadff15b167e2ee3032e21b83190ad49125 (diff)
downloadpdfium-007e6c0f9559412788b903bcb6a7601e220c3be8.tar.xz
Remove some FX_BOOLs
Grepping for FX_BOOL and |==| on the same line gives a very strong clue that the expression won't be out of range of the |bool| type iteself. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1736323003 .
Diffstat (limited to 'fpdfsdk/src')
-rw-r--r--fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp4
-rw-r--r--fpdfsdk/src/fsdk_baseannot.cpp48
-rw-r--r--fpdfsdk/src/fsdk_baseform.cpp6
-rw-r--r--fpdfsdk/src/fxedit/fxet_pageobjs.cpp6
-rw-r--r--fpdfsdk/src/javascript/Document.cpp3
5 files changed, 19 insertions, 48 deletions
diff --git a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
index bba44ab639..b28cdf7749 100644
--- a/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
+++ b/fpdfsdk/src/formfiller/FFL_CBA_Fontmap.cpp
@@ -196,9 +196,7 @@ void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont,
CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) {
CPDF_Dictionary* pAcroFormDict = NULL;
-
- FX_BOOL bWidget = (m_pAnnotDict->GetStringBy("Subtype") == "Widget");
-
+ const bool bWidget = (m_pAnnotDict->GetStringBy("Subtype") == "Widget");
if (bWidget) {
if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot())
pAcroFormDict = pRootDict->GetDictBy("AcroForm");
diff --git a/fpdfsdk/src/fsdk_baseannot.cpp b/fpdfsdk/src/fsdk_baseannot.cpp
index 705205f1e2..132d30b857 100644
--- a/fpdfsdk/src/fsdk_baseannot.cpp
+++ b/fpdfsdk/src/fsdk_baseannot.cpp
@@ -85,9 +85,7 @@ void CPDFSDK_DateTime::ResetDateTime() {
time_t curTime;
time(&curTime);
- struct tm* newtime;
- // newtime = gmtime(&curTime);
- newtime = localtime(&curTime);
+ struct tm* newtime = localtime(&curTime);
dt.year = newtime->tm_year + 1900;
dt.month = newtime->tm_mon + 1;
@@ -95,8 +93,6 @@ void CPDFSDK_DateTime::ResetDateTime() {
dt.hour = newtime->tm_hour;
dt.minute = newtime->tm_min;
dt.second = newtime->tm_sec;
- // dt.tzHour = _timezone / 3600 * -1;
- // dt.tzMinute = (abs(_timezone) % 3600) / 60;
}
CPDFSDK_DateTime& CPDFSDK_DateTime::operator=(
@@ -114,20 +110,18 @@ CPDFSDK_DateTime& CPDFSDK_DateTime::operator=(const FX_SYSTEMTIME& st) {
dt.hour = (uint8_t)st.wHour;
dt.minute = (uint8_t)st.wMinute;
dt.second = (uint8_t)st.wSecond;
- // dt.tzHour = _timezone / 3600 * -1;
- // dt.tzMinute = (abs(_timezone) % 3600) / 60;
return *this;
}
-FX_BOOL CPDFSDK_DateTime::operator==(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator==(const CPDFSDK_DateTime& datetime) const {
return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) == 0);
}
-FX_BOOL CPDFSDK_DateTime::operator!=(CPDFSDK_DateTime& datetime) {
- return (FXSYS_memcmp(&dt, &datetime.dt, sizeof(FX_DATETIME)) != 0);
+bool CPDFSDK_DateTime::operator!=(const CPDFSDK_DateTime& datetime) const {
+ return !(*this == datetime);
}
-FX_BOOL CPDFSDK_DateTime::operator>(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator>(const CPDFSDK_DateTime& datetime) const {
CPDFSDK_DateTime dt1 = ToGMT();
CPDFSDK_DateTime dt2 = datetime.ToGMT();
int d1 =
@@ -139,14 +133,10 @@ FX_BOOL CPDFSDK_DateTime::operator>(CPDFSDK_DateTime& datetime) {
int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) |
(int)dt2.dt.second;
- if (d1 > d3)
- return TRUE;
- if (d2 > d4)
- return TRUE;
- return FALSE;
+ return d1 > d3 || d2 > d4;
}
-FX_BOOL CPDFSDK_DateTime::operator>=(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator>=(const CPDFSDK_DateTime& datetime) const {
CPDFSDK_DateTime dt1 = ToGMT();
CPDFSDK_DateTime dt2 = datetime.ToGMT();
int d1 =
@@ -158,14 +148,10 @@ FX_BOOL CPDFSDK_DateTime::operator>=(CPDFSDK_DateTime& datetime) {
int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) |
(int)dt2.dt.second;
- if (d1 >= d3)
- return TRUE;
- if (d2 >= d4)
- return TRUE;
- return FALSE;
+ return d1 >= d3 || d2 >= d4;
}
-FX_BOOL CPDFSDK_DateTime::operator<(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator<(const CPDFSDK_DateTime& datetime) const {
CPDFSDK_DateTime dt1 = ToGMT();
CPDFSDK_DateTime dt2 = datetime.ToGMT();
int d1 =
@@ -177,14 +163,10 @@ FX_BOOL CPDFSDK_DateTime::operator<(CPDFSDK_DateTime& datetime) {
int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) |
(int)dt2.dt.second;
- if (d1 < d3)
- return TRUE;
- if (d2 < d4)
- return TRUE;
- return FALSE;
+ return d1 < d3 || d2 < d4;
}
-FX_BOOL CPDFSDK_DateTime::operator<=(CPDFSDK_DateTime& datetime) {
+bool CPDFSDK_DateTime::operator<=(const CPDFSDK_DateTime& datetime) const {
CPDFSDK_DateTime dt1 = ToGMT();
CPDFSDK_DateTime dt2 = datetime.ToGMT();
int d1 =
@@ -196,11 +178,7 @@ FX_BOOL CPDFSDK_DateTime::operator<=(CPDFSDK_DateTime& datetime) {
int d4 = (((int)dt2.dt.hour) << 16) | (((int)dt2.dt.minute) << 8) |
(int)dt2.dt.second;
- if (d1 <= d3)
- return TRUE;
- if (d2 <= d4)
- return TRUE;
- return FALSE;
+ return d1 <= d3 || d2 <= d4;
}
CPDFSDK_DateTime::operator time_t() {
@@ -402,7 +380,7 @@ void CPDFSDK_DateTime::ToSystemTime(FX_SYSTEMTIME& st) {
}
}
-CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT() {
+CPDFSDK_DateTime CPDFSDK_DateTime::ToGMT() const {
CPDFSDK_DateTime dt = *this;
dt.AddSeconds(-gAfxGetTimeZoneInSeconds(dt.dt.tzHour, dt.dt.tzMinute));
dt.dt.tzHour = 0;
diff --git a/fpdfsdk/src/fsdk_baseform.cpp b/fpdfsdk/src/fsdk_baseform.cpp
index 0359c0bc9f..79180324f7 100644
--- a/fpdfsdk/src/fsdk_baseform.cpp
+++ b/fpdfsdk/src/fsdk_baseform.cpp
@@ -662,10 +662,8 @@ FX_BOOL CPDFSDK_Widget::IsChecked() const {
#ifdef PDF_ENABLE_XFA
if (IXFA_WidgetHandler* pXFAWidgetHandler = GetXFAWidgetHandler()) {
if (IXFA_Widget* hWidget = GetMixXFAWidget()) {
- if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget)) {
- FX_BOOL bChecked = pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On;
- return bChecked;
- }
+ if (CXFA_WidgetAcc* pWidgetAcc = pXFAWidgetHandler->GetDataAcc(hWidget))
+ return pWidgetAcc->GetCheckState() == XFA_CHECKSTATE_On;
}
}
#endif // PDF_ENABLE_XFA
diff --git a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
index 752e537099..d7803311a5 100644
--- a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
@@ -151,10 +151,8 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
const CPVT_WordRange* pRange,
IFX_SystemHandler* pSystemHandler,
void* pFFLData) {
- FX_BOOL bContinuous = pEdit->GetCharArray() == 0;
- if (pEdit->GetCharSpace() > 0.0f)
- bContinuous = FALSE;
-
+ const bool bContinuous =
+ pEdit->GetCharArray() == 0 && pEdit->GetCharSpace() <= 0.0f;
FX_WORD SubWord = pEdit->GetPasswordChar();
FX_FLOAT fFontSize = pEdit->GetFontSize();
CPVT_WordRange wrSelect = pEdit->GetSelectWordRange();
diff --git a/fpdfsdk/src/javascript/Document.cpp b/fpdfsdk/src/javascript/Document.cpp
index 8b2b315ae8..4d774426f0 100644
--- a/fpdfsdk/src/javascript/Document.cpp
+++ b/fpdfsdk/src/javascript/Document.cpp
@@ -622,8 +622,7 @@ FX_BOOL Document::submitForm(IJS_Context* cc,
CPDFSDK_InterForm* pInterForm =
(CPDFSDK_InterForm*)m_pDocument->GetInterForm();
CPDF_InterForm* pPDFInterForm = pInterForm->GetInterForm();
- FX_BOOL bAll = (aFields.GetLength() == 0);
- if (bAll && bEmpty) {
+ if (aFields.GetLength() == 0 && bEmpty) {
if (pPDFInterForm->CheckRequiredFields(nullptr, true)) {
pRuntime->BeginBlock();
pInterForm->SubmitForm(strURL, FALSE);