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

Unified Diff: ui/gfx/geometry/size.cc

Issue 662273002: gfx:: De-templatize Size and SizeF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: inlines-size: . Created 6 years, 2 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/size.h ('k') | ui/gfx/geometry/size_base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/geometry/size.cc
diff --git a/ui/gfx/geometry/size.cc b/ui/gfx/geometry/size.cc
index 38ec4b3a516836f97582ce9c1ccad5ed7f29f54b..d916ebdadd3c94b2449060a10d7b36baf673d023 100644
--- a/ui/gfx/geometry/size.cc
+++ b/ui/gfx/geometry/size.cc
@@ -12,13 +12,16 @@
namespace gfx {
-template class SizeBase<Size, int>;
-
-#if defined(OS_MACOSX)
-Size::Size(const CGSize& s)
- : SizeBase<Size, int>(s.width, s.height) {
+#if defined(OS_WIN)
+SIZE Size::ToSIZE() const {
+ SIZE s;
+ s.cx = width();
+ s.cy = height();
+ return s;
}
+#endif
+#if defined(OS_MACOSX)
Size& Size::operator=(const CGSize& s) {
set_width(s.width);
set_height(s.height);
@@ -26,18 +29,23 @@ Size& Size::operator=(const CGSize& s) {
}
#endif
-#if defined(OS_WIN)
-SIZE Size::ToSIZE() const {
- SIZE s;
- s.cx = width();
- s.cy = height();
- return s;
+int Size::GetArea() const {
+ return width() * height();
}
-#elif defined(OS_MACOSX)
-CGSize Size::ToCGSize() const {
- return CGSizeMake(width(), height());
+
+void Size::Enlarge(int grow_width, int grow_height) {
+ SetSize(width() + grow_width, height() + grow_height);
+}
+
+void Size::SetToMin(const Size& other) {
+ width_ = width() <= other.width() ? width() : other.width();
+ height_ = height() <= other.height() ? height() : other.height();
+}
+
+void Size::SetToMax(const Size& other) {
+ width_ = width() >= other.width() ? width() : other.width();
+ height_ = height() >= other.height() ? height() : other.height();
}
-#endif
std::string Size::ToString() const {
return base::StringPrintf("%dx%d", width(), height());
« no previous file with comments | « ui/gfx/geometry/size.h ('k') | ui/gfx/geometry/size_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698