Index: third_party/WebKit/Source/platform/geometry/FloatRect.cpp |
diff --git a/third_party/WebKit/Source/platform/geometry/FloatRect.cpp b/third_party/WebKit/Source/platform/geometry/FloatRect.cpp |
index 13c4b815ff075a05fdba414b6d9e395ed78e6e63..6ff8f28e593989563fd9df1ad723a208809f5097 100644 |
--- a/third_party/WebKit/Source/platform/geometry/FloatRect.cpp |
+++ b/third_party/WebKit/Source/platform/geometry/FloatRect.cpp |
@@ -171,6 +171,35 @@ void FloatRect::scale(float sx, float sy) |
m_size.setHeight(height() * sy); |
} |
+float FloatRect::distanceTo(const FloatPoint& point) |
+{ |
+ float distance = 0.f; |
+ if (point.x() < this->x()) { |
fs
2016/01/13 10:22:03
I don't see the need for explicit this - here and
|
+ if (point.y() < this->y()) |
+ distance = (point - FloatPoint(this->x(), this->y())).diagonalLengthSquared(); |
fs
2016/01/13 10:22:03
FloatRect has minXMinYCorner (etc.) which would ma
|
+ else if (point.y() > this->maxY()) |
+ distance = (point - FloatPoint(this->x(), this->maxY())).diagonalLengthSquared(); |
fs
2016/01/13 10:22:03
The 'corner' areas compute the squared distance wh
|
+ else |
+ distance = this->x() - point.x(); |
+ } else if (point.x() > this->maxX()) { |
+ if (point.y() < this->y()) |
+ distance = (point - FloatPoint(this->maxX(), this->y())).diagonalLengthSquared(); |
+ else if (point.y() > this->maxY()) |
+ distance = (point - FloatPoint(this->maxX(), this->maxY())).diagonalLengthSquared(); |
+ else |
+ distance = point.x() - this->maxX(); |
+ } else { |
+ if (point.y() < this->y()) |
+ distance = this->y() - point.y(); |
+ else if (point.y() > this->maxY()) |
+ distance = point.y() - this->maxY(); |
+ else |
+ distance = 0.f; |
+ } |
+ |
+ return distance; |
+} |
+ |
FloatRect unionRect(const Vector<FloatRect>& rects) |
{ |
FloatRect result; |