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

Side by Side Diff: ui/gfx/mac/coordinate_conversion.mm

Issue 1380083005: Mac: Use [NSArray firstObject] for [NSScreen screens] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
« no previous file with comments | « ui/gfx/color_profile_mac_unittest.mm ('k') | ui/gfx/mac/coordinate_conversion_unittest.mm » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ui/gfx/mac/coordinate_conversion.h" 5 #import "ui/gfx/mac/coordinate_conversion.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "ui/gfx/geometry/point.h" 9 #include "ui/gfx/geometry/point.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
11 11
12 namespace gfx { 12 namespace gfx {
13 13
14 namespace { 14 namespace {
15 15
16 // The height of the primary display, which OSX defines as the monitor with the 16 // The height of the primary display, which OSX defines as the monitor with the
17 // menubar. This is always at index 0. 17 // menubar. This is always at index 0.
18 CGFloat PrimaryDisplayHeight() { 18 CGFloat PrimaryDisplayHeight() {
19 return NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]); 19 return NSMaxY([[[NSScreen screens] firstObject] frame]);
20 } 20 }
21 21
22 } // namespace 22 } // namespace
23 23
24 NSRect ScreenRectToNSRect(const Rect& rect) { 24 NSRect ScreenRectToNSRect(const Rect& rect) {
25 return NSMakeRect(rect.x(), 25 return NSMakeRect(rect.x(),
26 PrimaryDisplayHeight() - rect.y() - rect.height(), 26 PrimaryDisplayHeight() - rect.y() - rect.height(),
27 rect.width(), 27 rect.width(),
28 rect.height()); 28 rect.height());
29 } 29 }
30 30
31 Rect ScreenRectFromNSRect(const NSRect& rect) { 31 Rect ScreenRectFromNSRect(const NSRect& rect) {
32 return Rect(rect.origin.x, 32 return Rect(rect.origin.x,
33 PrimaryDisplayHeight() - rect.origin.y - rect.size.height, 33 PrimaryDisplayHeight() - rect.origin.y - rect.size.height,
34 rect.size.width, rect.size.height); 34 rect.size.width, rect.size.height);
35 } 35 }
36 36
37 NSPoint ScreenPointToNSPoint(const Point& point) { 37 NSPoint ScreenPointToNSPoint(const Point& point) {
38 return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y()); 38 return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y());
39 } 39 }
40 40
41 Point ScreenPointFromNSPoint(const NSPoint& point) { 41 Point ScreenPointFromNSPoint(const NSPoint& point) {
42 return Point(point.x, PrimaryDisplayHeight() - point.y); 42 return Point(point.x, PrimaryDisplayHeight() - point.y);
43 } 43 }
44 44
45 } // namespace gfx 45 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/color_profile_mac_unittest.mm ('k') | ui/gfx/mac/coordinate_conversion_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698