From 007e6c0f9559412788b903bcb6a7601e220c3be8 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 26 Feb 2016 14:31:56 -0800 Subject: 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 . --- xfa/src/fxfa/src/app/xfa_ffdocview.cpp | 6 +++--- xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp | 8 ++++---- xfa/src/fxfa/src/common/fxfa_localevalue.h | 6 +++--- xfa/src/fxfa/src/common/xfa_document.h | 2 +- xfa/src/fxfa/src/common/xfa_object.h | 4 ++-- xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp | 4 ++-- xfa/src/fxfa/src/parser/xfa_localevalue.cpp | 8 +++++--- xfa/src/fxfa/src/parser/xfa_object_imp.cpp | 5 ++--- 8 files changed, 22 insertions(+), 21 deletions(-) (limited to 'xfa/src/fxfa') diff --git a/xfa/src/fxfa/src/app/xfa_ffdocview.cpp b/xfa/src/fxfa/src/app/xfa_ffdocview.cpp index 218e9e3548..05b78ecca4 100644 --- a/xfa/src/fxfa/src/app/xfa_ffdocview.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffdocview.cpp @@ -783,10 +783,10 @@ void CXFA_FFDocView::RunBindItems() { CFX_WideStringC wsValueRef, wsLabelRef; binditems.GetValueRef(wsValueRef); binditems.GetLabelRef(wsLabelRef); - FX_BOOL bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef; - FX_BOOL bLabelUseContent = + const bool bUseValue = wsLabelRef.IsEmpty() || wsLabelRef == wsValueRef; + const bool bLabelUseContent = wsLabelRef.IsEmpty() || wsLabelRef == FX_WSTRC(L"$"); - FX_BOOL bValueUseContent = + const bool bValueUseContent = wsValueRef.IsEmpty() || wsValueRef == FX_WSTRC(L"$"); CFX_WideString wsValue, wsLabel; FX_DWORD uValueHash = FX_HashCode_String_GetW(CFX_WideString(wsValueRef), diff --git a/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp b/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp index e35b14f88f..7d646ca297 100644 --- a/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffwidgetacc.cpp @@ -374,7 +374,7 @@ int32_t CXFA_WidgetAcc::ProcessCalculate() { int32_t iRet = ExecuteScript(script, &EventParam); if (iRet == XFA_EVENTERROR_Sucess) { if (GetRawValue() != EventParam.m_wsResult) { - FX_BOOL bNotify = GetDoc()->GetDocType() == XFA_DOCTYPE_Static; + const bool bNotify = GetDoc()->GetDocType() == XFA_DOCTYPE_Static; SetValue(EventParam.m_wsResult, XFA_VALUEPICTURE_Raw); UpdateUIDisplay(); if (bNotify) { @@ -770,9 +770,9 @@ void CXFA_WidgetAcc::CalcCaptionSize(CFX_SizeF& szCap) { XFA_ELEMENT eUIType = (XFA_ELEMENT)GetUIType(); int32_t iCapPlacement = caption.GetPlacementType(); FX_FLOAT fCapReserve = caption.GetReserve(); - FX_BOOL bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top || - iCapPlacement == XFA_ATTRIBUTEENUM_Bottom; - FX_BOOL bReserveExit = fCapReserve > 0.01; + const bool bVert = iCapPlacement == XFA_ATTRIBUTEENUM_Top || + iCapPlacement == XFA_ATTRIBUTEENUM_Bottom; + const bool bReserveExit = fCapReserve > 0.01; CXFA_TextLayout* pCapTextLayout = ((CXFA_FieldLayoutData*)m_pLayoutData)->m_pCapTextLayout; if (pCapTextLayout) { diff --git a/xfa/src/fxfa/src/common/fxfa_localevalue.h b/xfa/src/fxfa/src/common/fxfa_localevalue.h index a876d6968e..0ac76c8aed 100644 --- a/xfa/src/fxfa/src/common/fxfa_localevalue.h +++ b/xfa/src/fxfa/src/common/fxfa_localevalue.h @@ -95,9 +95,9 @@ class CXFA_LocaleValue { FX_BOOL SetDateTime(const CFX_WideString& wsDateTime, const CFX_WideString& wsFormat, IFX_Locale* pLocale); - inline FX_BOOL IsNull() const { return m_dwType == XFA_VT_NULL; } - inline FX_BOOL IsEmpty() const { return m_wsValue.IsEmpty(); } - inline FX_BOOL IsValid() const { return m_bValid; } + bool IsNull() const { return m_dwType == XFA_VT_NULL; } + FX_BOOL IsEmpty() const { return m_wsValue.IsEmpty(); } + FX_BOOL IsValid() const { return m_bValid; } protected: FX_BOOL ParsePatternValue(const CFX_WideString& wsValue, diff --git a/xfa/src/fxfa/src/common/xfa_document.h b/xfa/src/fxfa/src/common/xfa_document.h index 1e70791748..60706ade98 100644 --- a/xfa/src/fxfa/src/common/xfa_document.h +++ b/xfa/src/fxfa/src/common/xfa_document.h @@ -151,7 +151,7 @@ class CXFA_Document : public IXFA_ObjFactory { void AddPurgeNode(CXFA_Node* pNode); FX_BOOL RemovePurgeNode(CXFA_Node* pNode); void PurgeNodes(); - FX_BOOL HasFlag(FX_DWORD dwFlag) { return (m_dwDocFlags & dwFlag) == dwFlag; } + bool HasFlag(FX_DWORD dwFlag) { return (m_dwDocFlags & dwFlag) == dwFlag; } void SetFlag(FX_DWORD dwFlag, FX_BOOL bOn = TRUE); FX_BOOL IsInteractive(); XFA_VERSION GetCurVersionMode() { return m_eCurVersionMode; } diff --git a/xfa/src/fxfa/src/common/xfa_object.h b/xfa/src/fxfa/src/common/xfa_object.h index be2b604c7f..7819c5f6ba 100644 --- a/xfa/src/fxfa/src/common/xfa_object.h +++ b/xfa/src/fxfa/src/common/xfa_object.h @@ -141,8 +141,8 @@ class CXFA_Node : public CXFA_Object { IFDE_XMLNode* GetXMLMappingNode() const { return m_pXMLNode; } IFDE_XMLNode* CreateXMLMappingNode(); FX_BOOL IsNeedSavingXMLNode(); - inline FX_DWORD GetNameHash() const { return m_dwNameHash; } - inline FX_BOOL IsUnnamed() const { return m_dwNameHash == 0; } + FX_DWORD GetNameHash() const { return m_dwNameHash; } + bool IsUnnamed() const { return m_dwNameHash == 0; } CXFA_Node* GetModelNode(); void UpdateNameHash(); FX_BOOL HasAttribute(XFA_ATTRIBUTE eAttr, FX_BOOL bCanInherit = FALSE); diff --git a/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp b/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp index 819a5e121b..719c9dcf78 100644 --- a/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp +++ b/xfa/src/fxfa/src/parser/xfa_layout_itemlayout.cpp @@ -817,12 +817,12 @@ FX_BOOL CXFA_ItemLayoutProcessor::ProcessKeepNodesForCheckNext( XFA_ItemLayoutProcessorStages& nCurStage, CXFA_Node*& pNextContainer, FX_BOOL& bLastKeepNode) { - FX_BOOL bCanSplite = pNextContainer->GetIntact() == XFA_ATTRIBUTEENUM_None; + const bool bCanSplit = pNextContainer->GetIntact() == XFA_ATTRIBUTEENUM_None; FX_BOOL bNextKeep = FALSE; if (XFA_ExistContainerKeep(pNextContainer, FALSE)) { bNextKeep = TRUE; } - if (bNextKeep && !bCanSplite) { + if (bNextKeep && !bCanSplit) { if (!m_bIsProcessKeep && !m_bKeepBreakFinish) { m_pKeepHeadNode = pNextContainer; m_bIsProcessKeep = TRUE; diff --git a/xfa/src/fxfa/src/parser/xfa_localevalue.cpp b/xfa/src/fxfa/src/parser/xfa_localevalue.cpp index 2222d0cf9c..838634d1e9 100644 --- a/xfa/src/fxfa/src/parser/xfa_localevalue.cpp +++ b/xfa/src/fxfa/src/parser/xfa_localevalue.cpp @@ -597,8 +597,10 @@ FX_BOOL CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate, if (nLen < wCountY || nLen > wCountY + wCountM + wCountD + 2) { return FALSE; } - FX_BOOL bSymbol = (wsDate.Find(0x2D) == -1) ? FALSE : TRUE; - FX_WORD wYear = 0, wMonth = 0, wDay = 0; + const bool bSymbol = wsDate.Find(0x2D) != -1; + FX_WORD wYear = 0; + FX_WORD wMonth = 0; + FX_WORD wDay = 0; const FX_WCHAR* pDate = (const FX_WCHAR*)wsDate; int nIndex = 0, nStart = 0; while (pDate[nIndex] != '\0' && nIndex < wCountY) { @@ -680,7 +682,7 @@ FX_BOOL CXFA_LocaleValue::ValidateCanonicalTime(const CFX_WideString& wsTime) { const FX_WORD wCountM = 2; const FX_WORD wCountS = 2; const FX_WORD wCountF = 3; - FX_BOOL bSymbol = (wsTime.Find(':') == -1) ? FALSE : TRUE; + const bool bSymbol = wsTime.Find(':') != -1; FX_WORD wHour = 0; FX_WORD wMinute = 0; FX_WORD wSecond = 0; diff --git a/xfa/src/fxfa/src/parser/xfa_object_imp.cpp b/xfa/src/fxfa/src/parser/xfa_object_imp.cpp index 67028ee3cd..65992c4201 100644 --- a/xfa/src/fxfa/src/parser/xfa_object_imp.cpp +++ b/xfa/src/fxfa/src/parser/xfa_object_imp.cpp @@ -2319,8 +2319,7 @@ void CXFA_Node::Script_Field_SetItemState(CFXJSE_Arguments* pArguments) { return; } int32_t iIndex = pArguments->GetInt32(0); - FX_BOOL bAdd = pArguments->GetInt32(1) == 0 ? FALSE : TRUE; - if (bAdd) { + if (pArguments->GetInt32(1) != 0) { pWidgetData->SetItemState(iIndex, TRUE, TRUE, TRUE); } else { if (pWidgetData->GetItemState(iIndex)) { @@ -3431,7 +3430,7 @@ void CXFA_Node::Script_Form_Recalculate(CFXJSE_Arguments* pArguments) { } int32_t argc = pArguments->GetLength(); if (argc == 1) { - FX_BOOL bScriptFlags = pArguments->GetInt32(0) == 0 ? FALSE : TRUE; + const bool bScriptFlags = pArguments->GetInt32(0) != 0; IXFA_Notify* pNotify = m_pDocument->GetParser()->GetNotify(); if (!pNotify) { return; -- cgit v1.2.3