| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. 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 13 matching lines...) Expand all Loading... |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef IntPoint_h | 27 #ifndef IntPoint_h |
| 28 #define IntPoint_h | 28 #define IntPoint_h |
| 29 | 29 |
| 30 #include "platform/geometry/IntSize.h" | 30 #include "platform/geometry/IntSize.h" |
| 31 #include "wtf/MathExtras.h" | 31 #include "wtf/MathExtras.h" |
| 32 #include "wtf/VectorTraits.h" | 32 #include "wtf/VectorTraits.h" |
| 33 | 33 |
| 34 #if OS(MACOSX) | |
| 35 typedef struct CGPoint CGPoint; | |
| 36 | |
| 37 #ifdef __OBJC__ | |
| 38 #import <Foundation/Foundation.h> | |
| 39 #endif | |
| 40 #endif | |
| 41 | |
| 42 namespace blink { | 34 namespace blink { |
| 43 | 35 |
| 44 class PLATFORM_EXPORT IntPoint { | 36 class PLATFORM_EXPORT IntPoint { |
| 45 public: | 37 public: |
| 46 IntPoint() : m_x(0), m_y(0) { } | 38 IntPoint() : m_x(0), m_y(0) { } |
| 47 IntPoint(int x, int y) : m_x(x), m_y(y) { } | 39 IntPoint(int x, int y) : m_x(x), m_y(y) { } |
| 48 explicit IntPoint(const IntSize& size) : m_x(size.width()), m_y(size.height(
)) { } | 40 explicit IntPoint(const IntSize& size) : m_x(size.width()), m_y(size.height(
)) { } |
| 49 | 41 |
| 50 static IntPoint zero() { return IntPoint(); } | 42 static IntPoint zero() { return IntPoint(); } |
| 51 | 43 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 81 void clampNegativeToZero() | 73 void clampNegativeToZero() |
| 82 { | 74 { |
| 83 *this = expandedTo(zero()); | 75 *this = expandedTo(zero()); |
| 84 } | 76 } |
| 85 | 77 |
| 86 IntPoint transposedPoint() const | 78 IntPoint transposedPoint() const |
| 87 { | 79 { |
| 88 return IntPoint(m_y, m_x); | 80 return IntPoint(m_y, m_x); |
| 89 } | 81 } |
| 90 | 82 |
| 91 #if OS(MACOSX) | |
| 92 explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lo
ssy | |
| 93 operator CGPoint() const; | |
| 94 | |
| 95 #if defined(__OBJC__) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES) | |
| 96 explicit IntPoint(const NSPoint&); // don't do this implicitly since it's lo
ssy | |
| 97 operator NSPoint() const; | |
| 98 #endif | |
| 99 #endif | |
| 100 | |
| 101 private: | 83 private: |
| 102 int m_x, m_y; | 84 int m_x, m_y; |
| 103 }; | 85 }; |
| 104 | 86 |
| 105 inline IntPoint& operator+=(IntPoint& a, const IntSize& b) | 87 inline IntPoint& operator+=(IntPoint& a, const IntSize& b) |
| 106 { | 88 { |
| 107 a.move(b.width(), b.height()); | 89 a.move(b.width(), b.height()); |
| 108 return a; | 90 return a; |
| 109 } | 91 } |
| 110 | 92 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 inline int IntPoint::distanceSquaredToPoint(const IntPoint& point) const | 139 inline int IntPoint::distanceSquaredToPoint(const IntPoint& point) const |
| 158 { | 140 { |
| 159 return ((*this) - point).diagonalLengthSquared(); | 141 return ((*this) - point).diagonalLengthSquared(); |
| 160 } | 142 } |
| 161 | 143 |
| 162 } // namespace blink | 144 } // namespace blink |
| 163 | 145 |
| 164 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::IntPoint); | 146 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::IntPoint); |
| 165 | 147 |
| 166 #endif // IntPoint_h | 148 #endif // IntPoint_h |
| OLD | NEW |