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

Unified Diff: ui/gfx/geometry/rect.h

Issue 2051343002: Make various gfx classes more amenable to use as compile-time constants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete destructor Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/geometry/quad_f.h ('k') | ui/gfx/geometry/rect_f.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/rect.h
diff --git a/ui/gfx/geometry/rect.h b/ui/gfx/geometry/rect.h
index a01e719882df5c6e2d6a150cde7619052f0cfbc6..beb6242318e3c33f4d973f4bfa36997130d9998f 100644
--- a/ui/gfx/geometry/rect.h
+++ b/ui/gfx/geometry/rect.h
@@ -34,12 +34,13 @@ class Insets;
class GFX_EXPORT Rect {
public:
- Rect() {}
- Rect(int width, int height) : size_(width, height) {}
- Rect(int x, int y, int width, int height)
+ constexpr Rect() = default;
+ constexpr Rect(int width, int height) : size_(width, height) {}
+ constexpr Rect(int x, int y, int width, int height)
: origin_(x, y), size_(width, height) {}
- explicit Rect(const Size& size) : size_(size) {}
- Rect(const Point& origin, const Size& size) : origin_(origin), size_(size) {}
+ constexpr explicit Rect(const Size& size) : size_(size) {}
+ constexpr Rect(const Point& origin, const Size& size)
+ : origin_(origin), size_(size) {}
#if defined(OS_WIN)
explicit Rect(const RECT& r);
@@ -47,8 +48,6 @@ class GFX_EXPORT Rect {
explicit Rect(const CGRect& r);
#endif
- ~Rect() {}
-
#if defined(OS_WIN)
// Construct an equivalent Win32 RECT object.
RECT ToRECT() const;
@@ -57,30 +56,30 @@ class GFX_EXPORT Rect {
CGRect ToCGRect() const;
#endif
- int x() const { return origin_.x(); }
+ constexpr int x() const { return origin_.x(); }
void set_x(int x) { origin_.set_x(x); }
- int y() const { return origin_.y(); }
+ constexpr int y() const { return origin_.y(); }
void set_y(int y) { origin_.set_y(y); }
- int width() const { return size_.width(); }
+ constexpr int width() const { return size_.width(); }
void set_width(int width) { size_.set_width(width); }
- int height() const { return size_.height(); }
+ constexpr int height() const { return size_.height(); }
void set_height(int height) { size_.set_height(height); }
- const Point& origin() const { return origin_; }
+ constexpr const Point& origin() const { return origin_; }
void set_origin(const Point& origin) { origin_ = origin; }
- const Size& size() const { return size_; }
+ constexpr const Size& size() const { return size_; }
void set_size(const Size& size) { size_ = size; }
- int right() const { return x() + width(); }
- int bottom() const { return y() + height(); }
+ constexpr int right() const { return x() + width(); }
+ constexpr int bottom() const { return y() + height(); }
- Point top_right() const { return Point(right(), y()); }
- Point bottom_left() const { return Point(x(), bottom()); }
- Point bottom_right() const { return Point(right(), bottom()); }
+ constexpr Point top_right() const { return Point(right(), y()); }
+ constexpr Point bottom_left() const { return Point(x(), bottom()); }
+ constexpr Point bottom_right() const { return Point(right(), bottom()); }
Vector2d OffsetFromOrigin() const { return Vector2d(x(), y()); }
« no previous file with comments | « ui/gfx/geometry/quad_f.h ('k') | ui/gfx/geometry/rect_f.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698