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

Side by Side Diff: ui/gfx/rect_base_impl.h

Issue 11086037: Revert 160976 - The center of a rect is x+width/2, y+height/2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/aura/root_window_unittest.cc ('k') | ui/gfx/rect_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gfx/rect_base.h" 5 #include "ui/gfx/rect_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 9
10 // This file provides the implementation for RectBaese template and 10 // This file provides the implementation for RectBaese template and
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return Class(new_x, new_y, new_width, new_height); 261 return Class(new_x, new_y, new_width, new_height);
262 } 262 }
263 263
264 template<typename Class, 264 template<typename Class,
265 typename PointClass, 265 typename PointClass,
266 typename SizeClass, 266 typename SizeClass,
267 typename InsetsClass, 267 typename InsetsClass,
268 typename Type> 268 typename Type>
269 PointClass RectBase<Class, PointClass, SizeClass, InsetsClass, Type>:: 269 PointClass RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::
270 CenterPoint() const { 270 CenterPoint() const {
271 return PointClass(x() + width() / 2, y() + height() / 2); 271 return PointClass(x() + (width() - 1) / 2, y() + (height() - 1) / 2);
272 } 272 }
273 273
274 template<typename Class, 274 template<typename Class,
275 typename PointClass, 275 typename PointClass,
276 typename SizeClass, 276 typename SizeClass,
277 typename InsetsClass, 277 typename InsetsClass,
278 typename Type> 278 typename Type>
279 Class RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Center( 279 Class RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::Center(
280 const SizeClass& size) const { 280 const SizeClass& size) const {
281 Type new_width = std::min(width(), size.width()); 281 Type new_width = std::min(width(), size.width());
(...skipping 27 matching lines...) Expand all
309 typename Type> 309 typename Type>
310 bool RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::SharesEdgeWith( 310 bool RectBase<Class, PointClass, SizeClass, InsetsClass, Type>::SharesEdgeWith(
311 const Class& rect) const { 311 const Class& rect) const {
312 return (y() == rect.y() && height() == rect.height() && 312 return (y() == rect.y() && height() == rect.height() &&
313 (x() == rect.right() || right() == rect.x())) || 313 (x() == rect.right() || right() == rect.x())) ||
314 (x() == rect.x() && width() == rect.width() && 314 (x() == rect.x() && width() == rect.width() &&
315 (y() == rect.bottom() || bottom() == rect.y())); 315 (y() == rect.bottom() || bottom() == rect.y()));
316 } 316 }
317 317
318 } // namespace gfx 318 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/aura/root_window_unittest.cc ('k') | ui/gfx/rect_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698