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/rect_f.h

Issue 11369144: ui: Make gfx::Point::Scale() mutate the class, similar to gfx::Rect. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for aura 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
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_RECT_F_H_ 5 #ifndef UI_GFX_RECT_F_H_
6 #define UI_GFX_RECT_F_H_ 6 #define UI_GFX_RECT_F_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "ui/gfx/point_f.h" 10 #include "ui/gfx/point_f.h"
(...skipping 16 matching lines...) Expand all
27 RectF(const gfx::PointF& origin, const gfx::SizeF& size); 27 RectF(const gfx::PointF& origin, const gfx::SizeF& size);
28 28
29 ~RectF(); 29 ~RectF();
30 30
31 /// Scales the rectangle by |scale|. 31 /// Scales the rectangle by |scale|.
32 void Scale(float scale) { 32 void Scale(float scale) {
33 Scale(scale, scale); 33 Scale(scale, scale);
34 } 34 }
35 35
36 void Scale(float x_scale, float y_scale) { 36 void Scale(float x_scale, float y_scale) {
37 set_origin(ScalePoint(origin(), x_scale, y_scale));
38
37 SizeF newSize = size().Scale(x_scale, y_scale); 39 SizeF newSize = size().Scale(x_scale, y_scale);
38 newSize.ClampToNonNegative(); 40 newSize.ClampToNonNegative();
39 set_origin(origin().Scale(x_scale, y_scale));
40 set_size(newSize); 41 set_size(newSize);
41 } 42 }
42 43
43 // This method reports if the RectF can be safely converted to an integer 44 // This method reports if the RectF can be safely converted to an integer
44 // Rect. When it is false, some dimension of the RectF is outside the bounds 45 // Rect. When it is false, some dimension of the RectF is outside the bounds
45 // of what an integer can represent, and converting it to a Rect will require 46 // of what an integer can represent, and converting it to a Rect will require
46 // clamping. 47 // clamping.
47 bool IsExpressibleAsRect() const; 48 bool IsExpressibleAsRect() const;
48 49
49 std::string ToString() const; 50 std::string ToString() const;
(...skipping 24 matching lines...) Expand all
74 // contained within the rect, because they will appear on one of these edges. 75 // contained within the rect, because they will appear on one of these edges.
75 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2); 76 UI_EXPORT RectF BoundingRect(const PointF& p1, const PointF& p2);
76 77
77 #if !defined(COMPILER_MSVC) 78 #if !defined(COMPILER_MSVC)
78 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>; 79 extern template class RectBase<RectF, PointF, SizeF, InsetsF, Vector2dF, float>;
79 #endif 80 #endif
80 81
81 } // namespace gfx 82 } // namespace gfx
82 83
83 #endif // UI_GFX_RECT_F_H_ 84 #endif // UI_GFX_RECT_F_H_
OLDNEW
« cc/layer_impl.cc ('K') | « ui/gfx/quad_unittest.cc ('k') | ui/gfx/shadow_value.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698