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

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

Issue 11270042: Add non-member non-mutating methods for common gfx::Rect operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
« no previous file with comments | « ui/gfx/image/image_skia_operations.cc ('k') | ui/gfx/rect_f.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Defines a simple integer rectangle class. The containment semantics 5 // Defines a simple integer rectangle class. The containment semantics
6 // are array-like; that is, the coordinate (x, y) is considered to be 6 // are array-like; that is, the coordinate (x, y) is considered to be
7 // contained by the rectangle, but the coordinate (x + width, y) is not. 7 // contained by the rectangle, but the coordinate (x + width, y) is not.
8 // The class will happily let you create malformed rectangles (that is, 8 // The class will happily let you create malformed rectangles (that is,
9 // rectangles with negative width and/or height), but there will be assertions 9 // rectangles with negative width and/or height), but there will be assertions
10 // in the operations (such as Contains()) to complain in this case. 10 // in the operations (such as Contains()) to complain in this case.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 }; 68 };
69 69
70 inline bool operator==(const Rect& lhs, const Rect& rhs) { 70 inline bool operator==(const Rect& lhs, const Rect& rhs) {
71 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); 71 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size();
72 } 72 }
73 73
74 inline bool operator!=(const Rect& lhs, const Rect& rhs) { 74 inline bool operator!=(const Rect& lhs, const Rect& rhs) {
75 return !(lhs == rhs); 75 return !(lhs == rhs);
76 } 76 }
77 77
78 inline Rect Intersection(const Rect& a, const Rect& b) {
sky 2012/10/25 23:31:53 I think we need more descriptive names otherwise w
danakj 2012/10/26 00:16:04 Sure, though I thought the same and enne@ convince
79 Rect result = a;
80 result.Intersect(b);
81 return result;
82 }
83
84 inline Rect Union(const Rect& a, const Rect& b) {
85 Rect result = a;
86 result.Union(b);
87 return result;
88 }
89
90 inline Rect Subtraction(const Rect& a, const Rect& b) {
91 Rect result = a;
92 result.Subtract(b);
93 return result;
94 }
95
78 #if !defined(COMPILER_MSVC) 96 #if !defined(COMPILER_MSVC)
79 extern template class RectBase<Rect, Point, Size, Insets, int>; 97 extern template class RectBase<Rect, Point, Size, Insets, int>;
80 #endif 98 #endif
81 99
82 } // namespace gfx 100 } // namespace gfx
83 101
84 #endif // UI_GFX_RECT_H_ 102 #endif // UI_GFX_RECT_H_
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia_operations.cc ('k') | ui/gfx/rect_f.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698