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

Side by Side Diff: third_party/WebKit/Source/platform/geometry/LayoutPoint.h

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) 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 20 matching lines...) Expand all
31 #ifndef LayoutPoint_h 31 #ifndef LayoutPoint_h
32 #define LayoutPoint_h 32 #define LayoutPoint_h
33 33
34 #include "platform/geometry/DoublePoint.h" 34 #include "platform/geometry/DoublePoint.h"
35 #include "platform/geometry/FloatPoint.h" 35 #include "platform/geometry/FloatPoint.h"
36 #include "platform/geometry/LayoutSize.h" 36 #include "platform/geometry/LayoutSize.h"
37 #include "wtf/Allocator.h" 37 #include "wtf/Allocator.h"
38 #include "wtf/Forward.h" 38 #include "wtf/Forward.h"
39 #include "wtf/MathExtras.h" 39 #include "wtf/MathExtras.h"
40 #include <algorithm> 40 #include <algorithm>
41 #include <iosfwd>
41 42
42 namespace blink { 43 namespace blink {
43 44
44 class PLATFORM_EXPORT LayoutPoint { 45 class PLATFORM_EXPORT LayoutPoint {
45 DISALLOW_NEW(); 46 DISALLOW_NEW();
46 public: 47 public:
47 LayoutPoint() { } 48 LayoutPoint() { }
48 LayoutPoint(LayoutUnit x, LayoutUnit y) : m_x(x), m_y(y) { } 49 LayoutPoint(LayoutUnit x, LayoutUnit y) : m_x(x), m_y(y) { }
49 LayoutPoint(int x, int y) : m_x(LayoutUnit(x)), m_y(LayoutUnit(y)) { } 50 LayoutPoint(int x, int y) : m_x(LayoutUnit(x)), m_y(LayoutUnit(y)) { }
50 LayoutPoint(const IntPoint& point) : m_x(point.x()), m_y(point.y()) { } 51 LayoutPoint(const IntPoint& point) : m_x(point.x()), m_y(point.y()) { }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 void clampNegativeToZero() 85 void clampNegativeToZero()
85 { 86 {
86 *this = expandedTo(zero()); 87 *this = expandedTo(zero());
87 } 88 }
88 89
89 LayoutPoint transposedPoint() const 90 LayoutPoint transposedPoint() const
90 { 91 {
91 return LayoutPoint(m_y, m_x); 92 return LayoutPoint(m_y, m_x);
92 } 93 }
93 94
94 #ifndef NDEBUG
95 String toString() const;
96 #endif
97
98 private: 95 private:
99 LayoutUnit m_x, m_y; 96 LayoutUnit m_x, m_y;
100 }; 97 };
101 98
102 ALWAYS_INLINE LayoutPoint& operator+=(LayoutPoint& a, const LayoutSize& b) 99 ALWAYS_INLINE LayoutPoint& operator+=(LayoutPoint& a, const LayoutSize& b)
103 { 100 {
104 a.move(b.width(), b.height()); 101 a.move(b.width(), b.height());
105 return a; 102 return a;
106 } 103 }
107 104
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 inline LayoutSize toLayoutSize(const LayoutPoint& p) 234 inline LayoutSize toLayoutSize(const LayoutPoint& p)
238 { 235 {
239 return LayoutSize(p.x(), p.y()); 236 return LayoutSize(p.x(), p.y());
240 } 237 }
241 238
242 inline LayoutPoint flooredLayoutPoint(const FloatSize& s) 239 inline LayoutPoint flooredLayoutPoint(const FloatSize& s)
243 { 240 {
244 return flooredLayoutPoint(FloatPoint(s)); 241 return flooredLayoutPoint(FloatPoint(s));
245 } 242 }
246 243
244 PLATFORM_EXPORT std::ostream& operator<<(std::ostream&, const LayoutPoint&);
245
247 } // namespace blink 246 } // namespace blink
248 247
249 #endif // LayoutPoint_h 248 #endif // LayoutPoint_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698