Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(793)

Unified Diff: third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm

Issue 1530723004: Use clampTo instead of chaining std::max(std::min(...)) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More rebase Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
diff --git a/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm b/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
index 111db7e83cdc0a05654f771995120b6a9366db9f..c99941a35cdfe2a578c2336491ea707c89c94a83 100644
--- a/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
+++ b/third_party/WebKit/Source/platform/mac/ScrollAnimatorMac.mm
@@ -38,6 +38,7 @@
#include "platform/scroll/ScrollbarThemeMacCommon.h"
#include "platform/scroll/ScrollbarThemeMacOverlayAPI.h"
#include "wtf/MainThread.h"
+#include "wtf/MathExtras.h"
#include "wtf/PassOwnPtr.h"
using namespace blink;
@@ -341,8 +342,7 @@ private:
m_timer.stop();
double fraction = delta / m_duration;
- fraction = std::min(1.0, fraction);
- fraction = std::max(0.0, fraction);
+ fraction = clampTo(fraction, 0.0, 1.0);
double progress = m_timingFunction->evaluate(fraction, 0.001);
[m_animation setCurrentProgress:progress];
}
@@ -768,8 +768,8 @@ FloatPoint ScrollAnimatorMac::adjustScrollPositionIfNecessary(const FloatPoint&
IntPoint minPos = m_scrollableArea->minimumScrollPosition();
IntPoint maxPos = m_scrollableArea->maximumScrollPosition();
- float newX = std::max<float>(std::min<float>(position.x(), maxPos.x()), minPos.x());
- float newY = std::max<float>(std::min<float>(position.y(), maxPos.y()), minPos.y());
+ float newX = clampTo<float, float>(position.x(), minPos.x(), maxPos.x());
+ float newY = clampTo<float, float>(position.y(), minPos.y(), maxPos.y());
return FloatPoint(newX, newY);
}

Powered by Google App Engine
This is Rietveld 408576698