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

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

Issue 1817693002: Support edge-inclusive intersections in mapToVisibleRectInAncestorSpace (Closed) Base URL: https://chromium.googlesource.com/chromium/src@intersection-observer-idle-callback
Patch Set: more tests Created 4 years, 9 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/LayoutRect.cpp
diff --git a/third_party/WebKit/Source/platform/geometry/LayoutRect.cpp b/third_party/WebKit/Source/platform/geometry/LayoutRect.cpp
index 444cddbe5f92f78bfedce3c7ad491a306dc0fa02..7e7b2ddaefc79d83e025f933187d05644953f871 100644
--- a/third_party/WebKit/Source/platform/geometry/LayoutRect.cpp
+++ b/third_party/WebKit/Source/platform/geometry/LayoutRect.cpp
@@ -80,6 +80,21 @@ void LayoutRect::intersect(const LayoutRect& other)
m_size = newMaxPoint - newLocation;
}
+bool LayoutRect::inclusiveIntersect(const LayoutRect& other)
+{
+ LayoutPoint newLocation(std::max(x(), other.x()), std::max(y(), other.y()));
+ LayoutPoint newMaxPoint(std::min(maxX(), other.maxX()), std::min(maxY(), other.maxY()));
+
+ if (newLocation.x() > newMaxPoint.x() || newLocation.y() > newMaxPoint.y()) {
+ *this = LayoutRect();
+ return false;
+ }
+
+ m_location = newLocation;
+ m_size = newMaxPoint - newLocation;
+ return true;
+}
+
void LayoutRect::unite(const LayoutRect& other)
{
// Handle empty special cases first.

Powered by Google App Engine
This is Rietveld 408576698