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

Unified Diff: third_party/WebKit/Source/platform/geometry/FloatRect.cpp

Issue 1580363002: Implement FloatRect::squaredDistanceTo function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months 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/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..7b5b79a5a6c35f7c7f5115c045b985d1d322d00b 100644
--- a/third_party/WebKit/Source/platform/geometry/FloatRect.cpp
+++ b/third_party/WebKit/Source/platform/geometry/FloatRect.cpp
@@ -171,6 +171,14 @@ void FloatRect::scale(float sx, float sy)
m_size.setHeight(height() * sy);
}
+float FloatRect::squaredDistanceTo(const FloatPoint& point) const
+{
+ FloatPoint closestPoint;
+ closestPoint.setX(clampTo<float>(point.x(), x(), maxX()));
+ closestPoint.setY(clampTo<float>(point.y(), y(), maxY()));
+ return (point - closestPoint).diagonalLengthSquared();
+}
+
FloatRect unionRect(const Vector<FloatRect>& rects)
{
FloatRect result;
« no previous file with comments | « third_party/WebKit/Source/platform/geometry/FloatRect.h ('k') | third_party/WebKit/Source/platform/geometry/FloatRectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698