From 2e53b58879bbc5b994d24d3fb1ccb3551f9dab64 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Sun, 18 Dec 2011 01:00:47 -0500 Subject: [PATCH] Bug 711799 - Add parentheses to a bunch of && expressions nested within || expressions. r=dholbert --- accessible/src/base/nsDocAccessible.cpp | 8 ++-- content/base/src/nsXMLHttpRequest.cpp | 4 +- .../html/content/src/nsHTMLButtonElement.cpp | 4 +- .../content/src/nsHTMLMenuItemElement.cpp | 2 +- .../content/src/nsHTMLTextAreaElement.cpp | 2 +- content/xbl/src/nsXBLPrototypeBinding.cpp | 6 +-- .../universalchardet/src/base/JpCntx.cpp | 4 +- layout/base/FrameLayerBuilder.cpp | 9 ++-- layout/generic/nsSelection.cpp | 2 +- .../converters/mozTXTToHTMLConv.cpp | 48 +++++++++---------- .../nsUrlClassifierDBService.cpp | 4 +- widget/src/gtk2/nsNativeKeyBindings.cpp | 6 ++- xpfe/appshell/src/nsWindowMediator.cpp | 8 ++-- 13 files changed, 55 insertions(+), 52 deletions(-) diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 7588f2f49be4..f4d8bcf56929 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -1565,14 +1565,14 @@ nsDocAccessible::AddDependentIDsFor(nsAccessible* aRelProvider, if (relAttr == nsGkAtoms::_for) { if (!aRelProvider->GetContent()->IsHTML() || - aRelProvider->GetContent()->Tag() != nsGkAtoms::label && - aRelProvider->GetContent()->Tag() != nsGkAtoms::output) + (aRelProvider->GetContent()->Tag() != nsGkAtoms::label && + aRelProvider->GetContent()->Tag() != nsGkAtoms::output)) continue; } else if (relAttr == nsGkAtoms::control) { if (!aRelProvider->GetContent()->IsXUL() || - aRelProvider->GetContent()->Tag() != nsGkAtoms::label && - aRelProvider->GetContent()->Tag() != nsGkAtoms::description) + (aRelProvider->GetContent()->Tag() != nsGkAtoms::label && + aRelProvider->GetContent()->Tag() != nsGkAtoms::description)) continue; } diff --git a/content/base/src/nsXMLHttpRequest.cpp b/content/base/src/nsXMLHttpRequest.cpp index 1114390c53ed..222f05ddb473 100644 --- a/content/base/src/nsXMLHttpRequest.cpp +++ b/content/base/src/nsXMLHttpRequest.cpp @@ -2691,8 +2691,8 @@ nsXMLHttpRequest::Send(nsIVariant *aBody) // can run script that would try to restart this request, and that could end // up doing our AsyncOpen on a null channel if the reentered AsyncOpen fails. ChangeState(XML_HTTP_REQUEST_SENT); - if (!mUploadComplete && - HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR)) || + if ((!mUploadComplete && + HasListenersFor(NS_LITERAL_STRING(UPLOADPROGRESS_STR))) || (mUpload && mUpload->HasListenersFor(NS_LITERAL_STRING(PROGRESS_STR)))) { StartProgressEventTimer(); } diff --git a/content/html/content/src/nsHTMLButtonElement.cpp b/content/html/content/src/nsHTMLButtonElement.cpp index 2a8485c92629..72fc8ab8a9d5 100644 --- a/content/html/content/src/nsHTMLButtonElement.cpp +++ b/content/html/content/src/nsHTMLButtonElement.cpp @@ -378,8 +378,8 @@ nsHTMLButtonElement::PostHandleEvent(nsEventChainPostVisitor& aVisitor) nsKeyEvent * keyEvent = (nsKeyEvent *)aVisitor.mEvent; if ((keyEvent->keyCode == NS_VK_RETURN && NS_KEY_PRESS == aVisitor.mEvent->message) || - keyEvent->keyCode == NS_VK_SPACE && - NS_KEY_UP == aVisitor.mEvent->message) { + (keyEvent->keyCode == NS_VK_SPACE && + NS_KEY_UP == aVisitor.mEvent->message)) { nsEventStatus status = nsEventStatus_eIgnore; nsMouseEvent event(NS_IS_TRUSTED_EVENT(aVisitor.mEvent), diff --git a/content/html/content/src/nsHTMLMenuItemElement.cpp b/content/html/content/src/nsHTMLMenuItemElement.cpp index c26b31fb6b3c..246cc353c594 100644 --- a/content/html/content/src/nsHTMLMenuItemElement.cpp +++ b/content/html/content/src/nsHTMLMenuItemElement.cpp @@ -471,7 +471,7 @@ nsHTMLMenuItemElement::WalkRadioGroup(Visitor* aVisitor) bool info2Empty = !info2.mValue || info2.mValue->IsEmptyString(); if (info1Empty != info2Empty || - info1.mValue && info2.mValue && !info1.mValue->Equals(*info2.mValue)) { + (info1.mValue && info2.mValue && !info1.mValue->Equals(*info2.mValue))) { continue; } diff --git a/content/html/content/src/nsHTMLTextAreaElement.cpp b/content/html/content/src/nsHTMLTextAreaElement.cpp index b2fbb81d8d97..7adaea4cf207 100644 --- a/content/html/content/src/nsHTMLTextAreaElement.cpp +++ b/content/html/content/src/nsHTMLTextAreaElement.cpp @@ -1142,7 +1142,7 @@ nsHTMLTextAreaElement::IntrinsicState() const // error and never applies if novalidate is set on the form owner. if ((!mForm || !mForm->HasAttr(kNameSpaceID_None, nsGkAtoms::novalidate)) && (GetValidityState(VALIDITY_STATE_CUSTOM_ERROR) || - mCanShowInvalidUI && ShouldShowValidityUI())) { + (mCanShowInvalidUI && ShouldShowValidityUI()))) { state |= NS_EVENT_STATE_MOZ_UI_INVALID; } } diff --git a/content/xbl/src/nsXBLPrototypeBinding.cpp b/content/xbl/src/nsXBLPrototypeBinding.cpp index 574798807fa8..c7948e3bc247 100644 --- a/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -641,9 +641,9 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute, // xbl:text set on us. if ((dstAttr == nsGkAtoms::text && dstNs == kNameSpaceID_XBL) || - realElement->NodeInfo()->Equals(nsGkAtoms::html, - kNameSpaceID_XUL) && - dstAttr == nsGkAtoms::value) { + (realElement->NodeInfo()->Equals(nsGkAtoms::html, + kNameSpaceID_XUL) && + dstAttr == nsGkAtoms::value)) { // Flush out all our kids. PRUint32 childCount = realElement->GetChildCount(); for (PRUint32 i = 0; i < childCount; i++) diff --git a/extensions/universalchardet/src/base/JpCntx.cpp b/extensions/universalchardet/src/base/JpCntx.cpp index b670664ec826..a6d29757d676 100644 --- a/extensions/universalchardet/src/base/JpCntx.cpp +++ b/extensions/universalchardet/src/base/JpCntx.cpp @@ -195,8 +195,8 @@ float JapaneseContextAnalysis::GetConfidence(void) PRInt32 SJISContextAnalysis::GetOrder(const char* str, PRUint32 *charLen) { //find out current char's byte length - if ((unsigned char)*str >= (unsigned char)0x81 && (unsigned char)*str <= (unsigned char)0x9f || - (unsigned char)*str >= (unsigned char)0xe0 && (unsigned char)*str <= (unsigned char)0xfc ) + if (((unsigned char)*str >= (unsigned char)0x81 && (unsigned char)*str <= (unsigned char)0x9f) || + ((unsigned char)*str >= (unsigned char)0xe0 && (unsigned char)*str <= (unsigned char)0xfc) ) *charLen = 2; else *charLen = 1; diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 50bce975cc29..fd7eca028291 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -1377,10 +1377,11 @@ ContainerState::ProcessDisplayItems(const nsDisplayList& aList, // Assign the item to a layer if (layerState == LAYER_ACTIVE_FORCE || layerState == LAYER_ACTIVE_EMPTY || - layerState == LAYER_ACTIVE && (aClip.mRoundedClipRects.IsEmpty() || - // We can use the visible rect here only because the item has its own - // layer, like the comment below. - !aClip.IsRectClippedByRoundedCorner(item->GetVisibleRect()))) { + (layerState == LAYER_ACTIVE && + (aClip.mRoundedClipRects.IsEmpty() || + // We can use the visible rect here only because the item has its own + // layer, like the comment below. + !aClip.IsRectClippedByRoundedCorner(item->GetVisibleRect())))) { // LAYER_ACTIVE_EMPTY means the layer is created just for its metadata. // We should never see an empty layer with any visible content! diff --git a/layout/generic/nsSelection.cpp b/layout/generic/nsSelection.cpp index 326560ecb85a..99bc5ba318f9 100644 --- a/layout/generic/nsSelection.cpp +++ b/layout/generic/nsSelection.cpp @@ -1626,7 +1626,7 @@ nsFrameSelection::AdjustForMaintainedSelection(nsIContent *aContent, // If aContent/aOffset is inside the maintained selection, or if it is on the // "anchor" side of the maintained selection, we need to do something. - if (relToStart < 0 && relToEnd > 0 || + if ((relToStart < 0 && relToEnd > 0) || (relToStart > 0 && mDomSelections[index]->GetDirection() == eDirNext) || (relToEnd < 0 && diff --git a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index 76b8fae81f77..08da82266e03 100644 --- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp @@ -613,12 +613,12 @@ mozTXTToHTMLConv::ItMatchesDelimited(const PRUnichar * aInString, if ( - (before == LT_IGNORE && (after == LT_IGNORE || after == LT_DELIMITER)) - && textLen < aRepLen || - (before != LT_IGNORE || after != LT_IGNORE && after != LT_DELIMITER) - && textLen < aRepLen + 1 || - before != LT_IGNORE && after != LT_IGNORE && after != LT_DELIMITER - && textLen < aRepLen + 2 + ((before == LT_IGNORE && (after == LT_IGNORE || after == LT_DELIMITER)) + && textLen < aRepLen) || + ((before != LT_IGNORE || (after != LT_IGNORE && after != LT_DELIMITER)) + && textLen < aRepLen + 1) || + (before != LT_IGNORE && after != LT_IGNORE && after != LT_DELIMITER + && textLen < aRepLen + 2) ) return false; @@ -627,28 +627,28 @@ mozTXTToHTMLConv::ItMatchesDelimited(const PRUnichar * aInString, if ( - before == LT_ALPHA - && !nsCRT::IsAsciiAlpha(text0) || - before == LT_DIGIT - && !nsCRT::IsAsciiDigit(text0) || - before == LT_DELIMITER + (before == LT_ALPHA + && !nsCRT::IsAsciiAlpha(text0)) || + (before == LT_DIGIT + && !nsCRT::IsAsciiDigit(text0)) || + (before == LT_DELIMITER && ( nsCRT::IsAsciiAlpha(text0) || nsCRT::IsAsciiDigit(text0) || text0 == *rep - ) || - after == LT_ALPHA - && !nsCRT::IsAsciiAlpha(textAfterPos) || - after == LT_DIGIT - && !nsCRT::IsAsciiDigit(textAfterPos) || - after == LT_DELIMITER + )) || + (after == LT_ALPHA + && !nsCRT::IsAsciiAlpha(textAfterPos)) || + (after == LT_DIGIT + && !nsCRT::IsAsciiDigit(textAfterPos)) || + (after == LT_DELIMITER && ( nsCRT::IsAsciiAlpha(textAfterPos) || nsCRT::IsAsciiDigit(textAfterPos) || textAfterPos == *rep - ) || + )) || !Substring(Substring(aInString, aInString+aInLength), (before == LT_IGNORE ? 0 : 1), aRepLen).Equals(Substring(rep, rep+aRepLen), @@ -754,7 +754,7 @@ mozTXTToHTMLConv::SmilyHit(const PRUnichar * aInString, PRInt32 aLength, bool co ( aLength <= PRInt32(delim) || IsSpace(aInString[delim]) || - aLength > PRInt32(delim + 1) + (aLength > PRInt32(delim + 1) && ( aInString[delim] == '.' || @@ -765,7 +765,7 @@ mozTXTToHTMLConv::SmilyHit(const PRUnichar * aInString, PRInt32 aLength, bool co aInString[delim] == '!' || aInString[delim] == '?' ) - && IsSpace(aInString[delim + 1]) + && IsSpace(aInString[delim + 1])) ) && ItMatchesDelimited(aInString, aLength, NS_ConvertASCIItoUTF16(tagTXT).get(), tagLen, col0 ? LT_IGNORE : LT_DELIMITER, LT_IGNORE) @@ -980,8 +980,8 @@ mozTXTToHTMLConv::GlyphHit(const PRUnichar * aInString, PRInt32 aInLength, bool ) && ( - 2 < aInLength && nsCRT::IsAsciiDigit(aInString[2]) || - 3 < aInLength && aInString[2] == '-' && nsCRT::IsAsciiDigit(aInString[3]) + (2 < aInLength && nsCRT::IsAsciiDigit(aInString[2])) || + (3 < aInLength && aInString[2] == '-' && nsCRT::IsAsciiDigit(aInString[3])) ) ) { @@ -991,8 +991,8 @@ mozTXTToHTMLConv::GlyphHit(const PRUnichar * aInString, PRInt32 aInLength, bool && ( nsCRT::IsAsciiDigit(aInString[delimPos]) || - aInString[delimPos] == '.' && delimPos + 1 < aInLength && - nsCRT::IsAsciiDigit(aInString[delimPos + 1]) + (aInString[delimPos] == '.' && delimPos + 1 < aInLength && + nsCRT::IsAsciiDigit(aInString[delimPos + 1])) ); delimPos++) ; diff --git a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp index 63e05c8b69cc..7a1a100998ee 100644 --- a/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp +++ b/toolkit/components/url-classifier/nsUrlClassifierDBService.cpp @@ -338,9 +338,9 @@ public: bool operator< (const nsUrlClassifierEntry& entry) const { return (mTableId < entry.mTableId || mChunkId < entry.mChunkId || - mHavePartial && !entry.mHavePartial || + (mHavePartial && !entry.mHavePartial) || (mHavePartial && mPartialHash < entry.mPartialHash) || - mHaveComplete && !entry.mHaveComplete || + (mHaveComplete && !entry.mHaveComplete) || (mHaveComplete && mCompleteHash < entry.mCompleteHash)); } diff --git a/widget/src/gtk2/nsNativeKeyBindings.cpp b/widget/src/gtk2/nsNativeKeyBindings.cpp index 484b90b5f77a..47469b0469c1 100644 --- a/widget/src/gtk2/nsNativeKeyBindings.cpp +++ b/widget/src/gtk2/nsNativeKeyBindings.cpp @@ -288,9 +288,11 @@ nsNativeKeyBindings::KeyPress(const nsNativeKeyEvent& aEvent, return true; nsKeyEvent *nativeKeyEvent = static_cast(aEvent.nativeEvent); - if (!nativeKeyEvent || nativeKeyEvent->eventStructType != NS_KEY_EVENT && - nativeKeyEvent->message != NS_KEY_PRESS) + if (!nativeKeyEvent || + (nativeKeyEvent->eventStructType != NS_KEY_EVENT && + nativeKeyEvent->message != NS_KEY_PRESS)) { return false; + } for (PRUint32 i = 0; i < nativeKeyEvent->alternativeCharCodes.Length(); ++i) { PRUint32 ch = nativeKeyEvent->isShift ? diff --git a/xpfe/appshell/src/nsWindowMediator.cpp b/xpfe/appshell/src/nsWindowMediator.cpp index 31fe03e74fc7..9e0b128c66c0 100644 --- a/xpfe/appshell/src/nsWindowMediator.cpp +++ b/xpfe/appshell/src/nsWindowMediator.cpp @@ -436,7 +436,7 @@ nsWindowMediator::CalculateZPosition( // locate inBelow. use topmost if it can't be found or isn't in the // z-order list info = GetInfoFor(inBelow); - if (!info || info->mYounger != info && info->mLower == info) + if (!info || (info->mYounger != info && info->mLower == info)) info = mTopmostWindow; else found = true; @@ -533,9 +533,9 @@ nsWindowMediator::SetZPosition( nsWindowInfo *inInfo, *belowInfo; - if (inPosition != nsIWindowMediator::zLevelTop && - inPosition != nsIWindowMediator::zLevelBottom && - inPosition != nsIWindowMediator::zLevelBelow || + if ((inPosition != nsIWindowMediator::zLevelTop && + inPosition != nsIWindowMediator::zLevelBottom && + inPosition != nsIWindowMediator::zLevelBelow) || !inWindow) { return NS_ERROR_INVALID_ARG; }