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

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

Issue 1371753004: ui/gfx: Make gfx::Size::GetArea use checked math. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 months 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 | « no previous file | ui/gfx/geometry/size.cc » ('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 29 matching lines...) Expand all
40 #elif defined(OS_MACOSX) 40 #elif defined(OS_MACOSX)
41 CGSize ToCGSize() const; 41 CGSize ToCGSize() const;
42 #endif 42 #endif
43 43
44 int width() const { return width_; } 44 int width() const { return width_; }
45 int height() const { return height_; } 45 int height() const { return height_; }
46 46
47 void set_width(int width) { width_ = width < 0 ? 0 : width; } 47 void set_width(int width) { width_ = width < 0 ? 0 : width; }
48 void set_height(int height) { height_ = height < 0 ? 0 : height; } 48 void set_height(int height) { height_ = height < 0 ? 0 : height; }
49 49
50 // This call will CHECK if the area of this size would overflow int.
50 int GetArea() const; 51 int GetArea() const;
51 52
52 void SetSize(int width, int height) { 53 void SetSize(int width, int height) {
53 set_width(width); 54 set_width(width);
54 set_height(height); 55 set_height(height);
55 } 56 }
56 57
57 void Enlarge(int grow_width, int grow_height); 58 void Enlarge(int grow_width, int grow_height);
58 59
59 void SetToMin(const Size& other); 60 void SetToMin(const Size& other);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 float y_scale); 92 float y_scale);
92 GFX_EXPORT Size ScaleToFlooredSize(const Size& size, float x_scale); 93 GFX_EXPORT Size ScaleToFlooredSize(const Size& size, float x_scale);
93 GFX_EXPORT Size ScaleToRoundedSize(const Size& size, 94 GFX_EXPORT Size ScaleToRoundedSize(const Size& size,
94 float x_scale, 95 float x_scale,
95 float y_scale); 96 float y_scale);
96 GFX_EXPORT Size ScaleToRoundedSize(const Size& size, float x_scale); 97 GFX_EXPORT Size ScaleToRoundedSize(const Size& size, float x_scale);
97 98
98 } // namespace gfx 99 } // namespace gfx
99 100
100 #endif // UI_GFX_GEOMETRY_SIZE_H_ 101 #endif // UI_GFX_GEOMETRY_SIZE_H_
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/geometry/size.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698