Index: ui/gfx/vector2d.h |
diff --git a/ui/gfx/vector2d.h b/ui/gfx/vector2d.h |
index 6ec37082f3eb1046d8be11bcfacac46e18c0e11c..aa0f1bd9375401632bbaad6c121d34fad785809a 100644 |
--- a/ui/gfx/vector2d.h |
+++ b/ui/gfx/vector2d.h |
@@ -40,6 +40,16 @@ class UI_EXPORT Vector2d { |
void operator+=(const Vector2d& other) { Add(other); } |
void operator-=(const Vector2d& other) { Subtract(other); } |
+ void ClampFromAbove(const Vector2d& other) { |
+ x_ = x_ <= other.x_ ? x_ : other.x_; |
+ y_ = y_ <= other.y_ ? y_ : other.y_; |
+ } |
+ |
+ void ClampFromBelow(const Vector2d& other) { |
+ x_ = x_ >= other.x_ ? x_ : other.x_; |
+ y_ = y_ >= other.y_ ? y_ : other.y_; |
+ } |
+ |
// Gives the square of the diagonal length of the vector. Since this is |
// cheaper to compute than Length(), it is useful when you want to compare |
// relative lengths of different vectors without needing the actual lengths. |