| Index: chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java b/chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java
|
| index 67d8e9ae18afeef54a30753d0d83685e4ddc431c..5ff9b32d23734db5a7ba76ebe66bbf4965bf632b 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/util/MathUtils.java
|
| @@ -39,6 +39,24 @@ public class MathUtils {
|
| * @param b Second boundary range value.
|
| * @return The passed in value if it is within the range, otherwise the closest boundary value.
|
| */
|
| + public static long clamp(long value, long a, long b) {
|
| + long min = (a > b) ? b : a;
|
| + long max = (a > b) ? a : b;
|
| + if (value < min) value = min;
|
| + else if (value > max) value = max;
|
| + return value;
|
| + }
|
| +
|
| + /**
|
| + * Returns the passed in value if it resides within the specified range (inclusive). If not,
|
| + * it will return the closest boundary from the range. The ordering of the boundary values does
|
| + * not matter.
|
| + *
|
| + * @param value The value to be compared against the range.
|
| + * @param a First boundary range value.
|
| + * @param b Second boundary range value.
|
| + * @return The passed in value if it is within the range, otherwise the closest boundary value.
|
| + */
|
| public static float clamp(float value, float a, float b) {
|
| float min = (a > b) ? b : a;
|
| float max = (a > b) ? a : b;
|
| @@ -46,4 +64,4 @@ public class MathUtils {
|
| else if (value > max) value = max;
|
| return value;
|
| }
|
| -}
|
| +}
|
|
|