OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2009 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... |
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "platform/geometry/IntRect.h" | 26 #include "platform/geometry/IntRect.h" |
27 | 27 |
28 #include "platform/geometry/FloatRect.h" | 28 #include "platform/geometry/FloatRect.h" |
29 #include "platform/geometry/LayoutRect.h" | 29 #include "platform/geometry/LayoutRect.h" |
30 #include "third_party/skia/include/core/SkRect.h" | 30 #include "third_party/skia/include/core/SkRect.h" |
31 #include "ui/gfx/geometry/rect.h" | 31 #include "ui/gfx/geometry/rect.h" |
32 #include "wtf/text/WTFString.h" | |
33 | 32 |
34 #include <algorithm> | 33 #include <algorithm> |
| 34 #include <ostream> // NOLINT |
35 | 35 |
36 namespace blink { | 36 namespace blink { |
37 | 37 |
38 IntRect::IntRect(const FloatRect& r) | 38 IntRect::IntRect(const FloatRect& r) |
39 : m_location(clampTo<int>(r.x()), clampTo<int>(r.y())) | 39 : m_location(clampTo<int>(r.x()), clampTo<int>(r.y())) |
40 , m_size(clampTo<int>(r.width()), clampTo<int>(r.height())) | 40 , m_size(clampTo<int>(r.width()), clampTo<int>(r.height())) |
41 { | 41 { |
42 } | 42 } |
43 | 43 |
44 IntRect::IntRect(const LayoutRect& r) | 44 IntRect::IntRect(const LayoutRect& r) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 if (!count) | 180 if (!count) |
181 return IntRect(); | 181 return IntRect(); |
182 | 182 |
183 IntRect result = rects[0]; | 183 IntRect result = rects[0]; |
184 for (size_t i = 1; i < count; ++i) | 184 for (size_t i = 1; i < count; ++i) |
185 result.uniteEvenIfEmpty(rects[i]); | 185 result.uniteEvenIfEmpty(rects[i]); |
186 | 186 |
187 return result; | 187 return result; |
188 } | 188 } |
189 | 189 |
190 #ifndef NDEBUG | 190 std::ostream& operator<<(std::ostream& os, const IntRect& rect) |
191 // Prints the rect to the screen. | |
192 void IntRect::show() const | |
193 { | 191 { |
194 LayoutRect(*this).show(); | 192 os << "IntRect(" |
| 193 << "x=" << rect.x() << ", " |
| 194 << "y=" << rect.y() << ", " |
| 195 << "width=" << rect.width() << ", " |
| 196 << "height=" << rect.height() << ")"; |
| 197 return os; |
195 } | 198 } |
196 | 199 |
197 String IntRect::toString() const | |
198 { | |
199 return String::format("%s %s", location().toString().ascii().data(), size().
toString().ascii().data()); | |
200 } | |
201 #endif | |
202 | |
203 } // namespace blink | 200 } // namespace blink |
OLD | NEW |