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

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

Issue 11110004: Make gfx::Rect class operations consistently mutate the class they are called on. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cc/ fixes 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
« no previous file with comments | « ui/gfx/image/image_skia_operations.cc ('k') | ui/gfx/rect_base.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 GdkRectangle ToGdkRectangle() const; 57 GdkRectangle ToGdkRectangle() const;
58 #elif defined(OS_MACOSX) 58 #elif defined(OS_MACOSX)
59 // Construct an equivalent CoreGraphics object. 59 // Construct an equivalent CoreGraphics object.
60 CGRect ToCGRect() const; 60 CGRect ToCGRect() const;
61 #endif 61 #endif
62 62
63 operator RectF() const { 63 operator RectF() const {
64 return RectF(origin().x(), origin().y(), size().width(), size().height()); 64 return RectF(origin().x(), origin().y(), size().width(), size().height());
65 } 65 }
66 66
67 RectF Scale(float scale) const WARN_UNUSED_RESULT {
68 return Scale(scale, scale);
69 }
70
71 RectF Scale(float x_scale, float y_scale) const WARN_UNUSED_RESULT {
72 RectF original = *this;
73 return original.Scale(x_scale, y_scale);
74 }
75
76 std::string ToString() const; 67 std::string ToString() const;
77 }; 68 };
78 69
79 inline bool operator==(const Rect& lhs, const Rect& rhs) { 70 inline bool operator==(const Rect& lhs, const Rect& rhs) {
80 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size(); 71 return lhs.origin() == rhs.origin() && lhs.size() == rhs.size();
81 } 72 }
82 73
83 inline bool operator!=(const Rect& lhs, const Rect& rhs) { 74 inline bool operator!=(const Rect& lhs, const Rect& rhs) {
84 return !(lhs == rhs); 75 return !(lhs == rhs);
85 } 76 }
86 77
87 #if !defined(COMPILER_MSVC) 78 #if !defined(COMPILER_MSVC)
88 extern template class RectBase<Rect, Point, Size, Insets, int>; 79 extern template class RectBase<Rect, Point, Size, Insets, int>;
89 #endif 80 #endif
90 81
91 } // namespace gfx 82 } // namespace gfx
92 83
93 #endif // UI_GFX_RECT_H_ 84 #endif // UI_GFX_RECT_H_
OLDNEW
« no previous file with comments | « ui/gfx/image/image_skia_operations.cc ('k') | ui/gfx/rect_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698