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

Side by Side Diff: third_party/WebKit/Source/platform/geometry/IntRect.cpp

Issue 2191233002: Add platform/geometry pretty printers for logging and testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adjust tests to work around uninteresting cross-platform differences Created 4 years, 4 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) 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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698