LEFT | RIGHT |
(no file at all) | |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2005 Nokia. All rights reserved. | 3 * Copyright (C) 2005 Nokia. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (l >= r || t >= b) { | 86 if (l >= r || t >= b) { |
87 l = 0; | 87 l = 0; |
88 t = 0; | 88 t = 0; |
89 r = 0; | 89 r = 0; |
90 b = 0; | 90 b = 0; |
91 } | 91 } |
92 | 92 |
93 setLocationAndSizeFromEdges(l, t, r, b); | 93 setLocationAndSizeFromEdges(l, t, r, b); |
94 } | 94 } |
95 | 95 |
| 96 bool FloatRect::inclusiveIntersect(const FloatRect& other) |
| 97 { |
| 98 float l = std::max(x(), other.x()); |
| 99 float t = std::max(y(), other.y()); |
| 100 float r = std::min(maxX(), other.maxX()); |
| 101 float b = std::min(maxY(), other.maxY()); |
| 102 |
| 103 // Return a clean empty rectangle for non-intersecting cases. |
| 104 if (l > r || t > b) { |
| 105 l = 0; |
| 106 t = 0; |
| 107 r = 0; |
| 108 b = 0; |
| 109 return false; |
| 110 } |
| 111 |
| 112 setLocationAndSizeFromEdges(l, t, r, b); |
| 113 return true; |
| 114 } |
| 115 |
| 116 |
96 void FloatRect::unite(const FloatRect& other) | 117 void FloatRect::unite(const FloatRect& other) |
97 { | 118 { |
98 // Handle empty special cases first. | 119 // Handle empty special cases first. |
99 if (other.isEmpty()) | 120 if (other.isEmpty()) |
100 return; | 121 return; |
101 if (isEmpty()) { | 122 if (isEmpty()) { |
102 *this = other; | 123 *this = other; |
103 return; | 124 return; |
104 } | 125 } |
105 | 126 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 if (ts.hasFormattingFlag(TextStream::Formatting::SVGStyleRect)) { | 251 if (ts.hasFormattingFlag(TextStream::Formatting::SVGStyleRect)) { |
231 // FIXME: callers should use the NumberRespectingIntegers flag. | 252 // FIXME: callers should use the NumberRespectingIntegers flag. |
232 return ts << "at (" << TextStream::FormatNumberRespectingIntegers(r.x())
<< "," << TextStream::FormatNumberRespectingIntegers(r.y()) | 253 return ts << "at (" << TextStream::FormatNumberRespectingIntegers(r.x())
<< "," << TextStream::FormatNumberRespectingIntegers(r.y()) |
233 << ") size " << TextStream::FormatNumberRespectingIntegers(r.width()
) << "x" << TextStream::FormatNumberRespectingIntegers(r.height()); | 254 << ") size " << TextStream::FormatNumberRespectingIntegers(r.width()
) << "x" << TextStream::FormatNumberRespectingIntegers(r.height()); |
234 } | 255 } |
235 | 256 |
236 return ts << r.location() << " " << r.size(); | 257 return ts << r.location() << " " << r.size(); |
237 } | 258 } |
238 | 259 |
239 } | 260 } |
LEFT | RIGHT |