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

Side by Side Diff: ui/gfx/rect_f.h

Issue 11293194: ui: Prefer +/- operators to apply offsets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: floats Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef UI_GFX_RECT_F_H_ 5 #ifndef UI_GFX_RECT_F_H_
6 #define UI_GFX_RECT_F_H_ 6 #define UI_GFX_RECT_F_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ui/gfx/point_f.h" 10 #include "ui/gfx/point_f.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 }; 51 };
52 52
53 inline bool operator==(const RectF& lhs, const RectF& rhs) { 53 inline bool operator==(const RectF& lhs, const RectF& rhs) {
54 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); 54 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size();
55 } 55 }
56 56
57 inline bool operator!=(const RectF& lhs, const RectF& rhs) { 57 inline bool operator!=(const RectF& lhs, const RectF& rhs) {
58 return !(lhs == rhs); 58 return !(lhs == rhs);
59 } 59 }
60 60
61 UI_EXPORT RectF operator+(const RectF& lhs, const Vector2dF& rhs);
62 UI_EXPORT RectF operator-(const RectF& lhs, const Vector2dF& rhs);
63
64 inline RectF operator+(const Vector2dF& lhs, const RectF& rhs) {
65 return rhs + lhs;
66 }
67
61 UI_EXPORT RectF IntersectRects(const RectF& a, const RectF& b); 68 UI_EXPORT RectF IntersectRects(const RectF& a, const RectF& b);
62 UI_EXPORT RectF UnionRects(const RectF& a, const RectF& b); 69 UI_EXPORT RectF UnionRects(const RectF& a, const RectF& b);
63 UI_EXPORT RectF SubtractRects(const RectF& a, const RectF& b); 70 UI_EXPORT RectF SubtractRects(const RectF& a, const RectF& b);
64 UI_EXPORT RectF ScaleRect(const RectF& r, float x_scale, float y_scale); 71 UI_EXPORT RectF ScaleRect(const RectF& r, float x_scale, float y_scale);
65 72
66 inline RectF ScaleRect(const RectF& r, float scale) { 73 inline RectF ScaleRect(const RectF& r, float scale) {
67 return ScaleRect(r, scale, scale); 74 return ScaleRect(r, scale, scale);
68 } 75 }
69 76
70 // Constructs a rectangle with |p1| and |p2| as opposite corners. 77 // Constructs a rectangle with |p1| and |p2| as opposite corners.
71 // 78 //
72 // This could also be thought of as "the smallest rect that contains both 79 // This could also be thought of as "the smallest rect that contains both
73 // points", except that we consider points on the right/bottom edges of the 80 // points", except that we consider points on the right/bottom edges of the
74 // rect to be outside the rect. So technically one or both points will not be 81 // rect to be outside the rect. So technically one or both points will not be
75 // contained within the rect, because they will appear on one of these edges. 82 // contained within the rect, because they will appear on one of these edges.
76 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); 83 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2);
77 84
78 #if !defined(COMPILER_MSVC) 85 #if !defined(COMPILER_MSVC)
79 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; 86 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>;
80 #endif 87 #endif
81 88
82 } // namespace gfx 89 } // namespace gfx
83 90
84 #endif // UI_GFX_RECT_F_H_ 91 #endif // UI_GFX_RECT_F_H_
OLDNEW
« .gitmodules ('K') | « ui/gfx/rect_base_impl.h ('k') | ui/gfx/rect_f.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698