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

Side by Side Diff: ui/gfx/geometry/size.h

Issue 649203003: Type conversion fixes, ui/gfx/ edition. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 6 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/geometry/safe_integer_conversions_unittest.cc ('k') | ui/gfx/geometry/vector2d.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 #ifndef UI_GFX_GEOMETRY_SIZE_H_ 5 #ifndef UI_GFX_GEOMETRY_SIZE_H_
6 #define UI_GFX_GEOMETRY_SIZE_H_ 6 #define UI_GFX_GEOMETRY_SIZE_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <string> 9 #include <string>
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } 60 }
61 61
62 void Enlarge(int grow_width, int grow_height); 62 void Enlarge(int grow_width, int grow_height);
63 63
64 void SetToMin(const Size& other); 64 void SetToMin(const Size& other);
65 void SetToMax(const Size& other); 65 void SetToMax(const Size& other);
66 66
67 bool IsEmpty() const { return !width() || !height(); } 67 bool IsEmpty() const { return !width() || !height(); }
68 68
69 operator SizeF() const { 69 operator SizeF() const {
70 return SizeF(width(), height()); 70 return SizeF(static_cast<float>(width()), static_cast<float>(height()));
71 } 71 }
72 72
73 std::string ToString() const; 73 std::string ToString() const;
74 74
75 private: 75 private:
76 int width_; 76 int width_;
77 int height_; 77 int height_;
78 }; 78 };
79 79
80 inline bool operator==(const Size& lhs, const Size& rhs) { 80 inline bool operator==(const Size& lhs, const Size& rhs) {
81 return lhs.width() == rhs.width() && lhs.height() == rhs.height(); 81 return lhs.width() == rhs.width() && lhs.height() == rhs.height();
82 } 82 }
83 83
84 inline bool operator!=(const Size& lhs, const Size& rhs) { 84 inline bool operator!=(const Size& lhs, const Size& rhs) {
85 return !(lhs == rhs); 85 return !(lhs == rhs);
86 } 86 }
87 87
88 // This is declared here for use in gtest-based unit tests but is defined in 88 // This is declared here for use in gtest-based unit tests but is defined in
89 // the gfx_test_support target. Depend on that to use this in your unit test. 89 // the gfx_test_support target. Depend on that to use this in your unit test.
90 // This should not be used in production code - call ToString() instead. 90 // This should not be used in production code - call ToString() instead.
91 void PrintTo(const Size& size, ::std::ostream* os); 91 void PrintTo(const Size& size, ::std::ostream* os);
92 92
93 } // namespace gfx 93 } // namespace gfx
94 94
95 #endif // UI_GFX_GEOMETRY_SIZE_H_ 95 #endif // UI_GFX_GEOMETRY_SIZE_H_
OLDNEW
« no previous file with comments | « ui/gfx/geometry/safe_integer_conversions_unittest.cc ('k') | ui/gfx/geometry/vector2d.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698