Commit 4e0baeec authored by Roberto Moura's avatar Roberto Moura Committed by Commit Bot

switch from MAX MIN to ClampToRange.

Replace nested macros with base::ClampToRange<CGFloat>(x, 0, 1).

Change-Id: I46a26b3bfe19fffc98b18063890317a93d0baaf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2372428
Auto-Submit: Roberto Moura <mouraroberto@google.com>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Roberto Moura <mouraroberto@google.com>
Cr-Commit-Position: refs/heads/master@{#801020}
parent 1762aeef
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/check.h" #include "base/check.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/numerics/ranges.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_utils.h"
#import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h" #import "ios/chrome/browser/ui/content_suggestions/ntp_home_constant.h"
...@@ -294,7 +295,8 @@ CGFloat ToolbarHeight() { ...@@ -294,7 +295,8 @@ CGFloat ToolbarHeight() {
CGFloat percent = 0; CGFloat percent = 0;
if (offset && offset > startScaleOffset) { if (offset && offset > startScaleOffset) {
CGFloat animatingOffset = offset - startScaleOffset; CGFloat animatingOffset = offset - startScaleOffset;
percent = MIN(1, MAX(0, animatingOffset / ntp_header::kAnimationDistance)); percent = base::ClampToRange<CGFloat>(
animatingOffset / ntp_header::kAnimationDistance, 0, 1);
} }
return percent; return percent;
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/util/force_touch_long_press_gesture_recognizer.h" #import "ios/chrome/browser/ui/util/force_touch_long_press_gesture_recognizer.h"
#import <UIKit/UIGestureRecognizerSubclass.h> #import <UIKit/UIGestureRecognizerSubclass.h>
#include "base/numerics/ranges.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
...@@ -15,7 +16,7 @@ ...@@ -15,7 +16,7 @@
@synthesize forceThreshold = _forceThreshold; @synthesize forceThreshold = _forceThreshold;
- (void)setForceThreshold:(CGFloat)forceThreshold { - (void)setForceThreshold:(CGFloat)forceThreshold {
_forceThreshold = MAX(0, MIN(1, forceThreshold)); _forceThreshold = base::ClampToRange<CGFloat>(forceThreshold, 0, 1);
} }
#pragma mark - UIGestureRecognizerSubclass #pragma mark - UIGestureRecognizerSubclass
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment