Bug 1073716: Use C++ std::abs() instead of C abs(), for non-'int'-typed values, to address clang warning. r=ehsan
--- a/content/media/MediaDecoderStateMachine.cpp
+++ b/content/media/MediaDecoderStateMachine.cpp
@@ -1305,17 +1305,17 @@ void MediaDecoderStateMachine::SetDurati
}
}
void MediaDecoderStateMachine::UpdateEstimatedDuration(int64_t aDuration)
{
AssertCurrentThreadInMonitor();
int64_t duration = GetDuration();
if (aDuration != duration &&
- abs(aDuration - duration) > ESTIMATED_DURATION_FUZZ_FACTOR_USECS) {
+ std::abs(aDuration - duration) > ESTIMATED_DURATION_FUZZ_FACTOR_USECS) {
SetDuration(aDuration);
nsCOMPtr<nsIRunnable> event =
NS_NewRunnableMethod(mDecoder, &MediaDecoder::DurationChanged);
NS_DispatchToMainThread(event);
}
}
void MediaDecoderStateMachine::SetMediaEndTime(int64_t aEndTime)
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -2168,18 +2168,18 @@ TabChild::UpdateTapState(const WidgetTou
if (!trackedTouch) {
return;
}
LayoutDevicePoint currentPoint = LayoutDevicePoint(trackedTouch->mRefPoint.x, trackedTouch->mRefPoint.y);
int64_t time = aEvent.time;
switch (aEvent.message) {
case NS_TOUCH_MOVE:
- if (abs(currentPoint.x - mGestureDownPoint.x) > sDragThreshold.width ||
- abs(currentPoint.y - mGestureDownPoint.y) > sDragThreshold.height) {
+ if (std::abs(currentPoint.x - mGestureDownPoint.x) > sDragThreshold.width ||
+ std::abs(currentPoint.y - mGestureDownPoint.y) > sDragThreshold.height) {
CancelTapTracking();
}
return;
case NS_TOUCH_END:
if (!nsIPresShell::gPreventMouseEvents) {
DispatchSynthesizedMouseEvent(NS_MOUSE_MOVE, time, currentPoint, mWidget);
DispatchSynthesizedMouseEvent(NS_MOUSE_BUTTON_DOWN, time, currentPoint, mWidget);
--- a/gfx/2d/Path.cpp
+++ b/gfx/2d/Path.cpp
@@ -247,17 +247,17 @@ FlattenBezierCurveSegment(const BezierCo
Float t = 0;
while (t < 1.0f) {
Point cp21 = currentCP.mCP2 - currentCP.mCP3;
Point cp31 = currentCP.mCP3 - currentCP.mCP1;
Float s3 = (cp31.x * cp21.y - cp31.y * cp21.x) / hypotf(cp21.x, cp21.y);
- t = 2 * Float(sqrt(aTolerance / (3. * abs(s3))));
+ t = 2 * Float(sqrt(aTolerance / (3. * std::abs(s3))));
if (t >= 1.0f) {
aSink->LineTo(aControlPoints.mCP4);
break;
}
Point prevCP2, prevCP3, nextCP1, nextCP2, nextCP3;
SplitBezier(currentCP, nullptr, ¤tCP, t);
@@ -276,33 +276,33 @@ FindInflectionApproximationRange(BezierC
Point cp21 = aControlPoints.mCP2 - aControlPoints.mCP1;
Point cp41 = aControlPoints.mCP4 - aControlPoints.mCP1;
if (cp21.x == 0.f && cp21.y == 0.f) {
// In this case s3 becomes lim[n->0] (cp41.x * n) / n - (cp41.y * n) / n = cp41.x - cp41.y.
// Use the absolute value so that Min and Max will correspond with the
// minimum and maximum of the range.
- *aMin = aT - CubicRoot(abs(aTolerance / (cp41.x - cp41.y)));
- *aMax = aT + CubicRoot(abs(aTolerance / (cp41.x - cp41.y)));
+ *aMin = aT - CubicRoot(std::abs(aTolerance / (cp41.x - cp41.y)));
+ *aMax = aT + CubicRoot(std::abs(aTolerance / (cp41.x - cp41.y)));
return;
}
Float s3 = (cp41.x * cp21.y - cp41.y * cp21.x) / hypotf(cp21.x, cp21.y);
if (s3 == 0) {
// This means within the precision we have it can be approximated
// infinitely by a linear segment. Deal with this by specifying the
// approximation range as extending beyond the entire curve.
*aMin = -1.0f;
*aMax = 2.0f;
return;
}
- Float tf = CubicRoot(abs(aTolerance / s3));
+ Float tf = CubicRoot(std::abs(aTolerance / s3));
*aMin = aT - tf * (1 - aT);
*aMax = aT + tf * (1 - aT);
}
/* Find the inflection points of a bezier curve. Will return false if the
* curve is degenerate in such a way that it is best approximated by a straight
* line.
--- a/gfx/src/FilterSupport.cpp
+++ b/gfx/src/FilterSupport.cpp
@@ -1315,17 +1315,17 @@ ResultChangeRegionForPrimitive(const Fil
case PrimitiveType::Offset:
{
IntPoint offset = atts.GetIntPoint(eOffsetOffset);
return aInputChangeRegions[0].MovedBy(offset.x, offset.y);
}
case PrimitiveType::DisplacementMap:
{
- int32_t scale = ceil(abs(atts.GetFloat(eDisplacementMapScale)));
+ int32_t scale = ceil(std::abs(atts.GetFloat(eDisplacementMapScale)));
return aInputChangeRegions[0].Inflated(nsIntMargin(scale, scale, scale, scale));
}
case PrimitiveType::GaussianBlur:
{
Size stdDeviation = atts.GetSize(eGaussianBlurStdDeviation);
int32_t dx = InflateSizeForBlurStdDev(stdDeviation.width);
int32_t dy = InflateSizeForBlurStdDev(stdDeviation.height);
@@ -1544,17 +1544,17 @@ SourceNeededRegionForPrimitive(const Fil
return aResultNeededRegion.MovedBy(-nsIntPoint(offset.x, offset.y));
}
case PrimitiveType::DisplacementMap:
{
if (aInputIndex == 1) {
return aResultNeededRegion;
}
- int32_t scale = ceil(abs(atts.GetFloat(eDisplacementMapScale)));
+ int32_t scale = ceil(std::abs(atts.GetFloat(eDisplacementMapScale)));
return aResultNeededRegion.Inflated(nsIntMargin(scale, scale, scale, scale));
}
case PrimitiveType::GaussianBlur:
{
Size stdDeviation = atts.GetSize(eGaussianBlurStdDeviation);
int32_t dx = InflateSizeForBlurStdDev(stdDeviation.width);
int32_t dy = InflateSizeForBlurStdDev(stdDeviation.height);