LEFT | RIGHT |
(no file at all) | |
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Return a clean empty rectangle for non-intersecting cases. | 64 // Return a clean empty rectangle for non-intersecting cases. |
65 if (newLocation.x() >= newMaxPoint.x() || newLocation.y() >= newMaxPoint.y()
) { | 65 if (newLocation.x() >= newMaxPoint.x() || newLocation.y() >= newMaxPoint.y()
) { |
66 newLocation = LayoutPoint(0, 0); | 66 newLocation = LayoutPoint(0, 0); |
67 newMaxPoint = LayoutPoint(0, 0); | 67 newMaxPoint = LayoutPoint(0, 0); |
68 } | 68 } |
69 | 69 |
70 m_location = newLocation; | 70 m_location = newLocation; |
71 m_size = newMaxPoint - newLocation; | 71 m_size = newMaxPoint - newLocation; |
72 } | 72 } |
73 | 73 |
| 74 bool LayoutRect::inclusiveIntersect(const LayoutRect& other) |
| 75 { |
| 76 LayoutPoint newLocation(std::max(x(), other.x()), std::max(y(), other.y())); |
| 77 LayoutPoint newMaxPoint(std::min(maxX(), other.maxX()), std::min(maxY(), oth
er.maxY())); |
| 78 |
| 79 if (newLocation.x() > newMaxPoint.x() || newLocation.y() > newMaxPoint.y())
{ |
| 80 newLocation = LayoutPoint(0, 0); |
| 81 newMaxPoint = LayoutPoint(0, 0); |
| 82 return false; |
| 83 } |
| 84 |
| 85 m_location = newLocation; |
| 86 m_size = newMaxPoint - newLocation; |
| 87 return true; |
| 88 } |
| 89 |
74 void LayoutRect::unite(const LayoutRect& other) | 90 void LayoutRect::unite(const LayoutRect& other) |
75 { | 91 { |
76 // Handle empty special cases first. | 92 // Handle empty special cases first. |
77 if (other.isEmpty()) | 93 if (other.isEmpty()) |
78 return; | 94 return; |
79 if (isEmpty()) { | 95 if (isEmpty()) { |
80 *this = other; | 96 *this = other; |
81 return; | 97 return; |
82 } | 98 } |
83 | 99 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 193 |
178 TextStream& operator<<(TextStream& ts, const LayoutRect& r) | 194 TextStream& operator<<(TextStream& ts, const LayoutRect& r) |
179 { | 195 { |
180 if (ts.hasFormattingFlag(TextStream::Formatting::LayoutUnitsAsIntegers)) | 196 if (ts.hasFormattingFlag(TextStream::Formatting::LayoutUnitsAsIntegers)) |
181 return ts << snappedIntRect(r); | 197 return ts << snappedIntRect(r); |
182 ···· | 198 ···· |
183 return ts << FloatRect(r); | 199 return ts << FloatRect(r); |
184 } | 200 } |
185 | 201 |
186 } // namespace WebCore | 202 } // namespace WebCore |
LEFT | RIGHT |