Bug 817574 - Replace NS_ABS with std::abs. r=roc

This commit is contained in:
Mats Palmgren 2012-12-04 13:33:33 +01:00
parent bc01553001
commit 60ccae9fe3
22 changed files with 91 additions and 59 deletions

View File

@ -97,6 +97,8 @@
#include "nsHTMLImageElement.h"
#include "nsHTMLVideoElement.h"
#include "mozilla/dom/CanvasRenderingContext2DBinding.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
#ifdef XP_WIN
#include "gfxWindowsPlatform.h"
@ -3739,8 +3741,8 @@ CanvasRenderingContext2D::CreateImageData(JSContext* cx, double sw,
int32_t wi = JS_DoubleToInt32(sw);
int32_t hi = JS_DoubleToInt32(sh);
uint32_t w = NS_ABS(wi);
uint32_t h = NS_ABS(hi);
uint32_t w = std::abs(wi);
uint32_t h = std::abs(hi);
return mozilla::dom::CreateImageData(cx, this, w, h, error);
}

View File

@ -100,6 +100,8 @@
#include "sampler.h"
#include "nsIDOMClientRect.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
#ifdef XP_MACOSX
#import <ApplicationServices/ApplicationServices.h>
@ -2070,8 +2072,8 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
// fire drag gesture if mouse has moved enough
nsIntPoint pt = aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();
if (NS_ABS(pt.x - mGestureDownPoint.x) > pixelThresholdX ||
NS_ABS(pt.y - mGestureDownPoint.y) > pixelThresholdY) {
if (std::abs(pt.x - mGestureDownPoint.x) > pixelThresholdX ||
std::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
@ -2895,14 +2897,14 @@ nsEventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
nsIntSize devPixelPageSize(pc->AppUnitsToDevPixels(pageSize.width),
pc->AppUnitsToDevPixels(pageSize.height));
if (!WheelPrefs::GetInstance()->IsOverOnePageScrollAllowedX(aEvent) &&
NS_ABS(actualDevPixelScrollAmount.x) > devPixelPageSize.width) {
std::abs(actualDevPixelScrollAmount.x) > devPixelPageSize.width) {
actualDevPixelScrollAmount.x =
(actualDevPixelScrollAmount.x >= 0) ? devPixelPageSize.width :
-devPixelPageSize.width;
}
if (!WheelPrefs::GetInstance()->IsOverOnePageScrollAllowedY(aEvent) &&
NS_ABS(actualDevPixelScrollAmount.y) > devPixelPageSize.height) {
std::abs(actualDevPixelScrollAmount.y) > devPixelPageSize.height) {
actualDevPixelScrollAmount.y =
(actualDevPixelScrollAmount.y >= 0) ? devPixelPageSize.height :
-devPixelPageSize.height;
@ -5556,7 +5558,7 @@ nsEventStateManager::WheelPrefs::IsOverOnePageScrollAllowedX(
{
Index index = GetIndexFor(aEvent);
Init(index);
return NS_ABS(mMultiplierX[index]) >=
return std::abs(mMultiplierX[index]) >=
MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL;
}
@ -5566,6 +5568,6 @@ nsEventStateManager::WheelPrefs::IsOverOnePageScrollAllowedY(
{
Index index = GetIndexFor(aEvent);
Init(index);
return NS_ABS(mMultiplierY[index]) >=
return std::abs(mMultiplierY[index]) >=
MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL;
}

View File

@ -72,6 +72,8 @@
#include "ImageContainer.h"
#include "nsIPowerManagerService.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
#ifdef MOZ_OGG
#include "OggDecoder.h"
@ -3364,10 +3366,10 @@ static double ClampPlaybackRate(double aPlaybackRate)
if (aPlaybackRate == 0.0) {
return aPlaybackRate;
}
if (NS_ABS(aPlaybackRate) < MIN_PLAYBACKRATE) {
if (std::abs(aPlaybackRate) < MIN_PLAYBACKRATE) {
return aPlaybackRate < 0 ? -MIN_PLAYBACKRATE : MIN_PLAYBACKRATE;
}
if (NS_ABS(aPlaybackRate) > MAX_PLAYBACKRATE) {
if (std::abs(aPlaybackRate) > MAX_PLAYBACKRATE) {
return aPlaybackRate < 0 ? -MAX_PLAYBACKRATE : MAX_PLAYBACKRATE;
}
return aPlaybackRate;

View File

@ -20,6 +20,8 @@
#include "MediaResource.h"
#include "nsError.h"
#include "mozilla/Preferences.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
using namespace mozilla::layers;
using namespace mozilla::dom;
@ -561,11 +563,11 @@ nsresult MediaDecoder::Seek(double aTime)
NS_ENSURE_SUCCESS(res, NS_OK);
res = seekable.Start(range + 1, &rightBound);
NS_ENSURE_SUCCESS(res, NS_OK);
double distanceLeft = NS_ABS(leftBound - aTime);
double distanceRight = NS_ABS(rightBound - aTime);
double distanceLeft = std::abs(leftBound - aTime);
double distanceRight = std::abs(rightBound - aTime);
if (distanceLeft == distanceRight) {
distanceLeft = NS_ABS(leftBound - mCurrentTime);
distanceRight = NS_ABS(rightBound - mCurrentTime);
distanceLeft = std::abs(leftBound - mCurrentTime);
distanceRight = std::abs(rightBound - mCurrentTime);
}
aTime = (distanceLeft < distanceRight) ? leftBound : rightBound;
} else {

View File

@ -34,7 +34,8 @@
// For calculating max history entries and max cachable contentviewers
#include "nspr.h"
#include <math.h> // for log()
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double), and std::log(double)
using namespace mozilla;
@ -310,7 +311,7 @@ nsSHistory::CalcMaxTotalViewers()
// except that we divide the final memory calculation by 4, since
// we assume each ContentViewer takes on average 4MB
uint32_t viewers = 0;
double x = log(kBytesD)/log(2.0) - 14;
double x = std::log(kBytesD)/std::log(2.0) - 14;
if (x > 0) {
viewers = (uint32_t)(x * x - x + 2.001); // add .001 for rounding
viewers /= 4;
@ -1088,7 +1089,7 @@ nsSHistory::GloballyEvictContentViewers()
TransactionAndDistance &container = shTransactions[j];
if (container.mViewer == contentViewer) {
container.mDistance = NS_MIN(container.mDistance,
NS_ABS(i - shist->mIndex));
std::abs(i - shist->mIndex));
found = true;
break;
}
@ -1097,7 +1098,7 @@ nsSHistory::GloballyEvictContentViewers()
// If we didn't find a TransactionAndDistance for this content viewer, make a new
// one.
if (!found) {
TransactionAndDistance container(trans, NS_ABS(i - shist->mIndex));
TransactionAndDistance container(trans, std::abs(i - shist->mIndex));
shTransactions.AppendElement(container);
}
}

View File

@ -55,6 +55,8 @@
#include "nsThreadUtils.h"
#include "nsUnicharUtils.h"
#include "nsWSRunObject.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
class nsISupports;
class nsRulesInfo;
@ -1926,7 +1928,7 @@ nsHTMLEditRules::WillDeleteSelection(Selection* aSelection,
res = nsWSRunObject::PrepareToDeleteRange(mHTMLEditor, address_of(visNode), &so, address_of(visNode), &eo);
NS_ENSURE_SUCCESS(res, res);
nsCOMPtr<nsIDOMCharacterData> nodeAsText(do_QueryInterface(visNode));
res = mHTMLEditor->DeleteText(nodeAsText, NS_MIN(so, eo), NS_ABS(eo - so));
res = mHTMLEditor->DeleteText(nodeAsText, NS_MIN(so, eo), std::abs(eo - so));
*aHandled = true;
NS_ENSURE_SUCCESS(res, res);
res = InsertBRIfNeeded(aSelection);

View File

@ -42,6 +42,8 @@
#include "nsStringFwd.h"
#include "nsSubstringTuple.h"
#include "nscore.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
class nsISelection;
@ -873,8 +875,8 @@ nsHTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent)
int32_t yThreshold =
LookAndFeel::GetInt(LookAndFeel::eIntID_DragThresholdY, 1);
if (NS_ABS(clientX - mOriginalX ) * 2 >= xThreshold ||
NS_ABS(clientY - mOriginalY ) * 2 >= yThreshold) {
if (std::abs(clientX - mOriginalX ) * 2 >= xThreshold ||
std::abs(clientY - mOriginalY ) * 2 >= yThreshold) {
mGrabberClicked = false;
StartMoving(nullptr);
}

View File

@ -7,6 +7,8 @@
#include "gfxImageSurface.h"
#include "sampler.h"
#include "gfxPlatform.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
#ifdef GFX_TILEDLAYER_DEBUG_OVERLAY
#include "cairo.h"
@ -361,7 +363,7 @@ BasicTiledThebesLayer::ComputeProgressiveUpdateRegion(BasicTiledLayerBuffer& aTi
if (!aRegionToPaint.IsEmpty()) {
break;
}
if (NS_ABS(scrollDiffY) >= NS_ABS(scrollDiffX)) {
if (std::abs(scrollDiffY) >= std::abs(scrollDiffX)) {
tileBounds.x += incX;
} else {
tileBounds.y += incY;

View File

@ -46,6 +46,8 @@
#include "sampler.h"
#include <algorithm>
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
using namespace mozilla;
using namespace mozilla::gfx;
@ -2774,8 +2776,8 @@ gfxFont::InitMetricsFromSfntTables(Metrics& aMetrics)
uint16_t(os2->version) >= 2) {
// version 2 and later includes the x-height field
SET_SIGNED(xHeight, os2->sxHeight);
// NS_ABS because of negative xHeight seen in Kokonor (Tibetan) font
aMetrics.xHeight = NS_ABS(aMetrics.xHeight);
// std::abs because of negative xHeight seen in Kokonor (Tibetan) font
aMetrics.xHeight = std::abs(aMetrics.xHeight);
}
// this should always be present
if (os2data.Length() >= offsetof(OS2Table, yStrikeoutPosition) +

View File

@ -9,13 +9,15 @@
#define __nsCSSColorUtils_h
#include "nsColor.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
// "Sufficient contrast" is determined by
// "Techniques For Accessibility Evalution And Repair Tools".
// See http://www.w3.org/TR/AERT#color-contrast
#define NS_SUFFICIENT_LUMINOSITY_DIFFERENCE 125000
#define NS_LUMINOSITY_DIFFERENCE(a, b) \
NS_ABS(NS_GetLuminosity(a) - NS_GetLuminosity(b))
std::abs(NS_GetLuminosity(a) - NS_GetLuminosity(b))
// To determine colors based on the background brightness and border color
void NS_GetSpecial3DColors(nscolor aResult[2],

View File

@ -51,6 +51,8 @@
#include "mozilla/Telemetry.h"
#include "mozilla/Types.h"
#include <ctime>
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
using namespace mozilla;
using namespace mozilla::css;
@ -1969,10 +1971,10 @@ ComputeRadialGradientLine(nsPresContext* aPresContext,
// Compute gradient shape: the x and y radii of an ellipse.
double radiusX, radiusY;
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);
double leftDistance = std::abs(aLineStart->x);
double rightDistance = std::abs(aBoxSize.width - aLineStart->x);
double topDistance = std::abs(aLineStart->y);
double bottomDistance = std::abs(aBoxSize.height - aLineStart->y);
switch (aGradient->mSize) {
case NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE:
radiusX = NS_MIN(leftDistance, rightDistance);

View File

@ -75,6 +75,8 @@
#include "mozilla/Likely.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/Util.h" // for DebugOnly
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
#include "sampler.h"
@ -5585,7 +5587,7 @@ nsTextFrame::PaintTextSelectionDecorations(gfxContext* aCtx,
if (type == aSelectionType) {
pt.x = (aFramePt.x + xOffset -
(mTextRun->IsRightToLeft() ? advance : 0)) / app;
gfxFloat width = NS_ABS(advance) / app;
gfxFloat width = std::abs(advance) / app;
gfxFloat xInFrame = pt.x - (aFramePt.x / app);
DrawSelectionDecorations(aCtx, dirtyRect, aSelectionType, this,
aTextPaintStyle, selectedStyle, pt, xInFrame,

View File

@ -30,6 +30,8 @@
#include "nsMathMLOperators.h"
#include "nsMathMLChar.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
using namespace mozilla;
@ -744,7 +746,7 @@ IsSizeOK(nsPresContext* aPresContext, nscoord a, nscoord b, uint32_t aHint)
// or in sloppy markups without protective <mrow></mrow>
bool isNormal =
(aHint & NS_STRETCH_NORMAL)
&& bool(float(NS_ABS(a - b))
&& bool(float(std::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.
@ -754,7 +756,7 @@ IsSizeOK(nsPresContext* aPresContext, nscoord a, nscoord b, uint32_t aHint)
float c = NS_MAX(float(b) * NS_MATHML_DELIMITER_FACTOR,
float(b) - nsPresContext::
CSSPointsToAppUnits(NS_MATHML_DELIMITER_SHORTFALL_POINTS));
isNearer = bool(float(NS_ABS(b - a)) <= (float(b) - c));
isNearer = bool(float(std::abs(b - a)) <= (float(b) - c));
}
// Smaller: Mainly for transitory use, to compare two candidate
// choices
@ -781,7 +783,7 @@ IsSizeBetter(nscoord a, nscoord olda, nscoord b, uint32_t 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 NS_ABS(a - b) < NS_ABS(olda - b);
return std::abs(a - b) < std::abs(olda - b);
}
// We want to place the glyphs even when they don't fit at their

View File

@ -22,10 +22,11 @@
#include "mozilla/FloatingPoint.h"
#include "mozilla/Likely.h"
#include "prlog.h"
#include <math.h>
#include "gfxMatrix.h"
#include "gfxQuaternion.h"
#include "nsPrintfCString.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
using namespace mozilla;
@ -383,7 +384,7 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty,
// just like eUnit_Integer.
int32_t startInt = aStartValue.GetIntValue();
int32_t endInt = aEndValue.GetIntValue();
aDistance = NS_ABS(endInt - startInt);
aDistance = std::abs(endInt - startInt);
return true;
}
default:
@ -394,13 +395,13 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty,
aStartValue.GetIntValue() == NS_STYLE_VISIBILITY_VISIBLE;
int32_t endVal =
aEndValue.GetIntValue() == NS_STYLE_VISIBILITY_VISIBLE;
aDistance = NS_ABS(startVal - endVal);
aDistance = std::abs(startVal - endVal);
return true;
}
case eUnit_Integer: {
int32_t startInt = aStartValue.GetIntValue();
int32_t endInt = aEndValue.GetIntValue();
aDistance = NS_ABS(endInt - startInt);
aDistance = std::abs(endInt - startInt);
return true;
}
case eUnit_Coord: {
@ -1293,7 +1294,7 @@ Decompose2DMatrix(const gfxMatrix &aMatrix, gfxPoint3D &aScale,
XYshear /= scaleY;
// A*D - B*C should now be 1 or -1
NS_ASSERTION(0.99 < NS_ABS(A*D - B*C) && NS_ABS(A*D - B*C) < 1.01,
NS_ASSERTION(0.99 < std::abs(A*D - B*C) && std::abs(A*D - B*C) < 1.01,
"determinant should now be 1 or -1");
if (A * D < B * C) {
A = -A;

View File

@ -39,6 +39,8 @@
#include "nsIScrollableFrame.h"
#include "nsCSSProps.h"
#include "mozilla/Likely.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
using namespace mozilla;
using namespace mozilla::layout;
@ -6362,7 +6364,7 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect)
if (!haveIntersect)
return false;
mDamageArea = nsIntRect(startColIndex, startRowIndex,
1 + NS_ABS(int32_t(endColIndex - startColIndex)),
1 + std::abs(int32_t(endColIndex - startColIndex)),
1 + endRowIndex - startRowIndex);
Reset();

View File

@ -60,6 +60,8 @@
#include "mozilla/Likely.h"
#include "mozilla/Util.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
#ifdef ACCESSIBILITY
#include "nsAccessibilityService.h"
@ -1822,7 +1824,7 @@ nsTreeBodyFrame::RowCountChanged(int32_t aIndex, int32_t aCount)
NS_ASSERTION(rowCount == mRowCount, "row count did not change by the amount suggested, check caller");
#endif
int32_t count = NS_ABS(aCount);
int32_t count = std::abs(aCount);
int32_t last = GetLastVisibleRow();
if (aIndex >= mTopRowIndex && aIndex <= last)
InvalidateRange(aIndex, last);

View File

@ -14,6 +14,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <gdk/gdk.h>
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
using namespace mozilla;
using namespace mozilla::widget;
@ -98,7 +100,7 @@ delete_from_cursor_cb(GtkWidget *w, GtkDeleteType del_type,
if (!cmd)
return; // unsupported command
count = NS_ABS(count);
count = std::abs(count);
for (int i = 0; i < count; ++i) {
gCurrentCallback(cmd, gCurrentCallbackData);
}
@ -168,7 +170,7 @@ move_cursor_cb(GtkWidget *w, GtkMovementStep step, gint count,
return; // unsupported command
count = NS_ABS(count);
count = std::abs(count);
for (int i = 0; i < count; ++i) {
gCurrentCallback(cmd, gCurrentCallbackData);
}

View File

@ -28,6 +28,8 @@
#include "nsIVariant.h"
#include "nsStyleConsts.h"
#include "nsAutoPtr.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
namespace mozilla {
namespace dom {
@ -1254,7 +1256,7 @@ public:
(lineOrPageDeltaX > 0 && lineOrPageDeltaY < 0)) {
return 0; // We cannot guess the answer in this case.
}
return (NS_ABS(lineOrPageDeltaX) > NS_ABS(lineOrPageDeltaY)) ?
return (std::abs(lineOrPageDeltaX) > std::abs(lineOrPageDeltaY)) ?
lineOrPageDeltaX : lineOrPageDeltaY;
}

View File

@ -118,6 +118,8 @@
#include "WidgetUtils.h"
#include "nsIWidgetListener.h"
#include "nsDOMTouchEvent.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
#ifdef MOZ_ENABLE_D3D9_LAYER
#include "LayerManagerD3D9.h"
@ -3433,7 +3435,7 @@ nsWindow::OverrideSystemMouseScrollSpeed(int32_t aOriginalDelta,
// on the document of SystemParametersInfo in MSDN.
const uint32_t kSystemDefaultScrollingSpeed = 3;
int32_t absOriginDelta = NS_ABS(aOriginalDelta);
int32_t absOriginDelta = std::abs(aOriginalDelta);
// Compute the simple overridden speed.
int32_t absComputedOverriddenDelta;
@ -6337,10 +6339,10 @@ bool nsWindow::OnGesture(WPARAM wParam, LPARAM lParam)
if (mDisplayPanFeedback) {
mGesture.UpdatePanFeedbackX(mWnd,
NS_ABS(RoundDown(wheelEvent.overflowDeltaX)),
std::abs(RoundDown(wheelEvent.overflowDeltaX)),
endFeedback);
mGesture.UpdatePanFeedbackY(mWnd,
NS_ABS(RoundDown(wheelEvent.overflowDeltaY)),
std::abs(RoundDown(wheelEvent.overflowDeltaY)),
endFeedback);
mGesture.PanFeedbackFinalize(mWnd, endFeedback);
}

View File

@ -19,6 +19,8 @@
#include "nsIClassInfoImpl.h"
#include "nsIIPCSerializableInputStream.h"
#include "mozilla/ipc/InputStreamUtils.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
using namespace mozilla::ipc;
@ -509,7 +511,7 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
}
// See if we have enough data in the current stream.
if (NS_ABS(remaining) < streamPos) {
if (std::abs(remaining) < streamPos) {
rv = stream->Seek(NS_SEEK_END, remaining);
NS_ENSURE_SUCCESS(rv, rv);
@ -517,7 +519,7 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
mStartedReadingCurrent = true;
remaining = 0;
} else if (NS_ABS(remaining) > streamPos) {
} else if (std::abs(remaining) > streamPos) {
if (i > oldCurrentStream ||
(i == oldCurrentStream && !oldStartedReadingCurrent)) {
// We're already at start so no need to seek this stream
@ -527,7 +529,7 @@ nsMultiplexInputStream::Seek(int32_t aWhence, int64_t aOffset)
rv = stream->Tell(&avail);
NS_ENSURE_SUCCESS(rv, rv);
int64_t newPos = streamPos + NS_MIN(avail, NS_ABS(remaining));
int64_t newPos = streamPos + NS_MIN(avail, std::abs(remaining));
rv = stream->Seek(NS_SEEK_END, -newPos);
NS_ENSURE_SUCCESS(rv, rv);

View File

@ -55,14 +55,6 @@ clamped( const T& a, const T& min, const T& max )
}
template <class T>
inline
T
NS_ABS( const T& a )
{
return a < 0 ? -a : a;
}
template <class InputIterator, class T>
inline
uint32_t

View File

@ -55,6 +55,8 @@
#include "prenv.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Element.h"
#include <cstdlib> // for std::abs(int/long)
#include <cmath> // for std::abs(float/double)
using namespace mozilla;
@ -1338,8 +1340,8 @@ void nsXULWindow::StaggerPosition(int32_t &aRequestedX, int32_t &aRequestedY,
listY = NSToIntRound(listY / scale);
}
if (NS_ABS(listX - aRequestedX) <= kSlop &&
NS_ABS(listY - aRequestedY) <= kSlop) {
if (std::abs(listX - aRequestedX) <= kSlop &&
std::abs(listY - aRequestedY) <= kSlop) {
// collision! offset and start over
if (bouncedX & 0x1)
aRequestedX -= kOffset;