diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-11 09:07:01 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-11 09:07:01 +0000 |
commit | e5c45f6c5f6778f1da0053ccbb8d95a15bdbcc14 (patch) | |
tree | d319bff466a413f5e090a542e058ce7ef7ed2b85 /ui/gfx/point.cc | |
parent | 394633964593be10c6bb220c73083e1b8308bf23 (diff) | |
download | chromium_src-e5c45f6c5f6778f1da0053ccbb8d95a15bdbcc14.zip chromium_src-e5c45f6c5f6778f1da0053ccbb8d95a15bdbcc14.tar.gz chromium_src-e5c45f6c5f6778f1da0053ccbb8d95a15bdbcc14.tar.bz2 |
Use template for Point/Size/Rect and remove duplicates
BUG=114664
TEST=none
Review URL: https://chromiumcodereview.appspot.com/10014027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@131737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/point.cc')
-rw-r--r-- | ui/gfx/point.cc | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/ui/gfx/point.cc b/ui/gfx/point.cc index ba9ced7..24e1ca2 100644 --- a/ui/gfx/point.cc +++ b/ui/gfx/point.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// 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. @@ -12,45 +12,49 @@ namespace gfx { -Point::Point() : x_(0), y_(0) { +template<> +PointBase<Point,int>::PointBase(int x, int y) : x_(x), y_(y) { } -Point::Point(int x, int y) : x_(x), y_(y) { +Point::Point() : PointBase<Point, int>(0, 0) { +} + +Point::Point(int x, int y) : PointBase<Point, int>(x, y) { } #if defined(OS_WIN) -Point::Point(DWORD point) { +Point::Point(DWORD point) : PointBase<Point, int>(0, 0){ POINTS points = MAKEPOINTS(point); - x_ = points.x; - y_ = points.y; + set_x(points.x); + set_y(points.y); } -Point::Point(const POINT& point) : x_(point.x), y_(point.y) { +Point::Point(const POINT& point) : PointBase<Point, int>(point.x, point.y) { } Point& Point::operator=(const POINT& point) { - x_ = point.x; - y_ = point.y; + set_x(point.x); + set_y(point.y); return *this; } POINT Point::ToPOINT() const { POINT p; - p.x = x_; - p.y = y_; + p.x = x(); + p.y = y(); return p; } #elif defined(OS_MACOSX) -Point::Point(const CGPoint& point) : x_(point.x), y_(point.y) { +Point::Point(const CGPoint& point) : PointBase<Point, int>(point.x, point.y) { } CGPoint Point::ToCGPoint() const { - return CGPointMake(x_, y_); + return CGPointMake(x(), y()); } #endif std::string Point::ToString() const { - return base::StringPrintf("%d,%d", x_, y_); + return base::StringPrintf("%d,%d", x(), y()); } } // namespace gfx |