Index: ui/gfx/vector2d_f.h |
diff --git a/ui/gfx/vector2d_f.h b/ui/gfx/vector2d_f.h |
index e78c68821b7f2f18d85decfccc30a7ba61a9bddd..2ce7d1d4a7e55a891261f1e37a20a906910029a1 100644 |
--- a/ui/gfx/vector2d_f.h |
+++ b/ui/gfx/vector2d_f.h |
@@ -38,6 +38,16 @@ class UI_EXPORT Vector2dF { |
void operator+=(const Vector2dF& other) { Add(other); } |
void operator-=(const Vector2dF& other) { Subtract(other); } |
+ void ClampToMax(const Vector2dF& max) { |
+ x_ = x_ <= max.x_ ? x_ : max.x_; |
+ y_ = y_ <= max.y_ ? y_ : max.y_; |
+ } |
+ |
+ void ClampToMin(const Vector2dF& min) { |
+ x_ = x_ >= min.x_ ? x_ : min.x_; |
+ y_ = y_ >= min.y_ ? y_ : min.y_; |
+ } |
+ |
// Gives the square of the diagonal length of the vector. |
double LengthSquared() const; |
// Gives the diagonal length of the vector. |