Clean up prbool misuse in layout. bug 398312, r+sr+a=dbaron

This commit is contained in:
tglek@mozilla.com 2007-10-09 17:00:05 -07:00
parent ac490cdd0b
commit 8cf3fb1c90
18 changed files with 29 additions and 35 deletions

View File

@ -1359,7 +1359,7 @@ nsresult nsBidiPresUtils::ProcessText(const PRUnichar* aText,
PRUint32 hints = 0; PRUint32 hints = 0;
aRenderingContext.GetHints(hints); aRenderingContext.GetHints(hints);
PRBool isBidiSystem = (hints & NS_RENDERING_HINT_BIDI_REORDERING); PRBool isBidiSystem = !!(hints & NS_RENDERING_HINT_BIDI_REORDERING);
for(int nPosResolve=0; nPosResolve < aPosResolveCount; ++nPosResolve) for(int nPosResolve=0; nPosResolve < aPosResolveCount; ++nPosResolve)
{ {
@ -1407,7 +1407,7 @@ nsresult nsBidiPresUtils::ProcessText(const PRUnichar* aText,
CalculateCharType(lineOffset, typeLimit, subRunLimit, subRunLength, subRunCount, charType, prevType); CalculateCharType(lineOffset, typeLimit, subRunLimit, subRunLength, subRunCount, charType, prevType);
if (eCharType_RightToLeftArabic == charType) { if (eCharType_RightToLeftArabic == charType) {
isBidiSystem = (hints & NS_RENDERING_HINT_ARABIC_SHAPING); isBidiSystem = !!(hints & NS_RENDERING_HINT_ARABIC_SHAPING);
} }
if (isBidiSystem && (CHARTYPE_IS_RTL(charType) ^ isRTL) ) { if (isBidiSystem && (CHARTYPE_IS_RTL(charType) ^ isRTL) ) {
// set reading order into DC // set reading order into DC

View File

@ -4129,7 +4129,7 @@ nsCSSRendering::DrawTableBorderSegment(nsIRenderingContext& aContext,
PRBool horizontal = ((NS_SIDE_TOP == aStartBevelSide) || (NS_SIDE_BOTTOM == aStartBevelSide)); PRBool horizontal = ((NS_SIDE_TOP == aStartBevelSide) || (NS_SIDE_BOTTOM == aStartBevelSide));
nscoord twipsPerPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerCSSPixel); nscoord twipsPerPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerCSSPixel);
PRBool ridgeGroove = NS_STYLE_BORDER_STYLE_RIDGE; PRUint8 ridgeGroove = NS_STYLE_BORDER_STYLE_RIDGE;
if ((twipsPerPixel >= aBorder.width) || (twipsPerPixel >= aBorder.height) || if ((twipsPerPixel >= aBorder.width) || (twipsPerPixel >= aBorder.height) ||
(NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle) || (NS_STYLE_BORDER_STYLE_DOTTED == aBorderStyle)) { (NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle) || (NS_STYLE_BORDER_STYLE_DOTTED == aBorderStyle)) {

View File

@ -592,7 +592,7 @@ nsCaret::DrawAtPositionWithHint(nsIDOMNode* aNode,
if (aBidiLevel & BIDI_LEVEL_UNDEFINED) { if (aBidiLevel & BIDI_LEVEL_UNDEFINED) {
nsFrameSelection* frameSelection = GetFrameSelection(); nsFrameSelection* frameSelection = GetFrameSelection();
if (!frameSelection) if (!frameSelection)
return NS_ERROR_FAILURE; return PR_FALSE;
frameSelection->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(theFrame)); frameSelection->SetCaretBidiLevel(NS_GET_EMBEDDING_LEVEL(theFrame));
} }

View File

@ -96,7 +96,7 @@ nsGenConList::DestroyNodesFor(nsIFrame* aFrame)
} }
// return -1 for ::before, +1 for ::after, and 0 otherwise. // return -1 for ::before, +1 for ::after, and 0 otherwise.
inline PRBool PseudoCompareType(nsIFrame *aFrame) inline PRInt32 PseudoCompareType(nsIFrame *aFrame)
{ {
nsIAtom *pseudo = aFrame->GetStyleContext()->GetPseudoType(); nsIAtom *pseudo = aFrame->GetStyleContext()->GetPseudoType();
if (pseudo == nsCSSPseudoElements::before) if (pseudo == nsCSSPseudoElements::before)

View File

@ -286,9 +286,7 @@ public:
PRBool GetFlag(PRUint32 aFlag) const PRBool GetFlag(PRUint32 aFlag) const
{ {
NS_ASSERTION(aFlag<=BRS_LASTFLAG, "bad flag"); NS_ASSERTION(aFlag<=BRS_LASTFLAG, "bad flag");
PRBool result = (mFlags & aFlag); return !!(mFlags & aFlag);
if (result) return PR_TRUE;
return PR_FALSE;
} }
}; };

View File

@ -290,7 +290,7 @@ nsBulletFrame::PaintBullet(nsIRenderingContext& aRenderingContext, nsPoint aPt,
case NS_STYLE_LIST_STYLE_HEBREW: case NS_STYLE_LIST_STYLE_HEBREW:
aRenderingContext.GetHints(hints); aRenderingContext.GetHints(hints);
isBidiSystem = (hints & NS_RENDERING_HINT_BIDI_REORDERING); isBidiSystem = !!(hints & NS_RENDERING_HINT_BIDI_REORDERING);
if (!isBidiSystem) { if (!isBidiSystem) {
if (GetListItemText(*myList, text)) { if (GetListItemText(*myList, text)) {
charType = eCharType_RightToLeft; charType = eCharType_RightToLeft;
@ -401,7 +401,7 @@ nsBulletFrame::PaintBullet(nsIRenderingContext& aRenderingContext, nsPoint aPt,
else { else {
//Mohamed //Mohamed
aRenderingContext.GetHints(hints); aRenderingContext.GetHints(hints);
isBidiSystem = (hints & NS_RENDERING_HINT_ARABIC_SHAPING); isBidiSystem = !!(hints & NS_RENDERING_HINT_ARABIC_SHAPING);
bidiUtils->FormatUnicodeText(presContext, (PRUnichar*)buffer, textLength, bidiUtils->FormatUnicodeText(presContext, (PRUnichar*)buffer, textLength,
charType, level, isBidiSystem, isNewTextRunSystem);//Mohamed charType, level, isBidiSystem, isNewTextRunSystem);//Mohamed
} }

View File

@ -4108,7 +4108,7 @@ nsFrame::GetSelected(PRBool *aSelected) const
{ {
if (!aSelected ) if (!aSelected )
return NS_ERROR_NULL_POINTER; return NS_ERROR_NULL_POINTER;
*aSelected = (PRBool)(mState & NS_FRAME_SELECTED_CONTENT); *aSelected = !!(mState & NS_FRAME_SELECTED_CONTENT);
return NS_OK; return NS_OK;
} }
@ -6758,7 +6758,7 @@ DR_Rule* DR_State::ParseRule(FILE* aFile)
while (GetToken(aFile, buf)) { while (GetToken(aFile, buf)) {
if (GetNumber(buf, doDisplay)) { if (GetNumber(buf, doDisplay)) {
if (rule) { if (rule) {
rule->mDisplay = (PRBool)doDisplay; rule->mDisplay = !!doDisplay;
break; break;
} }
else { else {

View File

@ -1430,7 +1430,7 @@ public:
* *
* GetView returns non-null if and only if |HasView| returns true. * GetView returns non-null if and only if |HasView| returns true.
*/ */
PRBool HasView() const { return mState & NS_FRAME_HAS_VIEW; } PRBool HasView() const { return !!(mState & NS_FRAME_HAS_VIEW); }
nsIView* GetView() const; nsIView* GetView() const;
virtual nsIView* GetViewExternal() const; virtual nsIView* GetViewExternal() const;
nsresult SetView(nsIView* aView); nsresult SetView(nsIView* aView);

View File

@ -138,7 +138,7 @@ public:
// If the frame's bidi visual state is set, return is-leftmost state // If the frame's bidi visual state is set, return is-leftmost state
// else return true if it's the first continuation. // else return true if it's the first continuation.
return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET)
? (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_LEFT_MOST) ? !!(GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_LEFT_MOST)
: (!GetPrevInFlow()); : (!GetPrevInFlow());
} }
@ -149,7 +149,7 @@ public:
// If the frame's bidi visual state is set, return is-rightmost state // If the frame's bidi visual state is set, return is-rightmost state
// else return true if it's the last continuation. // else return true if it's the last continuation.
return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET) return (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_STATE_IS_SET)
? (GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_RIGHT_MOST) ? !!(GetStateBits() & NS_INLINE_FRAME_BIDI_VISUAL_IS_RIGHT_MOST)
: (!GetNextInFlow()); : (!GetNextInFlow());
} }

View File

@ -166,9 +166,7 @@ protected:
PRBool GetFlag(PRUint32 aFlag) const PRBool GetFlag(PRUint32 aFlag) const
{ {
NS_ASSERTION(aFlag<=LL_LASTFLAG, "bad flag"); NS_ASSERTION(aFlag<=LL_LASTFLAG, "bad flag");
PRBool result = (mFlags & aFlag); return !!(mFlags & aFlag);
if (result) return PR_TRUE;
return PR_FALSE;
} }
public: public:
@ -447,9 +445,7 @@ protected:
PRBool GetFlag(PRUint32 aFlag) const PRBool GetFlag(PRUint32 aFlag) const
{ {
NS_ASSERTION(aFlag<=PFD_LASTFLAG, "bad flag"); NS_ASSERTION(aFlag<=PFD_LASTFLAG, "bad flag");
PRBool result = (mFlags & aFlag); return !!(mFlags & aFlag);
if (result) return PR_TRUE;
return PR_FALSE;
} }

View File

@ -1099,7 +1099,7 @@ nsFrameSelection::SetCaretBidiLevel(PRUint8 aLevel)
{ {
// If the current level is undefined, we have just inserted new text. // If the current level is undefined, we have just inserted new text.
// In this case, we don't want to reset the keyboard language // In this case, we don't want to reset the keyboard language
PRBool afterInsert = mCaretBidiLevel & BIDI_LEVEL_UNDEFINED; PRBool afterInsert = !!(mCaretBidiLevel & BIDI_LEVEL_UNDEFINED);
mCaretBidiLevel = aLevel; mCaretBidiLevel = aLevel;
nsIBidiKeyboard* bidiKeyboard = nsContentUtils::GetBidiKeyboard(); nsIBidiKeyboard* bidiKeyboard = nsContentUtils::GetBidiKeyboard();

View File

@ -107,7 +107,7 @@ public:
FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules); FindChildWithRules(const nsIAtom* aPseudoTag, nsRuleNode* aRules);
NS_HIDDEN_(PRBool) Equals(const nsStyleContext* aOther) const; NS_HIDDEN_(PRBool) Equals(const nsStyleContext* aOther) const;
PRBool HasTextDecorations() { return mBits & NS_STYLE_HAS_TEXT_DECORATIONS; } PRBool HasTextDecorations() { return !!(mBits & NS_STYLE_HAS_TEXT_DECORATIONS); }
NS_HIDDEN_(void) SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct); NS_HIDDEN_(void) SetStyle(nsStyleStructID aSID, nsStyleStruct* aStruct);

View File

@ -579,7 +579,7 @@ struct nsStyleOutline: public nsStyleStruct {
PRBool GetOutlineInitialColor() const PRBool GetOutlineInitialColor() const
{ {
return (mOutlineStyle & OUTLINE_COLOR_INITIAL); return !!(mOutlineStyle & OUTLINE_COLOR_INITIAL);
} }
protected: protected:

View File

@ -1268,7 +1268,7 @@ nsSVGGlyphFrame::ContainsPoint(float x, float y)
gfxContext *gfx = ctx.GetContext(); gfxContext *gfx = ctx.GetContext();
gfxTextRun *textRun = ctx.GetTextRun(); gfxTextRun *textRun = ctx.GetTextRun();
if (!gfx || !textRun) if (!gfx || !textRun)
return NS_ERROR_OUT_OF_MEMORY; return PR_FALSE;
nsresult rv = GetGlobalTransform(gfx); nsresult rv = GetGlobalTransform(gfx);
NS_ENSURE_SUCCESS(rv, PR_FALSE); NS_ENSURE_SUCCESS(rv, PR_FALSE);

View File

@ -854,7 +854,7 @@ nsSVGPatternFrame::SetupPaintServer(gfxContext *aContext,
} }
if (pMatrix.IsSingular()) { if (pMatrix.IsSingular()) {
return NS_ERROR_FAILURE; return PR_FALSE;
} }
pMatrix.Invert(); pMatrix.Invert();
@ -862,7 +862,7 @@ nsSVGPatternFrame::SetupPaintServer(gfxContext *aContext,
nsRefPtr<gfxPattern> pattern = new gfxPattern(surface); nsRefPtr<gfxPattern> pattern = new gfxPattern(surface);
if (!pattern) if (!pattern)
return NS_ERROR_FAILURE; return PR_FALSE;
pattern->SetMatrix(pMatrix); pattern->SetMatrix(pMatrix);
pattern->SetExtend(gfxPattern::EXTEND_REPEAT); pattern->SetExtend(gfxPattern::EXTEND_REPEAT);

View File

@ -300,7 +300,7 @@ nsBoxFrame::CacheAttributes()
else else
mState &= ~NS_STATE_EQUAL_SIZE; mState &= ~NS_STATE_EQUAL_SIZE;
PRBool autostretch = mState & NS_STATE_AUTO_STRETCH; PRBool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
GetInitialAutoStretch(autostretch); GetInitialAutoStretch(autostretch);
if (autostretch) if (autostretch)
mState |= NS_STATE_AUTO_STRETCH; mState |= NS_STATE_AUTO_STRETCH;
@ -1170,7 +1170,7 @@ nsBoxFrame::AttributeChanged(PRInt32 aNameSpaceID,
} }
#endif #endif
PRBool autostretch = mState & NS_STATE_AUTO_STRETCH; PRBool autostretch = !!(mState & NS_STATE_AUTO_STRETCH);
GetInitialAutoStretch(autostretch); GetInitialAutoStretch(autostretch);
if (autostretch) if (autostretch)
mState |= NS_STATE_AUTO_STRETCH; mState |= NS_STATE_AUTO_STRETCH;

View File

@ -1324,7 +1324,7 @@ nsSprocketLayout::GetPrefSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aS
nsIBox* child = aBox->GetChildBox(); nsIBox* child = aBox->GetChildBox();
nsFrameState frameState = 0; nsFrameState frameState = 0;
GetFrameState(aBox, frameState); GetFrameState(aBox, frameState);
PRBool isEqual = frameState & NS_STATE_EQUAL_SIZE; PRBool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
PRInt32 count = 0; PRInt32 count = 0;
while (child) while (child)
@ -1382,7 +1382,7 @@ nsSprocketLayout::GetMinSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSi
nsIBox* child = aBox->GetChildBox(); nsIBox* child = aBox->GetChildBox();
nsFrameState frameState = 0; nsFrameState frameState = 0;
GetFrameState(aBox, frameState); GetFrameState(aBox, frameState);
PRBool isEqual = frameState & NS_STATE_EQUAL_SIZE; PRBool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
PRInt32 count = 0; PRInt32 count = 0;
while (child) while (child)
@ -1453,7 +1453,7 @@ nsSprocketLayout::GetMaxSize(nsIBox* aBox, nsBoxLayoutState& aState, nsSize& aSi
nsIBox* child = aBox->GetChildBox(); nsIBox* child = aBox->GetChildBox();
nsFrameState frameState = 0; nsFrameState frameState = 0;
GetFrameState(aBox, frameState); GetFrameState(aBox, frameState);
PRBool isEqual = frameState & NS_STATE_EQUAL_SIZE; PRBool isEqual = !!(frameState & NS_STATE_EQUAL_SIZE);
PRInt32 count = 0; PRInt32 count = 0;
while (child) while (child)

View File

@ -87,17 +87,17 @@ class Row
void SetOpen(PRBool aOpen) { void SetOpen(PRBool aOpen) {
aOpen ? mFlags |= ROW_FLAG_OPEN : mFlags &= ~ROW_FLAG_OPEN; aOpen ? mFlags |= ROW_FLAG_OPEN : mFlags &= ~ROW_FLAG_OPEN;
} }
PRBool IsOpen() { return mFlags & ROW_FLAG_OPEN; } PRBool IsOpen() { return !!(mFlags & ROW_FLAG_OPEN); }
void SetEmpty(PRBool aEmpty) { void SetEmpty(PRBool aEmpty) {
aEmpty ? mFlags |= ROW_FLAG_EMPTY : mFlags &= ~ROW_FLAG_EMPTY; aEmpty ? mFlags |= ROW_FLAG_EMPTY : mFlags &= ~ROW_FLAG_EMPTY;
} }
PRBool IsEmpty() { return mFlags & ROW_FLAG_EMPTY; } PRBool IsEmpty() { return !!(mFlags & ROW_FLAG_EMPTY); }
void SetSeparator(PRBool aSeparator) { void SetSeparator(PRBool aSeparator) {
aSeparator ? mFlags |= ROW_FLAG_SEPARATOR : mFlags &= ~ROW_FLAG_SEPARATOR; aSeparator ? mFlags |= ROW_FLAG_SEPARATOR : mFlags &= ~ROW_FLAG_SEPARATOR;
} }
PRBool IsSeparator() { return mFlags & ROW_FLAG_SEPARATOR; } PRBool IsSeparator() { return !!(mFlags & ROW_FLAG_SEPARATOR); }
// Weak reference to a content item. // Weak reference to a content item.
nsIContent* mContent; nsIContent* mContent;