Skip to content

Commit

Permalink
Bug 847480 - Blindly convert all existing mozilla::Abs users to mozil…
Browse files Browse the repository at this point in the history
…la::DeprecatedAbs. Individualized conversions to the reformed mozilla::Abs will continue until mozilla::DeprecatedAbs is unused, at which point it will be removed. r=Ms2ger
  • Loading branch information
jswalden committed Mar 5, 2013
1 parent cb19ca3 commit 5ec763f
Show file tree
Hide file tree
Showing 31 changed files with 79 additions and 79 deletions.
4 changes: 2 additions & 2 deletions content/canvas/src/CanvasRenderingContext2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3716,8 +3716,8 @@ CanvasRenderingContext2D::CreateImageData(JSContext* cx, double sw,
int32_t wi = JS_DoubleToInt32(sw);
int32_t hi = JS_DoubleToInt32(sh);

uint32_t w = Abs(wi);
uint32_t h = Abs(hi);
uint32_t w = DeprecatedAbs(wi);
uint32_t h = DeprecatedAbs(hi);
return mozilla::dom::CreateImageData(cx, this, w, h, error);
}

Expand Down
16 changes: 8 additions & 8 deletions content/events/src/nsEventStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2052,8 +2052,8 @@ nsEventStateManager::GenerateDragGesture(nsPresContext* aPresContext,

// fire drag gesture if mouse has moved enough
nsIntPoint pt = aEvent->refPoint + aEvent->widget->WidgetToScreenOffset();
if (Abs(pt.x - mGestureDownPoint.x) > pixelThresholdX ||
Abs(pt.y - mGestureDownPoint.y) > pixelThresholdY) {
if (DeprecatedAbs(pt.x - mGestureDownPoint.x) > pixelThresholdX ||
DeprecatedAbs(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
Expand Down Expand Up @@ -2880,14 +2880,14 @@ nsEventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame,
nsIntSize devPixelPageSize(pc->AppUnitsToDevPixels(pageSize.width),
pc->AppUnitsToDevPixels(pageSize.height));
if (!WheelPrefs::GetInstance()->IsOverOnePageScrollAllowedX(aEvent) &&
Abs(actualDevPixelScrollAmount.x) > devPixelPageSize.width) {
DeprecatedAbs(actualDevPixelScrollAmount.x) > devPixelPageSize.width) {
actualDevPixelScrollAmount.x =
(actualDevPixelScrollAmount.x >= 0) ? devPixelPageSize.width :
-devPixelPageSize.width;
}

if (!WheelPrefs::GetInstance()->IsOverOnePageScrollAllowedY(aEvent) &&
Abs(actualDevPixelScrollAmount.y) > devPixelPageSize.height) {
DeprecatedAbs(actualDevPixelScrollAmount.y) > devPixelPageSize.height) {
actualDevPixelScrollAmount.y =
(actualDevPixelScrollAmount.y >= 0) ? devPixelPageSize.height :
-devPixelPageSize.height;
Expand Down Expand Up @@ -5590,8 +5590,8 @@ nsEventStateManager::WheelPrefs::ComputeActionFor(widget::WheelEvent* aEvent)
Init(index);

bool deltaXPreferred =
(Abs(aEvent->deltaX) > Abs(aEvent->deltaY) &&
Abs(aEvent->deltaX) > Abs(aEvent->deltaZ));
(DeprecatedAbs(aEvent->deltaX) > DeprecatedAbs(aEvent->deltaY) &&
DeprecatedAbs(aEvent->deltaX) > DeprecatedAbs(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 Abs(mMultiplierX[index]) >=
return DeprecatedAbs(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 Abs(mMultiplierY[index]) >=
return DeprecatedAbs(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 (Abs(aPlaybackRate) < MIN_PLAYBACKRATE) {
if (DeprecatedAbs(aPlaybackRate) < MIN_PLAYBACKRATE) {
return aPlaybackRate < 0 ? -MIN_PLAYBACKRATE : MIN_PLAYBACKRATE;
}
if (Abs(aPlaybackRate) > MAX_PLAYBACKRATE) {
if (DeprecatedAbs(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 = Abs(leftBound - aTime);
double distanceRight = Abs(rightBound - aTime);
double distanceLeft = DeprecatedAbs(leftBound - aTime);
double distanceRight = DeprecatedAbs(rightBound - aTime);
if (distanceLeft == distanceRight) {
distanceLeft = Abs(leftBound - mCurrentTime);
distanceRight = Abs(rightBound - mCurrentTime);
distanceLeft = DeprecatedAbs(leftBound - mCurrentTime);
distanceRight = DeprecatedAbs(rightBound - mCurrentTime);
}
aTime = (distanceLeft < distanceRight) ? leftBound : rightBound;
} else {
Expand Down
4 changes: 2 additions & 2 deletions docshell/shistory/src/nsSHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ nsSHistory::GloballyEvictContentViewers()
for (uint32_t j = 0; j < shTransactions.Length(); j++) {
TransactionAndDistance &container = shTransactions[j];
if (container.mViewer == contentViewer) {
container.mDistance = std::min(container.mDistance, Abs(i - shist->mIndex));
container.mDistance = std::min(container.mDistance, DeprecatedAbs(i - shist->mIndex));
found = true;
break;
}
Expand All @@ -1110,7 +1110,7 @@ nsSHistory::GloballyEvictContentViewers()
// If we didn't find a TransactionAndDistance for this content viewer, make a new
// one.
if (!found) {
TransactionAndDistance container(trans, Abs(i - shist->mIndex));
TransactionAndDistance container(trans, DeprecatedAbs(i - shist->mIndex));
shTransactions.AppendElement(container);
}
}
Expand Down
4 changes: 2 additions & 2 deletions editor/libeditor/html/nsHTMLEditRules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1936,7 +1936,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, std::min(so, eo), Abs(eo - so));
res = mHTMLEditor->DeleteText(nodeAsText, std::min(so, eo), DeprecatedAbs(eo - so));
*aHandled = true;
NS_ENSURE_SUCCESS(res, res);
res = InsertBRIfNeeded(aSelection);
Expand Down Expand Up @@ -4396,7 +4396,7 @@ nsHTMLEditRules::CreateStyleForInsertText(nsISelection *aSelection,
if (relFontSize) {
// dir indicated bigger versus smaller. 1 = bigger, -1 = smaller
int32_t dir = relFontSize > 0 ? 1 : -1;
for (int32_t j = 0; j < Abs(relFontSize); j++) {
for (int32_t j = 0; j < DeprecatedAbs(relFontSize); j++) {
res = mHTMLEditor->RelativeFontChangeOnTextNode(dir, nodeAsText,
0, -1);
NS_ENSURE_SUCCESS(res, res);
Expand Down
4 changes: 2 additions & 2 deletions editor/libeditor/html/nsHTMLObjectResizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -875,8 +875,8 @@ nsHTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent)
int32_t yThreshold =
LookAndFeel::GetInt(LookAndFeel::eIntID_DragThresholdY, 1);

if (Abs(clientX - mOriginalX) * 2 >= xThreshold ||
Abs(clientY - mOriginalY) * 2 >= yThreshold) {
if (DeprecatedAbs(clientX - mOriginalX) * 2 >= xThreshold ||
DeprecatedAbs(clientY - mOriginalY) * 2 >= yThreshold) {
mGrabberClicked = false;
StartMoving(nullptr);
}
Expand Down
2 changes: 1 addition & 1 deletion gfx/layers/basic/BasicTiledThebesLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ BasicTiledThebesLayer::ComputeProgressiveUpdateRegion(BasicTiledLayerBuffer& aTi
if (!aRegionToPaint.IsEmpty()) {
break;
}
if (Abs(scrollDiffY) >= Abs(scrollDiffX)) {
if (DeprecatedAbs(scrollDiffY) >= DeprecatedAbs(scrollDiffX)) {
tileBounds.x += incX;
} else {
tileBounds.y += incY;
Expand Down
6 changes: 3 additions & 3 deletions gfx/thebes/gfxFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ CalcStyleMatch(gfxFontEntry *aFontEntry, const gfxFontStyle *aStyle)
}

// measure of closeness of weight to the desired value
rank += 9 - Abs(aFontEntry->Weight() / 100 - aStyle->ComputeWeight());
rank += 9 - DeprecatedAbs(aFontEntry->Weight() / 100 - aStyle->ComputeWeight());
} else {
// if no font to match, prefer non-bold, non-italic fonts
if (!aFontEntry->IsItalic()) {
Expand Down 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);
// Abs because of negative xHeight seen in Kokonor (Tibetan) font
aMetrics.xHeight = Abs(aMetrics.xHeight);
// DeprecatedAbs because of negative xHeight seen in Kokonor (Tibetan) font
aMetrics.xHeight = DeprecatedAbs(aMetrics.xHeight);
}
// this should always be present
if (os2data.Length() >= offsetof(OS2Table, yStrikeoutPosition) +
Expand Down
8 changes: 4 additions & 4 deletions js/src/ion/RangeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using namespace js;
using namespace js::ion;

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

// This algorithm is based on the paper "Eliminating Range Checks Using
// Static Single Assignment Form" by Gough and Klaren.
Expand Down Expand Up @@ -672,7 +672,7 @@ MAbs::computeRange()
Range other(getOperand(0));

Range *range = new Range(0,
Max(Abs<int64_t>(other.lower()), Abs<int64_t>(other.upper())),
Max(DeprecatedAbs<int64_t>(other.lower()), DeprecatedAbs<int64_t>(other.upper())),
other.isDecimal(),
other.exponent());
setRange(range);
Expand Down Expand Up @@ -719,8 +719,8 @@ MMod::computeRange()
return;
Range lhs(getOperand(0));
Range rhs(getOperand(1));
int64_t a = Abs<int64_t>(rhs.lower());
int64_t b = Abs<int64_t>(rhs.upper());
int64_t a = DeprecatedAbs<int64_t>(rhs.lower());
int64_t b = DeprecatedAbs<int64_t>(rhs.upper());
if (a == 0 && b == 0)
return;
int64_t bound = Max(1-a, b-1);
Expand Down
4 changes: 2 additions & 2 deletions js/src/ion/RangeAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ class Range : public TempObject {
return;
}

uint32_t max = Max(mozilla::Abs<int64_t>(lower()),
mozilla::Abs<int64_t>(upper()));
uint32_t max = Max(mozilla::DeprecatedAbs<int64_t>(lower()),
mozilla::DeprecatedAbs<int64_t>(upper()));
JS_ASSERT_IF(lower() == JSVAL_INT_MIN, max == (uint32_t) JSVAL_INT_MIN);
JS_ASSERT(max <= (uint32_t) JSVAL_INT_MIN);
// The number of bits needed to encode |max| is the power of 2 plus one.
Expand Down
6 changes: 3 additions & 3 deletions js/src/ion/arm/Assembler-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ class DtrOffImm : public DtrOff
{
public:
DtrOffImm(int32_t imm)
: DtrOff(datastore::Imm12Data(mozilla::Abs(imm)), imm >= 0 ? IsUp : IsDown)
: DtrOff(datastore::Imm12Data(mozilla::DeprecatedAbs(imm)), imm >= 0 ? IsUp : IsDown)
{
JS_ASSERT((imm < 4096) && (imm > -4096));
}
Expand Down Expand Up @@ -790,7 +790,7 @@ class EDtrOffImm : public EDtrOff
{
public:
EDtrOffImm(int32_t imm)
: EDtrOff(datastore::Imm8Data(mozilla::Abs(imm)), (imm >= 0) ? IsUp : IsDown)
: EDtrOff(datastore::Imm8Data(mozilla::DeprecatedAbs(imm)), (imm >= 0) ? IsUp : IsDown)
{ }
};

Expand Down Expand Up @@ -838,7 +838,7 @@ class VFPOffImm : public VFPOff
{
public:
VFPOffImm(int32_t imm)
: VFPOff(datastore::Imm8VFPOffData(mozilla::Abs(imm) >> 2), imm < 0 ? IsDown : IsUp)
: VFPOff(datastore::Imm8VFPOffData(mozilla::DeprecatedAbs(imm) >> 2), imm < 0 ? IsDown : IsUp)
{ }
};
class VFPAddr
Expand Down
6 changes: 3 additions & 3 deletions js/src/ion/arm/MacroAssembler-arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using namespace js;
using namespace ion;

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

bool
isValueDTRDCandidate(ValueOperand &val)
Expand Down Expand Up @@ -2526,7 +2526,7 @@ MacroAssemblerARMCompat::storeValue(ValueOperand val, Operand dst) {
void
MacroAssemblerARMCompat::storeValue(ValueOperand val, const BaseIndex &dest)
{
if (isValueDTRDCandidate(val) && Abs(dest.offset) <= 255) {
if (isValueDTRDCandidate(val) && DeprecatedAbs(dest.offset) <= 255) {
Register tmpIdx;
if (dest.offset == 0) {
if (dest.scale == TimesOne) {
Expand All @@ -2550,7 +2550,7 @@ MacroAssemblerARMCompat::storeValue(ValueOperand val, const BaseIndex &dest)
void
MacroAssemblerARMCompat::loadValue(const BaseIndex &addr, ValueOperand val)
{
if (isValueDTRDCandidate(val) && Abs(addr.offset) <= 255) {
if (isValueDTRDCandidate(val) && DeprecatedAbs(addr.offset) <= 255) {
Register tmpIdx;
if (addr.offset == 0) {
if (addr.scale == TimesOne) {
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::Abs;
using mozilla::DeprecatedAbs;

#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 = Abs(x);
z = DeprecatedAbs(x);
vp->setNumber(z);
return JS_TRUE;
}
Expand Down
4 changes: 2 additions & 2 deletions js/src/methodjit/FastArithmetic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using namespace js::mjit;
using namespace js::analyze;
using namespace JSC;

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

typedef JSC::MacroAssembler::FPRegisterID FPRegisterID;

Expand Down Expand Up @@ -333,7 +333,7 @@ mjit::Compiler::jsop_binary_double(FrameEntry *lhs, FrameEntry *rhs, JSOp op,
(type == JSVAL_TYPE_INT32 ||
(type == JSVAL_TYPE_UNKNOWN &&
!(lhs->isConstant() && lhs->isType(JSVAL_TYPE_INT32) &&
Abs(lhs->getValue().toInt32()) == 1))))
DeprecatedAbs(lhs->getValue().toInt32()) == 1))))
{
RegisterID reg = frame.allocReg();
FPRegisterID fpReg = frame.allocFPReg();
Expand Down
8 changes: 4 additions & 4 deletions js/src/methodjit/LoopState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ using namespace js::mjit;
using namespace js::analyze;
using namespace js::types;

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

LoopState::LoopState(JSContext *cx, analyze::CrossScriptSSA *ssa,
mjit::Compiler *cc, FrameState *frame)
Expand Down Expand Up @@ -2029,7 +2029,7 @@ LoopState::computeInterval(const CrossSSAValue &cv, int32_t *pmin, int32_t *pmax
if (!computeInterval(rhsv, &rhsmin, &rhsmax) || rhsmin != rhsmax)
return false;

int32_t rhs = Abs(rhsmax);
int32_t rhs = DeprecatedAbs(rhsmax);
*pmin = -(rhs - 1);
*pmax = rhs - 1;
return true;
Expand Down Expand Up @@ -2063,8 +2063,8 @@ LoopState::computeInterval(const CrossSSAValue &cv, int32_t *pmin, int32_t *pmax
if (lhsmin == INT32_MIN || rhsmin == INT32_MIN)
return false;

int32_t nlhs = Max(Abs(lhsmin), Abs(lhsmax));
int32_t nrhs = Max(Abs(rhsmin), Abs(rhsmax));
int32_t nlhs = Max(DeprecatedAbs(lhsmin), DeprecatedAbs(lhsmax));
int32_t nrhs = Max(DeprecatedAbs(rhsmin), DeprecatedAbs(rhsmax));

if (!SafeMul(nlhs, nrhs, pmax))
return false;
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::Abs(diff) > 2 * skewThreshold) {
if (mozilla::DeprecatedAbs(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::Abs(time) > 8.64e15)
if (!MOZ_DOUBLE_IS_FINITE(time) || mozilla::DeprecatedAbs(time) > 8.64e15)
return js_NaN;

/* Step 3. */
Expand Down
2 changes: 1 addition & 1 deletion layout/base/nsCSSColorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// See http://www.w3.org/TR/AERT#color-contrast
#define NS_SUFFICIENT_LUMINOSITY_DIFFERENCE 125000
#define NS_LUMINOSITY_DIFFERENCE(a, b) \
mozilla::Abs(NS_GetLuminosity(a) - NS_GetLuminosity(b))
mozilla::DeprecatedAbs(NS_GetLuminosity(a) - NS_GetLuminosity(b))

// To determine colors based on the background brightness and border color
void NS_GetSpecial3DColors(nscolor aResult[2],
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 = Abs(aLineStart->x);
double rightDistance = Abs(aBoxSize.width - aLineStart->x);
double topDistance = Abs(aLineStart->y);
double bottomDistance = Abs(aBoxSize.height - aLineStart->y);
double leftDistance = DeprecatedAbs(aLineStart->x);
double rightDistance = DeprecatedAbs(aBoxSize.width - aLineStart->x);
double topDistance = DeprecatedAbs(aLineStart->y);
double bottomDistance = DeprecatedAbs(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 = Abs(advance) / app;
gfxFloat width = DeprecatedAbs(advance) / app;
gfxFloat xInFrame = pt.x - (aFramePt.x / app);
DrawSelectionDecorations(aCtx, dirtyRect, aSelectionType, this,
aTextPaintStyle, selectedStyle, pt, xInFrame,
Expand Down
Loading

0 comments on commit 5ec763f

Please sign in to comment.