summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-19 12:11:49 -0700
committerLei Zhang <thestig@chromium.org>2015-10-19 12:11:49 -0700
commitb0748bb1b207559deaec7a5f49c00c492a5f6082 (patch)
treeb4eb849c5d68388f74ca0e1006895e415f004a43
parent29cd8b9631408c0360c744e23a2733d24c9224ec (diff)
downloadpdfium-b0748bb1b207559deaec7a5f49c00c492a5f6082.tar.xz
Merge to XFA: Sanity check the values of TRUE and FALSE.
Get rid of cond ? TRUE : FALSE. TBR=tsepez@chromium.org Review URL: https://codereview.chromium.org/1405723003 . (cherry picked from commit aff4635dad81bc319266d9d84b81552580cd2b65) Review URL: https://codereview.chromium.org/1412793003 .
-rw-r--r--core/include/fxcrt/fx_system.h5
-rw-r--r--core/include/fxge/fx_dib.h7
-rw-r--r--core/src/fpdfapi/fpdf_render/fpdf_render.cpp2
-rw-r--r--core/src/fpdfdoc/doc_vt.cpp4
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Context.cpp2
-rw-r--r--core/src/fxge/dib/fx_dib_composite.cpp6
-rw-r--r--core/src/fxge/dib/fx_dib_convert.cpp2
-rw-r--r--core/src/fxge/win32/fx_win32_dwrite.cpp2
-rw-r--r--fpdfsdk/src/fpdfview.cpp2
9 files changed, 20 insertions, 12 deletions
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h
index f0d403501c..0ca04307a9 100644
--- a/core/include/fxcrt/fx_system.h
+++ b/core/include/fxcrt/fx_system.h
@@ -92,6 +92,11 @@ typedef int FX_STRSIZE;
#define FALSE 0
#endif
+#ifdef __cplusplus
+static_assert(TRUE == true, "true_needs_to_be_true");
+static_assert(FALSE == false, "false_needs_to_be_false");
+#endif
+
#ifndef NULL
#define NULL 0
#endif
diff --git a/core/include/fxge/fx_dib.h b/core/include/fxge/fx_dib.h
index 818aaac520..e22ab58065 100644
--- a/core/include/fxge/fx_dib.h
+++ b/core/include/fxge/fx_dib.h
@@ -196,13 +196,16 @@ class CFX_DIBSource {
int GetBPP() const { return m_bpp; }
+ // TODO(thestig): Investigate this. Given the possible values of FXDIB_Format,
+ // it feels as though this should be implemented as !!(m_AlphaFlag & 1) and
+ // IsOpaqueImage() below should never be able to return TRUE.
FX_BOOL IsAlphaMask() const { return m_AlphaFlag == 1; }
- FX_BOOL HasAlpha() const { return m_AlphaFlag & 2 ? TRUE : FALSE; }
+ FX_BOOL HasAlpha() const { return !!(m_AlphaFlag & 2); }
FX_BOOL IsOpaqueImage() const { return !(m_AlphaFlag & 3); }
- FX_BOOL IsCmykImage() const { return m_AlphaFlag & 4 ? TRUE : FALSE; }
+ FX_BOOL IsCmykImage() const { return !!(m_AlphaFlag & 4); }
int GetPaletteSize() const {
return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0));
diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
index 905e3d3518..be6483fc31 100644
--- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
+++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp
@@ -759,7 +759,7 @@ FX_BOOL CPDF_RenderStatus::ProcessTransparency(
group_alpha = pStateData->m_FillAlpha;
}
Transparency = pFormObj->m_pForm->m_Transparency;
- bGroupTransparent = Transparency & PDFTRANS_ISOLATED ? TRUE : FALSE;
+ bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED);
if (pFormObj->m_pForm->m_pFormDict) {
pFormResource = pFormObj->m_pForm->m_pFormDict->GetDict("Resources");
}
diff --git a/core/src/fpdfdoc/doc_vt.cpp b/core/src/fpdfdoc/doc_vt.cpp
index 396a7d6b71..fe5680ff9b 100644
--- a/core/src/fpdfdoc/doc_vt.cpp
+++ b/core/src/fpdfdoc/doc_vt.cpp
@@ -430,7 +430,7 @@ static FX_BOOL IsLatin(FX_WORD word) {
return FALSE;
}
static FX_BOOL IsDigit(FX_DWORD word) {
- return (word >= 0x0030 && word <= 0x0039) ? TRUE : FALSE;
+ return word >= 0x0030 && word <= 0x0039;
}
static FX_BOOL IsCJK(FX_DWORD word) {
if ((word >= 0x1100 && word <= 0x11FF) ||
@@ -542,7 +542,7 @@ static FX_BOOL IsPrefixSymbol(FX_WORD word) {
return FALSE;
}
static FX_BOOL IsSpace(FX_WORD word) {
- return (word == 0x0020 || word == 0x3000) ? TRUE : FALSE;
+ return word == 0x0020 || word == 0x3000;
}
static FX_BOOL NeedDivision(FX_WORD prevWord, FX_WORD curWord) {
if ((IsLatin(prevWord) || IsDigit(prevWord)) &&
diff --git a/core/src/fxcodec/jbig2/JBig2_Context.cpp b/core/src/fxcodec/jbig2/JBig2_Context.cpp
index 06863b0bc4..d0f6995e3d 100644
--- a/core/src/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_Context.cpp
@@ -381,7 +381,7 @@ int32_t CJBig2_Context::ProcessingParseSegmentData(CJBig2_Segment* pSegment,
m_pStream->readShortInteger(&wTemp) != 0) {
return JBIG2_ERROR_TOO_SHORT;
}
- pPageInfo->m_bIsStriped = ((wTemp >> 15) & 1) ? TRUE : FALSE;
+ pPageInfo->m_bIsStriped = !!(wTemp & 0x8000);
pPageInfo->m_wMaxStripeSize = wTemp & 0x7fff;
bool bMaxHeight = (pPageInfo->m_dwHeight == 0xffffffff);
if (bMaxHeight && pPageInfo->m_bIsStriped != TRUE)
diff --git a/core/src/fxge/dib/fx_dib_composite.cpp b/core/src/fxge/dib/fx_dib_composite.cpp
index 89a52f3dba..85741fdc54 100644
--- a/core/src/fxge/dib/fx_dib_composite.cpp
+++ b/core/src/fxge/dib/fx_dib_composite.cpp
@@ -4056,8 +4056,8 @@ inline void _ScanlineCompositor_InitSourcePalette(FXDIB_Format src_format,
void* icc_module,
void* pIccTransform) {
ICodec_IccModule* pIccModule = (ICodec_IccModule*)icc_module;
- FX_BOOL isSrcCmyk = src_format & 0x0400 ? TRUE : FALSE;
- FX_BOOL isDstCmyk = dest_format & 0x0400 ? TRUE : FALSE;
+ FX_BOOL isSrcCmyk = !!(src_format & 0x0400);
+ FX_BOOL isDstCmyk = !!(dest_format & 0x0400);
pDestPalette = NULL;
if (pIccTransform) {
if (pSrcPalette) {
@@ -4912,7 +4912,7 @@ FX_BOOL CFX_DIBitmap::CompositeRect(int left,
}
int Bpp = m_bpp / 8;
FX_BOOL bAlpha = HasAlpha();
- FX_BOOL bArgb = GetFormat() == FXDIB_Argb ? TRUE : FALSE;
+ FX_BOOL bArgb = GetFormat() == FXDIB_Argb;
if (src_alpha == 255) {
for (int row = rect.top; row < rect.bottom; row++) {
uint8_t* dest_scan = m_pBuffer + row * m_Pitch + rect.left * Bpp;
diff --git a/core/src/fxge/dib/fx_dib_convert.cpp b/core/src/fxge/dib/fx_dib_convert.cpp
index 3884d0fc8e..d29f00923d 100644
--- a/core/src/fxge/dib/fx_dib_convert.cpp
+++ b/core/src/fxge/dib/fx_dib_convert.cpp
@@ -1100,7 +1100,7 @@ CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format,
}
FX_BOOL ret = TRUE;
CFX_DIBitmap* pSrcAlpha = NULL;
- if (m_AlphaFlag & 2) {
+ if (HasAlpha()) {
pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask;
if (pSrcAlpha == NULL) {
delete pClone;
diff --git a/core/src/fxge/win32/fx_win32_dwrite.cpp b/core/src/fxge/win32/fx_win32_dwrite.cpp
index 5a3c16c2af..0a78dbf1cd 100644
--- a/core/src/fxge/win32/fx_win32_dwrite.cpp
+++ b/core/src/fxge/win32/fx_win32_dwrite.cpp
@@ -240,7 +240,7 @@ FX_BOOL CDWriteExt::DwRendingString(void* renderTarget,
stringRect, pClipRgn, pMatrix ? &transform : NULL, baselineOriginX,
baselineOriginY, DWRITE_MEASURING_MODE_NATURAL, &glyphRun,
RGB(FXARGB_R(text_color), FXARGB_G(text_color), FXARGB_B(text_color)));
- return SUCCEEDED(hr) ? TRUE : FALSE;
+ return SUCCEEDED(hr);
}
void CDWriteExt::DwDeleteRenderingTarget(void* renderTarget) {
delete (CDwGdiTextRenderer*)renderTarget;
diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp
index 6254eb2b67..8e794e1fd6 100644
--- a/fpdfsdk/src/fpdfview.cpp
+++ b/fpdfsdk/src/fpdfview.cpp
@@ -175,7 +175,7 @@ void FSDK_SetSandBoxPolicy(FPDF_DWORD policy, FPDF_BOOL enable) {
FPDF_BOOL FSDK_IsSandBoxPolicyEnabled(FPDF_DWORD policy) {
switch (policy) {
case FPDF_POLICY_MACHINETIME_ACCESS:
- return (foxit_sandbox_policy & 0x01) ? TRUE : FALSE;
+ return !!(foxit_sandbox_policy & 0x01);
default:
return FALSE;
}