Bug 671417 - Incorrect use of PRBool when other types are more appropriate or vice versa, r=bz,ehsan,dwitte,joe,vlad,luke,mak,roc
authorMichael Wu <mwu@mozilla.com>
Tue, 26 Jul 2011 23:43:37 -0700
changeset 73624 4d170faf61228cd902a53c6ba5719a70fef91639
parent 73623 6eca6c29e2c044628640c2f978ef27d53d65461c
child 73625 38e2e8f4b0b2792de83342d39af50436d7f8bbea
push idunknown
push userunknown
push dateunknown
reviewersbz, ehsan, dwitte, joe, vlad, luke, mak, roc
bugs671417
milestone8.0a1
Bug 671417 - Incorrect use of PRBool when other types are more appropriate or vice versa, r=bz,ehsan,dwitte,joe,vlad,luke,mak,roc
content/base/public/nsLineBreaker.h
content/base/src/nsGenericElement.cpp
content/base/src/nsLineBreaker.cpp
docshell/base/nsDocShell.cpp
editor/libeditor/html/nsHTMLEditRules.cpp
editor/libeditor/html/nsHTMLEditRules.h
editor/libeditor/html/nsTableEditor.cpp
extensions/cookie/nsCookiePermission.cpp
gfx/thebes/gfxPlatform.cpp
intl/uconv/src/nsUTF8ToUnicode.cpp
js/src/jstracer.cpp
js/src/methodjit/StubCalls.cpp
layout/xul/base/src/nsListBoxBodyFrame.cpp
layout/xul/base/src/nsMenuPopupFrame.cpp
layout/xul/base/src/nsMenuPopupFrame.h
toolkit/components/places/nsNavHistoryResult.h
widget/src/xpwidgets/nsPrintSettingsImpl.cpp
widget/src/xpwidgets/nsPrintSettingsImpl.h
--- a/content/base/public/nsLineBreaker.h
+++ b/content/base/public/nsLineBreaker.h
@@ -224,17 +224,17 @@ private:
   // appropriate sink(s). Then we clear the current word state.
   nsresult FlushCurrentWord();
 
   void UpdateCurrentWordLangGroup(nsIAtom *aLangGroup);
 
   void FindHyphenationPoints(nsHyphenator *aHyphenator,
                              const PRUnichar *aTextStart,
                              const PRUnichar *aTextLimit,
-                             PRPackedBool *aBreakState);
+                             PRUint8 *aBreakState);
 
   nsAutoTArray<PRUnichar,100> mCurrentWord;
   // All the items that contribute to mCurrentWord
   nsAutoTArray<TextItem,2>    mTextItems;
   nsIAtom*                    mCurrentWordLangGroup;
   PRPackedBool                mCurrentWordContainsMixedLang;
   PRPackedBool                mCurrentWordContainsComplexChar;
 
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -4000,17 +4000,17 @@ nsINode::ReplaceOrInsertBefore(PRBool aR
 
     // Remove the children from the fragment.
     for (PRUint32 i = count; i > 0;) {
       newContent->RemoveChildAt(--i, PR_TRUE);
     }
 
     PRBool appending =
       !IsNodeOfType(eDOCUMENT) && PRUint32(insPos) == GetChildCount();
-    PRBool firstInsPos = insPos;
+    PRInt32 firstInsPos = insPos;
     nsIContent* firstInsertedContent = fragChildren[0];
 
     // Iterate through the fragment's children, and insert them in the new
     // parent
     for (PRUint32 i = 0; i < count; ++i, ++insPos) {
       // XXXbz how come no reparenting here?  That seems odd...
       // Insert the child.
       res = InsertChildAt(fragChildren[i], insPos, !appending);
--- a/content/base/src/nsLineBreaker.cpp
+++ b/content/base/src/nsLineBreaker.cpp
@@ -307,17 +307,17 @@ nsLineBreaker::AppendText(nsIAtom* aLang
   }
   return NS_OK;
 }
 
 void
 nsLineBreaker::FindHyphenationPoints(nsHyphenator *aHyphenator,
                                      const PRUnichar *aTextStart,
                                      const PRUnichar *aTextLimit,
-                                     PRPackedBool *aBreakState)
+                                     PRUint8 *aBreakState)
 {
   nsDependentSubstring string(aTextStart, aTextLimit);
   nsAutoTArray<PRPackedBool,200> hyphens;
   if (NS_SUCCEEDED(aHyphenator->Hyphenate(string, hyphens))) {
     for (PRUint32 i = 0; i + 1 < string.Length(); ++i) {
       if (hyphens[i]) {
         aBreakState[i + 1] =
           gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_HYPHEN;
@@ -409,17 +409,17 @@ nsLineBreaker::AppendText(nsIAtom* aLang
     mBreakHere = PR_FALSE;
     mAfterBreakableSpace = isBreakableSpace;
 
     if (isSpace) {
       if (offset > wordStart && wordHasComplexChar) {
         if (aSink && !(aFlags & BREAK_SUPPRESS_INSIDE)) {
           // Save current start-of-word state because GetJISx4051Breaks will
           // set it to false
-          PRPackedBool currentStart = breakState[wordStart];
+          PRUint8 currentStart = breakState[wordStart];
           nsContentUtils::LineBreaker()->
             GetJISx4051Breaks(aText + wordStart, offset - wordStart,
                               breakState.Elements() + wordStart);
           breakState[wordStart] = currentStart;
         }
         wordHasComplexChar = PR_FALSE;
       }
 
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -242,17 +242,17 @@ static PRInt32 gNumberOfDocumentsLoading
 static PRInt32 gDocShellCount = 0;
 
 // Global reference to the URI fixup service.
 nsIURIFixup *nsDocShell::sURIFixup = 0;
 
 // True means we validate window targets to prevent frameset
 // spoofing. Initialize this to a non-bolean value so we know to check
 // the pref on the creation of the first docshell.
-static PRBool gValidateOrigin = (PRBool)0xffffffff;
+static PRUint32 gValidateOrigin = 0xffffffff;
 
 // Hint for native dispatch of events on how long to delay after 
 // all documents have loaded in milliseconds before favoring normal
 // native event dispatch priorites over performance
 #define NS_EVENT_STARVATION_DELAY_HINT 2000
 
 // This is needed for displaying an error message 
 // when navigation is attempted on a document when printing
@@ -4499,17 +4499,17 @@ nsDocShell::Create()
                  "Unexpected item type in docshell");
 
     NS_ENSURE_TRUE(Preferences::GetRootBranch(), NS_ERROR_FAILURE);
     mCreated = PR_TRUE;
 
     mAllowSubframes =
         Preferences::GetBool("browser.frames.enabled", mAllowSubframes);
 
-    if (gValidateOrigin == (PRBool)0xffffffff) {
+    if (gValidateOrigin == 0xffffffff) {
         // Check pref to see if we should prevent frameset spoofing
         gValidateOrigin =
             Preferences::GetBool("browser.frame.validate_origin", PR_TRUE);
     }
 
     // Should we use XUL error pages instead of alerts if possible?
     mUseErrorPages =
         Preferences::GetBool("browser.xul.error_pages.enabled", mUseErrorPages);
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -5079,17 +5079,17 @@ nsHTMLEditRules::GetInnerContent(nsIDOMN
 
   return res;
 }
 
 ///////////////////////////////////////////////////////////////////////////
 // ExpandSelectionForDeletion: this promotes our selection to include blocks
 // that have all their children selected.
 //                  
-PRBool
+nsresult
 nsHTMLEditRules::ExpandSelectionForDeletion(nsISelection *aSelection)
 {
   NS_ENSURE_TRUE(aSelection, NS_ERROR_NULL_POINTER);
   
   // don't need to touch collapsed selections
   PRBool bCollapsed;
   nsresult res = aSelection->GetIsCollapsed(&bCollapsed);
   NS_ENSURE_SUCCESS(res, res);
--- a/editor/libeditor/html/nsHTMLEditRules.h
+++ b/editor/libeditor/html/nsHTMLEditRules.h
@@ -221,17 +221,17 @@ protected:
                         PRBool aMozBRDoesntCount = PR_FALSE,
                         PRBool aListItemsNotEmpty = PR_FALSE);
   nsresult CheckForEmptyBlock(nsIDOMNode *aStartNode, 
                               nsIDOMNode *aBodyNode,
                               nsISelection *aSelection,
                               PRBool *aHandled);
   nsresult CheckForInvisibleBR(nsIDOMNode *aBlock, nsHTMLEditRules::BRLocation aWhere, 
                                nsCOMPtr<nsIDOMNode> *outBRNode, PRInt32 aOffset=0);
-  PRBool ExpandSelectionForDeletion(nsISelection *aSelection);
+  nsresult ExpandSelectionForDeletion(nsISelection *aSelection);
   PRBool IsFirstNode(nsIDOMNode *aNode);
   PRBool IsLastNode(nsIDOMNode *aNode);
 #ifdef XXX_DEAD_CODE
   PRBool AtStartOfBlock(nsIDOMNode *aNode, PRInt32 aOffset, nsIDOMNode *aBlock);
   PRBool AtEndOfBlock(nsIDOMNode *aNode, PRInt32 aOffset, nsIDOMNode *aBlock);
 #endif
   nsresult NormalizeSelection(nsISelection *inSelection);
   nsresult GetPromotedPoint(RulesEndpoint aWhere, nsIDOMNode *aNode, PRInt32 aOffset, 
--- a/editor/libeditor/html/nsTableEditor.cpp
+++ b/editor/libeditor/html/nsTableEditor.cpp
@@ -2672,29 +2672,29 @@ nsHTMLEditor::GetTableLayoutObject(nsIDO
   nsIFrame *layoutObject = nodeAsContent->GetPrimaryFrame();
   NS_ENSURE_TRUE(layoutObject, NS_ERROR_FAILURE);
 
   *tableLayoutObject = do_QueryFrame(layoutObject);
   return *tableLayoutObject ? NS_OK : NS_NOINTERFACE;
 }
 
 //Return actual number of cells (a cell with colspan > 1 counts as just 1)
-PRBool nsHTMLEditor::GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowIndex)
+PRInt32 nsHTMLEditor::GetNumberOfCellsInRow(nsIDOMElement* aTable, PRInt32 rowIndex)
 {
   PRInt32 cellCount = 0;
   nsCOMPtr<nsIDOMElement> cell;
   PRInt32 colIndex = 0;
   nsresult res;
   do {
     PRInt32 startRowIndex, startColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
     PRBool  isSelected;
     res = GetCellDataAt(aTable, rowIndex, colIndex, getter_AddRefs(cell),
                         &startRowIndex, &startColIndex, &rowSpan, &colSpan, 
                         &actualRowSpan, &actualColSpan, &isSelected);
-    NS_ENSURE_SUCCESS(res, res);
+    NS_ENSURE_SUCCESS(res, 0);
     if (cell)
     {
       // Only count cells that start in row we are working with
       if (startRowIndex == rowIndex)
         cellCount++;
       
       //Next possible location for a cell
       colIndex += actualColSpan;
--- a/extensions/cookie/nsCookiePermission.cpp
+++ b/extensions/cookie/nsCookiePermission.cpp
@@ -173,19 +173,20 @@ nsCookiePermission::PrefChanged(nsIPrefB
       NS_SUCCEEDED(aPrefBranch->GetIntPref(kCookiesLifetimePolicy, &val)))
     mCookiesLifetimePolicy = val;
 
   if (PREF_CHANGED(kCookiesLifetimeDays) &&
       NS_SUCCEEDED(aPrefBranch->GetIntPref(kCookiesLifetimeDays, &val)))
     // save cookie lifetime in seconds instead of days
     mCookiesLifetimeSec = val * 24 * 60 * 60;
 
+  PRBool bval;
   if (PREF_CHANGED(kCookiesAlwaysAcceptSession) &&
-      NS_SUCCEEDED(aPrefBranch->GetBoolPref(kCookiesAlwaysAcceptSession, &val)))
-    mCookiesAlwaysAcceptSession = val;
+      NS_SUCCEEDED(aPrefBranch->GetBoolPref(kCookiesAlwaysAcceptSession, &bval)))
+    mCookiesAlwaysAcceptSession = bval;
 }
 
 NS_IMETHODIMP
 nsCookiePermission::SetAccess(nsIURI         *aURI,
                               nsCookieAccess  aAccess)
 {
   // Lazily initialize ourselves
   if (!EnsureInitialized())
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -922,17 +922,17 @@ gfxPlatform::GetCMSMode()
 
 /* Chris Murphy (CM consultant) suggests this as a default in the event that we
 cannot reproduce relative + Black Point Compensation.  BPC brings an
 unacceptable performance overhead, so we go with perceptual. */
 #define INTENT_DEFAULT QCMS_INTENT_PERCEPTUAL
 #define INTENT_MIN 0
 #define INTENT_MAX 3
 
-PRBool
+int
 gfxPlatform::GetRenderingIntent()
 {
     if (gCMSIntent == -2) {
 
         /* Try to query the pref system for a rendering intent. */
         PRInt32 pIntent;
         if (NS_SUCCEEDED(Preferences::GetInt(CMIntentPrefName, &pIntent))) {
             /* If the pref is within range, use it as an override. */
--- a/intl/uconv/src/nsUTF8ToUnicode.cpp
+++ b/intl/uconv/src/nsUTF8ToUnicode.cpp
@@ -233,17 +233,17 @@ NS_IMETHODIMP nsUTF8ToUnicode::Convert(c
     mBytes = 1;
     mFirst = PR_FALSE;
   }
 
   // alias these locally for speed
   PRInt32 mUcs4 = this->mUcs4;
   PRUint8 mState = this->mState;
   PRUint8 mBytes = this->mBytes;
-  PRUint8 mFirst = this->mFirst;
+  PRPackedBool mFirst = this->mFirst;
 
   // Set mFirst to PR_FALSE now so we don't have to every time through the ASCII
   // branch within the loop.
   if (mFirst && aSrcLen && (0 == (0x80 & (*aSrc))))
     mFirst = PR_FALSE;
 
   for (in = aSrc; ((in < inend) && (out < outend)); ++in) {
     if (0 == mState) {
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -8987,17 +8987,17 @@ EvalCmp(LOpcode op, double l, double r)
     return cond;
 }
 
 static bool
 EvalCmp(JSContext *cx, LOpcode op, JSString* l, JSString* r, JSBool *ret)
 {
     if (op == LIR_eqd)
         return EqualStrings(cx, l, r, ret);
-    JSBool cmp;
+    int32 cmp;
     if (!CompareStrings(cx, l, r, &cmp))
         return false;
     *ret = EvalCmp(op, cmp, 0);
     return true;
 }
 
 JS_REQUIRES_STACK RecordingStatus
 TraceRecorder::strictEquality(bool equal, bool cmpCase)
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -811,17 +811,17 @@ template void JS_FASTCALL stubs::DefFun<
         Value &lval = regs.sp[-2];                                            \
         bool cond;                                                            \
         if (!ToPrimitive(cx, JSTYPE_NUMBER, &lval))                           \
             THROWV(JS_FALSE);                                                 \
         if (!ToPrimitive(cx, JSTYPE_NUMBER, &rval))                           \
             THROWV(JS_FALSE);                                                 \
         if (lval.isString() && rval.isString()) {                             \
             JSString *l = lval.toString(), *r = rval.toString();              \
-            JSBool cmp;                                                       \
+            int32 cmp;                                                        \
             if (!CompareStrings(cx, l, r, &cmp))                              \
                 THROWV(JS_FALSE);                                             \
             cond = cmp OP 0;                                                  \
         } else {                                                              \
             double l, r;                                                      \
             if (!ToNumber(cx, lval, &l) || !ToNumber(cx, rval, &r))           \
                 THROWV(JS_FALSE);                                             \
             cond = JSDOUBLE_COMPARE(l, OP, r, false);                         \
--- a/layout/xul/base/src/nsListBoxBodyFrame.cpp
+++ b/layout/xul/base/src/nsListBoxBodyFrame.cpp
@@ -102,17 +102,17 @@ public:
   // nsITimerCallback
   NS_DECL_NSITIMERCALLBACK
 
   void Start();
   void Stop();
   PRBool IsRunning();
 
   nsCOMPtr<nsITimer> mRepeatTimer;
-  PRBool mDelta;
+  PRInt32 mDelta;
   nsListBoxBodyFrame* mOuter;
 }; 
 
 nsListScrollSmoother::nsListScrollSmoother(nsListBoxBodyFrame* aOuter)
 {
   mDelta = 0;
   mOuter = aOuter;
 }
--- a/layout/xul/base/src/nsMenuPopupFrame.cpp
+++ b/layout/xul/base/src/nsMenuPopupFrame.cpp
@@ -109,24 +109,24 @@ NS_IMPL_FRAMEARENA_HELPERS(nsMenuPopupFr
 nsMenuPopupFrame::nsMenuPopupFrame(nsIPresShell* aShell, nsStyleContext* aContext)
   :nsBoxFrame(aShell, aContext),
   mCurrentMenu(nsnull),
   mPrefSize(-1, -1),
   mPopupType(ePopupTypePanel),
   mPopupState(ePopupClosed),
   mPopupAlignment(POPUPALIGNMENT_NONE),
   mPopupAnchor(POPUPALIGNMENT_NONE),
+  mConsumeRollupEvent(nsIPopupBoxObject::ROLLUP_DEFAULT),
   mFlipBoth(PR_FALSE),
   mIsOpenChanged(PR_FALSE),
   mIsContextMenu(PR_FALSE),
   mAdjustOffsetForContextMenu(PR_FALSE),
   mGeneratedChildren(PR_FALSE),
   mMenuCanOverlapOSBar(PR_FALSE),
   mShouldAutoPosition(PR_TRUE),
-  mConsumeRollupEvent(nsIPopupBoxObject::ROLLUP_DEFAULT),
   mInContentShell(PR_TRUE),
   mIsMenuLocked(PR_FALSE),
   mHFlip(PR_FALSE),
   mVFlip(PR_FALSE)
 {
   // the preference name is backwards here. True means that the 'top' level is
   // the default, and false means that the 'parent' level is the default.
   if (sDefaultLevelIsTop >= 0)
--- a/layout/xul/base/src/nsMenuPopupFrame.h
+++ b/layout/xul/base/src/nsMenuPopupFrame.h
@@ -430,27 +430,28 @@ protected:
   PRInt32 mScreenYPos;
 
   nsPopupType mPopupType; // type of popup
   nsPopupState mPopupState; // open state of the popup
 
   // popup alignment relative to the anchor node
   PRInt8 mPopupAlignment;
   PRInt8 mPopupAnchor;
+  // One of nsIPopupBoxObject::ROLLUP_DEFAULT/ROLLUP_CONSUME/ROLLUP_NO_CONSUME
+  PRInt8 mConsumeRollupEvent;
   PRPackedBool mFlipBoth; // flip in both directions
 
   PRPackedBool mIsOpenChanged; // true if the open state changed since the last layout
   PRPackedBool mIsContextMenu; // true for context menus
   // true if we need to offset the popup to ensure it's not under the mouse
   PRPackedBool mAdjustOffsetForContextMenu;
   PRPackedBool mGeneratedChildren; // true if the contents have been created
 
   PRPackedBool mMenuCanOverlapOSBar;    // can we appear over the taskbar/menubar?
   PRPackedBool mShouldAutoPosition; // Should SetPopupPosition be allowed to auto position popup?
-  PRPackedBool mConsumeRollupEvent; // Should the rollup event be consumed?
   PRPackedBool mInContentShell; // True if the popup is in a content shell
   PRPackedBool mIsMenuLocked; // Should events inside this menu be ignored?
 
   // the flip modes that were used when the popup was opened
   PRPackedBool mHFlip;
   PRPackedBool mVFlip;
 
   static PRInt8 sDefaultLevelIsTop;
--- a/toolkit/components/places/nsNavHistoryResult.h
+++ b/toolkit/components/places/nsNavHistoryResult.h
@@ -705,17 +705,17 @@ protected:
   enum AsyncCanceledState {
     NOT_CANCELED, CANCELED, CANCELED_RESTART_NEEDED
   };
 
   void CancelAsyncOpen(PRBool aRestart);
   nsresult NotifyOnStateChange(PRUint16 aOldState);
 
   nsCOMPtr<mozIStoragePendingStatement> mAsyncPendingStmt;
-  PRBool mAsyncCanceledState;
+  AsyncCanceledState mAsyncCanceledState;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryContainerResultNode,
                               NS_NAVHISTORYCONTAINERRESULTNODE_IID)
 
 // nsNavHistoryQueryResultNode
 //
 //    Overridden container type for complex queries over history and/or
--- a/widget/src/xpwidgets/nsPrintSettingsImpl.cpp
+++ b/widget/src/xpwidgets/nsPrintSettingsImpl.cpp
@@ -905,17 +905,17 @@ NS_IMETHODIMP nsPrintSettings::SetPlexNa
   }
   return NS_OK;
 }
 
 /* attribute boolean howToEnableFrameUI; */
 NS_IMETHODIMP nsPrintSettings::GetHowToEnableFrameUI(PRInt16 *aHowToEnableFrameUI)
 {
   NS_ENSURE_ARG_POINTER(aHowToEnableFrameUI);
-  *aHowToEnableFrameUI = (PRInt32)mHowToEnableFrameUI;
+  *aHowToEnableFrameUI = mHowToEnableFrameUI;
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintSettings::SetHowToEnableFrameUI(PRInt16 aHowToEnableFrameUI)
 {
   mHowToEnableFrameUI = aHowToEnableFrameUI;
   return NS_OK;
 }
 
--- a/widget/src/xpwidgets/nsPrintSettingsImpl.h
+++ b/widget/src/xpwidgets/nsPrintSettingsImpl.h
@@ -93,17 +93,17 @@ protected:
   PRInt32       mStartPageNum; // only used for ePrintRange_SpecifiedRange
   PRInt32       mEndPageNum;
   double        mScaling;
   PRBool        mPrintBGColors;  // print background colors
   PRBool        mPrintBGImages;  // print background images
 
   PRInt16       mPrintFrameTypeUsage;
   PRInt16       mPrintFrameType;
-  PRBool        mHowToEnableFrameUI;
+  PRInt16       mHowToEnableFrameUI;
   PRBool        mIsCancelled;
   PRBool        mPrintSilent;
   PRBool        mPrintPreview;
   PRBool        mShrinkToFit;
   PRBool        mShowPrintProgress;
   PRInt32       mPrintPageDelay;
 
   nsString      mTitle;