summaryrefslogtreecommitdiffstats
path: root/ui/gfx/size_f.cc
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-09 19:27:43 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-04-09 19:27:43 +0000
commit29197f8cd1fd499128a2ad845a866313d4eeaf00 (patch)
tree137cc52803e518f7b4edd94b93ab0c89d6df8aa8 /ui/gfx/size_f.cc
parente7aa62a3bf6993369b5adb61028fddb3eb7a58bf (diff)
downloadchromium_src-29197f8cd1fd499128a2ad845a866313d4eeaf00.zip
chromium_src-29197f8cd1fd499128a2ad845a866313d4eeaf00.tar.gz
chromium_src-29197f8cd1fd499128a2ad845a866313d4eeaf00.tar.bz2
Floating point based Point/Size/Rect and Insets
This is copied from integer version, instead of using template, to minimize conflict with m19 branch, as using template requires updating forward declaration of these classes in many places. I put this behind gyp flag for now so that we can move forward without breaking non DIP build until we can get aura working with DIP. BUG=114664 TEST=none Review URL: http://codereview.chromium.org/10025004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/size_f.cc')
-rw-r--r--ui/gfx/size_f.cc41
1 files changed, 41 insertions, 0 deletions
diff --git a/ui/gfx/size_f.cc b/ui/gfx/size_f.cc
new file mode 100644
index 0000000..aeffdd3
--- /dev/null
+++ b/ui/gfx/size_f.cc
@@ -0,0 +1,41 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/gfx/size_f.h"
+
+#include "base/logging.h"
+#include "base/stringprintf.h"
+
+namespace gfx {
+
+SizeF::SizeF() : width_(0), height_(0) {}
+
+SizeF::SizeF(float width, float height) {
+ set_width(width);
+ set_height(height);
+}
+
+SizeF::~SizeF() {}
+
+void SizeF::set_width(float width) {
+ if (width < 0) {
+ NOTREACHED() << "negative width:" << width;
+ width = 0;
+ }
+ width_ = width;
+}
+
+void SizeF::set_height(float height) {
+ if (height < 0) {
+ NOTREACHED() << "negative height:" << height;
+ height = 0;
+ }
+ height_ = height;
+}
+
+std::string SizeF::ToString() const {
+ return base::StringPrintf("%fx%f", width_, height_);
+}
+
+} // namespace gfx