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

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

Issue 2744423002: Handle large rects better. (Closed)
Patch Set: Review Feedback Created 3 years, 8 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
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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 Vector2d OffsetFromOrigin() const { return Vector2d(x(), y()); } 104 Vector2d OffsetFromOrigin() const { return Vector2d(x(), y()); }
105 105
106 void SetRect(int x, int y, int width, int height) { 106 void SetRect(int x, int y, int width, int height) {
107 origin_.SetPoint(x, y); 107 origin_.SetPoint(x, y);
108 // Ensure that width and height remain valid. 108 // Ensure that width and height remain valid.
109 set_width(width); 109 set_width(width);
110 set_height(height); 110 set_height(height);
111 } 111 }
112 112
113 void SetByBounds(int left, int top, int right, int bottom);
danakj 2017/03/29 19:00:47 I see what you're saying about the comment that wa
danakj 2017/03/29 20:50:35 Idk if u didn't see this also, so in case you want
Peter Mayo 2017/03/29 21:10:12 I didn't. I like it - added.
114
113 // Shrink the rectangle by a horizontal and vertical distance on all sides. 115 // Shrink the rectangle by a horizontal and vertical distance on all sides.
114 void Inset(int horizontal, int vertical) { 116 void Inset(int horizontal, int vertical) {
115 Inset(horizontal, vertical, horizontal, vertical); 117 Inset(horizontal, vertical, horizontal, vertical);
116 } 118 }
117 119
118 // Shrink the rectangle by the given insets. 120 // Shrink the rectangle by the given insets.
119 void Inset(const Insets& insets); 121 void Inset(const Insets& insets);
120 122
121 // Shrink the rectangle by the specified amount on each side. 123 // Shrink the rectangle by the specified amount on each side.
122 void Inset(int left, int top, int right, int bottom); 124 void Inset(int left, int top, int right, int bottom);
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 338 }
337 339
338 // This is declared here for use in gtest-based unit tests but is defined in 340 // This is declared here for use in gtest-based unit tests but is defined in
339 // the //ui/gfx:test_support target. Depend on that to use this in your unit 341 // the //ui/gfx:test_support target. Depend on that to use this in your unit
340 // test. This should not be used in production code - call ToString() instead. 342 // test. This should not be used in production code - call ToString() instead.
341 void PrintTo(const Rect& rect, ::std::ostream* os); 343 void PrintTo(const Rect& rect, ::std::ostream* os);
342 344
343 } // namespace gfx 345 } // namespace gfx
344 346
345 #endif // UI_GFX_GEOMETRY_RECT_H_ 347 #endif // UI_GFX_GEOMETRY_RECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698