Skip to content

Commit

Permalink
Bug 847480 - Convert DeprecatedAbs overloads taking floating point (e…
Browse files Browse the repository at this point in the history
…xcept for nscoord uses, when nscoord is optionally a floating point type) to Abs. r=Ms2ger
  • Loading branch information
jswalden committed Mar 5, 2013
1 parent c3efd26 commit f915a6c
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 49 deletions.
8 changes: 4 additions & 4 deletions content/events/src/nsEventStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5590,8 +5590,8 @@ nsEventStateManager::WheelPrefs::ComputeActionFor(widget::WheelEvent* aEvent)
Init(index);

bool deltaXPreferred =
(DeprecatedAbs(aEvent->deltaX) > DeprecatedAbs(aEvent->deltaY) &&
DeprecatedAbs(aEvent->deltaX) > DeprecatedAbs(aEvent->deltaZ));
(Abs(aEvent->deltaX) > Abs(aEvent->deltaY) &&
Abs(aEvent->deltaX) > Abs(aEvent->deltaZ));
Action* actions = deltaXPreferred ? mOverriddenActionsX : mActions;
if (actions[index] == ACTION_NONE || actions[index] == ACTION_SCROLL) {
return actions[index];
Expand Down Expand Up @@ -5625,7 +5625,7 @@ nsEventStateManager::WheelPrefs::IsOverOnePageScrollAllowedX(
{
Index index = GetIndexFor(aEvent);
Init(index);
return DeprecatedAbs(mMultiplierX[index]) >=
return Abs(mMultiplierX[index]) >=
MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL;
}

Expand All @@ -5635,6 +5635,6 @@ nsEventStateManager::WheelPrefs::IsOverOnePageScrollAllowedY(
{
Index index = GetIndexFor(aEvent);
Init(index);
return DeprecatedAbs(mMultiplierY[index]) >=
return Abs(mMultiplierY[index]) >=
MIN_MULTIPLIER_VALUE_ALLOWING_OVER_ONE_PAGE_SCROLL;
}
4 changes: 2 additions & 2 deletions content/html/content/src/nsHTMLMediaElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3382,10 +3382,10 @@ static double ClampPlaybackRate(double aPlaybackRate)
if (aPlaybackRate == 0.0) {
return aPlaybackRate;
}
if (DeprecatedAbs(aPlaybackRate) < MIN_PLAYBACKRATE) {
if (Abs(aPlaybackRate) < MIN_PLAYBACKRATE) {
return aPlaybackRate < 0 ? -MIN_PLAYBACKRATE : MIN_PLAYBACKRATE;
}
if (DeprecatedAbs(aPlaybackRate) > MAX_PLAYBACKRATE) {
if (Abs(aPlaybackRate) > MAX_PLAYBACKRATE) {
return aPlaybackRate < 0 ? -MAX_PLAYBACKRATE : MAX_PLAYBACKRATE;
}
return aPlaybackRate;
Expand Down
8 changes: 4 additions & 4 deletions content/media/MediaDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,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 = DeprecatedAbs(leftBound - aTime);
double distanceRight = DeprecatedAbs(rightBound - aTime);
double distanceLeft = Abs(leftBound - aTime);
double distanceRight = Abs(rightBound - aTime);
if (distanceLeft == distanceRight) {
distanceLeft = DeprecatedAbs(leftBound - mCurrentTime);
distanceRight = DeprecatedAbs(rightBound - mCurrentTime);
distanceLeft = Abs(leftBound - mCurrentTime);
distanceRight = Abs(rightBound - mCurrentTime);
}
aTime = (distanceLeft < distanceRight) ? leftBound : rightBound;
} else {
Expand Down
4 changes: 2 additions & 2 deletions gfx/thebes/gfxFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2966,8 +2966,8 @@ gfxFont::InitMetricsFromSfntTables(Metrics& aMetrics)
uint16_t(os2->version) >= 2) {
// version 2 and later includes the x-height field
SET_SIGNED(xHeight, os2->sxHeight);
// DeprecatedAbs because of negative xHeight seen in Kokonor (Tibetan) font
aMetrics.xHeight = DeprecatedAbs(aMetrics.xHeight);
// Abs because of negative xHeight seen in Kokonor (Tibetan) font
aMetrics.xHeight = Abs(aMetrics.xHeight);
}
// this should always be present
if (os2data.Length() >= offsetof(OS2Table, yStrikeoutPosition) +
Expand Down
4 changes: 2 additions & 2 deletions js/src/jsmath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

using namespace js;

using mozilla::DeprecatedAbs;
using mozilla::Abs;

#ifndef M_E
#define M_E 2.7182818284590452354
Expand Down Expand Up @@ -105,7 +105,7 @@ js_math_abs(JSContext *cx, unsigned argc, Value *vp)
}
if (!ToNumber(cx, vp[2], &x))
return JS_FALSE;
z = DeprecatedAbs(x);
z = Abs(x);
vp->setNumber(z);
return JS_TRUE;
}
Expand Down
2 changes: 1 addition & 1 deletion js/src/prmjtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ PRMJ_Now(void)
itself, but I have only seen it triggered by another program
doing some kind of file I/O. The symptoms are a negative diff
followed by an equally large positive diff. */
if (mozilla::DeprecatedAbs(diff) > 2 * skewThreshold) {
if (mozilla::Abs(diff) > 2 * skewThreshold) {
/*fprintf(stderr,"Clock skew detected (diff = %f)!\n", diff);*/

if (calibrated) {
Expand Down
2 changes: 1 addition & 1 deletion js/src/vm/DateTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ inline double
TimeClip(double time)
{
/* Steps 1-2. */
if (!MOZ_DOUBLE_IS_FINITE(time) || mozilla::DeprecatedAbs(time) > 8.64e15)
if (!MOZ_DOUBLE_IS_FINITE(time) || mozilla::Abs(time) > 8.64e15)
return js_NaN;

/* Step 3. */
Expand Down
8 changes: 4 additions & 4 deletions layout/base/nsCSSRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1984,10 +1984,10 @@ ComputeRadialGradientLine(nsPresContext* aPresContext,

// Compute gradient shape: the x and y radii of an ellipse.
double radiusX, radiusY;
double leftDistance = DeprecatedAbs(aLineStart->x);
double rightDistance = DeprecatedAbs(aBoxSize.width - aLineStart->x);
double topDistance = DeprecatedAbs(aLineStart->y);
double bottomDistance = DeprecatedAbs(aBoxSize.height - aLineStart->y);
double leftDistance = Abs(aLineStart->x);
double rightDistance = Abs(aBoxSize.width - aLineStart->x);
double topDistance = Abs(aLineStart->y);
double bottomDistance = Abs(aBoxSize.height - aLineStart->y);
switch (aGradient->mSize) {
case NS_STYLE_GRADIENT_SIZE_CLOSEST_SIDE:
radiusX = std::min(leftDistance, rightDistance);
Expand Down
2 changes: 1 addition & 1 deletion layout/generic/nsTextFrameThebes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5646,7 +5646,7 @@ nsTextFrame::PaintTextSelectionDecorations(gfxContext* aCtx,
if (type == aSelectionType) {
pt.x = (aFramePt.x + xOffset -
(mTextRun->IsRightToLeft() ? advance : 0)) / app;
gfxFloat width = DeprecatedAbs(advance) / app;
gfxFloat width = Abs(advance) / app;
gfxFloat xInFrame = pt.x - (aFramePt.x / app);
DrawSelectionDecorations(aCtx, dirtyRect, aSelectionType, this,
aTextPaintStyle, selectedStyle, pt, xInFrame,
Expand Down
8 changes: 4 additions & 4 deletions layout/style/nsStyleAnimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,13 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty,
case eUnit_Coord: {
nscoord startCoord = aStartValue.GetCoordValue();
nscoord endCoord = aEndValue.GetCoordValue();
aDistance = DeprecatedAbs<double>(endCoord - startCoord);
aDistance = Abs(double(endCoord) - double(startCoord));
return true;
}
case eUnit_Percent: {
float startPct = aStartValue.GetPercentValue();
float endPct = aEndValue.GetPercentValue();
aDistance = DeprecatedAbs<double>(endPct - startPct);
aDistance = Abs(double(endPct) - double(startPct));
return true;
}
case eUnit_Float: {
Expand All @@ -434,7 +434,7 @@ nsStyleAnimation::ComputeDistance(nsCSSProperty aProperty,

float startFloat = aStartValue.GetFloatValue();
float endFloat = aEndValue.GetFloatValue();
aDistance = DeprecatedAbs<double>(endFloat - startFloat);
aDistance = Abs(double(endFloat) - double(startFloat));
return true;
}
case eUnit_Color: {
Expand Down Expand Up @@ -1297,7 +1297,7 @@ Decompose2DMatrix(const gfxMatrix &aMatrix, gfxPoint3D &aScale,
XYshear /= scaleY;

// A*D - B*C should now be 1 or -1
NS_ASSERTION(0.99 < DeprecatedAbs(A*D - B*C) && DeprecatedAbs(A*D - B*C) < 1.01,
NS_ASSERTION(0.99 < Abs(A*D - B*C) && Abs(A*D - B*C) < 1.01,
"determinant should now be 1 or -1");
if (A * D < B * C) {
A = -A;
Expand Down
24 changes: 0 additions & 24 deletions mfbt/MathAlgorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ template<> struct AllowDeprecatedAbs<short> : TrueType {};
template<> struct AllowDeprecatedAbs<int> : TrueType {};
template<> struct AllowDeprecatedAbs<long> : TrueType {};
template<> struct AllowDeprecatedAbs<long long> : TrueType {};
template<> struct AllowDeprecatedAbs<float> : TrueType {};
template<> struct AllowDeprecatedAbs<double> : TrueType {};
template<> struct AllowDeprecatedAbs<long double> : TrueType {};

} // namespace detail

Expand All @@ -93,27 +90,6 @@ DeprecatedAbs(const T t)
return t >= 0 ? t : -t;
}

template<>
inline float
DeprecatedAbs<float>(const float f)
{
return fabsf(f);
}

template<>
inline double
DeprecatedAbs<double>(const double d)
{
return fabs(d);
}

template<>
inline long double
DeprecatedAbs<long double>(const long double d)
{
return fabsl(d);
}

namespace detail {

// For now mozilla::Abs only takes intN_T, the signed natural types, and
Expand Down

0 comments on commit f915a6c

Please sign in to comment.