From 86e18547a149bd2742edc495e81487dfdf6e27f2 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Thu, 2 Jun 2011 21:30:35 +0900 Subject: [PATCH 01/35] Bug 660742 back out f81b4d9534f5 --- accessible/src/base/nsAccessible.cpp | 27 +++++++++++-------- accessible/src/msaa/nsAccessNodeWrap.cpp | 30 ++++++++++++---------- accessible/src/msaa/nsAccessibleWrap.cpp | 1 + accessible/src/xul/nsXULMenuAccessible.cpp | 11 ++++---- modules/libpref/public/Preferences.h | 5 ---- modules/libpref/src/Preferences.cpp | 14 ---------- 6 files changed, 40 insertions(+), 48 deletions(-) diff --git a/accessible/src/base/nsAccessible.cpp b/accessible/src/base/nsAccessible.cpp index 63b4fe2e5b23..1d6aea11f1c0 100644 --- a/accessible/src/base/nsAccessible.cpp +++ b/accessible/src/base/nsAccessible.cpp @@ -89,6 +89,8 @@ #include "nsReadableUtils.h" #include "prdtoa.h" #include "nsIAtom.h" +#include "nsIPrefService.h" +#include "nsIPrefBranch.h" #include "nsIURI.h" #include "nsArrayUtils.h" #include "nsIMutableArray.h" @@ -104,9 +106,6 @@ #endif #include "mozilla/unused.h" -#include "mozilla/Preferences.h" - -using namespace mozilla; //////////////////////////////////////////////////////////////////////////////// @@ -340,9 +339,14 @@ nsAccessible::Description(nsString& aDescription) static PRInt32 GetAccessModifierMask(nsIContent* aContent) { + nsCOMPtr prefBranch = + do_GetService(NS_PREFSERVICE_CONTRACTID); + if (!prefBranch) + return 0; + // use ui.key.generalAccessKey (unless it is -1) - PRInt32 accessKey = -1; - nsresult rv = Preferences::GetInt("ui.key.generalAccessKey", accessKey); + PRInt32 accessKey; + nsresult rv = prefBranch->GetIntPref("ui.key.generalAccessKey", &accessKey); if (NS_SUCCEEDED(rv) && accessKey != -1) { switch (accessKey) { case nsIDOMKeyEvent::DOM_VK_SHIFT: return NS_MODIFIER_SHIFT; @@ -368,13 +372,14 @@ GetAccessModifierMask(nsIContent* aContent) PRInt32 itemType, accessModifierMask = 0; treeItem->GetItemType(&itemType); switch (itemType) { - case nsIDocShellTreeItem::typeChrome: - rv = Preferences::GetInt("ui.key.chromeAccess", &accessModifierMask); - break; - case nsIDocShellTreeItem::typeContent: - rv = Preferences::GetInt("ui.key.contentAccess", &accessModifierMask); - break; + case nsIDocShellTreeItem::typeChrome: + rv = prefBranch->GetIntPref("ui.key.chromeAccess", &accessModifierMask); + break; + + case nsIDocShellTreeItem::typeContent: + rv = prefBranch->GetIntPref("ui.key.contentAccess", &accessModifierMask); + break; } return NS_SUCCEEDED(rv) ? accessModifierMask : 0; diff --git a/accessible/src/msaa/nsAccessNodeWrap.cpp b/accessible/src/msaa/nsAccessNodeWrap.cpp index 849715813bc6..5e8a1f6ece61 100644 --- a/accessible/src/msaa/nsAccessNodeWrap.cpp +++ b/accessible/src/msaa/nsAccessNodeWrap.cpp @@ -54,13 +54,11 @@ #include "nsIDOMNSHTMLElement.h" #include "nsIFrame.h" #include "nsINameSpaceManager.h" +#include "nsIPrefService.h" +#include "nsIPrefBranch.h" #include "nsPIDOMWindow.h" #include "nsIServiceManager.h" -#include "mozilla/Preferences.h" - -using namespace mozilla; - /// the accessible library and cached methods HINSTANCE nsAccessNodeWrap::gmAccLib = nsnull; HINSTANCE nsAccessNodeWrap::gmUserLib = nsnull; @@ -713,16 +711,22 @@ void nsAccessNodeWrap::TurnOffNewTabSwitchingForJawsAndWE() // Check to see if the pref for disallowing CtrlTab is already set. // If so, bail out. // If not, set it. - if (Preferences::HasUserValue(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF)) { - // This pref has been set before. There is no default for it. - // Do nothing further, respect the setting that's there. - // That way, if noone touches it, it'll stay on after toggled once. - // If someone decided to turn it off, we respect that, too. - return; + nsCOMPtr prefs (do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (prefs) { + PRBool hasDisallowNewCtrlTabPref = PR_FALSE; + nsresult rv = prefs->PrefHasUserValue(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF, + &hasDisallowNewCtrlTabPref); + if (NS_SUCCEEDED(rv) && hasDisallowNewCtrlTabPref) { + // This pref has been set before. There is no default for it. + // Do nothing further, respect the setting that's there. + // That way, if noone touches it, it'll stay on after toggled once. + // If someone decided to turn it off, we respect that, too. + return; + } + + // Value has never been set, set it. + prefs->SetBoolPref(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF, PR_TRUE); } - - // Value has never been set, set it. - Preferences::SetBool(CTRLTAB_DISALLOW_FOR_SCREEN_READERS_PREF, PR_TRUE); } void nsAccessNodeWrap::DoATSpecificProcessing() diff --git a/accessible/src/msaa/nsAccessibleWrap.cpp b/accessible/src/msaa/nsAccessibleWrap.cpp index 955e9f5967ec..c51ced2fdca4 100644 --- a/accessible/src/msaa/nsAccessibleWrap.cpp +++ b/accessible/src/msaa/nsAccessibleWrap.cpp @@ -58,6 +58,7 @@ #include "nsIScrollableFrame.h" #include "nsINameSpaceManager.h" #include "nsINodeInfo.h" +#include "nsIPrefService.h" #include "nsRootAccessible.h" #include "nsIServiceManager.h" #include "nsTextFormatter.h" diff --git a/accessible/src/xul/nsXULMenuAccessible.cpp b/accessible/src/xul/nsXULMenuAccessible.cpp index 145ae1b6d111..6c869bd6aa29 100644 --- a/accessible/src/xul/nsXULMenuAccessible.cpp +++ b/accessible/src/xul/nsXULMenuAccessible.cpp @@ -50,6 +50,8 @@ #include "nsIDOMXULSelectCntrlItemEl.h" #include "nsIDOMXULMultSelectCntrlEl.h" #include "nsIDOMKeyEvent.h" +#include "nsIPrefService.h" +#include "nsIPrefBranch.h" #include "nsIServiceManager.h" #include "nsIPresShell.h" #include "nsIContent.h" @@ -57,10 +59,6 @@ #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" -#include "mozilla/Preferences.h" - -using namespace mozilla; - static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); @@ -412,7 +410,10 @@ nsXULMenuitemAccessible::GetKeyboardShortcut(nsAString& aAccessKey) // No need to cache pref service, this happens rarely if (gMenuAccesskeyModifier == -1) { // Need to initialize cached global accesskey pref - gMenuAccesskeyModifier = Preferences::GetInt("ui.key.menuAccessKey", 0); + gMenuAccesskeyModifier = 0; + nsCOMPtr prefBranch(do_GetService(NS_PREFSERVICE_CONTRACTID)); + if (prefBranch) + prefBranch->GetIntPref("ui.key.menuAccessKey", &gMenuAccesskeyModifier); } nsAutoString propertyKey; diff --git a/modules/libpref/public/Preferences.h b/modules/libpref/public/Preferences.h index 3a29558f61d4..abd143b110d4 100644 --- a/modules/libpref/public/Preferences.h +++ b/modules/libpref/public/Preferences.h @@ -188,11 +188,6 @@ public: */ static nsresult ClearUser(const char* aPref); - /** - * Whether the pref has a user value or not. - */ - static PRBool HasUserValue(const char* aPref); - /** * Adds/Removes the observer for the root pref branch. * The observer is referenced strongly if AddStrongObserver is used. On the diff --git a/modules/libpref/src/Preferences.cpp b/modules/libpref/src/Preferences.cpp index b6ff4463ed78..fbbfa873ca25 100644 --- a/modules/libpref/src/Preferences.cpp +++ b/modules/libpref/src/Preferences.cpp @@ -1285,20 +1285,6 @@ Preferences::ClearUser(const char* aPref) return sPreferences->mRootBranch->ClearUserPref(aPref); } -// static -PRBool -Preferences::HasUserValue(const char* aPref) -{ - NS_ENSURE_TRUE(InitStaticMembers(), PR_FALSE); - PRBool hasUserValue; - nsresult rv = - sPreferences->mRootBranch->PrefHasUserValue(aPref, &hasUserValue); - if (NS_FAILED(rv)) { - return PR_FALSE; - } - return hasUserValue; -} - // static nsresult Preferences::AddStrongObserver(nsIObserver* aObserver, From 63b9ab3636f33f568ad484a1d4fd8597c9db9c76 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 2 Jun 2011 14:56:46 +0200 Subject: [PATCH 02/35] Bug 629870 - Drop support for globalCompositeOperation=over,clear; r=sicking --- content/canvas/src/nsCanvasRenderingContext2D.cpp | 10 ++-------- content/canvas/test/test_canvas.html | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/content/canvas/src/nsCanvasRenderingContext2D.cpp b/content/canvas/src/nsCanvasRenderingContext2D.cpp index 976d890cfaf2..14fbb1973109 100644 --- a/content/canvas/src/nsCanvasRenderingContext2D.cpp +++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp @@ -3457,8 +3457,7 @@ nsCanvasRenderingContext2D::SetGlobalCompositeOperation(const nsAString& op) if (op.EqualsLiteral(cvsop)) \ thebes_op = gfxContext::OPERATOR_##thebesop; - CANVAS_OP_TO_THEBES_OP("clear", CLEAR) - else CANVAS_OP_TO_THEBES_OP("copy", SOURCE) + CANVAS_OP_TO_THEBES_OP("copy", SOURCE) else CANVAS_OP_TO_THEBES_OP("destination-atop", DEST_ATOP) else CANVAS_OP_TO_THEBES_OP("destination-in", DEST_IN) else CANVAS_OP_TO_THEBES_OP("destination-out", DEST_OUT) @@ -3469,8 +3468,6 @@ nsCanvasRenderingContext2D::SetGlobalCompositeOperation(const nsAString& op) else CANVAS_OP_TO_THEBES_OP("source-out", OUT) else CANVAS_OP_TO_THEBES_OP("source-over", OVER) else CANVAS_OP_TO_THEBES_OP("xor", XOR) - // not part of spec, kept here for compat - else CANVAS_OP_TO_THEBES_OP("over", OVER) // XXX ERRMSG we need to report an error to developers here! (bug 329026) else return NS_OK; @@ -3489,10 +3486,7 @@ nsCanvasRenderingContext2D::GetGlobalCompositeOperation(nsAString& op) if (thebes_op == gfxContext::OPERATOR_##thebesop) \ op.AssignLiteral(cvsop); - // XXX "darker" isn't really correct - CANVAS_OP_TO_THEBES_OP("clear", CLEAR) - else CANVAS_OP_TO_THEBES_OP("copy", SOURCE) - else CANVAS_OP_TO_THEBES_OP("darker", SATURATE) // XXX + CANVAS_OP_TO_THEBES_OP("copy", SOURCE) else CANVAS_OP_TO_THEBES_OP("destination-atop", DEST_ATOP) else CANVAS_OP_TO_THEBES_OP("destination-in", DEST_IN) else CANVAS_OP_TO_THEBES_OP("destination-out", DEST_OUT) diff --git a/content/canvas/test/test_canvas.html b/content/canvas/test/test_canvas.html index f75776b24b23..9bd1b3e6a128 100644 --- a/content/canvas/test/test_canvas.html +++ b/content/canvas/test/test_canvas.html @@ -1486,7 +1486,7 @@ var ctx = canvas.getContext('2d'); ctx.globalCompositeOperation = 'xor'; ctx.globalCompositeOperation = 'clear'; -todo(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'"); +ok(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'"); } @@ -1619,7 +1619,7 @@ var ctx = canvas.getContext('2d'); ctx.globalCompositeOperation = 'xor'; ctx.globalCompositeOperation = 'over'; -todo(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'"); +ok(ctx.globalCompositeOperation == 'xor', "ctx.globalCompositeOperation == 'xor'"); } From 0533cadbaca61e72005d74808b31acd5172be93e Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 2 Jun 2011 14:56:46 +0200 Subject: [PATCH 03/35] Bug 660694 - Fix comparisons between signed and unsigned integer expressions in nsDOMBlobBuilder.cpp by using unsigned integers consistently; r=sicking --- content/base/src/nsDOMBlobBuilder.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/base/src/nsDOMBlobBuilder.cpp b/content/base/src/nsDOMBlobBuilder.cpp index 482f345ca933..607667617303 100644 --- a/content/base/src/nsDOMBlobBuilder.cpp +++ b/content/base/src/nsDOMBlobBuilder.cpp @@ -151,16 +151,16 @@ nsDOMMultipartBlob::MozSlice(PRInt64 aStart, PRInt64 aEnd, aEnd = (PRInt64)thisLength; } + // Modifies aStart and aEnd. ParseSize((PRInt64)thisLength, aStart, aEnd); // If we clamped to nothing we create an empty blob nsTArray > blobs; - PRInt64 length = aEnd - aStart; - PRUint64 finalLength = length; + PRUint64 length = aEnd - aStart; PRUint64 skipStart = aStart; - NS_ABORT_IF_FALSE(aStart + length <= thisLength, "Er, what?"); + NS_ABORT_IF_FALSE(PRUint64(aStart) + length <= thisLength, "Er, what?"); // Prune the list of blobs if we can PRUint32 i; @@ -172,7 +172,7 @@ nsDOMMultipartBlob::MozSlice(PRInt64 aStart, PRInt64 aEnd, NS_ENSURE_SUCCESS(rv, rv); if (skipStart < l) { - PRInt64 upperBound = NS_MIN(l - skipStart, length); + PRUint64 upperBound = NS_MIN(l - skipStart, length); nsCOMPtr firstBlob; rv = mBlobs.ElementAt(i)->MozSlice(skipStart, skipStart + upperBound, @@ -212,7 +212,7 @@ nsDOMMultipartBlob::MozSlice(PRInt64 aStart, PRInt64 aEnd, } else { blobs.AppendElement(blob); } - length -= NS_MIN(l, length); + length -= NS_MIN(l, length); } // we can create our blob now From 471e6d31d01237769aca8b39f865088922f52ef0 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 2 Jun 2011 14:56:46 +0200 Subject: [PATCH 04/35] Bug 660604 - Remove nsIHTMLDocument::GetBodyContentExternal; r=jst --- content/html/document/src/nsHTMLDocument.cpp | 6 -- content/html/document/src/nsHTMLDocument.h | 2 - content/html/document/src/nsIHTMLDocument.h | 10 +-- layout/base/nsCSSRendering.cpp | 71 +++++++++++--------- layout/style/nsHTMLStyleSheet.cpp | 2 - 5 files changed, 41 insertions(+), 50 deletions(-) diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index c2b6519890ad..0922b6545542 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -2367,12 +2367,6 @@ nsHTMLDocument::ResolveName(const nsAString& aName, //---------------------------- -/* virtual */ nsIContent* -nsHTMLDocument::GetBodyContentExternal() -{ - return GetBodyElement(); -} - // forms related stuff NS_IMETHODIMP diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index 6ff20627aae0..336f2c6569b1 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -174,8 +174,6 @@ public: mDisableCookieAccess = PR_TRUE; } - virtual nsIContent* GetBodyContentExternal(); - class nsAutoEditingState { public: nsAutoEditingState(nsHTMLDocument* aDoc, EditingState aState) diff --git a/content/html/document/src/nsIHTMLDocument.h b/content/html/document/src/nsIHTMLDocument.h index d00c82348555..d6ee9a6b8b99 100644 --- a/content/html/document/src/nsIHTMLDocument.h +++ b/content/html/document/src/nsIHTMLDocument.h @@ -49,8 +49,8 @@ class nsContentList; class nsWrapperCache; #define NS_IHTMLDOCUMENT_IID \ -{ 0x30001b0c, 0xdb25, 0x4318, \ - { 0x85, 0xb8, 0x48, 0xb4, 0xea, 0x54, 0x8f, 0x23 } } +{ 0x51a360fa, 0xd659, 0x4d85, \ + { 0xa5, 0xc5, 0x4a, 0xbb, 0x0d, 0x97, 0x0f, 0x7a } } /** @@ -164,12 +164,6 @@ public: */ virtual void DisableCookieAccess() = 0; - /** - * Get the first child of the root , but don't do - * anything -related (like nsIDOMHTMLDocument::GetBody). - */ - virtual nsIContent* GetBodyContentExternal() = 0; - /** * Called when this nsIHTMLDocument's editor is destroyed. */ diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 7dc877676c9e..d56c32f8e5ad 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -67,7 +67,6 @@ #include "nsITheme.h" #include "nsThemeConstants.h" #include "nsIServiceManager.h" -#include "nsIHTMLDocument.h" #include "nsLayoutUtils.h" #include "nsINameSpaceManager.h" #include "nsBlockFrame.h" @@ -85,6 +84,8 @@ #include "nsCSSRenderingBorders.h" +using namespace mozilla; + /** * This is a small wrapper class to encapsulate image drawing that can draw an * nsStyleImage image, which may internally be a real image, a sub image, or a @@ -937,36 +938,43 @@ nsCSSRendering::FindBackgroundStyleFrame(nsIFrame* aForFrame) const nsStyleBackground* result = aForFrame->GetStyleBackground(); // Check if we need to do propagation from BODY rather than HTML. - if (result->IsTransparent()) { - nsIContent* content = aForFrame->GetContent(); - // The root element content can't be null. We wouldn't know what - // frame to create for aFrame. - // Use |GetOwnerDoc| so it works during destruction. - if (content) { - nsIDocument* document = content->GetOwnerDoc(); - nsCOMPtr htmlDoc = do_QueryInterface(document); - if (htmlDoc) { - nsIContent* bodyContent = htmlDoc->GetBodyContentExternal(); - // We need to null check the body node (bug 118829) since - // there are cases, thanks to the fix for bug 5569, where we - // will reflow a document with no body. In particular, if a - // SCRIPT element in the head blocks the parser and then has a - // SCRIPT that does "document.location.href = 'foo'", then - // nsParser::Terminate will call |DidBuildModel| methods - // through to the content sink, which will call |StartLayout| - // and thus |InitialReflow| on the pres shell. See bug 119351 - // for the ugly details. - if (bodyContent) { - nsIFrame *bodyFrame = bodyContent->GetPrimaryFrame(); - if (bodyFrame) { - return nsLayoutUtils::GetStyleFrame(bodyFrame); - } - } - } - } + if (!result->IsTransparent()) { + return aForFrame; } - return aForFrame; + nsIContent* content = aForFrame->GetContent(); + // The root element content can't be null. We wouldn't know what + // frame to create for aFrame. + // Use |GetOwnerDoc| so it works during destruction. + if (!content) { + return aForFrame; + } + + nsIDocument* document = content->GetOwnerDoc(); + if (!document) { + return aForFrame; + } + + dom::Element* bodyContent = document->GetBodyElement(); + // We need to null check the body node (bug 118829) since + // there are cases, thanks to the fix for bug 5569, where we + // will reflow a document with no body. In particular, if a + // SCRIPT element in the head blocks the parser and then has a + // SCRIPT that does "document.location.href = 'foo'", then + // nsParser::Terminate will call |DidBuildModel| methods + // through to the content sink, which will call |StartLayout| + // and thus |InitialReflow| on the pres shell. See bug 119351 + // for the ugly details. + if (!bodyContent) { + return aForFrame; + } + + nsIFrame *bodyFrame = bodyContent->GetPrimaryFrame(); + if (!bodyFrame) { + return aForFrame; + } + + return nsLayoutUtils::GetStyleFrame(bodyFrame); } /** @@ -1027,11 +1035,10 @@ FindElementBackground(nsIFrame* aForFrame, nsIFrame* aRootElementFrame, // We should only look at the background if we're in an HTML document nsIDocument* document = content->GetOwnerDoc(); - nsCOMPtr htmlDoc = do_QueryInterface(document); - if (!htmlDoc) + if (!document) return PR_TRUE; - nsIContent* bodyContent = htmlDoc->GetBodyContentExternal(); + dom::Element* bodyContent = document->GetBodyElement(); if (bodyContent != content) return PR_TRUE; // this wasn't the background that was propagated diff --git a/layout/style/nsHTMLStyleSheet.cpp b/layout/style/nsHTMLStyleSheet.cpp index 645d1e237eb4..f81fb80b6f15 100644 --- a/layout/style/nsHTMLStyleSheet.cpp +++ b/layout/style/nsHTMLStyleSheet.cpp @@ -63,8 +63,6 @@ #include "nsIDocument.h" #include "nsIPresShell.h" #include "nsStyleConsts.h" -#include "nsIHTMLDocument.h" -#include "nsIDOMHTMLElement.h" #include "nsCSSAnonBoxes.h" #include "nsRuleWalker.h" #include "nsRuleData.h" From 90dd8512822e8b2c65148043cfbbf8747f98dad5 Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Thu, 2 Jun 2011 14:56:46 +0200 Subject: [PATCH 05/35] Bug 660657 - Make nsCSSRendering::Init return void; r=roc --- layout/base/nsCSSRendering.cpp | 6 +----- layout/base/nsCSSRendering.h | 2 +- layout/build/nsLayoutStatics.cpp | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index d56c32f8e5ad..cbf74d244c31 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -379,14 +379,10 @@ static nscolor MakeBevelColor(mozilla::css::Side whichSide, PRUint8 style, static InlineBackgroundData* gInlineBGData = nsnull; // Initialize any static variables used by nsCSSRendering. -nsresult nsCSSRendering::Init() +void nsCSSRendering::Init() { NS_ASSERTION(!gInlineBGData, "Init called twice"); gInlineBGData = new InlineBackgroundData(); - if (!gInlineBGData) - return NS_ERROR_OUT_OF_MEMORY; - - return NS_OK; } // Clean up any global variables used by nsCSSRendering. diff --git a/layout/base/nsCSSRendering.h b/layout/base/nsCSSRendering.h index 4831148297ef..a57298ae595c 100644 --- a/layout/base/nsCSSRendering.h +++ b/layout/base/nsCSSRendering.h @@ -54,7 +54,7 @@ struct nsCSSRendering { /** * Initialize any static variables used by nsCSSRendering. */ - static nsresult Init(); + static void Init(); /** * Clean up any static variables used by nsCSSRendering. diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index e378385de8ad..6c6dcbde217b 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -186,11 +186,7 @@ nsLayoutStatics::Initialize() return rv; } - rv = nsCSSRendering::Init(); - if (NS_FAILED(rv)) { - NS_ERROR("Could not initialize nsCSSRendering"); - return rv; - } + nsCSSRendering::Init(); rv = nsTextFrameTextRunCache::Init(); if (NS_FAILED(rv)) { From 968bf5196abbcccb81dc0e372c6ced99ea905b8c Mon Sep 17 00:00:00 2001 From: Dominic Fandrey Date: Thu, 2 Jun 2011 14:56:50 +0200 Subject: [PATCH 06/35] Bug 645398 - Substitute PR_(MAX|MIN|ABS|ROUNDUP) macro calls; r=roc --- content/canvas/src/WebGLContext.h | 8 ++--- content/canvas/src/WebGLContextGL.cpp | 16 ++++----- content/canvas/src/WebGLContextValidate.cpp | 2 +- content/events/src/nsEventStateManager.cpp | 10 +++--- content/media/nsBuiltinDecoderReader.cpp | 2 +- content/media/nsMediaCache.cpp | 36 +++++++++---------- content/media/nsMediaStream.cpp | 2 +- content/smil/nsSMILAnimationController.cpp | 4 +-- content/smil/nsSMILTimeContainer.cpp | 2 +- content/xslt/src/base/txDouble.cpp | 2 +- content/xslt/src/base/txStringUtils.cpp | 2 +- .../src/xpath/txMozillaXPathTreeWalker.cpp | 2 +- content/xslt/src/xpath/txNodeSet.cpp | 2 +- content/xslt/src/xslt/txMozillaXMLOutput.cpp | 2 +- content/xul/content/src/nsXULElement.cpp | 2 +- db/morkreader/nsMorkReader.cpp | 6 ++-- docshell/shistory/src/nsSHistory.cpp | 4 +-- dom/indexedDB/IDBFactory.cpp | 6 ++-- dom/ipc/TabParent.cpp | 6 ++-- editor/libeditor/html/nsHTMLEditRules.cpp | 2 +- editor/libeditor/html/nsHTMLObjectResizer.cpp | 4 +-- .../gnomevfs/nsGnomeVFSProtocolHandler.cpp | 2 +- .../pref/autoconfig/src/nsAutoConfig.cpp | 2 +- gfx/thebes/gfxBlur.cpp | 12 +++---- gfx/thebes/gfxContext.cpp | 8 ++--- gfx/thebes/gfxCoreTextShaper.cpp | 7 ++-- gfx/thebes/gfxDWriteFontList.h | 2 +- gfx/thebes/gfxFT2Utils.cpp | 14 ++++---- gfx/thebes/gfxFontUtils.h | 7 ++-- gfx/thebes/gfxGDIFont.cpp | 2 +- gfx/thebes/gfxGDIFontList.cpp | 10 +++--- gfx/thebes/gfxHarfBuzzShaper.cpp | 5 +-- gfx/thebes/gfxImageSurface.cpp | 2 +- gfx/thebes/gfxMacFont.cpp | 2 +- gfx/thebes/gfxOS2Fonts.cpp | 14 ++++---- gfx/thebes/gfxRect.h | 1 + gfx/thebes/gfxSkipChars.cpp | 2 +- intl/uconv/src/nsConverterInputStream.cpp | 2 +- intl/uconv/src/nsUTF8ToUnicode.cpp | 3 +- intl/uconv/util/nsUCSupport.cpp | 3 +- layout/base/nsCSSColorUtils.h | 2 +- layout/base/nsCSSRendering.cpp | 8 ++--- layout/mathml/nsMathMLChar.cpp | 6 ++-- layout/style/nsStyleAnimation.cpp | 8 ++--- layout/tables/nsTableFrame.cpp | 10 +++--- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 2 +- modules/libpr0n/decoders/nsBMPDecoder.cpp | 4 +-- modules/libpr0n/decoders/nsGIFDecoder2.cpp | 2 +- modules/libpr0n/decoders/nsICODecoder.cpp | 2 +- modules/libpr0n/decoders/nsIconDecoder.cpp | 2 +- modules/libpr0n/decoders/nsPNGDecoder.cpp | 2 +- modules/libpr0n/src/RasterImage.cpp | 6 ++-- modules/libpr0n/src/imgRequest.cpp | 2 +- modules/libpref/src/prefapi.cpp | 2 +- netwerk/base/src/nsBufferedStreams.cpp | 9 ++--- netwerk/base/src/nsFileStreams.h | 3 +- netwerk/base/src/nsIncrementalDownload.cpp | 2 +- netwerk/base/src/nsSocketTransport2.cpp | 4 +-- netwerk/base/src/nsStandardURL.cpp | 2 +- netwerk/base/src/nsSyncStreamListener.cpp | 4 +-- netwerk/cache/nsCacheService.cpp | 14 ++++---- netwerk/cache/nsDiskCacheBlockFile.cpp | 4 +-- netwerk/cache/nsDiskCacheMap.cpp | 2 +- netwerk/cache/nsMemoryCacheDevice.cpp | 4 +-- netwerk/protocol/about/nsAboutCacheEntry.cpp | 4 +-- netwerk/protocol/file/nsFileChannel.cpp | 2 +- netwerk/protocol/http/HttpBaseChannel.cpp | 2 +- .../protocol/http/nsHttpChunkedDecoder.cpp | 2 +- netwerk/protocol/http/nsHttpConnectionMgr.cpp | 2 +- netwerk/protocol/http/nsHttpResponseHead.cpp | 2 +- netwerk/protocol/http/nsHttpTransaction.cpp | 8 ++--- .../streamconv/converters/nsBinHexDecoder.cpp | 2 +- .../streamconv/converters/nsIndexedToHTML.cpp | 2 +- .../converters/nsMultiMixedConv.cpp | 2 +- .../streamconv/converters/nsTXTToHTMLConv.cpp | 4 +-- .../exthandler/nsExternalHelperAppService.cpp | 2 +- widget/src/android/nsWindow.cpp | 2 +- widget/src/gtk2/nsNativeKeyBindings.cpp | 4 +-- widget/src/gtk2/nsNativeThemeGTK.cpp | 8 ++--- widget/src/gtk2/nsPrintSettingsGTK.cpp | 4 +-- widget/src/gtk2/nsWindow.cpp | 8 ++--- widget/src/os2/nsIdleServiceOS2.cpp | 2 +- widget/src/windows/KeyboardLayout.cpp | 8 +++-- widget/src/windows/nsIMM32Handler.cpp | 2 +- widget/src/windows/nsNativeThemeWin.cpp | 4 +-- widget/src/windows/nsTextStore.cpp | 22 ++++++------ widget/src/xpwidgets/nsBaseDragService.cpp | 4 +-- widget/src/xpwidgets/nsIdleService.cpp | 2 +- widget/src/xpwidgets/nsNativeTheme.cpp | 2 +- widget/src/xpwidgets/nsNativeTheme.h | 1 + widget/tests/TestWinTSF.cpp | 8 ++--- xpcom/ds/nsExpirationTracker.h | 2 +- xpcom/glue/nsQuickSort.cpp | 5 +-- xpcom/glue/nsTArray-inl.h | 2 +- xpcom/glue/nsTArray.h | 1 + xpcom/glue/nsVersionComparator.cpp | 2 +- xpcom/glue/nsVoidArray.cpp | 4 +-- xpcom/io/nsFastLoadFile.cpp | 5 +-- xpcom/io/nsFastLoadFile.h | 3 +- xpcom/io/nsPipe3.cpp | 3 +- xpcom/io/nsScriptableInputStream.cpp | 2 +- xpcom/io/nsStorageStream.cpp | 9 ++--- xpcom/io/nsUnicharInputStream.cpp | 2 +- xpcom/string/public/nsAlgorithm.h | 17 +++++++++ xpcom/string/src/nsReadableUtils.cpp | 4 +-- xpcom/string/src/nsTSubstring.cpp | 8 ++--- xpcom/tests/TestPipes.cpp | 4 +-- xpfe/appshell/src/nsXULWindow.cpp | 4 +-- xpinstall/src/CertReader.cpp | 2 +- xpinstall/src/nsXPInstallManager.cpp | 4 +-- 110 files changed, 280 insertions(+), 246 deletions(-) diff --git a/content/canvas/src/WebGLContext.h b/content/canvas/src/WebGLContext.h index 28e37260ca6c..f0064b81b1c8 100644 --- a/content/canvas/src/WebGLContext.h +++ b/content/canvas/src/WebGLContext.h @@ -949,7 +949,7 @@ protected: FakeBlackStatus mFakeBlackStatus; void EnsureMaxLevelWithCustomImagesAtLeast(size_t aMaxLevelWithCustomImages) { - mMaxLevelWithCustomImages = PR_MAX(mMaxLevelWithCustomImages, aMaxLevelWithCustomImages); + mMaxLevelWithCustomImages = NS_MAX(mMaxLevelWithCustomImages, aMaxLevelWithCustomImages); mImageInfos.EnsureLengthAtLeast((mMaxLevelWithCustomImages + 1) * mFacesCount); } @@ -979,8 +979,8 @@ protected: const ImageInfo& actual = ImageInfoAt(level, face); if (actual != expected) return PR_FALSE; - expected.mWidth = PR_MAX(1, expected.mWidth >> 1); - expected.mHeight = PR_MAX(1, expected.mHeight >> 1); + expected.mWidth = NS_MAX(1, expected.mWidth >> 1); + expected.mHeight = NS_MAX(1, expected.mHeight >> 1); // if the current level has size 1x1, we can stop here: the spec doesn't seem to forbid the existence // of extra useless levels. @@ -1091,7 +1091,7 @@ public: ImageInfo imageInfo = ImageInfoAt(0, 0); NS_ASSERTION(imageInfo.IsPowerOfTwo(), "this texture is NPOT, so how could GenerateMipmap() ever accept it?"); - WebGLsizei size = PR_MAX(imageInfo.mWidth, imageInfo.mHeight); + WebGLsizei size = NS_MAX(imageInfo.mWidth, imageInfo.mHeight); // so, the size is a power of two, let's find its log in base 2. size_t maxLevel = 0; diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index 63967b0a1807..7dc3985ea04f 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -744,13 +744,13 @@ WebGLContext::CopyTexSubImage2D_base(WebGLenum target, return NS_OK; } - GLint actual_x = PR_MIN(framebufferWidth, PR_MAX(0, x)); - GLint actual_x_plus_width = PR_MIN(framebufferWidth, PR_MAX(0, x + width)); + GLint actual_x = NS_MIN(framebufferWidth, NS_MAX(0, x)); + GLint actual_x_plus_width = NS_MIN(framebufferWidth, NS_MAX(0, x + width)); GLsizei actual_width = actual_x_plus_width - actual_x; GLint actual_xoffset = xoffset + actual_x - x; - GLint actual_y = PR_MIN(framebufferHeight, PR_MAX(0, y)); - GLint actual_y_plus_height = PR_MIN(framebufferHeight, PR_MAX(0, y + height)); + GLint actual_y = NS_MIN(framebufferHeight, NS_MAX(0, y)); + GLint actual_y_plus_height = NS_MIN(framebufferHeight, NS_MAX(0, y + height)); GLsizei actual_height = actual_y_plus_height - actual_y; GLint actual_yoffset = yoffset + actual_y - y; @@ -2987,12 +2987,12 @@ WebGLContext::ReadPixels_base(WebGLint x, WebGLint y, WebGLsizei width, WebGLsiz } // compute the parameters of the subrect we're actually going to call glReadPixels on - GLint subrect_x = PR_MAX(x, 0); - GLint subrect_end_x = PR_MIN(x+width, boundWidth); + GLint subrect_x = NS_MAX(x, 0); + GLint subrect_end_x = NS_MIN(x+width, boundWidth); GLsizei subrect_width = subrect_end_x - subrect_x; - GLint subrect_y = PR_MAX(y, 0); - GLint subrect_end_y = PR_MIN(y+height, boundHeight); + GLint subrect_y = NS_MAX(y, 0); + GLint subrect_end_y = NS_MIN(y+height, boundHeight); GLsizei subrect_height = subrect_end_y - subrect_y; if (subrect_width < 0 || subrect_height < 0 || diff --git a/content/canvas/src/WebGLContextValidate.cpp b/content/canvas/src/WebGLContextValidate.cpp index cd540fad0c68..fa9334da890d 100644 --- a/content/canvas/src/WebGLContextValidate.cpp +++ b/content/canvas/src/WebGLContextValidate.cpp @@ -538,7 +538,7 @@ WebGLContext::InitAndValidateGL() error = gl->fGetError(); switch (error) { case LOCAL_GL_NO_ERROR: - mGLMaxVaryingVectors = PR_MIN(maxVertexOutputComponents, minFragmentInputComponents) / 4; + mGLMaxVaryingVectors = NS_MIN(maxVertexOutputComponents, minFragmentInputComponents) / 4; break; case LOCAL_GL_INVALID_ENUM: mGLMaxVaryingVectors = 16; // = 64/4, 64 is the min value for maxVertexOutputComponents in OpenGL 3.2 spec diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 2123fce2927e..6c14675e4ed7 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -770,7 +770,7 @@ nsMouseWheelTransaction::LimitToOnePageScroll(PRInt32 aScrollLines, nsSize pageAmount = sf->GetPageScrollAmount(); nscoord pageScroll = aIsHorizontal ? pageAmount.width : pageAmount.height; - if (PR_ABS(aScrollLines) * lineScroll < pageScroll) + if (NS_ABS(aScrollLines) * lineScroll < pageScroll) return aScrollLines; nscoord maxLines = (pageScroll / lineScroll); @@ -1272,7 +1272,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, if (!gPixelScrollDeltaX || !pixelHeight) break; - if (PR_ABS(gPixelScrollDeltaX) >= pixelHeight) { + if (NS_ABS(gPixelScrollDeltaX) >= pixelHeight) { PRInt32 numLines = (PRInt32)ceil((float)gPixelScrollDeltaX/(float)pixelHeight); gPixelScrollDeltaX -= numLines*pixelHeight; @@ -1287,7 +1287,7 @@ nsEventStateManager::PreHandleEvent(nsPresContext* aPresContext, if (!gPixelScrollDeltaY || !pixelHeight) break; - if (PR_ABS(gPixelScrollDeltaY) >= pixelHeight) { + if (NS_ABS(gPixelScrollDeltaY) >= pixelHeight) { PRInt32 numLines = (PRInt32)ceil((float)gPixelScrollDeltaY/(float)pixelHeight); gPixelScrollDeltaY -= numLines*pixelHeight; @@ -1990,8 +1990,8 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext, // fire drag gesture if mouse has moved enough nsIntPoint pt = aEvent->refPoint + aEvent->widget->WidgetToScreenOffset(); - if (PR_ABS(pt.x - mGestureDownPoint.x) > pixelThresholdX || - PR_ABS(pt.y - mGestureDownPoint.y) > pixelThresholdY) { + if (NS_ABS(pt.x - mGestureDownPoint.x) > pixelThresholdX || + NS_ABS(pt.y - mGestureDownPoint.y) > pixelThresholdY) { if (mClickHoldContextMenu) { // stop the click-hold before we fire off the drag gesture, in case // it takes a long time diff --git a/content/media/nsBuiltinDecoderReader.cpp b/content/media/nsBuiltinDecoderReader.cpp index aa83f773fc75..eb89f4fbb727 100644 --- a/content/media/nsBuiltinDecoderReader.cpp +++ b/content/media/nsBuiltinDecoderReader.cpp @@ -254,7 +254,7 @@ VideoData* nsBuiltinDecoderReader::FindStartTime(PRInt64& aOutStartTime) } } - PRInt64 startTime = PR_MIN(videoStartTime, audioStartTime); + PRInt64 startTime = NS_MIN(videoStartTime, audioStartTime); if (startTime != PR_INT64_MAX) { aOutStartTime = startTime; } diff --git a/content/media/nsMediaCache.cpp b/content/media/nsMediaCache.cpp index 023f90180adc..60699b74328a 100644 --- a/content/media/nsMediaCache.cpp +++ b/content/media/nsMediaCache.cpp @@ -818,14 +818,14 @@ nsMediaCache::FindReusableBlock(TimeStamp aNow, { mReentrantMonitor.AssertCurrentThreadIn(); - PRUint32 length = PR_MIN(PRUint32(aMaxSearchBlockIndex), mIndex.Length()); + PRUint32 length = NS_MIN(PRUint32(aMaxSearchBlockIndex), mIndex.Length()); if (aForStream && aForStreamBlock > 0 && PRUint32(aForStreamBlock) <= aForStream->mBlocks.Length()) { PRInt32 prevCacheBlock = aForStream->mBlocks[aForStreamBlock - 1]; if (prevCacheBlock >= 0) { PRUint32 freeBlockScanEnd = - PR_MIN(length, prevCacheBlock + FREE_BLOCK_SCAN_LIMIT); + NS_MIN(length, prevCacheBlock + FREE_BLOCK_SCAN_LIMIT); for (PRUint32 i = prevCacheBlock; i < freeBlockScanEnd; ++i) { if (IsBlockFree(i)) return i; @@ -1046,7 +1046,7 @@ nsMediaCache::PredictNextUse(TimeStamp aNow, PRInt32 aBlock) PRInt64 millisecondsAhead = bytesAhead*1000/bo->mStream->mPlaybackBytesPerSecond; prediction = TimeDuration::FromMilliseconds( - PR_MIN(millisecondsAhead, PR_INT32_MAX)); + NS_MIN(millisecondsAhead, PR_INT32_MAX)); break; } default: @@ -1074,7 +1074,7 @@ nsMediaCache::PredictNextUseForIncomingData(nsMediaCacheStream* aStream) return TimeDuration(0); PRInt64 millisecondsAhead = bytesAhead*1000/aStream->mPlaybackBytesPerSecond; return TimeDuration::FromMilliseconds( - PR_MIN(millisecondsAhead, PR_INT32_MAX)); + NS_MIN(millisecondsAhead, PR_INT32_MAX)); } enum StreamAction { NONE, SEEK, RESUME, SUSPEND }; @@ -1124,7 +1124,7 @@ nsMediaCache::Update() continue; } TimeDuration predictedUse = PredictNextUse(now, blockIndex); - latestPredictedUseForOverflow = PR_MAX(latestPredictedUseForOverflow, predictedUse); + latestPredictedUseForOverflow = NS_MAX(latestPredictedUseForOverflow, predictedUse); } // Now try to move overflowing blocks to the main part of the cache. @@ -1649,7 +1649,7 @@ nsMediaCache::NoteSeek(nsMediaCacheStream* aStream, PRInt64 aOldOffset) // be converted. PRInt32 blockIndex = aOldOffset/BLOCK_SIZE; PRInt32 endIndex = - PR_MIN((aStream->mStreamOffset + BLOCK_SIZE - 1)/BLOCK_SIZE, + NS_MIN((aStream->mStreamOffset + BLOCK_SIZE - 1)/BLOCK_SIZE, aStream->mBlocks.Length()); TimeStamp now = TimeStamp::Now(); while (blockIndex < endIndex) { @@ -1669,7 +1669,7 @@ nsMediaCache::NoteSeek(nsMediaCacheStream* aStream, PRInt64 aOldOffset) PRInt32 blockIndex = (aStream->mStreamOffset + BLOCK_SIZE - 1)/BLOCK_SIZE; PRInt32 endIndex = - PR_MIN((aOldOffset + BLOCK_SIZE - 1)/BLOCK_SIZE, + NS_MIN((aOldOffset + BLOCK_SIZE - 1)/BLOCK_SIZE, aStream->mBlocks.Length()); while (blockIndex < endIndex) { PRInt32 cacheBlockIndex = aStream->mBlocks[endIndex - 1]; @@ -1713,7 +1713,7 @@ nsMediaCacheStream::NotifyDataStarted(PRInt64 aOffset) if (mStreamLength >= 0) { // If we started reading at a certain offset, then for sure // the stream is at least that long. - mStreamLength = PR_MAX(mStreamLength, mChannelOffset); + mStreamLength = NS_MAX(mStreamLength, mChannelOffset); } } @@ -1768,7 +1768,7 @@ nsMediaCacheStream::NotifyDataReceived(PRInt64 aSize, const char* aData, while (size > 0) { PRUint32 blockIndex = mChannelOffset/BLOCK_SIZE; PRInt32 blockOffset = PRInt32(mChannelOffset - blockIndex*BLOCK_SIZE); - PRInt32 chunkSize = PRInt32(PR_MIN(BLOCK_SIZE - blockOffset, size)); + PRInt32 chunkSize = NS_MIN(BLOCK_SIZE - blockOffset, size); // This gets set to something non-null if we have a whole block // of data to write to the cache @@ -1809,7 +1809,7 @@ nsMediaCacheStream::NotifyDataReceived(PRInt64 aSize, const char* aData, while (nsMediaCacheStream* stream = iter.Next()) { if (stream->mStreamLength >= 0) { // The stream is at least as long as what we've read - stream->mStreamLength = PR_MAX(stream->mStreamLength, mChannelOffset); + stream->mStreamLength = NS_MAX(stream->mStreamLength, mChannelOffset); } stream->UpdatePrincipal(aPrincipal); stream->mClient->CacheClientNotifyDataReceived(); @@ -1975,9 +1975,9 @@ nsMediaCacheStream::GetCachedDataEndInternal(PRInt64 aOffset) if (mStreamLength >= 0) { // The last block in the cache may only be partially valid, so limit // the cached range to the stream length - result = PR_MIN(result, mStreamLength); + result = NS_MIN(result, mStreamLength); } - return PR_MAX(result, aOffset); + return NS_MAX(result, aOffset); } PRInt64 @@ -2106,7 +2106,7 @@ nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes) PRUint32 streamBlock = PRUint32(mStreamOffset/BLOCK_SIZE); PRUint32 offsetInStreamBlock = PRUint32(mStreamOffset - streamBlock*BLOCK_SIZE); - PRInt32 size = PR_MIN(aCount - count, BLOCK_SIZE - offsetInStreamBlock); + PRInt32 size = NS_MIN(aCount - count, BLOCK_SIZE - offsetInStreamBlock); if (mStreamLength >= 0) { // Don't try to read beyond the end of the stream @@ -2115,7 +2115,7 @@ nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes) // Get out of here and return NS_OK break; } - size = PR_MIN(size, PRInt32(bytesRemaining)); + size = NS_MIN(size, PRInt32(bytesRemaining)); } PRInt32 bytes; @@ -2125,7 +2125,7 @@ nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes) // We can just use the data in mPartialBlockBuffer. In fact we should // use it rather than waiting for the block to fill and land in // the cache. - bytes = PR_MIN(size, mChannelOffset - mStreamOffset); + bytes = NS_MIN(size, mChannelOffset - mStreamOffset); memcpy(aBuffer + count, reinterpret_cast(mPartialBlockBuffer) + offsetInStreamBlock, bytes); if (mCurrentMode == MODE_METADATA) { @@ -2192,7 +2192,7 @@ nsMediaCacheStream::ReadFromCache(char* aBuffer, PRUint32 streamBlock = PRUint32(streamOffset/BLOCK_SIZE); PRUint32 offsetInStreamBlock = PRUint32(streamOffset - streamBlock*BLOCK_SIZE); - PRInt32 size = PR_MIN(aCount - count, BLOCK_SIZE - offsetInStreamBlock); + PRInt32 size = NS_MIN(aCount - count, BLOCK_SIZE - offsetInStreamBlock); if (mStreamLength >= 0) { // Don't try to read beyond the end of the stream @@ -2200,7 +2200,7 @@ nsMediaCacheStream::ReadFromCache(char* aBuffer, if (bytesRemaining <= 0) { return NS_ERROR_FAILURE; } - size = PR_MIN(size, PRInt32(bytesRemaining)); + size = NS_MIN(size, PRInt32(bytesRemaining)); } PRInt32 bytes; @@ -2210,7 +2210,7 @@ nsMediaCacheStream::ReadFromCache(char* aBuffer, // We can just use the data in mPartialBlockBuffer. In fact we should // use it rather than waiting for the block to fill and land in // the cache. - bytes = PR_MIN(size, mChannelOffset - streamOffset); + bytes = NS_MIN(size, mChannelOffset - streamOffset); memcpy(aBuffer + count, reinterpret_cast(mPartialBlockBuffer) + offsetInStreamBlock, bytes); } else { diff --git a/content/media/nsMediaStream.cpp b/content/media/nsMediaStream.cpp index 1da816e86c10..d0eda60a05c2 100644 --- a/content/media/nsMediaStream.cpp +++ b/content/media/nsMediaStream.cpp @@ -938,7 +938,7 @@ public: { return (aOffset < mSize) ? aOffset : -1; } - virtual PRInt64 GetCachedDataEnd(PRInt64 aOffset) { return PR_MAX(aOffset, mSize); } + virtual PRInt64 GetCachedDataEnd(PRInt64 aOffset) { return NS_MAX(aOffset, mSize); } virtual PRBool IsDataCachedToEndOfStream(PRInt64 aOffset) { return PR_TRUE; } virtual PRBool IsSuspendedByCache() { return PR_FALSE; } virtual PRBool IsSuspended() { return PR_FALSE; } diff --git a/content/smil/nsSMILAnimationController.cpp b/content/smil/nsSMILAnimationController.cpp index 7ac8d3a0213d..eeeeb2db1af8 100644 --- a/content/smil/nsSMILAnimationController.cpp +++ b/content/smil/nsSMILAnimationController.cpp @@ -579,7 +579,7 @@ nsSMILAnimationController::DoMilestoneSamples() // Because we're only performing this clamping at the last moment, the // animations will still all get sampled in the correct order and // dependencies will be appropriately resolved. - sampleTime = PR_MAX(nextMilestone.mTime, sampleTime); + sampleTime = NS_MAX(nextMilestone.mTime, sampleTime); for (PRUint32 i = 0; i < length; ++i) { nsISMILAnimationElement* elem = params.mElements[i].get(); @@ -596,7 +596,7 @@ nsSMILAnimationController::DoMilestoneSamples() continue; // Clamp the converted container time to non-negative values. - nsSMILTime containerTime = PR_MAX(0, containerTimeValue.GetMillis()); + nsSMILTime containerTime = NS_MAX(0, containerTimeValue.GetMillis()); if (nextMilestone.mIsEnd) { elem->TimedElement().SampleEndAt(containerTime); diff --git a/content/smil/nsSMILTimeContainer.cpp b/content/smil/nsSMILTimeContainer.cpp index 47a43fb8da16..436f281df3dc 100644 --- a/content/smil/nsSMILTimeContainer.cpp +++ b/content/smil/nsSMILTimeContainer.cpp @@ -149,7 +149,7 @@ nsSMILTimeContainer::SetCurrentTime(nsSMILTime aSeekTo) { // SVG 1.1 doesn't specify what to do for negative times so we adopt SVGT1.2's // behaviour of clamping negative times to 0. - aSeekTo = PR_MAX(0, aSeekTo); + aSeekTo = NS_MAX(0, aSeekTo); // The following behaviour is consistent with: // http://www.w3.org/2003/01/REC-SVG11-20030114-errata diff --git a/content/xslt/src/base/txDouble.cpp b/content/xslt/src/base/txDouble.cpp index 5e42f234adac..3bfaf21a714f 100644 --- a/content/xslt/src/base/txDouble.cpp +++ b/content/xslt/src/base/txDouble.cpp @@ -261,7 +261,7 @@ void Double::toString(double aValue, nsAString& aDest) } } // mantissa - int firstlen = PR_MIN(intDigits, endp - buf); + int firstlen = NS_MIN(intDigits, endp - buf); for (i = 0; i < firstlen; i++) { *dest = buf[i]; ++dest; } diff --git a/content/xslt/src/base/txStringUtils.cpp b/content/xslt/src/base/txStringUtils.cpp index 5714017814fb..a9553d60fcb7 100644 --- a/content/xslt/src/base/txStringUtils.cpp +++ b/content/xslt/src/base/txStringUtils.cpp @@ -121,7 +121,7 @@ public: void write(const PRUnichar* aSource, PRUint32 aSourceLength) { - PRUint32 len = PR_MIN(PRUint32(mIter.size_forward()), aSourceLength); + PRUint32 len = NS_MIN(PRUint32(mIter.size_forward()), aSourceLength); PRUnichar* cp = mIter.get(); const PRUnichar* end = aSource + len; while (aSource != end) { diff --git a/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp b/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp index 7c74972f9dbb..ca3558ab82f7 100644 --- a/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp +++ b/content/xslt/src/xpath/txMozillaXPathTreeWalker.cpp @@ -712,7 +712,7 @@ txXPathNodeUtils::comparePosition(const txXPathNode& aNode, PRInt32 otherTotal = otherParents.Length() - 1; NS_ASSERTION(total != otherTotal, "Can't have same number of parents"); - PRInt32 lastIndex = PR_MIN(total, otherTotal); + PRInt32 lastIndex = NS_MIN(total, otherTotal); PRInt32 i; parent = nsnull; for (i = 0; i <= lastIndex; ++i) { diff --git a/content/xslt/src/xpath/txNodeSet.cpp b/content/xslt/src/xpath/txNodeSet.cpp index e67baffdc64a..d45a2f68c8e1 100644 --- a/content/xslt/src/xpath/txNodeSet.cpp +++ b/content/xslt/src/xpath/txNodeSet.cpp @@ -552,7 +552,7 @@ PRBool txNodeSet::ensureGrowSize(PRInt32 aSize) // This isn't 100% safe. But until someone manages to make a 1gig nodeset // it should be ok. - PRInt32 newLength = PR_MAX(oldLength, kTxNodeSetMinSize); + PRInt32 newLength = NS_MAX(oldLength, kTxNodeSetMinSize); while (newLength < ensureSize) { newLength *= kTxNodeSetGrowFactor; diff --git a/content/xslt/src/xslt/txMozillaXMLOutput.cpp b/content/xslt/src/xslt/txMozillaXMLOutput.cpp index 0cbc8547d82f..10cc3f6a2fae 100644 --- a/content/xslt/src/xslt/txMozillaXMLOutput.cpp +++ b/content/xslt/src/xslt/txMozillaXMLOutput.cpp @@ -684,7 +684,7 @@ txMozillaXMLOutput::createTxWrapper() // The new documentElement should go after the document type. // This is needed for cases when there is no existing // documentElement in the document. - rootLocation = PR_MAX(rootLocation, j + 1); + rootLocation = NS_MAX(rootLocation, j + 1); #endif ++j; } diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 21f27e0664aa..fe0b02e2c90b 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -1039,7 +1039,7 @@ nsXULElement::RemoveChildAt(PRUint32 aIndex, PRBool aNotify) PRInt32 treeRows; listBox->GetRowCount(&treeRows); if (treeRows > 0) { - newCurrentIndex = PR_MIN((treeRows - 1), newCurrentIndex); + newCurrentIndex = NS_MIN((treeRows - 1), newCurrentIndex); nsCOMPtr newCurrentItem; listBox->GetItemAtIndex(newCurrentIndex, getter_AddRefs(newCurrentItem)); nsCOMPtr xulCurItem = do_QueryInterface(newCurrentItem); diff --git a/db/morkreader/nsMorkReader.cpp b/db/morkreader/nsMorkReader.cpp index b66ac91873d5..1320b1398003 100644 --- a/db/morkreader/nsMorkReader.cpp +++ b/db/morkreader/nsMorkReader.cpp @@ -315,7 +315,7 @@ nsMorkReader::ParseMap(const nsCSubstring &aLine, StringMap *aMap) } ++idx; } - PRUint32 tokenEnd = PR_MIN(idx, len); + PRUint32 tokenEnd = NS_MIN(idx, len); ++idx; nsCString value; @@ -463,7 +463,7 @@ nsMorkReader::ParseTable(const nsCSubstring &aLine, const IndexMap &aColumnMap) ++idx; } - tokenEnd = PR_MIN(idx, len); + tokenEnd = NS_MIN(idx, len); nsCAutoString column; const nsCSubstring &colValue = @@ -496,7 +496,7 @@ nsMorkReader::ParseTable(const nsCSubstring &aLine, const IndexMap &aColumnMap) } ++idx; } - tokenEnd = PR_MIN(idx, len); + tokenEnd = NS_MIN(idx, len); ++idx; const nsCSubstring &value = diff --git a/docshell/shistory/src/nsSHistory.cpp b/docshell/shistory/src/nsSHistory.cpp index d68bd45022b7..2d0230417b81 100644 --- a/docshell/shistory/src/nsSHistory.cpp +++ b/docshell/shistory/src/nsSHistory.cpp @@ -1003,7 +1003,7 @@ nsSHistory::EvictGlobalContentViewer() // This SHEntry has a ContentViewer, so check how far away it is from // the currently used SHEntry within this SHistory object if (viewer) { - PRInt32 distance = PR_ABS(shist->mIndex - i); + PRInt32 distance = NS_ABS(shist->mIndex - i); #ifdef DEBUG_PAGE_CACHE printf("Has a cached content viewer: %s\n", spec.get()); @@ -1213,7 +1213,7 @@ PRBool IsSameTree(nsISHEntry* aEntry1, nsISHEntry* aEntry2) container1->GetChildCount(&count1); container2->GetChildCount(&count2); // We allow null entries in the end of the child list. - PRInt32 count = PR_MAX(count1, count2); + PRInt32 count = NS_MAX(count1, count2); for (PRInt32 i = 0; i < count; ++i) { nsCOMPtr child1, child2; container1->GetChildAt(i, getter_AddRefs(child1)); diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index 53c8df1e5191..29d55a7f7ca2 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -627,7 +627,7 @@ IDBFactory::SetCurrentDatabase(IDBDatabase* aDatabase) PRUint32 IDBFactory::GetIndexedDBQuota() { - return PRUint32(PR_MAX(gIndexedDBQuota, 0)); + return PRUint32(NS_MAX(gIndexedDBQuota, 0)); } // static @@ -983,9 +983,9 @@ OpenDatabaseHelper::DoDatabaseWork(mozIStorageConnection* aConnection) nsAutoPtr& objectStoreInfo = mObjectStores[i]; for (PRUint32 j = 0; j < objectStoreInfo->indexes.Length(); j++) { IndexInfo& indexInfo = objectStoreInfo->indexes[j]; - mLastIndexId = PR_MAX(indexInfo.id, mLastIndexId); + mLastIndexId = NS_MAX(indexInfo.id, mLastIndexId); } - mLastObjectStoreId = PR_MAX(objectStoreInfo->id, mLastObjectStoreId); + mLastObjectStoreId = NS_MAX(objectStoreInfo->id, mLastObjectStoreId); } return NS_OK; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index ac3e5f1d8097..0f636df6daef 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -400,7 +400,7 @@ TabParent::HandleQueryContentEvent(nsQueryContentEvent& aEvent) { case NS_QUERY_SELECTED_TEXT: { - aEvent.mReply.mOffset = PR_MIN(mIMESelectionAnchor, mIMESelectionFocus); + aEvent.mReply.mOffset = NS_MIN(mIMESelectionAnchor, mIMESelectionFocus); if (mIMESelectionAnchor == mIMESelectionFocus) { aEvent.mReply.mString.Truncate(0); } else { @@ -446,7 +446,7 @@ bool TabParent::SendCompositionEvent(nsCompositionEvent& event) { mIMEComposing = event.message == NS_COMPOSITION_START; - mIMECompositionStart = PR_MIN(mIMESelectionAnchor, mIMESelectionFocus); + mIMECompositionStart = NS_MIN(mIMESelectionAnchor, mIMESelectionFocus); if (mIMECompositionEnding) return true; event.seqno = ++mIMESeqno; @@ -471,7 +471,7 @@ TabParent::SendTextEvent(nsTextEvent& event) // We must be able to simulate the selection because // we might not receive selection updates in time if (!mIMEComposing) { - mIMECompositionStart = PR_MIN(mIMESelectionAnchor, mIMESelectionFocus); + mIMECompositionStart = NS_MIN(mIMESelectionAnchor, mIMESelectionFocus); } mIMESelectionAnchor = mIMESelectionFocus = mIMECompositionStart + event.theText.Length(); diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index 27973f427b33..0ea70be4ec34 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -2023,7 +2023,7 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection, res = nsWSRunObject::PrepareToDeleteRange(mHTMLEditor, address_of(visNode), &so, address_of(visNode), &eo); NS_ENSURE_SUCCESS(res, res); nsCOMPtr nodeAsText(do_QueryInterface(visNode)); - res = mHTMLEditor->DeleteText(nodeAsText, NS_MIN(so, eo), PR_ABS(eo - so)); + res = mHTMLEditor->DeleteText(nodeAsText, NS_MIN(so, eo), NS_ABS(eo - so)); *aHandled = PR_TRUE; NS_ENSURE_SUCCESS(res, res); res = InsertBRIfNeeded(aSelection); diff --git a/editor/libeditor/html/nsHTMLObjectResizer.cpp b/editor/libeditor/html/nsHTMLObjectResizer.cpp index 88c8471c8026..f3d7e9922aa0 100644 --- a/editor/libeditor/html/nsHTMLObjectResizer.cpp +++ b/editor/libeditor/html/nsHTMLObjectResizer.cpp @@ -927,8 +927,8 @@ nsHTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent) look->GetMetric(nsILookAndFeel::eMetric_DragThresholdX, xThreshold); look->GetMetric(nsILookAndFeel::eMetric_DragThresholdY, yThreshold); - if (PR_ABS(clientX - mOriginalX ) * 2 >= xThreshold || - PR_ABS(clientY - mOriginalY ) * 2 >= yThreshold) { + if (NS_ABS(clientX - mOriginalX ) * 2 >= xThreshold || + NS_ABS(clientY - mOriginalY ) * 2 >= yThreshold) { mGrabberClicked = PR_FALSE; StartMoving(nsnull); } diff --git a/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp b/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp index 3f38fc104e19..0ac0f440f4b2 100644 --- a/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp +++ b/extensions/gnomevfs/nsGnomeVFSProtocolHandler.cpp @@ -523,7 +523,7 @@ nsGnomeVFSInputStream::DoRead(char *aBuf, PRUint32 aCount, PRUint32 *aCountRead) PRUint32 bufLen = mDirBuf.Length() - mDirBufCursor; if (bufLen) { - PRUint32 n = PR_MIN(bufLen, aCount); + PRUint32 n = NS_MIN(bufLen, aCount); memcpy(aBuf, mDirBuf.get() + mDirBufCursor, n); *aCountRead += n; aBuf += n; diff --git a/extensions/pref/autoconfig/src/nsAutoConfig.cpp b/extensions/pref/autoconfig/src/nsAutoConfig.cpp index 80c0804c9bef..0805c10770fc 100644 --- a/extensions/pref/autoconfig/src/nsAutoConfig.cpp +++ b/extensions/pref/autoconfig/src/nsAutoConfig.cpp @@ -137,7 +137,7 @@ nsAutoConfig::OnDataAvailable(nsIRequest *request, char buf[1024]; while (aLength) { - size = PR_MIN(aLength, sizeof(buf)); + size = NS_MIN(aLength, sizeof(buf)); rv = aIStream->Read(buf, size, &amt); if (NS_FAILED(rv)) return rv; diff --git a/gfx/thebes/gfxBlur.cpp b/gfx/thebes/gfxBlur.cpp index 613c6957e3e5..c9e76c8c8785 100644 --- a/gfx/thebes/gfxBlur.cpp +++ b/gfx/thebes/gfxBlur.cpp @@ -348,11 +348,11 @@ SpreadHorizontal(unsigned char* aInput, break; } - PRInt32 sMin = PR_MAX(x - aRadius, 0); - PRInt32 sMax = PR_MIN(x + aRadius, aWidth - 1); + PRInt32 sMin = NS_MAX(x - aRadius, 0); + PRInt32 sMax = NS_MIN(x + aRadius, aWidth - 1); PRInt32 v = 0; for (PRInt32 s = sMin; s <= sMax; ++s) { - v = PR_MAX(v, aInput[aStride * y + s]); + v = NS_MAX(v, aInput[aStride * y + s]); } aOutput[aStride * y + x] = v; } @@ -393,11 +393,11 @@ SpreadVertical(unsigned char* aInput, break; } - PRInt32 sMin = PR_MAX(y - aRadius, 0); - PRInt32 sMax = PR_MIN(y + aRadius, aRows - 1); + PRInt32 sMin = NS_MAX(y - aRadius, 0); + PRInt32 sMax = NS_MIN(y + aRadius, aRows - 1); PRInt32 v = 0; for (PRInt32 s = sMin; s <= sMax; ++s) { - v = PR_MAX(v, aInput[aStride * s + x]); + v = NS_MAX(v, aInput[aStride * s + x]); } aOutput[aStride * y + x] = v; } diff --git a/gfx/thebes/gfxContext.cpp b/gfx/thebes/gfxContext.cpp index 8c4ccfc81d8f..a2f3e68afbf1 100644 --- a/gfx/thebes/gfxContext.cpp +++ b/gfx/thebes/gfxContext.cpp @@ -398,10 +398,10 @@ gfxContext::UserToDevice(const gfxRect& rect) const ymax = ymin; for (int i = 0; i < 3; i++) { cairo_user_to_device(mCairo, &x[i], &y[i]); - xmin = PR_MIN(xmin, x[i]); - xmax = PR_MAX(xmax, x[i]); - ymin = PR_MIN(ymin, y[i]); - ymax = PR_MAX(ymax, y[i]); + xmin = NS_MIN(xmin, x[i]); + xmax = NS_MAX(xmax, x[i]); + ymin = NS_MIN(ymin, y[i]); + ymax = NS_MAX(ymax, y[i]); } return gfxRect(xmin, ymin, xmax - xmin, ymax - ymin); diff --git a/gfx/thebes/gfxCoreTextShaper.cpp b/gfx/thebes/gfxCoreTextShaper.cpp index 2d385599088f..c45629b7e607 100644 --- a/gfx/thebes/gfxCoreTextShaper.cpp +++ b/gfx/thebes/gfxCoreTextShaper.cpp @@ -39,6 +39,7 @@ * ***** END LICENSE BLOCK ***** */ #include "prtypes.h" +#include "nsAlgorithm.h" #include "prmem.h" #include "nsString.h" #include "nsBidiUtils.h" @@ -378,7 +379,7 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxTextRun *aTextRun, // find the maximum glyph index covered by the clump so far for (PRInt32 i = charStart; i != charEnd; i += direction) { if (charToGlyph[i] != NO_GLYPH) { - glyphEnd = PR_MAX(glyphEnd, charToGlyph[i] + 1); // update extent of glyph range + glyphEnd = NS_MAX(glyphEnd, charToGlyph[i] + 1); // update extent of glyph range } } @@ -453,8 +454,8 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxTextRun *aTextRun, continue; } // Ensure we won't try to go beyond the valid length of the textRun's text - baseCharIndex = PR_MAX(baseCharIndex, aRunStart); - endCharIndex = PR_MIN(endCharIndex, aRunStart + aRunLength); + baseCharIndex = NS_MAX(baseCharIndex, aRunStart); + endCharIndex = NS_MIN(endCharIndex, aRunStart + aRunLength); // Now we're ready to set the glyph info in the textRun; measure the glyph width // of the first (perhaps only) glyph, to see if it is "Simple" diff --git a/gfx/thebes/gfxDWriteFontList.h b/gfx/thebes/gfxDWriteFontList.h index ed2d309f8841..cef79707cf58 100644 --- a/gfx/thebes/gfxDWriteFontList.h +++ b/gfx/thebes/gfxDWriteFontList.h @@ -99,7 +99,7 @@ public: mItalic = (aFont->GetStyle() == DWRITE_FONT_STYLE_ITALIC || aFont->GetStyle() == DWRITE_FONT_STYLE_OBLIQUE); mStretch = FontStretchFromDWriteStretch(aFont->GetStretch()); - PRUint16 weight = PR_ROUNDUP(aFont->GetWeight() - 50, 100); + PRUint16 weight = NS_ROUNDUP(aFont->GetWeight() - 50, 100); weight = NS_MAX(100, weight); weight = NS_MIN(900, weight); diff --git a/gfx/thebes/gfxFT2Utils.cpp b/gfx/thebes/gfxFT2Utils.cpp index 07504e0cdeab..4bffbd705ca2 100644 --- a/gfx/thebes/gfxFT2Utils.cpp +++ b/gfx/thebes/gfxFT2Utils.cpp @@ -70,7 +70,7 @@ ScaleRoundDesignUnits(FT_Short aDesignMetric, FT_Fixed aScale) static void SnapLineToPixels(gfxFloat& aOffset, gfxFloat& aSize) { - gfxFloat snappedSize = PR_MAX(NS_floor(aSize + 0.5), 1.0); + gfxFloat snappedSize = NS_MAX(NS_floor(aSize + 0.5), 1.0); // Correct offset for change in size gfxFloat offset = aOffset - 0.5 * (aSize - snappedSize); // Snap offset @@ -201,10 +201,10 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics, gfxFloat avgCharWidth = ScaleRoundDesignUnits(os2->xAvgCharWidth, ftMetrics.x_scale); aMetrics->aveCharWidth = - PR_MAX(aMetrics->aveCharWidth, avgCharWidth); + NS_MAX(aMetrics->aveCharWidth, avgCharWidth); } aMetrics->aveCharWidth = - PR_MAX(aMetrics->aveCharWidth, aMetrics->zeroOrAveCharWidth); + NS_MAX(aMetrics->aveCharWidth, aMetrics->zeroOrAveCharWidth); if (aMetrics->aveCharWidth == 0.0) { aMetrics->aveCharWidth = aMetrics->spaceWidth; } @@ -213,7 +213,7 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics, } // Apparently hinting can mean that max_advance is not always accurate. aMetrics->maxAdvance = - PR_MAX(aMetrics->maxAdvance, aMetrics->aveCharWidth); + NS_MAX(aMetrics->maxAdvance, aMetrics->aveCharWidth); // gfxFont::Metrics::underlineOffset is the position of the top of the // underline. @@ -258,7 +258,7 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics, if (os2 && os2->ySuperscriptYOffset) { gfxFloat val = ScaleRoundDesignUnits(os2->ySuperscriptYOffset, ftMetrics.y_scale); - aMetrics->superscriptOffset = PR_MAX(1.0, val); + aMetrics->superscriptOffset = NS_MAX(1.0, val); } else { aMetrics->superscriptOffset = aMetrics->xHeight; } @@ -268,7 +268,7 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics, ftMetrics.y_scale); // some fonts have the incorrect sign. val = fabs(val); - aMetrics->subscriptOffset = PR_MAX(1.0, val); + aMetrics->subscriptOffset = NS_MAX(1.0, val); } else { aMetrics->subscriptOffset = aMetrics->xHeight; } @@ -290,7 +290,7 @@ gfxFT2LockedFace::GetMetrics(gfxFont::Metrics* aMetrics, // Text input boxes currently don't work well with lineHeight // significantly less than maxHeight (with Verdana, for example). - lineHeight = NS_floor(PR_MAX(lineHeight, aMetrics->maxHeight) + 0.5); + lineHeight = NS_floor(NS_MAX(lineHeight, aMetrics->maxHeight) + 0.5); aMetrics->externalLeading = lineHeight - aMetrics->internalLeading - aMetrics->emHeight; diff --git a/gfx/thebes/gfxFontUtils.h b/gfx/thebes/gfxFontUtils.h index 5e17405837e6..d928a80b3116 100644 --- a/gfx/thebes/gfxFontUtils.h +++ b/gfx/thebes/gfxFontUtils.h @@ -43,6 +43,7 @@ #include "gfxTypes.h" #include "prtypes.h" +#include "nsAlgorithm.h" #include "prcpucfg.h" #include "nsDataHashtable.h" @@ -122,7 +123,7 @@ public: // first block, check bits if ((block = mBlocks[startBlock])) { start = aStart; - end = PR_MIN(aEnd, ((startBlock+1) << BLOCK_INDEX_SHIFT) - 1); + end = NS_MIN(aEnd, ((startBlock+1) << BLOCK_INDEX_SHIFT) - 1); for (i = start; i <= end; i++) { if ((block->mBits[(i>>3) & (BLOCK_SIZE - 1)]) & (1 << (i & 0x7))) return PR_TRUE; @@ -210,7 +211,7 @@ public: } const PRUint32 start = aStart > blockFirstBit ? aStart - blockFirstBit : 0; - const PRUint32 end = PR_MIN(aEnd - blockFirstBit, BLOCK_SIZE_BITS - 1); + const PRUint32 end = NS_MIN(aEnd - blockFirstBit, BLOCK_SIZE_BITS - 1); for (PRUint32 bit = start; bit <= end; ++bit) { block->mBits[bit>>3] |= 1 << (bit & 0x7); @@ -254,7 +255,7 @@ public: } const PRUint32 start = aStart > blockFirstBit ? aStart - blockFirstBit : 0; - const PRUint32 end = PR_MIN(aEnd - blockFirstBit, BLOCK_SIZE_BITS - 1); + const PRUint32 end = NS_MIN(aEnd - blockFirstBit, BLOCK_SIZE_BITS - 1); for (PRUint32 bit = start; bit <= end; ++bit) { block->mBits[bit>>3] &= ~(1 << (bit & 0x7)); diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp index 579e869be31f..f66afaa7560b 100644 --- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -374,7 +374,7 @@ gfxGDIFont::Initialize() mMetrics->maxAscent = metrics.tmAscent; mMetrics->maxDescent = metrics.tmDescent; mMetrics->maxAdvance = metrics.tmMaxCharWidth; - mMetrics->aveCharWidth = PR_MAX(1, metrics.tmAveCharWidth); + mMetrics->aveCharWidth = NS_MAX(1, metrics.tmAveCharWidth); // The font is monospace when TMPF_FIXED_PITCH is *not* set! // See http://msdn2.microsoft.com/en-us/library/ms534202(VS.85).aspx if (!(metrics.tmPitchAndFamily & TMPF_FIXED_PITCH)) { diff --git a/gfx/thebes/gfxGDIFontList.cpp b/gfx/thebes/gfxGDIFontList.cpp index 46462203a023..ec6a6a3438d3 100644 --- a/gfx/thebes/gfxGDIFontList.cpp +++ b/gfx/thebes/gfxGDIFontList.cpp @@ -434,7 +434,7 @@ GDIFontEntry::InitLogFont(const nsAString& aName, mLogFont.lfItalic = mItalic; mLogFont.lfWeight = mWeight; - int len = PR_MIN(aName.Length(), LF_FACESIZE - 1); + int len = NS_MIN(aName.Length(), LF_FACESIZE - 1); memcpy(&mLogFont.lfFaceName, nsPromiseFlatString(aName).get(), len * 2); mLogFont.lfFaceName[len] = '\0'; } @@ -468,7 +468,7 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe, GDIFontFamily *ff = reinterpret_cast(data); // Some fonts claim to support things > 900, but we don't so clamp the sizes - logFont.lfWeight = PR_MAX(PR_MIN(logFont.lfWeight, 900), 100); + logFont.lfWeight = NS_MAX(NS_MIN(logFont.lfWeight, 900), 100); gfxWindowsFontType feType = GDIFontEntry::DetermineFontType(metrics, fontType); @@ -551,7 +551,7 @@ GDIFontFamily::FindStyleVariations() memset(&logFont, 0, sizeof(LOGFONTW)); logFont.lfCharSet = DEFAULT_CHARSET; logFont.lfPitchAndFamily = 0; - PRUint32 l = PR_MIN(mName.Length(), LF_FACESIZE - 1); + PRUint32 l = NS_MIN(mName.Length(), LF_FACESIZE - 1); memcpy(logFont.lfFaceName, nsPromiseFlatString(mName).get(), l * sizeof(PRUnichar)); @@ -820,7 +820,7 @@ public: while (mCurrentChunk < mNumChunks && bytesLeft) { FontDataChunk& currentChunk = mDataChunks[mCurrentChunk]; - PRUint32 bytesToCopy = PR_MIN(bytesLeft, + PRUint32 bytesToCopy = NS_MIN(bytesLeft, currentChunk.mLength - mChunkOffset); memcpy(out, currentChunk.mData + mChunkOffset, bytesToCopy); bytesLeft -= bytesToCopy; @@ -888,7 +888,7 @@ gfxGDIFontList::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry, PRUint32 eotlen; isEmbedded = PR_TRUE; - PRUint32 nameLen = PR_MIN(uniqueName.Length(), LF_FACESIZE - 1); + PRUint32 nameLen = NS_MIN(uniqueName.Length(), LF_FACESIZE - 1); nsPromiseFlatString fontName(Substring(uniqueName, 0, nameLen)); FontDataOverlay overlayNameData = {0, 0, 0}; diff --git a/gfx/thebes/gfxHarfBuzzShaper.cpp b/gfx/thebes/gfxHarfBuzzShaper.cpp index 7105b07fb72d..96dbb468ff97 100644 --- a/gfx/thebes/gfxHarfBuzzShaper.cpp +++ b/gfx/thebes/gfxHarfBuzzShaper.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "prtypes.h" +#include "nsAlgorithm.h" #include "prmem.h" #include "nsString.h" #include "nsBidiUtils.h" @@ -335,7 +336,7 @@ GetKernValueFmt0(const void* aSubtable, if (aIsOverride) { aValue = PRInt16(lo->value); } else if (aIsMinimum) { - aValue = PR_MAX(aValue, PRInt16(lo->value)); + aValue = NS_MAX(aValue, PRInt32(lo->value)); } else { aValue += PRInt16(lo->value); } @@ -1047,7 +1048,7 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext, // find the maximum glyph index covered by the clump so far for (PRInt32 i = charStart; i < charEnd; ++i) { if (charToGlyph[i] != NO_GLYPH) { - glyphEnd = PR_MAX(glyphEnd, charToGlyph[i] + 1); + glyphEnd = NS_MAX(glyphEnd, charToGlyph[i] + 1); // update extent of glyph range } } diff --git a/gfx/thebes/gfxImageSurface.cpp b/gfx/thebes/gfxImageSurface.cpp index b978d543a53d..2a3d291d1844 100644 --- a/gfx/thebes/gfxImageSurface.cpp +++ b/gfx/thebes/gfxImageSurface.cpp @@ -212,7 +212,7 @@ gfxImageSurface::CopyFrom(gfxImageSurface *other) if (other->mStride == mStride) { memcpy (mData, other->mData, mStride * mSize.height); } else { - int lineSize = PR_MIN(other->mStride, mStride); + int lineSize = NS_MIN(other->mStride, mStride); for (int i = 0; i < mSize.height; i++) { unsigned char *src = other->mData + other->mStride * i; unsigned char *dst = mData + mStride * i; diff --git a/gfx/thebes/gfxMacFont.cpp b/gfx/thebes/gfxMacFont.cpp index 4c018257c380..b6959149cbf9 100644 --- a/gfx/thebes/gfxMacFont.cpp +++ b/gfx/thebes/gfxMacFont.cpp @@ -228,7 +228,7 @@ gfxMacFont::InitMetrics() return; } - mAdjustedSize = PR_MAX(mStyle.size, 1.0f); + mAdjustedSize = NS_MAX(mStyle.size, 1.0); mFUnitsConvFactor = mAdjustedSize / upem; // For CFF fonts, when scaling values read from CGFont* APIs, we need to diff --git a/gfx/thebes/gfxOS2Fonts.cpp b/gfx/thebes/gfxOS2Fonts.cpp index 520d64af3c92..ecdb5d866665 100644 --- a/gfx/thebes/gfxOS2Fonts.cpp +++ b/gfx/thebes/gfxOS2Fonts.cpp @@ -130,7 +130,7 @@ static void FillMetricsDefaults(gfxFont::Metrics *aMetrics) // line as close to the original position as possible. static void SnapLineToPixels(gfxFloat& aOffset, gfxFloat& aSize) { - gfxFloat snappedSize = PR_MAX(NS_floor(aSize + 0.5), 1.0); + gfxFloat snappedSize = NS_MAX(NS_floor(aSize + 0.5), 1.0); // Correct offset for change in size gfxFloat offset = aOffset - 0.5 * (aSize - snappedSize); // Snap offset @@ -240,12 +240,12 @@ const gfxFont::Metrics& gfxOS2Font::GetMetrics() TT_OS2 *os2 = (TT_OS2 *)FT_Get_Sfnt_Table(face, ft_sfnt_os2); if (os2 && os2->version != 0xFFFF) { // should be there if not old Mac font // if we are here we can improve the avgCharWidth - mMetrics->aveCharWidth = PR_MAX(mMetrics->aveCharWidth, + mMetrics->aveCharWidth = NS_MAX(mMetrics->aveCharWidth, os2->xAvgCharWidth * xScale); - mMetrics->superscriptOffset = PR_MAX(os2->ySuperscriptYOffset * yScale, 1.0); + mMetrics->superscriptOffset = NS_MAX(os2->ySuperscriptYOffset * yScale, 1.0); // some fonts have the incorrect sign (from gfxPangoFonts) - mMetrics->subscriptOffset = PR_MAX(fabs(os2->ySubscriptYOffset * yScale), + mMetrics->subscriptOffset = NS_MAX(fabs(os2->ySubscriptYOffset * yScale), 1.0); mMetrics->strikeoutOffset = os2->yStrikeoutPosition * yScale; mMetrics->strikeoutSize = os2->yStrikeoutSize * yScale; @@ -267,11 +267,11 @@ const gfxFont::Metrics& gfxOS2Font::GetMetrics() mMetrics->emDescent = -face->descender * yScale; mMetrics->maxHeight = face->height * yScale; // the max units determine frame heights, better be generous - mMetrics->maxAscent = PR_MAX(face->bbox.yMax * yScale, + mMetrics->maxAscent = NS_MAX(face->bbox.yMax * yScale, mMetrics->emAscent); - mMetrics->maxDescent = PR_MAX(-face->bbox.yMin * yScale, + mMetrics->maxDescent = NS_MAX(-face->bbox.yMin * yScale, mMetrics->emDescent); - mMetrics->maxAdvance = PR_MAX(face->max_advance_width * xScale, + mMetrics->maxAdvance = NS_MAX(face->max_advance_width * xScale, mMetrics->aveCharWidth); // leadings are not available directly (only for WinFNTs); diff --git a/gfx/thebes/gfxRect.h b/gfx/thebes/gfxRect.h index ed376e41a39d..91b1de0f06b5 100644 --- a/gfx/thebes/gfxRect.h +++ b/gfx/thebes/gfxRect.h @@ -38,6 +38,7 @@ #ifndef GFX_RECT_H #define GFX_RECT_H +#include "nsAlgorithm.h" #include "gfxTypes.h" #include "gfxPoint.h" #include "gfxCore.h" diff --git a/gfx/thebes/gfxSkipChars.cpp b/gfx/thebes/gfxSkipChars.cpp index 60bebf44bb7c..9145a19b8c45 100644 --- a/gfx/thebes/gfxSkipChars.cpp +++ b/gfx/thebes/gfxSkipChars.cpp @@ -240,7 +240,7 @@ gfxSkipCharsBuilder::FlushRun() // Fill in buffer entries starting at mBufferLength, as many as necessary PRUint32 charCount = mRunCharCount; for (;;) { - PRUint32 chars = PR_MIN(255, charCount); + PRUint32 chars = NS_MIN(255, charCount); if (!mBuffer.AppendElement(chars)) { mInErrorState = PR_TRUE; return; diff --git a/intl/uconv/src/nsConverterInputStream.cpp b/intl/uconv/src/nsConverterInputStream.cpp index 4552aef9f509..a9f9164ac79e 100644 --- a/intl/uconv/src/nsConverterInputStream.cpp +++ b/intl/uconv/src/nsConverterInputStream.cpp @@ -248,7 +248,7 @@ nsConverterInputStream::Fill(nsresult * aErrorCode) ++srcConsumed; // XXX this is needed to make sure we don't underrun our buffer; // bug 160784 again - srcConsumed = PR_MAX(srcConsumed, 0); + srcConsumed = NS_MAX(srcConsumed, 0); mConverter->Reset(); } NS_ASSERTION(srcConsumed <= mByteData->GetLength(), diff --git a/intl/uconv/src/nsUTF8ToUnicode.cpp b/intl/uconv/src/nsUTF8ToUnicode.cpp index 95ccc5e47bf1..505fd3dd6972 100644 --- a/intl/uconv/src/nsUTF8ToUnicode.cpp +++ b/intl/uconv/src/nsUTF8ToUnicode.cpp @@ -35,6 +35,7 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsAlgorithm.h" #include "nsUCSupport.h" #include "nsUTF8ToUnicode.h" #include "mozilla/SSE.h" @@ -249,7 +250,7 @@ NS_IMETHODIMP nsUTF8ToUnicode::Convert(const char * aSrc, // When mState is zero we expect either a US-ASCII character or a // multi-octet sequence. if (0 == (0x80 & (*in))) { - PRInt32 max_loops = PR_MIN(inend - in, outend - out); + PRInt32 max_loops = NS_MIN(inend - in, outend - out); Convert_ascii_run(in, out, max_loops); --in; // match the rest of the cases mBytes = 1; diff --git a/intl/uconv/util/nsUCSupport.cpp b/intl/uconv/util/nsUCSupport.cpp index 55c5abb89f72..507a7e23f1f9 100644 --- a/intl/uconv/util/nsUCSupport.cpp +++ b/intl/uconv/util/nsUCSupport.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "pratom.h" +#include "nsAlgorithm.h" #include "nsIComponentManager.h" #include "nsUCSupport.h" #include "nsUnicodeDecodeHelper.h" @@ -106,7 +107,7 @@ nsBufferDecoderSupport::~nsBufferDecoderSupport() void nsBufferDecoderSupport::FillBuffer(const char ** aSrc, PRInt32 aSrcLength) { - PRInt32 bcr = PR_MIN(mBufferCapacity - mBufferLength, aSrcLength); + PRInt32 bcr = NS_MIN(mBufferCapacity - mBufferLength, aSrcLength); memcpy(mBuffer + mBufferLength, *aSrc, bcr); mBufferLength += bcr; (*aSrc) += bcr; diff --git a/layout/base/nsCSSColorUtils.h b/layout/base/nsCSSColorUtils.h index 4c793511eb5c..6fa835112f53 100644 --- a/layout/base/nsCSSColorUtils.h +++ b/layout/base/nsCSSColorUtils.h @@ -47,7 +47,7 @@ // See http://www.w3.org/TR/AERT#color-contrast #define NS_SUFFICIENT_LUMINOSITY_DIFFERENCE 125000 #define NS_LUMINOSITY_DIFFERENCE(a, b) \ - PR_ABS(NS_GetLuminosity(a) - NS_GetLuminosity(b)) + NS_ABS(NS_GetLuminosity(a) - NS_GetLuminosity(b)) // To determine colors based on the background brightness and border color void NS_GetSpecial3DColors(nscolor aResult[2], diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index cbf74d244c31..56d55a6e6abb 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -1825,10 +1825,10 @@ ComputeRadialGradientLine(nsPresContext* aPresContext, // Compute gradient shape: the x and y radii of an ellipse. double radiusX, radiusY; - double leftDistance = PR_ABS(aLineStart->x); - double rightDistance = PR_ABS(aBoxSize.width - aLineStart->x); - double topDistance = PR_ABS(aLineStart->y); - double bottomDistance = PR_ABS(aBoxSize.height - aLineStart->y); + double leftDistance = NS_ABS(aLineStart->x); + double rightDistance = NS_ABS(aBoxSize.width - aLineStart->x); + double topDistance = NS_ABS(aLineStart->y); + double bottomDistance = NS_ABS(aBoxSize.height - aLineStart->y); switch (aGradient->mSize) { case NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE: radiusX = NS_MIN(leftDistance, rightDistance); diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index 7d1f83f9093c..4da0a3b8290f 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -888,7 +888,7 @@ IsSizeOK(nsPresContext* aPresContext, nscoord a, nscoord b, PRUint32 aHint) // or in sloppy markups without protective PRBool isNormal = (aHint & NS_STRETCH_NORMAL) - && PRBool(float(PR_ABS(a - b)) + && PRBool(float(NS_ABS(a - b)) < (1.0f - NS_MATHML_DELIMITER_FACTOR) * float(b)); // Nearer: True if 'a' is around max{ +/-10% of 'b' , 'b' - 5pt }, // as documented in The TeXbook, Ch.17, p.152. @@ -897,7 +897,7 @@ IsSizeOK(nsPresContext* aPresContext, nscoord a, nscoord b, PRUint32 aHint) if (aHint & (NS_STRETCH_NEARER | NS_STRETCH_LARGEOP)) { float c = NS_MAX(float(b) * NS_MATHML_DELIMITER_FACTOR, float(b) - nsPresContext::CSSPointsToAppUnits(NS_MATHML_DELIMITER_SHORTFALL_POINTS)); - isNearer = PRBool(float(PR_ABS(b - a)) <= (float(b) - c)); + isNearer = PRBool(float(NS_ABS(b - a)) <= (float(b) - c)); } // Smaller: Mainly for transitory use, to compare two candidate // choices @@ -924,7 +924,7 @@ IsSizeBetter(nscoord a, nscoord olda, nscoord b, PRUint32 aHint) return (a <= olda) ? (olda > b) : (a <= b); // XXXkt prob want log scale here i.e. 1.5 is closer to 1 than 0.5 - return PR_ABS(a - b) < PR_ABS(olda - b); + return NS_ABS(a - b) < NS_ABS(olda - b); } // We want to place the glyphs even when they don't fit at their diff --git a/layout/style/nsStyleAnimation.cpp b/layout/style/nsStyleAnimation.cpp index 22f752a01a73..7db5f530b185 100644 --- a/layout/style/nsStyleAnimation.cpp +++ b/layout/style/nsStyleAnimation.cpp @@ -282,7 +282,7 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty, // just like eUnit_Integer. PRInt32 startInt = aStartValue.GetIntValue(); PRInt32 endInt = aEndValue.GetIntValue(); - aDistance = PR_ABS(endInt - startInt); + aDistance = NS_ABS(endInt - startInt); return PR_TRUE; } default: @@ -293,13 +293,13 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty, aStartValue.GetIntValue() == NS_STYLE_VISIBILITY_VISIBLE; PRInt32 endVal = aEndValue.GetIntValue() == NS_STYLE_VISIBILITY_VISIBLE; - aDistance = PR_ABS(startVal - endVal); + aDistance = NS_ABS(startVal - endVal); return PR_TRUE; } case eUnit_Integer: { PRInt32 startInt = aStartValue.GetIntValue(); PRInt32 endInt = aEndValue.GetIntValue(); - aDistance = PR_ABS(endInt - startInt); + aDistance = NS_ABS(endInt - startInt); return PR_TRUE; } case eUnit_Coord: { @@ -1110,7 +1110,7 @@ DecomposeMatrix(const nsStyleTransformMatrix &aMatrix, XYshear /= scaleY; // A*D - B*C should now be 1 or -1 - NS_ASSERTION(0.99 < PR_ABS(A*D - B*C) && PR_ABS(A*D - B*C) < 1.01, + NS_ASSERTION(0.99 < NS_ABS(A*D - B*C) && NS_ABS(A*D - B*C) < 1.01, "determinant should now be 1 or -1"); if (A * D < B * C) { A = -A; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index 2b01126541d9..0882d5fd3345 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -6272,7 +6272,7 @@ BCPaintBorderIterator::SetDamageArea(nsRect aDirtyRect) if (!haveIntersect) return PR_FALSE; mDamageArea = nsRect(startColIndex, startRowIndex, - 1 + PR_ABS(PRInt32(endColIndex - startColIndex)), + 1 + NS_ABS(PRInt32(endColIndex - startColIndex)), 1 + endRowIndex - startRowIndex); Reset(); @@ -6611,7 +6611,7 @@ BCVerticalSeg::Start(BCPaintBorderIterator& aIter, aIter.mBCData->GetCorner(ownerSide, bevel) : 0; PRBool topBevel = (aVerSegWidth > 0) ? bevel : PR_FALSE; - BCPixelSize maxHorSegHeight = PR_MAX(aIter.mPrevHorSegHeight, aHorSegHeight); + BCPixelSize maxHorSegHeight = NS_MAX(aIter.mPrevHorSegHeight, aHorSegHeight); nscoord offset = CalcVerCornerOffset(ownerSide, cornerSubWidth, maxHorSegHeight, PR_TRUE, topBevel); @@ -6673,7 +6673,7 @@ BCVerticalSeg::GetBottomCorner(BCPaintBorderIterator& aIter, cornerSubWidth = aIter.mBCData->GetCorner(ownerSide, bevel); } mIsBottomBevel = (mWidth > 0) ? bevel : PR_FALSE; - mBottomHorSegHeight = PR_MAX(aIter.mPrevHorSegHeight, aHorSegHeight); + mBottomHorSegHeight = NS_MAX(aIter.mPrevHorSegHeight, aHorSegHeight); mBottomOffset = CalcVerCornerOffset(ownerSide, cornerSubWidth, mBottomHorSegHeight, PR_FALSE, mIsBottomBevel); @@ -6815,7 +6815,7 @@ BCHorizontalSeg::Start(BCPaintBorderIterator& aIter, PRBool leftBevel = (aHorSegHeight > 0) ? bevel : PR_FALSE; PRInt32 relColIndex = aIter.GetRelativeColIndex(); - nscoord maxVerSegWidth = PR_MAX(aIter.mVerInfo[relColIndex].mWidth, + nscoord maxVerSegWidth = NS_MAX(aIter.mVerInfo[relColIndex].mWidth, aBottomVerSegWidth); nscoord offset = CalcHorCornerOffset(cornerOwnerSide, cornerSubWidth, maxVerSegWidth, PR_TRUE, leftBevel, @@ -6855,7 +6855,7 @@ BCHorizontalSeg::GetRightCorner(BCPaintBorderIterator& aIter, mIsRightBevel = (mWidth > 0) ? bevel : 0; PRInt32 relColIndex = aIter.GetRelativeColIndex(); - nscoord verWidth = PR_MAX(aIter.mVerInfo[relColIndex].mWidth, aLeftSegWidth); + nscoord verWidth = NS_MAX(aIter.mVerInfo[relColIndex].mWidth, aLeftSegWidth); mEndOffset = CalcHorCornerOffset(ownerSide, cornerSubWidth, verWidth, PR_FALSE, mIsRightBevel, aIter.mTableIsLTR); mLength += mEndOffset; diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index fd5ac810484e..f9b4473842b1 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -1844,7 +1844,7 @@ nsTreeBodyFrame::RowCountChanged(PRInt32 aIndex, PRInt32 aCount) NS_ASSERTION(rowCount == mRowCount, "row count did not change by the amount suggested, check caller"); #endif - PRInt32 count = PR_ABS(aCount); + PRInt32 count = NS_ABS(aCount); PRInt32 last = GetLastVisibleRow(); if (aIndex >= mTopRowIndex && aIndex <= last) InvalidateRange(aIndex, last); diff --git a/modules/libpr0n/decoders/nsBMPDecoder.cpp b/modules/libpr0n/decoders/nsBMPDecoder.cpp index 0df2f42c86d4..6d4c69c7d7b7 100644 --- a/modules/libpr0n/decoders/nsBMPDecoder.cpp +++ b/modules/libpr0n/decoders/nsBMPDecoder.cpp @@ -424,7 +424,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) // the second byte // Work around bitmaps that specify too many pixels mState = eRLEStateInitial; - PRUint32 pixelsNeeded = PR_MIN((PRUint32)(mBIH.width - mCurPos), mStateData); + PRUint32 pixelsNeeded = NS_MIN(mBIH.width - mCurPos, mStateData); if (pixelsNeeded) { PRUint32* d = mImageData + PIXEL_OFFSET(mCurLine, mCurPos); mCurPos += pixelsNeeded; @@ -504,7 +504,7 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) byte = *aBuffer++; aCount--; mState = eRLEStateInitial; - mCurLine -= PR_MIN(byte, mCurLine); + mCurLine -= NS_MIN(byte, mCurLine); break; case eRLEStateAbsoluteMode: // Absolute Mode diff --git a/modules/libpr0n/decoders/nsGIFDecoder2.cpp b/modules/libpr0n/decoders/nsGIFDecoder2.cpp index f58c67175083..f6a5ef18424d 100644 --- a/modules/libpr0n/decoders/nsGIFDecoder2.cpp +++ b/modules/libpr0n/decoders/nsGIFDecoder2.cpp @@ -627,7 +627,7 @@ nsGIFDecoder2::WriteInternal(const char *aBuffer, PRUint32 aCount) (mGIFStruct.bytes_in_hold) ? mGIFStruct.hold : nsnull; if (p) { // Add what we have sofar to the block - PRUint32 l = PR_MIN(len, mGIFStruct.bytes_to_consume); + PRUint32 l = NS_MIN(len, mGIFStruct.bytes_to_consume); memcpy(p+mGIFStruct.bytes_in_hold, buf, l); if (l < mGIFStruct.bytes_to_consume) { diff --git a/modules/libpr0n/decoders/nsICODecoder.cpp b/modules/libpr0n/decoders/nsICODecoder.cpp index bf6ab94bb12a..c81ce882c319 100644 --- a/modules/libpr0n/decoders/nsICODecoder.cpp +++ b/modules/libpr0n/decoders/nsICODecoder.cpp @@ -433,7 +433,7 @@ nsICODecoder::WriteInternal(const char* aBuffer, PRUint32 aCount) } while (mCurLine > 0 && aCount > 0) { - PRUint32 toCopy = PR_MIN(rowSize - mRowBytes, aCount); + PRUint32 toCopy = NS_MIN(rowSize - mRowBytes, aCount); if (toCopy) { memcpy(mRow + mRowBytes, aBuffer, toCopy); aCount -= toCopy; diff --git a/modules/libpr0n/decoders/nsIconDecoder.cpp b/modules/libpr0n/decoders/nsIconDecoder.cpp index bbc8312dce4e..343241cc3166 100644 --- a/modules/libpr0n/decoders/nsIconDecoder.cpp +++ b/modules/libpr0n/decoders/nsIconDecoder.cpp @@ -133,7 +133,7 @@ nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) case iconStateReadPixels: // How many bytes are we reading? - bytesToRead = PR_MIN(aCount, mPixBytesTotal - mPixBytesRead); + bytesToRead = NS_MIN(aCount, mPixBytesTotal - mPixBytesRead); // Copy the bytes memcpy(mImageData + mPixBytesRead, aBuffer, bytesToRead); diff --git a/modules/libpr0n/decoders/nsPNGDecoder.cpp b/modules/libpr0n/decoders/nsPNGDecoder.cpp index d2bf3e9ee9fc..1e9de136defe 100644 --- a/modules/libpr0n/decoders/nsPNGDecoder.cpp +++ b/modules/libpr0n/decoders/nsPNGDecoder.cpp @@ -306,7 +306,7 @@ nsPNGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount) return; // Read data into our header buffer - PRUint32 bytesToRead = PR_MIN(aCount, BYTES_NEEDED_FOR_DIMENSIONS - + PRUint32 bytesToRead = NS_MIN(aCount, BYTES_NEEDED_FOR_DIMENSIONS - mHeaderBytesRead); memcpy(mHeaderBuf + mHeaderBytesRead, aBuffer, bytesToRead); mHeaderBytesRead += bytesToRead; diff --git a/modules/libpr0n/src/RasterImage.cpp b/modules/libpr0n/src/RasterImage.cpp index 02a4dd37d034..6468901b6f80 100644 --- a/modules/libpr0n/src/RasterImage.cpp +++ b/modules/libpr0n/src/RasterImage.cpp @@ -1924,8 +1924,8 @@ RasterImage::DrawFrameTo(imgFrame *aSrc, if (aSrc->GetIsPaletted()) { // Larger than the destination frame, clip it - PRInt32 width = PR_MIN(aSrcRect.width, dstRect.width - aSrcRect.x); - PRInt32 height = PR_MIN(aSrcRect.height, dstRect.height - aSrcRect.y); + PRInt32 width = NS_MIN(aSrcRect.width, dstRect.width - aSrcRect.x); + PRInt32 height = NS_MIN(aSrcRect.height, dstRect.height - aSrcRect.y); // The clipped image must now fully fit within destination image frame NS_ASSERTION((aSrcRect.x >= 0) && (aSrcRect.y >= 0) && @@ -2577,7 +2577,7 @@ RasterImage::DecodeSomeData(PRUint32 aMaxBytes) // write the proper amount of data - PRUint32 bytesToDecode = PR_MIN(aMaxBytes, + PRUint32 bytesToDecode = NS_MIN(aMaxBytes, mSourceData.Length() - mBytesDecoded); nsresult rv = WriteToDecoder(mSourceData.Elements() + mBytesDecoded, bytesToDecode); diff --git a/modules/libpr0n/src/imgRequest.cpp b/modules/libpr0n/src/imgRequest.cpp index 8c8da7a2f9d8..5e0ec03edf42 100644 --- a/modules/libpr0n/src/imgRequest.cpp +++ b/modules/libpr0n/src/imgRequest.cpp @@ -1123,7 +1123,7 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx // its source buffer if (len > 0) { PRUint32 sizeHint = (PRUint32) len; - sizeHint = PR_MIN(sizeHint, 20000000); /* Bound by something reasonable */ + sizeHint = NS_MIN(sizeHint, 20000000); /* Bound by something reasonable */ RasterImage* rasterImage = static_cast(mImage.get()); rasterImage->SetSourceSizeHint(sizeHint); } diff --git a/modules/libpref/src/prefapi.cpp b/modules/libpref/src/prefapi.cpp index 3791383b7164..feb07e1fa076 100644 --- a/modules/libpref/src/prefapi.cpp +++ b/modules/libpref/src/prefapi.cpp @@ -475,7 +475,7 @@ nsresult PREF_GetCharPref(const char *pref_name, char * return_buffer, int * len *length = PL_strlen(stringVal) + 1; else { - PL_strncpy(return_buffer, stringVal, PR_MIN((size_t)*length - 1, PL_strlen(stringVal) + 1)); + PL_strncpy(return_buffer, stringVal, NS_MIN(*length - 1, PL_strlen(stringVal) + 1)); return_buffer[*length - 1] = '\0'; } rv = NS_OK; diff --git a/netwerk/base/src/nsBufferedStreams.cpp b/netwerk/base/src/nsBufferedStreams.cpp index 0c6af594704f..030e2ce007d5 100644 --- a/netwerk/base/src/nsBufferedStreams.cpp +++ b/netwerk/base/src/nsBufferedStreams.cpp @@ -38,6 +38,7 @@ #include "IPC/IPCMessageUtils.h" #include "mozilla/net/NeckoMessageUtils.h" +#include "nsAlgorithm.h" #include "nsBufferedStreams.h" #include "nsStreamUtils.h" #include "nsCRT.h" @@ -345,7 +346,7 @@ nsBufferedInputStream::ReadSegments(nsWriteSegmentFun writer, void *closure, nsresult rv = NS_OK; while (count > 0) { - PRUint32 amt = PR_MIN(count, mFillPoint - mCursor); + PRUint32 amt = NS_MIN(count, mFillPoint - mCursor); if (amt > 0) { PRUint32 read = 0; rv = writer(this, closure, mBuffer + mCursor, *result, amt, &read); @@ -577,7 +578,7 @@ nsBufferedOutputStream::Write(const char *buf, PRUint32 count, PRUint32 *result) nsresult rv = NS_OK; PRUint32 written = 0; while (count > 0) { - PRUint32 amt = PR_MIN(count, mBufferSize - mCursor); + PRUint32 amt = NS_MIN(count, mBufferSize - mCursor); if (amt > 0) { memcpy(mBuffer + mCursor, buf + written, amt); written += amt; @@ -668,7 +669,7 @@ nsBufferedOutputStream::WriteSegments(nsReadSegmentFun reader, void * closure, P *_retval = 0; nsresult rv; while (count > 0) { - PRUint32 left = PR_MIN(count, mBufferSize - mCursor); + PRUint32 left = NS_MIN(count, mBufferSize - mCursor); if (left == 0) { rv = Flush(); if (NS_FAILED(rv)) @@ -685,7 +686,7 @@ nsBufferedOutputStream::WriteSegments(nsReadSegmentFun reader, void * closure, P mCursor += read; *_retval += read; count -= read; - mFillPoint = PR_MAX(mFillPoint, mCursor); + mFillPoint = NS_MAX(mFillPoint, mCursor); } return NS_OK; } diff --git a/netwerk/base/src/nsFileStreams.h b/netwerk/base/src/nsFileStreams.h index 3206eae7fe42..804af964295e 100644 --- a/netwerk/base/src/nsFileStreams.h +++ b/netwerk/base/src/nsFileStreams.h @@ -38,6 +38,7 @@ #ifndef nsFileStreams_h__ #define nsFileStreams_h__ +#include "nsAlgorithm.h" #include "nsIFileStreams.h" #include "nsIFile.h" #include "nsIInputStream.h" @@ -193,7 +194,7 @@ public: private: PRUint32 TruncateSize(PRUint32 aSize) { - return (PRUint32)PR_MIN(mLength - mPosition, (PRUint64)aSize); + return (PRUint32)NS_MIN(mLength - mPosition, aSize); } PRUint64 mStart; diff --git a/netwerk/base/src/nsIncrementalDownload.cpp b/netwerk/base/src/nsIncrementalDownload.cpp index 265a3e48c27b..6c829307e6ad 100644 --- a/netwerk/base/src/nsIncrementalDownload.cpp +++ b/netwerk/base/src/nsIncrementalDownload.cpp @@ -696,7 +696,7 @@ nsIncrementalDownload::OnDataAvailable(nsIRequest *request, { while (count) { PRUint32 space = mChunkSize - mChunkLen; - PRUint32 n, len = PR_MIN(space, count); + PRUint32 n, len = NS_MIN(space, count); nsresult rv = input->Read(mChunk + mChunkLen, len, &n); if (NS_FAILED(rv)) diff --git a/netwerk/base/src/nsSocketTransport2.cpp b/netwerk/base/src/nsSocketTransport2.cpp index 230de01fed98..5cc6780f5c79 100644 --- a/netwerk/base/src/nsSocketTransport2.cpp +++ b/netwerk/base/src/nsSocketTransport2.cpp @@ -1950,7 +1950,7 @@ nsSocketTransport::SetTimeout(PRUint32 type, PRUint32 value) { NS_ENSURE_ARG_MAX(type, nsISocketTransport::TIMEOUT_READ_WRITE); // truncate overly large timeout values. - mTimeouts[type] = (PRUint16) PR_MIN(value, PR_UINT16_MAX); + mTimeouts[type] = (PRUint16) NS_MIN(value, PR_UINT16_MAX); PostEvent(MSG_TIMEOUT_CHANGED); return NS_OK; } @@ -2082,7 +2082,7 @@ DumpBytesToFile(const char *path, const char *header, const char *buf, PRInt32 n while (n) { p = (const unsigned char *) buf; - PRInt32 i, row_max = PR_MIN(16, n); + PRInt32 i, row_max = NS_MIN(16, n); for (i = 0; i < row_max; ++i) fprintf(fp, "%02x ", *p++); diff --git a/netwerk/base/src/nsStandardURL.cpp b/netwerk/base/src/nsStandardURL.cpp index 984351b136cc..9f550e6b793f 100644 --- a/netwerk/base/src/nsStandardURL.cpp +++ b/netwerk/base/src/nsStandardURL.cpp @@ -1040,7 +1040,7 @@ nsStandardURL::GetAsciiSpec(nsACString &result) } // try to guess the capacity required for result... - result.SetCapacity(mSpec.Length() + PR_MIN(32, mSpec.Length()/10)); + result.SetCapacity(mSpec.Length() + NS_MIN(32, mSpec.Length()/10)); result = Substring(mSpec, 0, mScheme.mLen + 3); diff --git a/netwerk/base/src/nsSyncStreamListener.cpp b/netwerk/base/src/nsSyncStreamListener.cpp index 147e1ce46ec6..3691d74f5021 100644 --- a/netwerk/base/src/nsSyncStreamListener.cpp +++ b/netwerk/base/src/nsSyncStreamListener.cpp @@ -178,7 +178,7 @@ nsSyncStreamListener::Read(char *buf, if (NS_FAILED(Available(&avail))) return mStatus; - avail = PR_MIN(avail, bufLen); + avail = NS_MIN(avail, bufLen); mStatus = mPipeIn->Read(buf, avail, result); return mStatus; } @@ -198,7 +198,7 @@ nsSyncStreamListener::ReadSegments(nsWriteSegmentFun writer, if (NS_FAILED(Available(&avail))) return mStatus; - avail = PR_MIN(avail, count); + avail = NS_MIN(avail, count); mStatus = mPipeIn->ReadSegments(writer, closure, avail, result); return mStatus; } diff --git a/netwerk/cache/nsCacheService.cpp b/netwerk/cache/nsCacheService.cpp index ef88e76d83f5..49902cc5419a 100644 --- a/netwerk/cache/nsCacheService.cpp +++ b/netwerk/cache/nsCacheService.cpp @@ -357,7 +357,7 @@ nsCacheProfilePrefObserver::Remove() void nsCacheProfilePrefObserver::SetDiskCacheCapacity(PRInt32 capacity) { - mDiskCacheCapacity = PR_MAX(0, capacity); + mDiskCacheCapacity = NS_MAX(0, capacity); } @@ -418,7 +418,7 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject, rv = branch->GetIntPref(DISK_CACHE_CAPACITY_PREF, &capacity); if (NS_FAILED(rv)) return rv; - mDiskCacheCapacity = PR_MAX(0, capacity); + mDiskCacheCapacity = NS_MAX(0, capacity); nsCacheService::SetDiskCacheCapacity(mDiskCacheCapacity); // Update the cache capacity when smart sizing is turned on/off @@ -448,7 +448,7 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject, rv = branch->GetIntPref(DISK_CACHE_CAPACITY_PREF, &newCapacity); if (NS_FAILED(rv)) return rv; - mDiskCacheCapacity = PR_MAX(0, newCapacity); + mDiskCacheCapacity = NS_MAX(0, newCapacity); nsCacheService::SetDiskCacheCapacity(mDiskCacheCapacity); } #if 0 @@ -477,7 +477,7 @@ nsCacheProfilePrefObserver::Observe(nsISupports * subject, PRInt32 capacity = 0; rv = branch->GetIntPref(OFFLINE_CACHE_CAPACITY_PREF, &capacity); if (NS_FAILED(rv)) return rv; - mOfflineCacheCapacity = PR_MAX(0, capacity); + mOfflineCacheCapacity = NS_MAX(0, capacity); nsCacheService::SetOfflineCacheCapacity(mOfflineCacheCapacity); #if 0 } else if (!strcmp(OFFLINE_CACHE_DIR_PREF, data.get())) { @@ -580,7 +580,7 @@ nsCacheProfilePrefObserver::GetSmartCacheSize(const nsAString& cachePath) // 0 MB <= Available < 500 MB: Use between 50MB and 200MB if (kBytesAvail < DEFAULT_CACHE_SIZE * 2) - return PR_MAX(MIN_CACHE_SIZE, kBytesAvail * 4 / 10); + return NS_MAX(MIN_CACHE_SIZE, kBytesAvail * 4 / 10); // 500MB <= Available < 2.5 GB: Use 250MB if (kBytesAvail < static_cast(DEFAULT_CACHE_SIZE) * 10) @@ -654,7 +654,7 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch) mDiskCacheCapacity = DISK_CACHE_CAPACITY; (void)branch->GetIntPref(DISK_CACHE_CAPACITY_PREF, &mDiskCacheCapacity); - mDiskCacheCapacity = PR_MAX(0, mDiskCacheCapacity); + mDiskCacheCapacity = NS_MAX(0, mDiskCacheCapacity); (void) branch->GetComplexValue(DISK_CACHE_DIR_PREF, // ignore error NS_GET_IID(nsILocalFile), @@ -750,7 +750,7 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch) mOfflineCacheCapacity = OFFLINE_CACHE_CAPACITY; (void)branch->GetIntPref(OFFLINE_CACHE_CAPACITY_PREF, &mOfflineCacheCapacity); - mOfflineCacheCapacity = PR_MAX(0, mOfflineCacheCapacity); + mOfflineCacheCapacity = NS_MAX(0, mOfflineCacheCapacity); (void) branch->GetComplexValue(OFFLINE_CACHE_DIR_PREF, // ignore error NS_GET_IID(nsILocalFile), diff --git a/netwerk/cache/nsDiskCacheBlockFile.cpp b/netwerk/cache/nsDiskCacheBlockFile.cpp index a1b53898e0fd..b8d93f4070b6 100644 --- a/netwerk/cache/nsDiskCacheBlockFile.cpp +++ b/netwerk/cache/nsDiskCacheBlockFile.cpp @@ -393,9 +393,9 @@ nsDiskCacheBlockFile::Write(PRInt32 offset, const void *buf, PRInt32 amount) if (mFileSize) while(mFileSize < upTo) mFileSize *= 2; - mFileSize = PR_MIN(maxPreallocate, PR_MAX(mFileSize, minPreallocate)); + mFileSize = NS_MIN(maxPreallocate, NS_MAX(mFileSize, minPreallocate)); } - mFileSize = PR_MIN(mFileSize, maxFileSize); + mFileSize = NS_MIN(mFileSize, maxFileSize); // Appears to cause bug 617123? Disabled for now. //mozilla::fallocate(mFD, mFileSize); } diff --git a/netwerk/cache/nsDiskCacheMap.cpp b/netwerk/cache/nsDiskCacheMap.cpp index 296b0bd0d28c..707bc3bb58ba 100644 --- a/netwerk/cache/nsDiskCacheMap.cpp +++ b/netwerk/cache/nsDiskCacheMap.cpp @@ -1139,7 +1139,7 @@ nsDiskCacheMap::NotifyCapacityChange(PRUint32 capacity) // Heuristic 2. we don't want more than 32MB reserved to store the record // map in memory. const PRInt32 RECORD_COUNT_LIMIT = 32 * 1024 * 1024 / sizeof(nsDiskCacheRecord); - PRInt32 maxRecordCount = PR_MIN(PRInt32(capacity), RECORD_COUNT_LIMIT); + PRInt32 maxRecordCount = NS_MIN(PRInt32(capacity), RECORD_COUNT_LIMIT); if (mMaxRecordCount < maxRecordCount) { // We can only grow mMaxRecordCount = maxRecordCount; diff --git a/netwerk/cache/nsMemoryCacheDevice.cpp b/netwerk/cache/nsMemoryCacheDevice.cpp index 2beea7909c64..da5f554e51f7 100644 --- a/netwerk/cache/nsMemoryCacheDevice.cpp +++ b/netwerk/cache/nsMemoryCacheDevice.cpp @@ -405,9 +405,9 @@ nsMemoryCacheDevice::EvictionList(nsCacheEntry * entry, PRInt32 deltaSize) // compute which eviction queue this entry should go into, // based on floor(log2(size/nref)) PRInt32 size = deltaSize + (PRInt32)entry->Size(); - PRInt32 fetchCount = PR_MAX(1, entry->FetchCount()); + PRInt32 fetchCount = NS_MAX(1, entry->FetchCount()); - return PR_MIN(PR_FloorLog2(size / fetchCount), kQueueCount - 1); + return NS_MIN(PR_FloorLog2(size / fetchCount), kQueueCount - 1); } diff --git a/netwerk/protocol/about/nsAboutCacheEntry.cpp b/netwerk/protocol/about/nsAboutCacheEntry.cpp index 216310c58419..cad25fbdbdaa 100644 --- a/netwerk/protocol/about/nsAboutCacheEntry.cpp +++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp @@ -65,7 +65,7 @@ HexDump(PRUint32 *state, const char *buf, PRInt32 n, nsCString &result) p = (const unsigned char *) buf; - PRInt32 i, row_max = PR_MIN(HEXDUMP_MAX_ROWS, n); + PRInt32 i, row_max = NS_MIN(HEXDUMP_MAX_ROWS, n); // print hex codes: for (i = 0; i < row_max; ++i) { @@ -405,7 +405,7 @@ nsAboutCacheEntry::WriteCacheEntryDescription(nsIOutputStream *outputStream, PRUint32 hexDumpState = 0; char chunk[4096]; while (dataSize) { - PRUint32 count = PR_MIN(dataSize, sizeof(chunk)); + PRUint32 count = NS_MIN(dataSize, sizeof(chunk)); if (NS_FAILED(stream->Read(chunk, count, &n)) || n == 0) break; dataSize -= n; diff --git a/netwerk/protocol/file/nsFileChannel.cpp b/netwerk/protocol/file/nsFileChannel.cpp index 4e86e0232bd5..b1d6af8cfb6b 100644 --- a/netwerk/protocol/file/nsFileChannel.cpp +++ b/netwerk/protocol/file/nsFileChannel.cpp @@ -118,7 +118,7 @@ nsFileCopyEvent::DoCopy() if (NS_FAILED(rv)) break; - PRInt32 num = PR_MIN((PRInt32) len, chunk); + PRInt32 num = NS_MIN((PRInt32) len, chunk); PRUint32 result; rv = mSource->ReadSegments(NS_CopySegmentToStream, mDest, num, &result); diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index aaefffd082c1..4f2b6513b3a3 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -1025,7 +1025,7 @@ HttpBaseChannel::SetRedirectionLimit(PRUint32 value) { ENSURE_CALLED_BEFORE_ASYNC_OPEN(); - mRedirectionLimit = PR_MIN(value, 0xff); + mRedirectionLimit = NS_MIN(value, 0xff); return NS_OK; } diff --git a/netwerk/protocol/http/nsHttpChunkedDecoder.cpp b/netwerk/protocol/http/nsHttpChunkedDecoder.cpp index 93645387fc0d..f339d8cb3b73 100644 --- a/netwerk/protocol/http/nsHttpChunkedDecoder.cpp +++ b/netwerk/protocol/http/nsHttpChunkedDecoder.cpp @@ -76,7 +76,7 @@ nsHttpChunkedDecoder::HandleChunkedContent(char *buf, while (count) { if (mChunkRemaining) { - PRUint32 amt = PR_MIN(mChunkRemaining, count); + PRUint32 amt = NS_MIN(mChunkRemaining, count); count -= amt; mChunkRemaining -= amt; diff --git a/netwerk/protocol/http/nsHttpConnectionMgr.cpp b/netwerk/protocol/http/nsHttpConnectionMgr.cpp index 45ad333933f5..3cc0cb2b32bf 100644 --- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp +++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp @@ -470,7 +470,7 @@ nsHttpConnectionMgr::PruneDeadConnectionsCB(nsHashKey *key, void *data, void *cl NS_RELEASE(conn); self->mNumIdleConns--; } else { - timeToNextExpire = PR_MIN(timeToNextExpire, conn->TimeToLive()); + timeToNextExpire = NS_MIN(timeToNextExpire, conn->TimeToLive()); } } } diff --git a/netwerk/protocol/http/nsHttpResponseHead.cpp b/netwerk/protocol/http/nsHttpResponseHead.cpp index 2dbef4d0b7b7..9a25e586b035 100644 --- a/netwerk/protocol/http/nsHttpResponseHead.cpp +++ b/netwerk/protocol/http/nsHttpResponseHead.cpp @@ -269,7 +269,7 @@ nsHttpResponseHead::ComputeCurrentAge(PRUint32 now, // Compute corrected received age if (NS_SUCCEEDED(GetAgeValue(&ageValue))) - *result = PR_MAX(*result, ageValue); + *result = NS_MAX(*result, ageValue); NS_ASSERTION(now >= requestTime, "bogus request time"); diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index 90fc8f9ef7fd..c66e36b92398 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -734,7 +734,7 @@ nsHttpTransaction::LocateHttpStart(char *buf, PRUint32 len, // mLineBuf can contain partial match from previous search if (!mLineBuf.IsEmpty()) { NS_ASSERTION(mLineBuf.Length() < HTTPHeaderLen, "ouch"); - PRInt32 checkChars = PR_MIN(len, HTTPHeaderLen - mLineBuf.Length()); + PRInt32 checkChars = NS_MIN(len, HTTPHeaderLen - mLineBuf.Length()); if (PL_strncasecmp(buf, HTTPHeader + mLineBuf.Length(), checkChars) == 0) { mLineBuf.Append(buf, checkChars); @@ -753,7 +753,7 @@ nsHttpTransaction::LocateHttpStart(char *buf, PRUint32 len, PRBool firstByte = PR_TRUE; while (len > 0) { - if (PL_strncasecmp(buf, HTTPHeader, PR_MIN(len, HTTPHeaderLen)) == 0) { + if (PL_strncasecmp(buf, HTTPHeader, NS_MIN(len, HTTPHeaderLen)) == 0) { if (len < HTTPHeaderLen) { // partial HTTPHeader sequence found // save partial match to mLineBuf @@ -887,7 +887,7 @@ nsHttpTransaction::ParseHead(char *buf, if (!mConnection || !mConnection->LastTransactionExpectedNoContent()) { // tolerate only minor junk before the status line mHttpResponseMatched = PR_TRUE; - char *p = LocateHttpStart(buf, PR_MIN(count, 11), PR_TRUE); + char *p = LocateHttpStart(buf, NS_MIN(count, 11), PR_TRUE); if (!p) { // Treat any 0.9 style response of a put as a failure. if (mRequestHead->Method() == nsHttp::Put) @@ -1111,7 +1111,7 @@ nsHttpTransaction::HandleContent(char *buf, mContentRead += *contentRead; /* when uncommenting, take care of 64-bit integers w/ PR_MAX... if (mProgressSink) - mProgressSink->OnProgress(nsnull, nsnull, mContentRead, PR_MAX(0, mContentLength)); + mProgressSink->OnProgress(nsnull, nsnull, mContentRead, NS_MAX(0, mContentLength)); */ } diff --git a/netwerk/streamconv/converters/nsBinHexDecoder.cpp b/netwerk/streamconv/converters/nsBinHexDecoder.cpp index f86d10ad28ca..cba07265f75f 100644 --- a/netwerk/streamconv/converters/nsBinHexDecoder.cpp +++ b/netwerk/streamconv/converters/nsBinHexDecoder.cpp @@ -163,7 +163,7 @@ nsBinHexDecoder::OnDataAvailable(nsIRequest* request, PRUint32 numBytesRead = 0; while (aCount > 0) // while we still have bytes to copy... { - aStream->Read(mDataBuffer, PR_MIN(aCount, nsIOService::gDefaultSegmentSize - 1), &numBytesRead); + aStream->Read(mDataBuffer, NS_MIN(aCount, nsIOService::gDefaultSegmentSize - 1), &numBytesRead); if (aCount >= numBytesRead) aCount -= numBytesRead; // subtract off the number of bytes we just read else diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp index fc81410cb659..9d7ba910ae85 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -858,7 +858,7 @@ nsIndexedToHTML::OnIndexAvailable(nsIRequest *aRequest, descriptionAffix.Cut(0, descriptionAffix.Length() - 25); if (NS_IS_LOW_SURROGATE(descriptionAffix.First())) descriptionAffix.Cut(0, 1); - description.Truncate(PR_MIN(71, description.Length() - 28)); + description.Truncate(NS_MIN(71, description.Length() - 28)); if (NS_IS_HIGH_SURROGATE(description.Last())) description.Truncate(description.Length() - 1); diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/netwerk/streamconv/converters/nsMultiMixedConv.cpp index 6ecc16e4b7b2..a480b99f3a5c 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -606,7 +606,7 @@ nsMultiMixedConv::OnDataAvailable(nsIRequest *request, nsISupports *context, // have enough info to start a part, go ahead and buffer // enough to collect a boundary token. if (!mPartChannel || !(cursor[bufLen-1] == nsCRT::LF) ) - bufAmt = PR_MIN(mTokenLen - 1, bufLen); + bufAmt = NS_MIN(mTokenLen - 1, bufLen); } if (bufAmt) { diff --git a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp index b0e39795c0c9..2a3d8cd65194 100644 --- a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp @@ -200,8 +200,8 @@ nsTXTToHTMLConv::OnDataAvailable(nsIRequest* request, nsISupports *aContext, } PRInt32 end = mBuffer.RFind(TOKEN_DELIMITERS, mBuffer.Length()); - mBuffer.Left(pushBuffer, PR_MAX(cursor, end)); - mBuffer.Cut(0, PR_MAX(cursor, end)); + mBuffer.Left(pushBuffer, NS_MAX(cursor, end)); + mBuffer.Cut(0, NS_MAX(cursor, end)); cursor = 0; if (!pushBuffer.IsEmpty()) { diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 00c10f832cb0..465ed5312238 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -1934,7 +1934,7 @@ NS_IMETHODIMP nsExternalAppHandler::OnDataAvailable(nsIRequest *request, nsISupp while (NS_SUCCEEDED(rv) && count > 0) // while we still have bytes to copy... { readError = PR_TRUE; - rv = inStr->Read(mDataBuffer, PR_MIN(count, mBufferSize - 1), &numBytesRead); + rv = inStr->Read(mDataBuffer, NS_MIN(count, mBufferSize - 1), &numBytesRead); if (NS_SUCCEEDED(rv)) { if (count >= numBytesRead) diff --git a/widget/src/android/nsWindow.cpp b/widget/src/android/nsWindow.cpp index 4495152e4f1f..48ad135c0a2f 100644 --- a/widget/src/android/nsWindow.cpp +++ b/widget/src/android/nsWindow.cpp @@ -1655,7 +1655,7 @@ nsWindow::OnIMEEvent(AndroidGeckoEvent *ae) selEvent.mOffset = PRUint32(ae->Count() >= 0 ? ae->Offset() : ae->Offset() + ae->Count()); - selEvent.mLength = PRUint32(PR_ABS(ae->Count())); + selEvent.mLength = PRUint32(NS_ABS(ae->Count())); selEvent.mReversed = ae->Count() >= 0 ? PR_FALSE : PR_TRUE; DispatchEvent(&selEvent); diff --git a/widget/src/gtk2/nsNativeKeyBindings.cpp b/widget/src/gtk2/nsNativeKeyBindings.cpp index 9c5fb6c518f1..a940977f3912 100644 --- a/widget/src/gtk2/nsNativeKeyBindings.cpp +++ b/widget/src/gtk2/nsNativeKeyBindings.cpp @@ -126,7 +126,7 @@ delete_from_cursor_cb(GtkWidget *w, GtkDeleteType del_type, if (!cmd) return; // unsupported command - count = PR_ABS(count); + count = NS_ABS(count); for (int i = 0; i < count; ++i) { gCurrentCallback(cmd, gCurrentCallbackData); } @@ -196,7 +196,7 @@ move_cursor_cb(GtkWidget *w, GtkMovementStep step, gint count, return; // unsupported command - count = PR_ABS(count); + count = NS_ABS(count); for (int i = 0; i < count; ++i) { gCurrentCallback(cmd, gCurrentCallbackData); } diff --git a/widget/src/gtk2/nsNativeThemeGTK.cpp b/widget/src/gtk2/nsNativeThemeGTK.cpp index 800271f122e8..7a7ff667fd0b 100644 --- a/widget/src/gtk2/nsNativeThemeGTK.cpp +++ b/widget/src/gtk2/nsNativeThemeGTK.cpp @@ -186,8 +186,8 @@ nsNativeThemeGTK::GetTabMarginPixels(nsIFrame* aFrame) IsBottomTab(aFrame) ? aFrame->GetUsedMargin().top : aFrame->GetUsedMargin().bottom; - return PR_MIN(MOZ_GTK_TAB_MARGIN_MASK, - PR_MAX(0, + return NS_MIN(MOZ_GTK_TAB_MARGIN_MASK, + NS_MAX(0, aFrame->PresContext()->AppUnitsToDevPixels(-margin))); } @@ -1080,11 +1080,11 @@ nsNativeThemeGTK::GetMinimumWidgetSize(nsRenderingContext* aContext, if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL) { aResult->width = metrics.slider_width; - aResult->height = PR_MIN(NSAppUnitsToIntPixels(rect.height, p2a), + aResult->height = NS_MIN(NSAppUnitsToIntPixels(rect.height, p2a), metrics.min_slider_size); } else { aResult->height = metrics.slider_width; - aResult->width = PR_MIN(NSAppUnitsToIntPixels(rect.width, p2a), + aResult->width = NS_MIN(NSAppUnitsToIntPixels(rect.width, p2a), metrics.min_slider_size); } diff --git a/widget/src/gtk2/nsPrintSettingsGTK.cpp b/widget/src/gtk2/nsPrintSettingsGTK.cpp index 1f32c9f439b1..9a41a7f98be9 100644 --- a/widget/src/gtk2/nsPrintSettingsGTK.cpp +++ b/widget/src/gtk2/nsPrintSettingsGTK.cpp @@ -285,7 +285,7 @@ nsPrintSettingsGTK::GetStartPageRange(PRInt32 *aStartPageRange) // the lowest start page. PRInt32 start(lstRanges[0].start); for (gint ii = 1; ii < ctRanges; ii++) { - start = PR_MIN(lstRanges[ii].start, start); + start = NS_MIN(lstRanges[ii].start, start); } *aStartPageRange = start + 1; } @@ -320,7 +320,7 @@ nsPrintSettingsGTK::GetEndPageRange(PRInt32 *aEndPageRange) } else { PRInt32 end(lstRanges[0].end); for (gint ii = 1; ii < ctRanges; ii++) { - end = PR_MAX(lstRanges[ii].end, end); + end = NS_MAX(lstRanges[ii].end, end); } *aEndPageRange = end + 1; } diff --git a/widget/src/gtk2/nsWindow.cpp b/widget/src/gtk2/nsWindow.cpp index d421dc0df95b..c356d835811c 100644 --- a/widget/src/gtk2/nsWindow.cpp +++ b/widget/src/gtk2/nsWindow.cpp @@ -4735,8 +4735,8 @@ nsWindow::ResizeTransparencyBitmap(PRInt32 aNewWidth, PRInt32 aNewHeight) memset(newBits, 255, newSize); // Now copy the intersection of the old and new areas into the new mask - PRInt32 copyWidth = PR_MIN(aNewWidth, mTransparencyBitmapWidth); - PRInt32 copyHeight = PR_MIN(aNewHeight, mTransparencyBitmapHeight); + PRInt32 copyWidth = NS_MIN(aNewWidth, mTransparencyBitmapWidth); + PRInt32 copyHeight = NS_MIN(aNewHeight, mTransparencyBitmapHeight); PRInt32 oldRowBytes = (mTransparencyBitmapWidth+7)/8; PRInt32 newRowBytes = (aNewWidth+7)/8; PRInt32 copyBytes = (copyWidth+7)/8; @@ -6539,8 +6539,8 @@ nsWindow::GetThebesSurface() gint width, height; gdk_drawable_get_size(d, &width, &height); // Owen Taylor says this is the right thing to do! - width = PR_MIN(32767, width); - height = PR_MIN(32767, height); + width = NS_MIN(32767, width); + height = NS_MIN(32767, height); gfxIntSize size(width, height); Visual* visual = GDK_VISUAL_XVISUAL(gdk_drawable_get_visual(d)); diff --git a/widget/src/os2/nsIdleServiceOS2.cpp b/widget/src/os2/nsIdleServiceOS2.cpp index 7fd1908d5431..cc44bc369ce1 100644 --- a/widget/src/os2/nsIdleServiceOS2.cpp +++ b/widget/src/os2/nsIdleServiceOS2.cpp @@ -76,7 +76,7 @@ nsIdleServiceOS2::PollIdleTime(PRUint32 *aIdleTime) // we are only interested in activity in general, so take the minimum // of both timers - *aIdleTime = PR_MIN(mouse, keyboard); + *aIdleTime = NS_MIN(mouse, keyboard); return true; } diff --git a/widget/src/windows/KeyboardLayout.cpp b/widget/src/windows/KeyboardLayout.cpp index 3b7ed7e8b709..762a6e7c0673 100644 --- a/widget/src/windows/KeyboardLayout.cpp +++ b/widget/src/windows/KeyboardLayout.cpp @@ -35,10 +35,12 @@ * * ***** END LICENSE BLOCK ***** */ -#include "nsMemory.h" #include "KeyboardLayout.h" + +#include "nsMemory.h" #include "nsToolkit.h" #include "nsQuickSort.h" +#include "nsAlgorithm.h" #include @@ -329,7 +331,7 @@ KeyboardLayout::GetUniChars(PRUnichar* aUniChars, PRUint8* aShiftStates, PRUint32 aMaxChars) const { - PRUint32 chars = PR_MIN(mNumOfChars, aMaxChars); + PRUint32 chars = NS_MIN(mNumOfChars, aMaxChars); memcpy(aUniChars, mChars, chars * sizeof(PRUnichar)); memcpy(aShiftStates, mShiftStates, chars); @@ -351,7 +353,7 @@ KeyboardLayout::GetUniCharsWithShiftState(PRUint8 aVirtualKey, PRUnichar uniChars[5]; PRUint32 numOfBaseChars = mVirtualKeys[key].GetUniChars(aShiftStates, uniChars, &finalShiftState); - PRUint32 chars = PR_MIN(numOfBaseChars, aMaxChars); + PRUint32 chars = NS_MIN(numOfBaseChars, aMaxChars); memcpy(aUniChars, uniChars, chars * sizeof(PRUnichar)); return chars; } diff --git a/widget/src/windows/nsIMM32Handler.cpp b/widget/src/windows/nsIMM32Handler.cpp index 43f56107e770..50e99a21570a 100644 --- a/widget/src/windows/nsIMM32Handler.cpp +++ b/widget/src/windows/nsIMM32Handler.cpp @@ -1856,7 +1856,7 @@ nsIMM32Handler::GetCharacterRectOfSelectedTextAt(nsWindow* aWindow, useCaretRect = PR_FALSE; if (mCursorPosition != NO_IME_CARET) { PRUint32 cursorPosition = - PR_MIN(PRUint32(mCursorPosition), mCompositionString.Length()); + NS_MIN(mCursorPosition, mCompositionString.Length()); offset -= cursorPosition; NS_ASSERTION(offset >= 0, "offset is negative!"); } diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index 435777c28497..b0e09967ce66 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -209,8 +209,8 @@ static SIZE GetGutterSize(HANDLE theme, HDC hdc) SIZE itemSize; nsUXThemeData::getThemePartSize(theme, hdc, MENU_POPUPITEM, MPI_NORMAL, NULL, TS_TRUE, &itemSize); - int width = PR_MAX(itemSize.cx, checkboxBGSize.cx + gutterSize.cx); - int height = PR_MAX(itemSize.cy, checkboxBGSize.cy); + int width = NS_MAX(itemSize.cx, checkboxBGSize.cx + gutterSize.cx); + int height = NS_MAX(itemSize.cy, checkboxBGSize.cy); SIZE ret; ret.cx = width; ret.cy = height; diff --git a/widget/src/windows/nsTextStore.cpp b/widget/src/windows/nsTextStore.cpp index 457ccfe3e995..051702f6f1e9 100644 --- a/widget/src/windows/nsTextStore.cpp +++ b/widget/src/windows/nsTextStore.cpp @@ -769,9 +769,9 @@ nsTextStore::SendTextEventForCompositionString() if (mCompositionSelection.acpStart != mCompositionSelection.acpEnd && textRanges.Length() == 1) { nsTextRange& range = textRanges[0]; - LONG start = PR_MIN(mCompositionSelection.acpStart, + LONG start = NS_MIN(mCompositionSelection.acpStart, mCompositionSelection.acpEnd); - LONG end = PR_MAX(mCompositionSelection.acpStart, + LONG end = NS_MAX(mCompositionSelection.acpStart, mCompositionSelection.acpEnd); if ((LONG)range.mStartOffset == start - mCompositionStart && (LONG)range.mEndOffset == end - mCompositionStart && @@ -783,7 +783,7 @@ nsTextStore::SendTextEventForCompositionString() } // The caret position has to be collapsed. - LONG caretPosition = PR_MAX(mCompositionSelection.acpStart, + LONG caretPosition = NS_MAX(mCompositionSelection.acpStart, mCompositionSelection.acpEnd); caretPosition -= mCompositionStart; nsTextRange caretRange; @@ -892,11 +892,11 @@ nsTextStore::GetText(LONG acpStart, // OnUpdateComposition. In this case the returned text would // be out of sync because we haven't sent NS_TEXT_TEXT in // OnUpdateComposition yet. Manually resync here. - compOldEnd = PR_MIN(LONG(length) + acpStart, + compOldEnd = NS_MIN(LONG(length) + acpStart, mCompositionLength + mCompositionStart); - compNewEnd = PR_MIN(LONG(length) + acpStart, + compNewEnd = NS_MIN(LONG(length) + acpStart, LONG(mCompositionString.Length()) + mCompositionStart); - compNewStart = PR_MAX(acpStart, mCompositionStart); + compNewStart = NS_MAX(acpStart, mCompositionStart); // Check if the range is affected if (compOldEnd > compNewStart || compNewEnd > compNewStart) { NS_ASSERTION(compOldEnd >= mCompositionStart && @@ -914,7 +914,7 @@ nsTextStore::GetText(LONG acpStart, if (compOldEnd > compNewStart || compNewEnd > compNewStart) { // Resync composition string const PRUnichar* compStrStart = mCompositionString.BeginReading() + - PR_MAX(compNewStart - mCompositionStart, 0); + NS_MAX(compNewStart - mCompositionStart, 0); event.mReply.mString.Replace(compNewStart - acpStart, compOldEnd - mCompositionStart, compStrStart, compNewEnd - mCompositionStart); @@ -922,7 +922,7 @@ nsTextStore::GetText(LONG acpStart, } NS_ENSURE_TRUE(-1 == acpEnd || event.mReply.mString.Length() == length, TS_E_INVALIDPOS); - length = PR_MIN(length, event.mReply.mString.Length()); + length = NS_MIN(length, event.mReply.mString.Length()); if (pchPlain && cchPlainReq) { memcpy(pchPlain, event.mReply.mString.BeginReading(), @@ -1453,9 +1453,9 @@ nsTextStore::OnTextChangeInternal(PRUint32 aStart, PRUint32 aNewEnd) { if (!mLock && mSink && 0 != (mSinkMask & TS_AS_TEXT_CHANGE)) { - mTextChange.acpStart = PR_MIN(mTextChange.acpStart, LONG(aStart)); - mTextChange.acpOldEnd = PR_MAX(mTextChange.acpOldEnd, LONG(aOldEnd)); - mTextChange.acpNewEnd = PR_MAX(mTextChange.acpNewEnd, LONG(aNewEnd)); + mTextChange.acpStart = NS_MIN(mTextChange.acpStart, LONG(aStart)); + mTextChange.acpOldEnd = NS_MAX(mTextChange.acpOldEnd, LONG(aOldEnd)); + mTextChange.acpNewEnd = NS_MAX(mTextChange.acpNewEnd, LONG(aNewEnd)); ::PostMessageW(mWindow->GetWindowHandle(), WM_USER_TSF_TEXTCHANGE, 0, 0); } diff --git a/widget/src/xpwidgets/nsBaseDragService.cpp b/widget/src/xpwidgets/nsBaseDragService.cpp index 6a04415c9d7e..d682e0343c3a 100644 --- a/widget/src/xpwidgets/nsBaseDragService.cpp +++ b/widget/src/xpwidgets/nsBaseDragService.cpp @@ -594,9 +594,9 @@ nsBaseDragService::DrawDragForImage(nsPresContext* aPresContext, if (destSize.width > maxWidth || destSize.height > maxHeight) { float scale = 1.0; if (destSize.width > maxWidth) - scale = PR_MIN(scale, float(maxWidth) / destSize.width); + scale = NS_MIN(scale, float(maxWidth) / destSize.width); if (destSize.height > maxHeight) - scale = PR_MIN(scale, float(maxHeight) / destSize.height); + scale = NS_MIN(scale, float(maxHeight) / destSize.height); destSize.width = NSToIntFloor(float(destSize.width) * scale); destSize.height = NSToIntFloor(float(destSize.height) * scale); diff --git a/widget/src/xpwidgets/nsIdleService.cpp b/widget/src/xpwidgets/nsIdleService.cpp index 29aa17204a17..58a97cf72b0b 100644 --- a/widget/src/xpwidgets/nsIdleService.cpp +++ b/widget/src/xpwidgets/nsIdleService.cpp @@ -402,7 +402,7 @@ nsIdleService::CheckAwayState(bool aNoTimeReset) } else { // If it hasn't expired yet, then we should note the time when it should // expire. - nextWaitTime = PR_MIN(nextWaitTime, curListener.reqIdleTime); + nextWaitTime = NS_MIN(nextWaitTime, curListener.reqIdleTime); } } diff --git a/widget/src/xpwidgets/nsNativeTheme.cpp b/widget/src/xpwidgets/nsNativeTheme.cpp index 294875b44253..a44e0b8a3aa5 100644 --- a/widget/src/xpwidgets/nsNativeTheme.cpp +++ b/widget/src/xpwidgets/nsNativeTheme.cpp @@ -519,7 +519,7 @@ nsNativeTheme::QueueAnimatedContentForRefresh(nsIContent* aContent, "aMinimumFrameRate must be less than 1000!"); PRUint32 timeout = PRUint32(NS_floor(1000 / aMinimumFrameRate)); - timeout = PR_MIN(mAnimatedContentTimeout, timeout); + timeout = NS_MIN(mAnimatedContentTimeout, timeout); if (!mAnimatedContentTimer) { mAnimatedContentTimer = do_CreateInstance(NS_TIMER_CONTRACTID); diff --git a/widget/src/xpwidgets/nsNativeTheme.h b/widget/src/xpwidgets/nsNativeTheme.h index b91f75b66073..6b15f9246e6e 100644 --- a/widget/src/xpwidgets/nsNativeTheme.h +++ b/widget/src/xpwidgets/nsNativeTheme.h @@ -40,6 +40,7 @@ // code duplication. #include "prtypes.h" +#include "nsAlgorithm.h" #include "nsIAtom.h" #include "nsCOMPtr.h" #include "nsString.h" diff --git a/widget/tests/TestWinTSF.cpp b/widget/tests/TestWinTSF.cpp index eb5524645a6e..e92f638ec61b 100644 --- a/widget/tests/TestWinTSF.cpp +++ b/widget/tests/TestWinTSF.cpp @@ -732,8 +732,8 @@ public: // ITfReadOnlyProperty if (targetStart > end || targetEnd < start) continue; // Otherwise, shrink to the target range. - start = PR_MAX(targetStart, start); - end = PR_MIN(targetEnd, end); + start = NS_MAX(targetStart, start); + end = NS_MIN(targetEnd, end); } nsRefPtr range = new TSFRangeImpl(start, end - start); NS_ENSURE_TRUE(range, E_OUTOFMEMORY); @@ -952,8 +952,8 @@ public: // ITfCompositionView LONG tmpStart, tmpEnd; HRESULT hr = GetRegularExtent(mAttrProp->mRanges[i], tmpStart, tmpEnd); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); - start = PR_MIN(start, tmpStart); - end = PR_MAX(end, tmpEnd); + start = NS_MIN(start, tmpStart); + end = NS_MAX(end, tmpEnd); } nsRefPtr range = new TSFRangeImpl(); NS_ENSURE_TRUE(range, E_OUTOFMEMORY); diff --git a/xpcom/ds/nsExpirationTracker.h b/xpcom/ds/nsExpirationTracker.h index 8a93589a9775..619ca0bbdb55 100644 --- a/xpcom/ds/nsExpirationTracker.h +++ b/xpcom/ds/nsExpirationTracker.h @@ -203,7 +203,7 @@ template class nsExpirationTracker { for (;;) { // Objects could have been removed so index could be outside // the array - index = PR_MIN(index, generation.Length()); + index = NS_MIN(index, generation.Length()); if (index == 0) break; --index; diff --git a/xpcom/glue/nsQuickSort.cpp b/xpcom/glue/nsQuickSort.cpp index 0a71d25ddd63..9d4a443c7174 100644 --- a/xpcom/glue/nsQuickSort.cpp +++ b/xpcom/glue/nsQuickSort.cpp @@ -35,6 +35,7 @@ #include #include "prtypes.h" +#include "nsAlgorithm.h" #include "nsQuickSort.h" PR_BEGIN_EXTERN_C @@ -164,9 +165,9 @@ loop: SWAPINIT(a, es); } pn = (char *)a + n * es; - r = PR_MIN(pa - (char *)a, pb - pa); + r = NS_MIN(pa - (char *)a, pb - pa); vecswap(a, pb - r, r); - r = PR_MIN(pd - pc, (int)(pn - pd - es)); + r = NS_MIN(pd - pc, pn - pd - es); vecswap(pb, pn - r, r); if ((r = pb - pa) > (int)es) NS_QuickSort(a, r / es, es, cmp, data); diff --git a/xpcom/glue/nsTArray-inl.h b/xpcom/glue/nsTArray-inl.h index 3aaa8d4cc561..026e8fb2f39a 100644 --- a/xpcom/glue/nsTArray-inl.h +++ b/xpcom/glue/nsTArray-inl.h @@ -89,7 +89,7 @@ nsTArray_base::EnsureCapacity(size_type capacity, size_type elemSize) { // capacity. (Note that mCapacity is only 31 bits wide, so // multiplication promotes its type. We use |2u| instead of |2| // to make sure it's promoted to unsigned.) - capacity = PR_MAX(capacity, mHdr->mCapacity * 2u); + capacity = NS_MAX(capacity, mHdr->mCapacity * 2U); Header *header; if (UsesAutoArrayBuffer()) { diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h index 45cbd3ae837f..f385a680ce30 100644 --- a/xpcom/glue/nsTArray.h +++ b/xpcom/glue/nsTArray.h @@ -42,6 +42,7 @@ #include #include "prtypes.h" +#include "nsAlgorithm.h" #include "nscore.h" #include "nsQuickSort.h" #include "nsDebug.h" diff --git a/xpcom/glue/nsVersionComparator.cpp b/xpcom/glue/nsVersionComparator.cpp index 29e0bbd76f09..c1afa7748412 100644 --- a/xpcom/glue/nsVersionComparator.cpp +++ b/xpcom/glue/nsVersionComparator.cpp @@ -290,7 +290,7 @@ CompareVP(VersionPartW &v1, VersionPartW &v2) if (r) return r; - r = wcsncmp(v1.strB, v2.strB, PR_MIN(v1.strBlen,v2.strBlen)); + r = wcsncmp(v1.strB, v2.strB, NS_MIN(v1.strBlen,v2.strBlen)); if (r) return r; diff --git a/xpcom/glue/nsVoidArray.cpp b/xpcom/glue/nsVoidArray.cpp index a4319762957b..2661b2dbdb0a 100644 --- a/xpcom/glue/nsVoidArray.cpp +++ b/xpcom/glue/nsVoidArray.cpp @@ -282,7 +282,7 @@ PRBool nsVoidArray::GrowArrayBy(PRInt32 aGrowBy) // Also, limit the increase in size to about a VM page or two. if (GetArraySize() >= kMaxGrowArrayBy) { - newCapacity = GetArraySize() + PR_MAX(kMaxGrowArrayBy,aGrowBy); + newCapacity = GetArraySize() + NS_MAX(kMaxGrowArrayBy,aGrowBy); newSize = SIZEOF_IMPL(newCapacity); } else @@ -951,7 +951,7 @@ CompareCString(const nsCString* aCString1, const nsCString* aCString2, void*) const char* s2; PRUint32 len1 = NS_CStringGetData(*aCString1, &s1); PRUint32 len2 = NS_CStringGetData(*aCString2, &s2); - int r = memcmp(s1, s2, PR_MIN(len1, len2)); + int r = memcmp(s1, s2, NS_MIN(len1, len2)); if (r) return r; diff --git a/xpcom/io/nsFastLoadFile.cpp b/xpcom/io/nsFastLoadFile.cpp index 6d8036807ccb..4f3882eff2bf 100644 --- a/xpcom/io/nsFastLoadFile.cpp +++ b/xpcom/io/nsFastLoadFile.cpp @@ -38,6 +38,7 @@ #include #include "prtypes.h" +#include "nsAlgorithm.h" #include "nscore.h" #include "nsDebug.h" #include "nsEnumeratorUtils.h" @@ -566,7 +567,7 @@ nsFastLoadFileReader::Read(char* aBuffer, PRUint32 aCount, PRUint32 *aBytesRead) if (!mFileData) return NS_BASE_STREAM_CLOSED; - PRUint32 count = PR_MIN(mFileLen - mFilePos, aCount); + PRUint32 count = NS_MIN(mFileLen - mFilePos, aCount); memcpy(aBuffer, mFileData+mFilePos, count); *aBytesRead = count; mFilePos += count; @@ -595,7 +596,7 @@ nsFastLoadFileReader::ReadSegments(nsWriteSegmentFun aWriter, void* aClosure, if (!mFileData) return NS_BASE_STREAM_CLOSED; - PRUint32 count = PR_MIN(mFileLen - mFilePos, aCount); + PRUint32 count = NS_MIN(mFileLen - mFilePos, aCount); // Errors returned from the writer get ignored. aWriter(this, aClosure, (char*)(mFileData + mFilePos), 0, diff --git a/xpcom/io/nsFastLoadFile.h b/xpcom/io/nsFastLoadFile.h index 85bcf68f4acf..2ec29aedb28c 100644 --- a/xpcom/io/nsFastLoadFile.h +++ b/xpcom/io/nsFastLoadFile.h @@ -45,6 +45,7 @@ #include "prtypes.h" #include "pldhash.h" +#include "nsAlgorithm.h" #include "nsBinaryStream.h" #include "nsCOMPtr.h" @@ -283,7 +284,7 @@ class nsFastLoadFileReader NS_IMETHOD ReadID(nsID *aResult); void SeekTo(PRInt64 aOffset) { - mFilePos = PR_MAX(0, PR_MIN(aOffset, mFileLen)); + mFilePos = NS_MAX(0, NS_MIN(aOffset, mFileLen)); NS_ASSERTION(aOffset == mFilePos, "Attempt to seek out of bounds"); } diff --git a/xpcom/io/nsPipe3.cpp b/xpcom/io/nsPipe3.cpp index 0bba4cf2ea9a..78b35bbd4dc5 100644 --- a/xpcom/io/nsPipe3.cpp +++ b/xpcom/io/nsPipe3.cpp @@ -47,6 +47,7 @@ #include "prlog.h" #include "nsIClassInfoImpl.h" #include "nsAtomicRefcnt.h" +#include "nsAlgorithm.h" using namespace mozilla; @@ -958,7 +959,7 @@ nsPipeInputStream::Search(const char *forString, len2 = limit2 - cursor2; // check if the string is straddling the next buffer segment - PRUint32 lim = PR_MIN(strLen, len2 + 1); + PRUint32 lim = NS_MIN(strLen, len2 + 1); for (i = 0; i < lim; ++i) { PRUint32 strPart1Len = strLen - i - 1; PRUint32 strPart2Len = strLen - strPart1Len; diff --git a/xpcom/io/nsScriptableInputStream.cpp b/xpcom/io/nsScriptableInputStream.cpp index d0b02e839781..4a7960b1c07a 100644 --- a/xpcom/io/nsScriptableInputStream.cpp +++ b/xpcom/io/nsScriptableInputStream.cpp @@ -73,7 +73,7 @@ nsScriptableInputStream::Read(PRUint32 aCount, char **_retval) { rv = mInputStream->Available(&count); if (NS_FAILED(rv)) return rv; - count = PR_MIN(count, aCount); + count = NS_MIN(count, aCount); buffer = (char*)nsMemory::Alloc(count+1); // make room for '\0' if (!buffer) return NS_ERROR_OUT_OF_MEMORY; diff --git a/xpcom/io/nsStorageStream.cpp b/xpcom/io/nsStorageStream.cpp index 4202a6f23696..ead96a87ffa3 100644 --- a/xpcom/io/nsStorageStream.cpp +++ b/xpcom/io/nsStorageStream.cpp @@ -46,6 +46,7 @@ * with the attendant performance loss and heap fragmentation. */ +#include "nsAlgorithm.h" #include "nsStorageStream.h" #include "nsSegmentedBuffer.h" #include "nsStreamUtils.h" @@ -204,7 +205,7 @@ nsStorageStream::Write(const char *aBuffer, PRUint32 aCount, PRUint32 *aNumWritt this, mWriteCursor, mSegmentEnd)); } - count = PR_MIN(availableInSegment, remaining); + count = NS_MIN(availableInSegment, remaining); memcpy(mWriteCursor, readCursor, count); remaining -= count; readCursor += count; @@ -441,11 +442,11 @@ nsStorageInputStream::ReadSegments(nsWriteSegmentFun writer, void * closure, PRU goto out; mReadCursor = mStorageStream->mSegmentedBuffer->GetSegment(++mSegmentNum); - mSegmentEnd = mReadCursor + PR_MIN(mSegmentSize, available); + mSegmentEnd = mReadCursor + NS_MIN(mSegmentSize, available); availableInSegment = mSegmentEnd - mReadCursor; } - count = PR_MIN(availableInSegment, remainingCapacity); + count = NS_MIN(availableInSegment, remainingCapacity); rv = writer(this, closure, mReadCursor, aCount - remainingCapacity, count, &bytesConsumed); if (NS_FAILED(rv) || (bytesConsumed == 0)) @@ -537,7 +538,7 @@ nsStorageInputStream::Seek(PRUint32 aPosition) mReadCursor = mStorageStream->mSegmentedBuffer->GetSegment(mSegmentNum) + segmentOffset; PRUint32 available = length - aPosition; - mSegmentEnd = mReadCursor + PR_MIN(mSegmentSize - segmentOffset, available); + mSegmentEnd = mReadCursor + NS_MIN(mSegmentSize - segmentOffset, available); mLogicalCursor = aPosition; return NS_OK; } diff --git a/xpcom/io/nsUnicharInputStream.cpp b/xpcom/io/nsUnicharInputStream.cpp index 3bb984d1e8ae..5cedd6e794bd 100644 --- a/xpcom/io/nsUnicharInputStream.cpp +++ b/xpcom/io/nsUnicharInputStream.cpp @@ -100,7 +100,7 @@ StringUnicharInputStream::ReadSegments(nsWriteUnicharSegmentFun aWriter, PRUint32 totalBytesWritten = 0; nsresult rv; - aCount = PR_MIN(mString.Length() - mPos, aCount); + aCount = NS_MIN(mString.Length() - mPos, aCount); nsAString::const_iterator iter; mString.BeginReading(iter); diff --git a/xpcom/string/public/nsAlgorithm.h b/xpcom/string/public/nsAlgorithm.h index 53f7172bbd5b..00ce3d7be3ab 100644 --- a/xpcom/string/public/nsAlgorithm.h +++ b/xpcom/string/public/nsAlgorithm.h @@ -54,6 +54,15 @@ // for NS_ASSERTION #endif + +template +inline +T +NS_ROUNDUP( const T& a, const T& b ) + { + return ((a + (b - 1)) / b) * b; + } + template inline const T& @@ -70,6 +79,14 @@ NS_MAX( const T& a, const T& b ) return a > b ? a : b; } +template +inline +T +NS_ABS( const T& a ) + { + return a < 0 ? -a : a; + } + template inline PRUint32 diff --git a/xpcom/string/src/nsReadableUtils.cpp b/xpcom/string/src/nsReadableUtils.cpp index 3251c6d2f94e..81b9cc00ed97 100644 --- a/xpcom/string/src/nsReadableUtils.cpp +++ b/xpcom/string/src/nsReadableUtils.cpp @@ -637,7 +637,7 @@ class CopyToUpperCase PRUint32 write( const char* aSource, PRUint32 aSourceLength ) { - PRUint32 len = PR_MIN(PRUint32(mIter.size_forward()), aSourceLength); + PRUint32 len = NS_MIN(PRUint32(mIter.size_forward()), aSourceLength); char* cp = mIter.get(); const char* end = aSource + len; while (aSource != end) { @@ -718,7 +718,7 @@ class CopyToLowerCase PRUint32 write( const char* aSource, PRUint32 aSourceLength ) { - PRUint32 len = PR_MIN(PRUint32(mIter.size_forward()), aSourceLength); + PRUint32 len = NS_MIN(PRUint32(mIter.size_forward()), aSourceLength); char* cp = mIter.get(); const char* end = aSource + len; while (aSource != end) { diff --git a/xpcom/string/src/nsTSubstring.cpp b/xpcom/string/src/nsTSubstring.cpp index 4e71b2d6dc1d..988a46674a02 100644 --- a/xpcom/string/src/nsTSubstring.cpp +++ b/xpcom/string/src/nsTSubstring.cpp @@ -454,7 +454,7 @@ nsTSubstring_CharT::Adopt( char_type* data, size_type length ) void nsTSubstring_CharT::Replace( index_type cutStart, size_type cutLength, char_type c ) { - cutStart = PR_MIN(cutStart, Length()); + cutStart = NS_MIN(cutStart, Length()); if (ReplacePrep(cutStart, cutLength, 1)) mData[cutStart] = c; @@ -482,7 +482,7 @@ nsTSubstring_CharT::Replace( index_type cutStart, size_type cutLength, const cha } } - cutStart = PR_MIN(cutStart, Length()); + cutStart = NS_MIN(cutStart, Length()); if (ReplacePrep(cutStart, cutLength, length) && length > 0) char_traits::copy(mData + cutStart, data, length); @@ -505,7 +505,7 @@ nsTSubstring_CharT::ReplaceASCII( index_type cutStart, size_type cutLength, cons } #endif - cutStart = PR_MIN(cutStart, Length()); + cutStart = NS_MIN(cutStart, Length()); if (ReplacePrep(cutStart, cutLength, length) && length > 0) char_traits::copyASCII(mData + cutStart, data, length); @@ -523,7 +523,7 @@ nsTSubstring_CharT::Replace( index_type cutStart, size_type cutLength, const sub size_type length = tuple.Length(); - cutStart = PR_MIN(cutStart, Length()); + cutStart = NS_MIN(cutStart, Length()); if (ReplacePrep(cutStart, cutLength, length) && length > 0) tuple.WriteTo(mData + cutStart, length); diff --git a/xpcom/tests/TestPipes.cpp b/xpcom/tests/TestPipes.cpp index 67a4d82743ab..8194d49185cb 100644 --- a/xpcom/tests/TestPipes.cpp +++ b/xpcom/tests/TestPipes.cpp @@ -315,7 +315,7 @@ TestShortWrites(nsIInputStream* in, nsIOutputStream* out) char* buf = PR_smprintf("%d %s", i, kTestPattern); PRUint32 len = strlen(buf); len = len * rand() / RAND_MAX; - len = PR_MAX(1, len); + len = NS_MAX(1, len); rv = WriteAll(out, buf, len, &writeCount); if (NS_FAILED(rv)) return rv; NS_ASSERTION(writeCount == len, "didn't write enough"); @@ -424,7 +424,7 @@ TestChainedPipes() char* buf = PR_smprintf("%d %s", i, kTestPattern); PRUint32 len = strlen(buf); len = len * rand() / RAND_MAX; - len = PR_MAX(1, len); + len = NS_MAX(1, len); rv = WriteAll(out1, buf, len, &writeCount); if (NS_FAILED(rv)) return rv; NS_ASSERTION(writeCount == len, "didn't write enough"); diff --git a/xpfe/appshell/src/nsXULWindow.cpp b/xpfe/appshell/src/nsXULWindow.cpp index 90d375fac708..459d76ab4dce 100644 --- a/xpfe/appshell/src/nsXULWindow.cpp +++ b/xpfe/appshell/src/nsXULWindow.cpp @@ -1342,8 +1342,8 @@ void nsXULWindow::StaggerPosition(PRInt32 &aRequestedX, PRInt32 &aRequestedY, nsCOMPtr listBaseWindow(do_QueryInterface(supportsWindow)); listBaseWindow->GetPosition(&listX, &listY); - if (PR_ABS(listX - aRequestedX) <= kSlop && - PR_ABS(listY - aRequestedY) <= kSlop) { + if (NS_ABS(listX - aRequestedX) <= kSlop && + NS_ABS(listY - aRequestedY) <= kSlop) { // collision! offset and start over if (bouncedX & 0x1) aRequestedX -= kOffset; diff --git a/xpinstall/src/CertReader.cpp b/xpinstall/src/CertReader.cpp index 479588f00b4a..b34e0d9aed50 100644 --- a/xpinstall/src/CertReader.cpp +++ b/xpinstall/src/CertReader.cpp @@ -166,7 +166,7 @@ CertReader::OnDataAvailable(nsIRequest *request, while (aLength) { - size = PR_MIN(aLength, sizeof(buf)); + size = NS_MIN(aLength, sizeof(buf)); rv = aIStream->Read(buf, size, &amt); if (NS_FAILED(rv)) diff --git a/xpinstall/src/nsXPInstallManager.cpp b/xpinstall/src/nsXPInstallManager.cpp index 41b9f033ff33..2c463acb0b29 100644 --- a/xpinstall/src/nsXPInstallManager.cpp +++ b/xpinstall/src/nsXPInstallManager.cpp @@ -1229,7 +1229,7 @@ nsXPInstallManager::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, PRUint32 length) { #define XPI_ODA_BUFFER_SIZE 8*1024 - PRUint32 amt = PR_MIN(XPI_ODA_BUFFER_SIZE, length); + PRUint32 amt = NS_MIN(XPI_ODA_BUFFER_SIZE, length); nsresult err; char buffer[XPI_ODA_BUFFER_SIZE]; PRUint32 writeCount; @@ -1256,7 +1256,7 @@ nsXPInstallManager::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, } length -= amt; - amt = PR_MIN(XPI_ODA_BUFFER_SIZE, length); + amt = NS_MIN(XPI_ODA_BUFFER_SIZE, length); } while (length > 0); From 01bbe1fa34d7f5dd96c32c6c081f3b6fba35bdfd Mon Sep 17 00:00:00 2001 From: Dave Townsend Date: Thu, 2 Jun 2011 09:16:31 -0700 Subject: [PATCH 07/35] Bug 661016: Add an ID to the detail rows to allow for overlaying. r=Unfocused --- toolkit/mozapps/extensions/content/extensions.xul | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolkit/mozapps/extensions/content/extensions.xul b/toolkit/mozapps/extensions/content/extensions.xul index 18205408894d..1cb6c2db1cb2 100644 --- a/toolkit/mozapps/extensions/content/extensions.xul +++ b/toolkit/mozapps/extensions/content/extensions.xul @@ -563,7 +563,7 @@ - +