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

Side by Side Diff: ui/gfx/geometry/rect.cc

Issue 1061733002: Remove windows/mac/ios specific code from //ui (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix default try set Created 5 years, 8 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
« no previous file with comments | « ui/gfx/geometry/rect.h ('k') | ui/gfx/geometry/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/geometry/rect.h" 5 #include "ui/gfx/geometry/rect.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #if defined(OS_WIN)
10 #include <windows.h>
11 #endif
12
13 #include "base/logging.h" 9 #include "base/logging.h"
14 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
15 #include "ui/gfx/geometry/insets.h" 11 #include "ui/gfx/geometry/insets.h"
16 12
17 namespace gfx { 13 namespace gfx {
18 14
19 #if defined(OS_WIN)
20 Rect::Rect(const RECT& r)
21 : origin_(r.left, r.top),
22 size_(std::abs(r.right - r.left), std::abs(r.bottom - r.top)) {
23 }
24 #elif defined(OS_MACOSX)
25 Rect::Rect(const CGRect& r)
26 : origin_(r.origin.x, r.origin.y), size_(r.size.width, r.size.height) {
27 }
28 #endif
29
30 #if defined(OS_WIN)
31 RECT Rect::ToRECT() const {
32 RECT r;
33 r.left = x();
34 r.right = right();
35 r.top = y();
36 r.bottom = bottom();
37 return r;
38 }
39 #elif defined(OS_MACOSX)
40 CGRect Rect::ToCGRect() const {
41 return CGRectMake(x(), y(), width(), height());
42 }
43 #endif
44
45 void AdjustAlongAxis(int dst_origin, int dst_size, int* origin, int* size) { 15 void AdjustAlongAxis(int dst_origin, int dst_size, int* origin, int* size) {
46 *size = std::min(dst_size, *size); 16 *size = std::min(dst_size, *size);
47 if (*origin < dst_origin) 17 if (*origin < dst_origin)
48 *origin = dst_origin; 18 *origin = dst_origin;
49 else 19 else
50 *origin = std::min(dst_origin + dst_size, *origin + *size) - *size; 20 *origin = std::min(dst_origin + dst_size, *origin + *size) - *size;
51 } 21 }
52 22
53 } // namespace 23 } // namespace
54 24
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 242
273 Rect BoundingRect(const Point& p1, const Point& p2) { 243 Rect BoundingRect(const Point& p1, const Point& p2) {
274 int rx = std::min(p1.x(), p2.x()); 244 int rx = std::min(p1.x(), p2.x());
275 int ry = std::min(p1.y(), p2.y()); 245 int ry = std::min(p1.y(), p2.y());
276 int rr = std::max(p1.x(), p2.x()); 246 int rr = std::max(p1.x(), p2.x());
277 int rb = std::max(p1.y(), p2.y()); 247 int rb = std::max(p1.y(), p2.y());
278 return Rect(rx, ry, rr - rx, rb - ry); 248 return Rect(rx, ry, rr - rx, rb - ry);
279 } 249 }
280 250
281 } // namespace gfx 251 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/geometry/rect.h ('k') | ui/gfx/geometry/rect_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698