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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012, Google Inc. All rights reserved. 2 * Copyright (c) 2012, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 // Return a clean empty rectangle for non-intersecting cases. 73 // Return a clean empty rectangle for non-intersecting cases.
74 if (newLocation.x() >= newMaxPoint.x() || newLocation.y() >= newMaxPoint.y() ) { 74 if (newLocation.x() >= newMaxPoint.x() || newLocation.y() >= newMaxPoint.y() ) {
75 newLocation = LayoutPoint(); 75 newLocation = LayoutPoint();
76 newMaxPoint = LayoutPoint(); 76 newMaxPoint = LayoutPoint();
77 } 77 }
78 78
79 m_location = newLocation; 79 m_location = newLocation;
80 m_size = newMaxPoint - newLocation; 80 m_size = newMaxPoint - newLocation;
81 } 81 }
82 82
83 bool LayoutRect::inclusiveIntersect(const LayoutRect& other)
84 {
85 LayoutPoint newLocation(std::max(x(), other.x()), std::max(y(), other.y()));
86 LayoutPoint newMaxPoint(std::min(maxX(), other.maxX()), std::min(maxY(), oth er.maxY()));
87
88 if (newLocation.x() > newMaxPoint.x() || newLocation.y() > newMaxPoint.y()) {
89 *this = LayoutRect();
90 return false;
91 }
92
93 m_location = newLocation;
94 m_size = newMaxPoint - newLocation;
95 return true;
96 }
97
83 void LayoutRect::unite(const LayoutRect& other) 98 void LayoutRect::unite(const LayoutRect& other)
84 { 99 {
85 // Handle empty special cases first. 100 // Handle empty special cases first.
86 if (other.isEmpty()) 101 if (other.isEmpty())
87 return; 102 return;
88 if (isEmpty()) { 103 if (isEmpty()) {
89 *this = other; 104 *this = other;
90 return; 105 return;
91 } 106 }
92 107
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 } 190 }
176 191
177 LayoutRect enclosingLayoutRect(const FloatRect& rect) 192 LayoutRect enclosingLayoutRect(const FloatRect& rect)
178 { 193 {
179 LayoutPoint location = flooredLayoutPoint(rect.minXMinYCorner()); 194 LayoutPoint location = flooredLayoutPoint(rect.minXMinYCorner());
180 LayoutPoint maxPoint = ceiledLayoutPoint(rect.maxXMaxYCorner()); 195 LayoutPoint maxPoint = ceiledLayoutPoint(rect.maxXMaxYCorner());
181 return LayoutRect(location, maxPoint - location); 196 return LayoutRect(location, maxPoint - location);
182 } 197 }
183 198
184 } // namespace blink 199 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698