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

Unified Diff: ui/gfx/geometry/size_f.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: 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
Index: ui/gfx/geometry/size_f.h
diff --git a/ui/gfx/geometry/size_f.h b/ui/gfx/geometry/size_f.h
index 2ee2f51973c635e96ad0236067d5ae9fedb88482..bde15e5f32f7b373ebb4a528afc6cb9be69108b6 100644
--- a/ui/gfx/geometry/size_f.h
+++ b/ui/gfx/geometry/size_f.h
@@ -18,17 +18,16 @@ namespace gfx {
// A floating version of gfx::Size.
class GFX_EXPORT SizeF {
public:
- SizeF() : width_(0.f), height_(0.f) {}
- SizeF(float width, float height)
- : width_(fmaxf(0, width)), height_(fmaxf(0, height)) {}
- ~SizeF() {}
+ constexpr SizeF() : width_(0.f), height_(0.f) {}
+ constexpr SizeF(float width, float height)
+ : width_(width < 0 ? 0 : width), height_(height < 0 ? 0 : height) {}
Peter Kasting 2016/06/10 00:19:19 This behavior will only differ when one of the pro
danakj 2016/06/10 00:36:48 Hm. https://bugs.chromium.org/p/chromium/issues/de
Peter Kasting 2016/06/10 05:50:06 Is there somewhere that covers how to do this/what
Peter Kasting 2016/06/10 07:03:18 ...except on MSVC. F___. OK, going back to my ot
- explicit SizeF(const Size& size)
+ constexpr explicit SizeF(const Size& size)
: SizeF(static_cast<float>(size.width()),
static_cast<float>(size.height())) {}
- float width() const { return width_; }
- float height() const { return height_; }
+ constexpr float width() const { return width_; }
+ constexpr float height() const { return height_; }
void set_width(float width) { width_ = fmaxf(0, width); }
void set_height(float height) { height_ = fmaxf(0, height); }
« ui/gfx/geometry/rect.h ('K') | « ui/gfx/geometry/size.h ('k') | ui/gfx/geometry/vector2d.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698