diff --git a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java index c0da18ff70bd..b20d602a21cb 100644 --- a/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java +++ b/android/source/src/java/org/mozilla/gecko/gfx/JavaPanZoomController.java @@ -21,6 +21,7 @@ import org.mozilla.gecko.util.FloatUtils; import java.util.Timer; import java.util.TimerTask; +import java.lang.StrictMath; /* * Handles the kinetic scrolling and zooming physics for a layer controller. @@ -543,7 +544,7 @@ class JavaPanZoomController private float getVelocity() { float xvel = mX.getRealVelocity(); float yvel = mY.getRealVelocity(); - return (float) Math.sqrt(xvel * xvel + yvel * yvel); + return (float) StrictMath.hypot(xvel, yvel); } public PointF getVelocityVector() { diff --git a/android/source/src/java/org/mozilla/gecko/gfx/PointUtils.java b/android/source/src/java/org/mozilla/gecko/gfx/PointUtils.java index 4eb07a31f147..4eff380527d2 100644 --- a/android/source/src/java/org/mozilla/gecko/gfx/PointUtils.java +++ b/android/source/src/java/org/mozilla/gecko/gfx/PointUtils.java @@ -11,6 +11,8 @@ import android.graphics.PointF; import org.json.JSONException; import org.json.JSONObject; +import java.lang.StrictMath; + public final class PointUtils { public static PointF add(PointF one, PointF two) { return new PointF(one.x + two.x, one.y + two.y); @@ -30,7 +32,7 @@ public final class PointUtils { /* Computes the magnitude of the given vector. */ public static float distance(PointF point) { - return (float)Math.sqrt(point.x * point.x + point.y * point.y); + return (float)StrictMath.hypot(point.x, point.y); } /** Computes the scalar distance between two points. */