diff --git a/content/base/src/nsTextFragment.cpp b/content/base/src/nsTextFragment.cpp index 7b59934425f..6bfe907ece2 100644 --- a/content/base/src/nsTextFragment.cpp +++ b/content/base/src/nsTextFragment.cpp @@ -165,7 +165,7 @@ Is8BitUnvectorized(const PRUnichar *str, const PRUnichar *end) // Align ourselves to a word boundary. PRInt32 alignLen = - PR_MIN(len, PRInt32(((-NS_PTR_TO_UINT32(str)) & alignMask) / sizeof(PRUnichar))); + NS_MIN(len, PRInt32(((-NS_PTR_TO_INT32(str)) & alignMask) / sizeof(PRUnichar))); for (; i < alignLen; i++) { if (str[i] > 255) return PR_FALSE; diff --git a/content/base/src/nsTextFragmentSSE2.cpp b/content/base/src/nsTextFragmentSSE2.cpp index bef7d696b78..4f3feb0da55 100644 --- a/content/base/src/nsTextFragmentSSE2.cpp +++ b/content/base/src/nsTextFragmentSSE2.cpp @@ -3,6 +3,7 @@ #include #include "nscore.h" +#include "nsAlgorithm.h" namespace mozilla { namespace SSE2 { @@ -35,7 +36,7 @@ Is8Bit(const PRUnichar *str, const PRUnichar *end) // Align ourselves to a 16-byte boundary, as required by _mm_load_si128 // (i.e. MOVDQA). PRInt32 alignLen = - PR_MIN(len, PRInt32(((-NS_PTR_TO_UINT32(str)) & 0xf) / sizeof(PRUnichar))); + NS_MIN(len, PRInt32(((-NS_PTR_TO_INT32(str)) & 0xf) / sizeof(PRUnichar))); for (; i < alignLen; i++) { if (str[i] > 255) return PR_FALSE; diff --git a/content/canvas/src/CustomQS_Canvas2D.h b/content/canvas/src/CustomQS_Canvas2D.h index 5f761641ad5..62300524e5b 100644 --- a/content/canvas/src/CustomQS_Canvas2D.h +++ b/content/canvas/src/CustomQS_Canvas2D.h @@ -287,8 +287,8 @@ nsIDOMCanvasRenderingContext2D_CreateImageData(JSContext *cx, uintN argc, jsval int32 wi = JS_DoubleToInt32(width); int32 hi = JS_DoubleToInt32(height); - uint32 w = PR_ABS(wi); - uint32 h = PR_ABS(hi); + uint32 w = NS_ABS(wi); + uint32 h = NS_ABS(hi); return CreateImageData(cx, w, h, NULL, 0, 0, vp); } diff --git a/content/html/content/src/nsHTMLProgressElement.cpp b/content/html/content/src/nsHTMLProgressElement.cpp index 59d83d4e826..becd8edd37f 100644 --- a/content/html/content/src/nsHTMLProgressElement.cpp +++ b/content/html/content/src/nsHTMLProgressElement.cpp @@ -186,7 +186,7 @@ nsHTMLProgressElement::GetValue(double* aValue) double max; GetMax(&max); - *aValue = PR_MIN(*aValue, max); + *aValue = NS_MIN(*aValue, max); return NS_OK; } diff --git a/content/media/nsAudioStream.cpp b/content/media/nsAudioStream.cpp index 551d3520ba4..2e6fee6e6a7 100644 --- a/content/media/nsAudioStream.cpp +++ b/content/media/nsAudioStream.cpp @@ -329,7 +329,7 @@ static int VolumeScaleChanged(const char* aPref, void *aClosure) { gVolumeScale = 1.0; } else { NS_ConvertUTF16toUTF8 utf8(value); - gVolumeScale = PR_MAX(0, PR_strtod(utf8.get(), nsnull)); + gVolumeScale = NS_MAX(0, PR_strtod(utf8.get(), nsnull)); } return 0; } diff --git a/content/media/nsBuiltinDecoderStateMachine.cpp b/content/media/nsBuiltinDecoderStateMachine.cpp index 88686529e61..6646a1353f8 100644 --- a/content/media/nsBuiltinDecoderStateMachine.cpp +++ b/content/media/nsBuiltinDecoderStateMachine.cpp @@ -1535,7 +1535,7 @@ void nsBuiltinDecoderStateMachine::AdvanceFrame() void nsBuiltinDecoderStateMachine::Wait(PRInt64 aUsecs) { mDecoder->GetReentrantMonitor().AssertCurrentThreadIn(); - TimeStamp end = TimeStamp::Now() + UsecsToDuration(PR_MAX(USECS_PER_MS, aUsecs)); + TimeStamp end = TimeStamp::Now() + UsecsToDuration(NS_MAX(USECS_PER_MS, aUsecs)); TimeStamp now; while ((now = TimeStamp::Now()) < end && mState != DECODER_STATE_SHUTDOWN && diff --git a/content/media/nsMediaCache.cpp b/content/media/nsMediaCache.cpp index 60699b74328..187ad983871 100644 --- a/content/media/nsMediaCache.cpp +++ b/content/media/nsMediaCache.cpp @@ -741,8 +741,8 @@ static PRInt32 GetMaxBlocks() // Cache size is in KB PRInt32 cacheSize = Preferences::GetInt("media.cache_size", 500*1024); PRInt64 maxBlocks = static_cast(cacheSize)*1024/nsMediaCache::BLOCK_SIZE; - maxBlocks = PR_MAX(maxBlocks, 1); - return PRInt32(PR_MIN(maxBlocks, PR_INT32_MAX)); + maxBlocks = NS_MAX(maxBlocks, 1); + return PRInt32(NS_MIN(maxBlocks, PR_INT32_MAX)); } PRInt32 diff --git a/content/media/wave/nsWaveReader.cpp b/content/media/wave/nsWaveReader.cpp index 7eeb4191c3e..d983abe73b4 100644 --- a/content/media/wave/nsWaveReader.cpp +++ b/content/media/wave/nsWaveReader.cpp @@ -381,7 +381,7 @@ nsWaveReader::ScanForwardUntil(PRUint32 aWantedChunk, PRUint32* aChunkSize) PR_STATIC_ASSERT(MAX_CHUNK_SIZE < UINT_MAX / sizeof(char)); nsAutoArrayPtr chunk(new char[MAX_CHUNK_SIZE]); while (chunkSize > 0) { - PRUint32 size = PR_MIN(chunkSize, MAX_CHUNK_SIZE); + PRUint32 size = NS_MIN(chunkSize, MAX_CHUNK_SIZE); if (!ReadAll(chunk.get(), size)) { return PR_FALSE; } @@ -545,8 +545,8 @@ nsWaveReader::GetDataLength() // the content length rather than the expected PCM data length. PRInt64 streamLength = mDecoder->GetCurrentStream()->GetLength(); if (streamLength >= 0) { - PRInt64 dataLength = PR_MAX(0, streamLength - mWavePCMOffset); - length = PR_MIN(dataLength, length); + PRInt64 dataLength = NS_MAX(0, streamLength - mWavePCMOffset); + length = NS_MIN(dataLength, length); } return length; } diff --git a/docshell/shistory/src/nsSHEntry.cpp b/docshell/shistory/src/nsSHEntry.cpp index 61b6d593091..6989571bc97 100644 --- a/docshell/shistory/src/nsSHEntry.cpp +++ b/docshell/shistory/src/nsSHEntry.cpp @@ -656,7 +656,7 @@ nsSHEntry::AddChild(nsISHEntry * aChild, PRInt32 aOffset) // If there are dynamically added children before that, those must be // moved to be after aOffset. if (mChildren.Count() > 0) { - PRInt32 start = PR_MIN(mChildren.Count() - 1, aOffset); + PRInt32 start = NS_MIN(mChildren.Count() - 1, aOffset); PRInt32 dynEntryIndex = -1; nsISHEntry* dynEntry = nsnull; for (PRInt32 i = start; i >= 0; --i) { diff --git a/dom/plugins/test/testplugin/nptest_macosx.mm b/dom/plugins/test/testplugin/nptest_macosx.mm index 5bf1b09d907..dd7379ec738 100644 --- a/dom/plugins/test/testplugin/nptest_macosx.mm +++ b/dom/plugins/test/testplugin/nptest_macosx.mm @@ -32,6 +32,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nptest_platform.h" +#include "nsAlgorithm.h" #include using namespace std; @@ -191,8 +192,8 @@ pluginDraw(InstanceData* instanceData, NPCocoaEvent* event) // Initialize a rectangular path. CGMutablePathRef path = CGPathCreateMutable(); - CGRect bounds = CGRectMake(10.0, 10.0, PR_MAX(0.0, windowWidth - 20.0), - PR_MAX(0.0, windowHeight - 20.0)); + CGRect bounds = CGRectMake(10.0, 10.0, NS_MAX(0.0, windowWidth - 20.0), + NS_MAX(0.0, windowHeight - 20.0)); CGPathAddRect(path, NULL, bounds); // Initialize an attributed string. diff --git a/extensions/gio/nsGIOProtocolHandler.cpp b/extensions/gio/nsGIOProtocolHandler.cpp index 9faa639298d..893c2fb00ce 100644 --- a/extensions/gio/nsGIOProtocolHandler.cpp +++ b/extensions/gio/nsGIOProtocolHandler.cpp @@ -481,7 +481,7 @@ nsGIOInputStream::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/gfx/src/nsBoundingMetrics.h b/gfx/src/nsBoundingMetrics.h index 6a9bf029e07..415ad90b320 100644 --- a/gfx/src/nsBoundingMetrics.h +++ b/gfx/src/nsBoundingMetrics.h @@ -108,8 +108,8 @@ struct nsBoundingMetrics { else { if (ascent < bm.ascent) ascent = bm.ascent; if (descent < bm.descent) descent = bm.descent; - leftBearing = PR_MIN(leftBearing, width + bm.leftBearing); - rightBearing = PR_MAX(rightBearing, width + bm.rightBearing); + leftBearing = NS_MIN(leftBearing, width + bm.leftBearing); + rightBearing = NS_MAX(rightBearing, width + bm.rightBearing); } width += bm.width; } diff --git a/gfx/src/nsCoord.h b/gfx/src/nsCoord.h index 65cdbe20130..89d5014cc56 100644 --- a/gfx/src/nsCoord.h +++ b/gfx/src/nsCoord.h @@ -38,6 +38,7 @@ #ifndef NSCOORD_H #define NSCOORD_H +#include "nsAlgorithm.h" #include "nscore.h" #include "nsMathUtils.h" #include @@ -142,8 +143,8 @@ inline nscoord _nscoordSaturatingMultiply(nscoord aCoord, float aScale, float product = aCoord * aScale; if (requireNotNegative ? aCoord > 0 : (aCoord > 0) == (aScale > 0)) - return NSToCoordRoundWithClamp(PR_MIN(nscoord_MAX, product)); - return NSToCoordRoundWithClamp(PR_MAX(nscoord_MIN, product)); + return NSToCoordRoundWithClamp(NS_MIN(nscoord_MAX, product)); + return NSToCoordRoundWithClamp(NS_MAX(nscoord_MIN, product)); #endif } @@ -218,13 +219,13 @@ NSCoordSaturatingAdd(nscoord a, nscoord b) "Doing nscoord addition with values > nscoord_MAX"); NS_ASSERTION((PRInt64)a + (PRInt64)b > (PRInt64)nscoord_MIN, "nscoord addition will reach or pass nscoord_MIN"); - // This one's only a warning because the PR_MIN below means that + // This one's only a warning because the NS_MIN below means that // we'll handle this case correctly. NS_WARN_IF_FALSE((PRInt64)a + (PRInt64)b < (PRInt64)nscoord_MAX, "nscoord addition capped to nscoord_MAX"); // Cap the result, just in case we're dealing with numbers near nscoord_MAX - return PR_MIN(nscoord_MAX, a + b); + return NS_MIN(nscoord_MAX, a + b); } #endif } @@ -277,13 +278,13 @@ NSCoordSaturatingSubtract(nscoord a, nscoord b, "Doing nscoord subtraction with values > nscoord_MAX"); NS_ASSERTION((PRInt64)a - (PRInt64)b > (PRInt64)nscoord_MIN, "nscoord subtraction will reach or pass nscoord_MIN"); - // This one's only a warning because the PR_MIN below means that + // This one's only a warning because the NS_MIN below means that // we'll handle this case correctly. NS_WARN_IF_FALSE((PRInt64)a - (PRInt64)b < (PRInt64)nscoord_MAX, "nscoord subtraction capped to nscoord_MAX"); // Cap the result, in case we're dealing with numbers near nscoord_MAX - return PR_MIN(nscoord_MAX, a - b); + return NS_MIN(nscoord_MAX, a - b); } } #endif diff --git a/gfx/src/nsDeviceContext.cpp b/gfx/src/nsDeviceContext.cpp index 35aa5ba873e..6ca8300c32f 100644 --- a/gfx/src/nsDeviceContext.cpp +++ b/gfx/src/nsDeviceContext.cpp @@ -381,7 +381,7 @@ nsDeviceContext::SetDPI() dpi = mWidget->GetDPI(); if (prefDPI < 0) { - dpi = PR_MAX(96.0f, dpi); + dpi = NS_MAX(96.0f, dpi); } } else { dpi = 96.0f; @@ -406,7 +406,7 @@ nsDeviceContext::SetDPI() } mAppUnitsPerDevNotScaledPixel = - PR_MAX(1, NS_lround(AppUnitsPerCSSPixel() / devPixelsPerCSSPixel)); + NS_MAX(1, NS_lround(AppUnitsPerCSSPixel() / devPixelsPerCSSPixel)); } NS_ASSERTION(dpi != -1.0, "no dpi set"); @@ -836,5 +836,5 @@ void nsDeviceContext::UpdateScaledAppUnits() { mAppUnitsPerDevPixel = - PR_MAX(1, NSToIntRound(float(mAppUnitsPerDevNotScaledPixel) / mPixelScale)); + NS_MAX(1, NSToIntRound(float(mAppUnitsPerDevNotScaledPixel) / mPixelScale)); } diff --git a/gfx/src/nsFontMetrics.cpp b/gfx/src/nsFontMetrics.cpp index d4c45405b89..7a07b9a182a 100644 --- a/gfx/src/nsFontMetrics.cpp +++ b/gfx/src/nsFontMetrics.cpp @@ -197,7 +197,7 @@ static gfxFloat ComputeMaxDescent(const gfxFont::Metrics& aMetrics, gfxFloat offset = NS_floor(-aFontGroup->GetUnderlineOffset() + 0.5); gfxFloat size = NS_round(aMetrics.underlineSize); gfxFloat minDescent = NS_floor(offset + size + 0.5); - return PR_MAX(minDescent, aMetrics.maxDescent); + return NS_MAX(minDescent, aMetrics.maxDescent); } static gfxFloat ComputeMaxAscent(const gfxFont::Metrics& aMetrics) @@ -279,7 +279,7 @@ nsFontMetrics::GetMaxStringLength() const gfxFont::Metrics& m = GetMetrics(); const double x = 32767.0 / m.maxAdvance; PRInt32 len = (PRInt32)floor(x); - return PR_MAX(1, len); + return NS_MAX(1, len); } nscoord diff --git a/gfx/src/nsRegion.cpp b/gfx/src/nsRegion.cpp index 1ab37cd3e49..30757781e72 100644 --- a/gfx/src/nsRegion.cpp +++ b/gfx/src/nsRegion.cpp @@ -71,13 +71,13 @@ inline PRBool nsRegion::nsRectFast::Intersects (const nsRect& aRect) const inline PRBool nsRegion::nsRectFast::IntersectRect (const nsRect& aRect1, const nsRect& aRect2) { - const nscoord xmost = PR_MIN (aRect1.XMost (), aRect2.XMost ()); - x = PR_MAX (aRect1.x, aRect2.x); + const nscoord xmost = NS_MIN (aRect1.XMost (), aRect2.XMost ()); + x = NS_MAX (aRect1.x, aRect2.x); width = xmost - x; if (width <= 0) return PR_FALSE; - const nscoord ymost = PR_MIN (aRect1.YMost (), aRect2.YMost ()); - y = PR_MAX (aRect1.y, aRect2.y); + const nscoord ymost = NS_MIN (aRect1.YMost (), aRect2.YMost ()); + y = NS_MAX (aRect1.y, aRect2.y); height = ymost - y; if (height <= 0) return PR_FALSE; @@ -86,8 +86,8 @@ inline PRBool nsRegion::nsRectFast::IntersectRect (const nsRect& aRect1, const n inline void nsRegion::nsRectFast::UnionRect (const nsRect& aRect1, const nsRect& aRect2) { - const nscoord xmost = PR_MAX (aRect1.XMost (), aRect2.XMost ()); - const nscoord ymost = PR_MAX (aRect1.YMost (), aRect2.YMost ()); + const nscoord xmost = NS_MAX (aRect1.XMost (), aRect2.XMost ()); + const nscoord ymost = NS_MAX (aRect1.YMost (), aRect2.YMost ()); x = PR_MIN (aRect1.x, aRect2.x); y = PR_MIN (aRect1.y, aRect2.y); width = xmost - x; diff --git a/gfx/src/nsRenderingContext.cpp b/gfx/src/nsRenderingContext.cpp index 924cbd324c9..0fab59ebc3d 100644 --- a/gfx/src/nsRenderingContext.cpp +++ b/gfx/src/nsRenderingContext.cpp @@ -78,7 +78,7 @@ static PRInt32 FindSafeLength(const char *aString, PRUint32 aLength, PRUint32 aMaxChunkLength) { // Since it's ASCII, we don't need to worry about clusters or RTL - return PR_MIN(aLength, aMaxChunkLength); + return NS_MIN(aLength, aMaxChunkLength); } ////////////////////////////////////////////////////////////////////// @@ -481,7 +481,7 @@ nsRenderingContext::GetMaxChunkLength() { if (!mFontMetrics) return 1; - return PR_MIN(mFontMetrics->GetMaxStringLength(), MAX_GFX_TEXT_BUF_SIZE); + return NS_MIN(mFontMetrics->GetMaxStringLength(), MAX_GFX_TEXT_BUF_SIZE); } nscoord diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index 5304e376280..f11331310b8 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -54,6 +54,7 @@ #include "prtypes.h" #include "gfxTypes.h" +#include "nsAlgorithm.h" #include "gfxContext.h" #include "gfxFontMissingGlyphs.h" #include "gfxUserFontSet.h" @@ -1019,8 +1020,8 @@ gfxFontCache::DestroyFont(gfxFont *aFont) void gfxFont::RunMetrics::CombineWith(const RunMetrics& aOther, PRBool aOtherIsOnLeft) { - mAscent = PR_MAX(mAscent, aOther.mAscent); - mDescent = PR_MAX(mDescent, aOther.mDescent); + mAscent = NS_MAX(mAscent, aOther.mAscent); + mDescent = NS_MAX(mDescent, aOther.mDescent); if (aOtherIsOnLeft) { mBoundingBox = (mBoundingBox + gfxPoint(aOther.mAdvanceWidth, 0)).Union(aOther.mBoundingBox); @@ -1261,8 +1262,8 @@ gfxFont::Draw(gfxTextRun *aTextRun, PRUint32 aStart, PRUint32 aEnd, static void UnionRange(gfxFloat aX, gfxFloat* aDestMin, gfxFloat* aDestMax) { - *aDestMin = PR_MIN(*aDestMin, aX); - *aDestMax = PR_MAX(*aDestMax, aX); + *aDestMin = NS_MIN(*aDestMin, aX); + *aDestMax = NS_MAX(*aDestMax, aX); } // We get precise glyph extents if the textrun creator requested them, or @@ -1681,8 +1682,8 @@ gfxFont::InitMetricsFromSfntTables(Metrics& aMetrics) PRUint16(os2->version) >= 2) { // version 2 and later includes the x-height field SET_SIGNED(xHeight, os2->sxHeight); - // PR_ABS because of negative xHeight seen in Kokonor (Tibetan) font - aMetrics.xHeight = PR_ABS(aMetrics.xHeight); + // NS_ABS because of negative xHeight seen in Kokonor (Tibetan) font + aMetrics.xHeight = NS_ABS(aMetrics.xHeight); } // this should always be present if (os2data.Length() >= offsetof(OS2Table, yStrikeoutPosition) + @@ -1777,10 +1778,10 @@ gfxFont::SanitizeMetrics(gfxFont::Metrics *aMetrics, PRBool aIsBadUnderlineFont) aMetrics->subscriptOffset = aMetrics->xHeight; } - aMetrics->underlineSize = PR_MAX(1.0, aMetrics->underlineSize); - aMetrics->strikeoutSize = PR_MAX(1.0, aMetrics->strikeoutSize); + aMetrics->underlineSize = NS_MAX(1.0, aMetrics->underlineSize); + aMetrics->strikeoutSize = NS_MAX(1.0, aMetrics->strikeoutSize); - aMetrics->underlineOffset = PR_MIN(aMetrics->underlineOffset, -1.0); + aMetrics->underlineOffset = NS_MIN(aMetrics->underlineOffset, -1.0); if (aMetrics->maxAscent < 1.0) { // We cannot draw strikeout line and overline in the ascent... @@ -1802,13 +1803,13 @@ gfxFont::SanitizeMetrics(gfxFont::Metrics *aMetrics, PRBool aIsBadUnderlineFont) if (!mStyle.systemFont && aIsBadUnderlineFont) { // First, we need 2 pixels between baseline and underline at least. Because many CJK characters // put their glyphs on the baseline, so, 1 pixel is too close for CJK characters. - aMetrics->underlineOffset = PR_MIN(aMetrics->underlineOffset, -2.0); + aMetrics->underlineOffset = NS_MIN(aMetrics->underlineOffset, -2.0); // Next, we put the underline to bottom of below of the descent space. if (aMetrics->internalLeading + aMetrics->externalLeading > aMetrics->underlineSize) { - aMetrics->underlineOffset = PR_MIN(aMetrics->underlineOffset, -aMetrics->emDescent); + aMetrics->underlineOffset = NS_MIN(aMetrics->underlineOffset, -aMetrics->emDescent); } else { - aMetrics->underlineOffset = PR_MIN(aMetrics->underlineOffset, + aMetrics->underlineOffset = NS_MIN(aMetrics->underlineOffset, aMetrics->underlineSize - aMetrics->emDescent); } } @@ -1816,7 +1817,7 @@ gfxFont::SanitizeMetrics(gfxFont::Metrics *aMetrics, PRBool aIsBadUnderlineFont) // will stay within the boundary. else if (aMetrics->underlineSize - aMetrics->underlineOffset > aMetrics->maxDescent) { if (aMetrics->underlineSize > aMetrics->maxDescent) - aMetrics->underlineSize = PR_MAX(aMetrics->maxDescent, 1.0); + aMetrics->underlineSize = NS_MAX(aMetrics->maxDescent, 1.0); // The max underlineOffset is 1px (the min underlineSize is 1px, and min maxDescent is 0px.) aMetrics->underlineOffset = aMetrics->underlineSize - aMetrics->maxDescent; } @@ -1827,11 +1828,11 @@ gfxFont::SanitizeMetrics(gfxFont::Metrics *aMetrics, PRBool aIsBadUnderlineFont) gfxFloat halfOfStrikeoutSize = NS_floor(aMetrics->strikeoutSize / 2.0 + 0.5); if (halfOfStrikeoutSize + aMetrics->strikeoutOffset > aMetrics->maxAscent) { if (aMetrics->strikeoutSize > aMetrics->maxAscent) { - aMetrics->strikeoutSize = PR_MAX(aMetrics->maxAscent, 1.0); + aMetrics->strikeoutSize = NS_MAX(aMetrics->maxAscent, 1.0); halfOfStrikeoutSize = NS_floor(aMetrics->strikeoutSize / 2.0 + 0.5); } gfxFloat ascent = NS_floor(aMetrics->maxAscent + 0.5); - aMetrics->strikeoutOffset = PR_MAX(halfOfStrikeoutSize, ascent / 2.0); + aMetrics->strikeoutOffset = NS_MAX(halfOfStrikeoutSize, ascent / 2.0); } // If overline is larger than the ascent, the line should be resized. @@ -2048,7 +2049,7 @@ gfxFontGroup::BuildFontList() if (font->GetFontEntry()->mIsBadUnderlineFont) { gfxFloat first = mFonts[0]->GetMetrics().underlineOffset; gfxFloat bad = font->GetMetrics().underlineOffset; - mUnderlineOffset = PR_MIN(first, bad); + mUnderlineOffset = NS_MIN(first, bad); break; } } @@ -2997,10 +2998,10 @@ gfxTextRun::GlyphRunIterator::NextRun() { if (mGlyphRun->mCharacterOffset >= mEndOffset) return PR_FALSE; - mStringStart = PR_MAX(mStartOffset, mGlyphRun->mCharacterOffset); + mStringStart = NS_MAX(mStartOffset, mGlyphRun->mCharacterOffset); PRUint32 last = mNextIndex + 1 < mTextRun->mGlyphRuns.Length() ? mTextRun->mGlyphRuns[mNextIndex + 1].mCharacterOffset : mTextRun->mCharacterCount; - mStringEnd = PR_MIN(mEndOffset, last); + mStringEnd = NS_MIN(mEndOffset, last); ++mNextIndex; return PR_TRUE; @@ -3025,7 +3026,7 @@ AccountStorageForTextRun(gfxTextRun *aTextRun, PRInt32 aSign) } bytes += sizeof(gfxTextRun); gTextRunStorage += bytes*aSign; - gTextRunStorageHighWaterMark = PR_MAX(gTextRunStorageHighWaterMark, gTextRunStorage); + gTextRunStorageHighWaterMark = NS_MAX(gTextRunStorageHighWaterMark, gTextRunStorage); } #endif @@ -3355,17 +3356,17 @@ ClipPartialLigature(gfxTextRun *aTextRun, gfxFloat *aLeft, gfxFloat *aRight, { if (aLigature->mClipBeforePart) { if (aTextRun->IsRightToLeft()) { - *aRight = PR_MIN(*aRight, aXOrigin); + *aRight = NS_MIN(*aRight, aXOrigin); } else { - *aLeft = PR_MAX(*aLeft, aXOrigin); + *aLeft = NS_MAX(*aLeft, aXOrigin); } } if (aLigature->mClipAfterPart) { gfxFloat endEdge = aXOrigin + aTextRun->GetDirection()*aLigature->mPartWidth; if (aTextRun->IsRightToLeft()) { - *aLeft = PR_MAX(*aLeft, endEdge); + *aLeft = NS_MAX(*aLeft, endEdge); } else { - *aRight = PR_MIN(*aRight, endEdge); + *aRight = NS_MIN(*aRight, endEdge); } } } @@ -3732,12 +3733,12 @@ gfxTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength, PRBool aCanWordWrap, gfxBreakPriority *aBreakPriority) { - aMaxLength = PR_MIN(aMaxLength, mCharacterCount - aStart); + aMaxLength = NS_MIN(aMaxLength, mCharacterCount - aStart); NS_ASSERTION(aStart + aMaxLength <= mCharacterCount, "Substring out of range"); PRUint32 bufferStart = aStart; - PRUint32 bufferLength = PR_MIN(aMaxLength, MEASUREMENT_BUFFER_SIZE); + PRUint32 bufferLength = NS_MIN(aMaxLength, MEASUREMENT_BUFFER_SIZE); PropertyProvider::Spacing spacingBuffer[MEASUREMENT_BUFFER_SIZE]; PRBool haveSpacing = aProvider && (mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING) != 0; if (haveSpacing) { @@ -3776,7 +3777,7 @@ gfxTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength, if (i >= bufferStart + bufferLength) { // Fetch more spacing and hyphenation data bufferStart = i; - bufferLength = PR_MIN(aStart + aMaxLength, i + MEASUREMENT_BUFFER_SIZE) - i; + bufferLength = NS_MIN(aStart + aMaxLength, i + MEASUREMENT_BUFFER_SIZE) - i; if (haveSpacing) { GetAdjustedSpacing(this, bufferStart, bufferStart + bufferLength, aProvider, spacingBuffer); @@ -4137,7 +4138,7 @@ gfxTextRun::SetMissingGlyph(PRUint32 aIndex, PRUint32 aChar) // Setting advance width to zero will prevent drawing the hexbox details->mAdvance = 0; } else { - gfxFloat width = PR_MAX(glyphRun->mFont->GetMetrics().aveCharWidth, + gfxFloat width = NS_MAX(glyphRun->mFont->GetMetrics().aveCharWidth, gfxFontMissingGlyphs::GetDesiredMinWidth(aChar)); details->mAdvance = PRUint32(width*GetAppUnitsPerDevUnit()); } diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index f2a64b3a5c9..252c2934ba8 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -42,6 +42,7 @@ #define GFX_FONT_H #include "prtypes.h" +#include "nsAlgorithm.h" #include "gfxTypes.h" #include "nsString.h" #include "gfxPoint.h" @@ -167,8 +168,8 @@ struct THEBES_API gfxFontStyle { // Not meant to be called when sizeAdjust = 0. gfxFloat GetAdjustedSize(gfxFloat aspect) const { NS_ASSERTION(sizeAdjust != 0.0, "Not meant to be called when sizeAdjust = 0"); - gfxFloat adjustedSize = PR_MAX(NS_round(size*(sizeAdjust/aspect)), 1.0); - return PR_MIN(adjustedSize, FONT_MAX_SIZE); + gfxFloat adjustedSize = NS_MAX(NS_round(size*(sizeAdjust/aspect)), 1.0); + return NS_MIN(adjustedSize, FONT_MAX_SIZE); } PLDHashNumber Hash() const { diff --git a/gfx/thebes/gfxMacPlatformFontList.mm b/gfx/thebes/gfxMacPlatformFontList.mm index 7039a644c49..78ddf8c4edb 100644 --- a/gfx/thebes/gfxMacPlatformFontList.mm +++ b/gfx/thebes/gfxMacPlatformFontList.mm @@ -821,7 +821,7 @@ gfxMacPlatformFontList::GetStandardFamilyName(const nsAString& aFontName, nsAStr // convert the name to a Pascal-style Str255 to try as Quickdraw name Str255 qdname; NS_ConvertUTF16toUTF8 utf8name(aFontName); - qdname[0] = PR_MAX(255, strlen(utf8name.get())); + qdname[0] = NS_MAX(255, strlen(utf8name.get())); memcpy(&qdname[1], utf8name.get(), qdname[0]); // look up the Quickdraw name diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 5f076c7aaa8..23cab9e52ef 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -1125,8 +1125,8 @@ nsCSSRendering::PaintBoxShadowOuter(nsPresContext* aPresContext, skipGfxRect = nsLayoutUtils::RectToGfxRect(paddingRect, twipsPerPixel); } else if (hasBorderRadius) { skipGfxRect.Deflate(gfxMargin( - 0, PR_MAX(borderRadii[C_TL].height, borderRadii[C_TR].height), - 0, PR_MAX(borderRadii[C_BL].height, borderRadii[C_BR].height))); + 0, NS_MAX(borderRadii[C_TL].height, borderRadii[C_TR].height), + 0, NS_MAX(borderRadii[C_BL].height, borderRadii[C_BR].height))); } for (PRUint32 i = shadows->Length(); i > 0; --i) { @@ -1362,8 +1362,8 @@ nsCSSRendering::PaintBoxShadowInner(nsPresContext* aPresContext, gfxRect skipGfxRect = nsLayoutUtils::RectToGfxRect(skipRect, twipsPerPixel); if (hasBorderRadius) { skipGfxRect.Deflate( - gfxMargin(0, PR_MAX(clipRectRadii[C_TL].height, clipRectRadii[C_TR].height), - 0, PR_MAX(clipRectRadii[C_BL].height, clipRectRadii[C_BR].height))); + gfxMargin(0, NS_MAX(clipRectRadii[C_TL].height, clipRectRadii[C_TR].height), + 0, NS_MAX(clipRectRadii[C_BL].height, clipRectRadii[C_BR].height))); } // When there's a blur radius, gfxAlphaBoxBlur leaves the skiprect area diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 91aa9e605e6..dcf66351ccd 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -56,6 +56,7 @@ /* a presentation of a document, part 2 */ +#include "nsAlgorithm.h" #include "nsIPresShell.h" #include "nsPresContext.h" #include "nsIContent.h" @@ -623,7 +624,7 @@ StackArena::Allocate(size_t aSize) // make sure we are aligned. Beard said 8 was safer then 4. // Round size to multiple of 8 - aSize = PR_ROUNDUP(aSize, 8); + aSize = NS_ROUNDUP(aSize, 8); // if the size makes the stack overflow. Grab another block for the stack if (mPos + aSize >= BLOCK_INCREMENT) diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 3011153fee3..d749b28ad71 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -2199,8 +2199,8 @@ nsGfxScrollFrameInner::ScrollBy(nsIntPoint aDelta, nsPoint clampAmount = mDestination - newPos; float appUnitsPerDevPixel = mOuter->PresContext()->AppUnitsPerDevPixel(); *aOverflow = nsIntPoint( - NSAppUnitsToIntPixels(PR_ABS(clampAmount.x), appUnitsPerDevPixel), - NSAppUnitsToIntPixels(PR_ABS(clampAmount.y), appUnitsPerDevPixel)); + NSAppUnitsToIntPixels(NS_ABS(clampAmount.x), appUnitsPerDevPixel), + NSAppUnitsToIntPixels(NS_ABS(clampAmount.y), appUnitsPerDevPixel)); } } diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index a9e375f560f..53edb287c58 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -2802,7 +2802,7 @@ PropertyProvider::CalcTabWidths(PRUint32 aStart, PRUint32 aLength) PRUint32 startOffset = mStart.GetSkippedOffset(); PRUint32 tabsEnd = mTabWidths ? - mTabWidths->mLimit : PR_MAX(mTabWidthsAnalyzedLimit, startOffset); + mTabWidths->mLimit : NS_MAX(mTabWidthsAnalyzedLimit, startOffset); if (tabsEnd < aStart + aLength) { NS_ASSERTION(mReflowing, @@ -2847,7 +2847,7 @@ PropertyProvider::CalcTabWidths(PRUint32 aStart, PRUint32 aLength) if (!mTabWidths) { // Delete any stale property that may be left on the frame mFrame->Properties().Delete(TabWidthProperty()); - mTabWidthsAnalyzedLimit = PR_MAX(mTabWidthsAnalyzedLimit, + mTabWidthsAnalyzedLimit = NS_MAX(mTabWidthsAnalyzedLimit, aStart + aLength); } } @@ -5001,7 +5001,7 @@ nsTextFrame::PaintTextSelectionDecorations(gfxContext* aCtx, if (type == aSelectionType) { pt.x = (aFramePt.x + xOffset - (mTextRun->IsRightToLeft() ? advance : 0)) / app; - gfxFloat width = PR_ABS(advance) / app; + gfxFloat width = NS_ABS(advance) / app; DrawSelectionDecorations(aCtx, aSelectionType, this, aTextPaintStyle, selectedStyle, pt, width, mAscent / app, decorationMetrics); @@ -6209,7 +6209,7 @@ nsTextFrame::AddInlineMinWidthForFlow(nsRenderingContext *aRenderingContext, (mTextRun->GetFlags() & gfxTextRunFactory::TEXT_ENABLE_HYPHEN_BREAKS) != 0)); if (hyphenating) { gfxSkipCharsIterator tmp(iter); - len = PR_MIN(GetContentOffset() + GetInFlowContentLength(), + len = NS_MIN(GetContentOffset() + GetInFlowContentLength(), tmp.ConvertSkippedToOriginal(flowEndInTextRun)) - iter.GetOriginalOffset(); } PropertyProvider provider(mTextRun, textStyle, frag, this, diff --git a/netwerk/base/src/nsUnicharStreamLoader.cpp b/netwerk/base/src/nsUnicharStreamLoader.cpp index 0e311b8aedc..96e79ab1ba9 100644 --- a/netwerk/base/src/nsUnicharStreamLoader.cpp +++ b/netwerk/base/src/nsUnicharStreamLoader.cpp @@ -256,7 +256,7 @@ nsUnicharStreamLoader::WriteSegmentFun(nsIInputStream *, ++consumed; // XXX this is needed to make sure we don't underrun our buffer; // bug 160784 again - consumed = PR_MAX(consumed, 0); + consumed = NS_MAX(consumed, 0); self->mDecoder->Reset(); } } while (consumed < aCount); diff --git a/netwerk/cache/nsDiskCacheStreams.cpp b/netwerk/cache/nsDiskCacheStreams.cpp index 7786818c56f..dba6d3c103a 100644 --- a/netwerk/cache/nsDiskCacheStreams.cpp +++ b/netwerk/cache/nsDiskCacheStreams.cpp @@ -756,7 +756,7 @@ nsDiskCacheStreamIO::FlushBufferToFile() PRInt64 dataSize = mBinding->mCacheEntry->PredictedDataSize(); if (dataSize != -1) - mozilla::fallocate(mFD, PR_MIN(dataSize, kPreallocateLimit)); + mozilla::fallocate(mFD, NS_MIN(dataSize, kPreallocateLimit)); } // write buffer diff --git a/netwerk/protocol/http/nsHttpTransaction.cpp b/netwerk/protocol/http/nsHttpTransaction.cpp index d1f5d2c663c..33e5af864b2 100644 --- a/netwerk/protocol/http/nsHttpTransaction.cpp +++ b/netwerk/protocol/http/nsHttpTransaction.cpp @@ -1090,8 +1090,7 @@ nsHttpTransaction::HandleContent(char *buf, // NOT persistent, we simply accept everything in |buf|. if (mConnection->IsPersistent() || mPreserveStream) { PRInt64 remaining = mContentLength - mContentRead; - PRInt64 count64 = count; - *contentRead = PR_MIN(count64, remaining); + *contentRead = PRUint32(NS_MIN(count, remaining)); *contentRemaining = count - *contentRead; } else { @@ -1113,7 +1112,7 @@ nsHttpTransaction::HandleContent(char *buf, if (*contentRead) { // update count of content bytes read and report progress... mContentRead += *contentRead; - /* when uncommenting, take care of 64-bit integers w/ PR_MAX... + /* when uncommenting, take care of 64-bit integers w/ NS_MAX... if (mProgressSink) mProgressSink->OnProgress(nsnull, nsnull, mContentRead, NS_MAX(0, mContentLength)); */ diff --git a/netwerk/test/TestHttp.cpp b/netwerk/test/TestHttp.cpp index a4b2982ad67..5084efd9ffd 100644 --- a/netwerk/test/TestHttp.cpp +++ b/netwerk/test/TestHttp.cpp @@ -64,7 +64,7 @@ MyListener::OnDataAvailable(nsIRequest *req, nsISupports *ctxt, PRUint32 bytesRead=0; while (count) { - PRUint32 amount = PR_MIN(count, sizeof(buf)); + PRUint32 amount = NS_MIN(count, sizeof(buf)); rv = stream->Read(buf, amount, &bytesRead); if (NS_FAILED(rv)) { diff --git a/netwerk/test/TestMCTransport.cpp b/netwerk/test/TestMCTransport.cpp index 93d1a4c2f0f..63c9200d91a 100644 --- a/netwerk/test/TestMCTransport.cpp +++ b/netwerk/test/TestMCTransport.cpp @@ -137,7 +137,7 @@ TestListener::OnDataAvailable(nsIRequest *req, nsISupports *ctx, PRUint32 nread = 0; while (count) { - PRUint32 amount = PR_MIN(count, sizeof(buf)); + PRUint32 amount = NS_MIN(count, sizeof(buf)); rv = is->Read(buf, amount, &nread); if (NS_FAILED(rv)) return rv; diff --git a/netwerk/test/TestOverlappedIO.cpp b/netwerk/test/TestOverlappedIO.cpp index 562b3e94962..5ccd7dd46c9 100644 --- a/netwerk/test/TestOverlappedIO.cpp +++ b/netwerk/test/TestOverlappedIO.cpp @@ -200,7 +200,7 @@ TestProvider::OnDataWritable(nsIRequest *request, nsISupports *context, return NS_BASE_STREAM_CLOSED; PRUint32 writeCount, amount; - amount = PR_MIN(count, mDataLen - mOffset); + amount = NS_MIN(count, mDataLen - mOffset); nsresult rv = output->Write(mData + mOffset, amount, &writeCount); if (NS_SUCCEEDED(rv)) { printf("wrote %u bytes\n", writeCount); diff --git a/netwerk/test/TestPageLoad.cpp b/netwerk/test/TestPageLoad.cpp index 81deee2196b..d6f897daf7d 100644 --- a/netwerk/test/TestPageLoad.cpp +++ b/netwerk/test/TestPageLoad.cpp @@ -205,7 +205,7 @@ MyListener::OnDataAvailable(nsIRequest *req, nsISupports *ctxt, rv = stream->ReadSegments(streamParse, &offset, count, &bytesRead); } else { while (count) { - PRUint32 amount = PR_MIN(count, sizeof(buf)); + PRUint32 amount = NS_MIN(count, sizeof(buf)); rv = stream->Read(buf, amount, &bytesRead); count -= bytesRead; } diff --git a/netwerk/test/TestPerf.cpp b/netwerk/test/TestPerf.cpp index e3862e57891..7bfe7937c5c 100644 --- a/netwerk/test/TestPerf.cpp +++ b/netwerk/test/TestPerf.cpp @@ -83,7 +83,7 @@ MyListener::OnDataAvailable(nsIRequest *req, nsISupports *ctx, char buf[4096]; PRUint32 n, bytesRead; while (count) { - n = PR_MIN(count, sizeof(buf)); + n = NS_MIN(count, sizeof(buf)); rv = stream->Read(buf, n, &bytesRead); if (NS_FAILED(rv)) break; diff --git a/netwerk/test/TestProtocols.cpp b/netwerk/test/TestProtocols.cpp index 772971aaef6..1105c21c4fb 100644 --- a/netwerk/test/TestProtocols.cpp +++ b/netwerk/test/TestProtocols.cpp @@ -517,7 +517,7 @@ InputTestConsumer::OnDataAvailable(nsIRequest *request, URLLoadInfo* info = (URLLoadInfo*)context; 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/netwerk/test/TestStreamChannel.cpp b/netwerk/test/TestStreamChannel.cpp index 05f8a4cd734..a148cb27b1d 100644 --- a/netwerk/test/TestStreamChannel.cpp +++ b/netwerk/test/TestStreamChannel.cpp @@ -98,7 +98,7 @@ public: nsresult rv; while (count) { - PRUint32 n, amt = PR_MIN(count, sizeof(buf)); + PRUint32 n, amt = NS_MIN(count, sizeof(buf)); rv = stream->Read(buf, amt, &n); if (NS_FAILED(rv)) { diff --git a/netwerk/test/TestStreamPump.cpp b/netwerk/test/TestStreamPump.cpp index 4d73376ca26..0b8e3844b04 100644 --- a/netwerk/test/TestStreamPump.cpp +++ b/netwerk/test/TestStreamPump.cpp @@ -96,7 +96,7 @@ public: nsresult rv; while (count) { - PRUint32 n, amt = PR_MIN(count, sizeof(buf)); + PRUint32 n, amt = NS_MIN(count, sizeof(buf)); rv = stream->Read(buf, amt, &n); if (NS_FAILED(rv)) { diff --git a/netwerk/test/TestThreadedIO.cpp b/netwerk/test/TestThreadedIO.cpp index 25615a8607d..994efbfd882 100644 --- a/netwerk/test/TestThreadedIO.cpp +++ b/netwerk/test/TestThreadedIO.cpp @@ -175,7 +175,7 @@ TestListener::OnDataAvailable( nsIChannel *aChannel, unsigned int bytesRead; // Read a buffer full or the number remaining (whichever is smaller). rv = aStream->Read( buffer, - PR_MIN( sizeof( buffer ), bytesRemaining ), + NS_MIN( sizeof( buffer ), bytesRemaining ), &bytesRead ); if ( NS_SUCCEEDED( rv ) ) { // Write the bytes just read to the output file. diff --git a/netwerk/test/TestUpload.cpp b/netwerk/test/TestUpload.cpp index fa77970533e..9dfa0f0fbd8 100644 --- a/netwerk/test/TestUpload.cpp +++ b/netwerk/test/TestUpload.cpp @@ -105,7 +105,7 @@ InputTestConsumer::OnDataAvailable(nsIRequest *request, nsresult rv; while (aLength) { - size = PR_MIN(aLength, sizeof(buf)); + size = NS_MIN(aLength, sizeof(buf)); rv = aIStream->Read(buf, size, &amt); if (NS_FAILED(rv)) { NS_ASSERTION((NS_BASE_STREAM_WOULD_BLOCK != rv), diff --git a/testing/mochitest/ssltunnel/Makefile.in b/testing/mochitest/ssltunnel/Makefile.in index 60218c9d8f6..03a4c297abe 100644 --- a/testing/mochitest/ssltunnel/Makefile.in +++ b/testing/mochitest/ssltunnel/Makefile.in @@ -56,8 +56,9 @@ CPPSRCS = ssltunnel.cpp LOCAL_INCLUDES += $(NSPR_CFLAGS) $(NSS_CFLAGS) LIBS = \ - $(NSPR_LIBS) \ - $(NSS_LIBS) \ - $(NULL) + $(NSPR_LIBS) \ + $(NSS_LIBS) \ + $(MOZALLOC_LIB) \ + $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/testing/mochitest/ssltunnel/ssltunnel.cpp b/testing/mochitest/ssltunnel/ssltunnel.cpp index ed84c2097c4..049b4891283 100644 --- a/testing/mochitest/ssltunnel/ssltunnel.cpp +++ b/testing/mochitest/ssltunnel/ssltunnel.cpp @@ -59,6 +59,7 @@ #include "prnetdb.h" #include "prtpool.h" #include "prtypes.h" +#include "nsAlgorithm.h" #include "nss.h" #include "pk11func.h" #include "key.h" @@ -231,8 +232,8 @@ struct relayBuffer } bool empty() { return bufferhead == buffertail; } - size_t free() { return bufferend - buffertail; } - size_t margin() { return free() + BUF_MARGIN; } + size_t areafree() { return bufferend - buffertail; } + size_t margin() { return areafree() + BUF_MARGIN; } size_t present() { return buffertail - bufferhead; } }; @@ -693,17 +694,17 @@ void HandleConnection(void* data) continue; } // PR_POLL_EXCEPT, PR_POLL_ERR, PR_POLL_HUP handling - if (out_flags & PR_POLL_READ && !buffers[s].free()) + if (out_flags & PR_POLL_READ && !buffers[s].areafree()) { LOG_DEBUG((" no place in read buffer but got read flag, dropping it now!")); in_flags &= ~PR_POLL_READ; } - if (out_flags & PR_POLL_READ && buffers[s].free()) + if (out_flags & PR_POLL_READ && buffers[s].areafree()) { LOG_DEBUG((" :reading")); PRInt32 bytesRead = PR_Recv(sockets[s].fd, buffers[s].buffertail, - buffers[s].free(), 0, PR_INTERVAL_NO_TIMEOUT); + buffers[s].areafree(), 0, PR_INTERVAL_NO_TIMEOUT); if (bytesRead == 0) { @@ -788,7 +789,7 @@ void HandleConnection(void* data) break; } // end of CONNECT handling - if (!buffers[s].free()) + if (!buffers[s].areafree()) { // Do not poll for read when the buffer is full LOG_DEBUG((" no place in our read buffer, stop reading")); @@ -1283,8 +1284,8 @@ int main(int argc, char** argv) } // create a thread pool to handle connections - threads = PR_CreateThreadPool(PR_MAX(INITIAL_THREADS, servers.size()*2), - PR_MAX(MAX_THREADS, servers.size()*2), + threads = PR_CreateThreadPool(NS_MAX(INITIAL_THREADS, servers.size()*2), + NS_MAX(MAX_THREADS, servers.size()*2), DEFAULT_STACKSIZE); if (!threads) { LOG_ERROR(("Failed to create thread pool\n")); diff --git a/widget/src/cocoa/GfxInfo.mm b/widget/src/cocoa/GfxInfo.mm index de7e9d89576..d7fad725257 100644 --- a/widget/src/cocoa/GfxInfo.mm +++ b/widget/src/cocoa/GfxInfo.mm @@ -67,7 +67,7 @@ GfxInfo::Init() if (CGLQueryRendererInfo(0xffffffff, &renderer, &rendererCount) != kCGLNoError) return rv; - rendererCount = (GLint) PR_MIN(rendererCount, (GLint) NS_ARRAY_LENGTH(mRendererIDs)); + rendererCount = (GLint) NS_MIN(rendererCount, (GLint) NS_ARRAY_LENGTH(mRendererIDs)); for (GLint i = 0; i < rendererCount; i++) { GLint prop = 0; diff --git a/widget/src/cocoa/nsNativeThemeCocoa.mm b/widget/src/cocoa/nsNativeThemeCocoa.mm index 4831fe9b396..54f33163441 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.mm +++ b/widget/src/cocoa/nsNativeThemeCocoa.mm @@ -728,7 +728,7 @@ nsNativeThemeCocoa::DrawCheckboxOrRadio(CGContextRef cgContext, PRBool inCheckbo [cell setControlTint:(FrameIsInActiveWindow(aFrame) ? [NSColor currentControlTint] : NSClearControlTint)]; // Ensure that the control is square. - float length = PR_MIN(inBoxRect.size.width, inBoxRect.size.height); + float length = NS_MIN(inBoxRect.size.width, inBoxRect.size.height); HIRect drawRect = CGRectMake(inBoxRect.origin.x + (int)((inBoxRect.size.width - length) / 2.0f), inBoxRect.origin.y + (int)((inBoxRect.size.height - length) / 2.0f), length, length); @@ -2741,5 +2741,5 @@ nsNativeThemeCocoa::GetProgressMaxValue(nsIFrame* aFrame) } } - return (double)PR_MAX(CheckIntAttr(aFrame, nsWidgetAtoms::max, 100), 1); + return (double)NS_MAX(CheckIntAttr(aFrame, nsWidgetAtoms::max, 100), 1); } diff --git a/widget/src/qt/nsWindow.cpp b/widget/src/qt/nsWindow.cpp index 2fb711bafee..bea6c5d85f1 100644 --- a/widget/src/qt/nsWindow.cpp +++ b/widget/src/qt/nsWindow.cpp @@ -309,8 +309,8 @@ UpdateOffScreenBuffers(int aDepth, QSize aSize, QWidget* aWidget = nsnull) return true; } - gBufferMaxSize.width = PR_MAX(gBufferMaxSize.width, size.width); - gBufferMaxSize.height = PR_MAX(gBufferMaxSize.height, size.height); + gBufferMaxSize.width = NS_MAX(gBufferMaxSize.width, size.width); + gBufferMaxSize.height = NS_MAX(gBufferMaxSize.height, size.height); // Check if system depth has related gfxImage format gfxASurface::gfxImageFormat format = diff --git a/widget/src/windows/nsIMM32Handler.cpp b/widget/src/windows/nsIMM32Handler.cpp index 50e99a21570..ca7be887cd9 100644 --- a/widget/src/windows/nsIMM32Handler.cpp +++ b/widget/src/windows/nsIMM32Handler.cpp @@ -1201,7 +1201,7 @@ nsIMM32Handler::HandleComposition(nsWindow* aWindow, PRUint32 maxlen = compANSIStr.Length(); mClauseArray[0] = 0; // first value must be 0 for (PRInt32 i = 1; i < clauseArrayLength; i++) { - PRUint32 len = PR_MIN(mClauseArray[i], maxlen); + PRUint32 len = NS_MIN(mClauseArray[i], maxlen); mClauseArray[i] = ::MultiByteToWideChar(GetKeyboardCodePage(), MB_PRECOMPOSED, (LPCSTR)compANSIStr.get(), @@ -1212,7 +1212,7 @@ nsIMM32Handler::HandleComposition(nsWindow* aWindow, } // compClauseArrayLength may be negative. I.e., ImmGetCompositionStringW // may return an error code. - mClauseArray.SetLength(PR_MAX(0, clauseArrayLength)); + mClauseArray.SetLength(NS_MAX(0, clauseArrayLength)); PR_LOG(gIMM32Log, PR_LOG_ALWAYS, ("IMM32: HandleComposition, GCS_COMPCLAUSE, mClauseLength=%ld\n", @@ -1238,7 +1238,7 @@ nsIMM32Handler::HandleComposition(nsWindow* aWindow, // attrStrLen may be negative. I.e., ImmGetCompositionStringW may return an // error code. - mAttributeArray.SetLength(PR_MAX(0, attrArrayLength)); + mAttributeArray.SetLength(NS_MAX(0, attrArrayLength)); PR_LOG(gIMM32Log, PR_LOG_ALWAYS, ("IMM32: HandleComposition, GCS_COMPATTR, mAttributeLength=%ld\n", diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp index 3746be107aa..b8a0a5bf752 100644 --- a/widget/src/windows/nsWindow.cpp +++ b/widget/src/windows/nsWindow.cpp @@ -2527,7 +2527,7 @@ void nsWindow::UpdateOpaqueRegion(const nsIntRegion &aOpaqueRegion) if (mCustomNonClient) { // The minimum glass height must be the caption buttons height, // otherwise the buttons are drawn incorrectly. - largest.y = PR_MAX(largest.y, + largest.y = NS_MAX(largest.y, nsUXThemeData::sCommandButtons[CMDBUTTONIDX_BUTTONBOX].cy); } margins.cyTopHeight = largest.y; @@ -3370,7 +3370,7 @@ nsWindow::OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta, // on the document of SystemParametersInfo in MSDN. const PRUint32 kSystemDefaultScrollingSpeed = 3; - PRInt32 absOriginDelta = PR_ABS(aOriginalDelta); + PRInt32 absOriginDelta = NS_ABS(aOriginalDelta); // Compute the simple overridden speed. PRInt32 absComputedOverriddenDelta; @@ -3428,7 +3428,7 @@ nsWindow::OverrideSystemMouseScrollSpeed(PRInt32 aOriginalDelta, } absComputedOverriddenDelta = - PR_MIN(absComputedOverriddenDelta, absDeltaLimit); + NS_MIN(absComputedOverriddenDelta, absDeltaLimit); aOverriddenDelta = (aOriginalDelta > 0) ? absComputedOverriddenDelta : -absComputedOverriddenDelta; @@ -6937,8 +6937,8 @@ LRESULT nsWindow::OnKeyDown(const MSG &aMsg, } if (numOfUniChars > 0 || numOfShiftedChars > 0 || numOfUnshiftedChars > 0) { - PRUint32 num = PR_MAX(numOfUniChars, - PR_MAX(numOfShiftedChars, numOfUnshiftedChars)); + PRUint32 num = NS_MAX(numOfUniChars, + NS_MAX(numOfShiftedChars, numOfUnshiftedChars)); PRUint32 skipUniChars = num - numOfUniChars; PRUint32 skipShiftedChars = num - numOfShiftedChars; PRUint32 skipUnshiftedChars = num - numOfUnshiftedChars; diff --git a/xpcom/string/src/nsUTF8UtilsSSE2.cpp b/xpcom/string/src/nsUTF8UtilsSSE2.cpp index b4493e26261..69811716257 100644 --- a/xpcom/string/src/nsUTF8UtilsSSE2.cpp +++ b/xpcom/string/src/nsUTF8UtilsSSE2.cpp @@ -1,4 +1,5 @@ #include "nscore.h" +#include "nsAlgorithm.h" #include #include @@ -11,7 +12,7 @@ LossyConvertEncoding16to8::write_sse2(const PRUnichar* aSource, // Align source to a 16-byte boundary. PRUint32 i = 0; PRUint32 alignLen = - PR_MIN(aSourceLength, (-NS_PTR_TO_UINT32(aSource) & 0xf) / sizeof(PRUnichar)); + NS_MIN(aSourceLength, PRUint32(-NS_PTR_TO_INT32(aSource) & 0xf) / sizeof(PRUnichar)); for (; i < alignLen; i++) { dest[i] = static_cast(aSource[i]); } @@ -64,7 +65,7 @@ LossyConvertEncoding8to16::write_sse2(const char* aSource, // to wait for a load to complete, but you can keep on moving after issuing a // store. PRUint32 i = 0; - PRUint32 alignLen = PR_MIN(aSourceLength, (-NS_PTR_TO_UINT32(aSource) & 0xf)); + PRUint32 alignLen = NS_MIN(aSourceLength, PRUint32(-NS_PTR_TO_INT32(aSource) & 0xf)); for (; i < alignLen; i++) { dest[i] = static_cast(aSource[i]); }