Chromium Code Reviews| 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) |
|
chrishtr
2016/03/21 22:14:50
Unittest this.
|
| +{ |
| + 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. |