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

Side by Side Diff: chrome/browser/ui/cocoa/panels/panel_utils_cocoa.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
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 #import "chrome/browser/ui/cocoa/panels/panel_utils_cocoa.h" 5 #import "chrome/browser/ui/cocoa/panels/panel_utils_cocoa.h"
6 6
7 namespace cocoa_utils { 7 namespace cocoa_utils {
8 8
9 NSRect ConvertRectToCocoaCoordinates(const gfx::Rect& bounds) { 9 NSRect ConvertRectToCocoaCoordinates(const gfx::Rect& bounds) {
10 // Flip coordinates based on the primary screen. 10 // Flip coordinates based on the primary screen.
11 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 11 NSScreen* screen = [[NSScreen screens] firstObject];
12 12
13 return NSMakeRect( 13 return NSMakeRect(
14 bounds.x(), NSHeight([screen frame]) - bounds.height() - bounds.y(), 14 bounds.x(), NSHeight([screen frame]) - bounds.height() - bounds.y(),
15 bounds.width(), bounds.height()); 15 bounds.width(), bounds.height());
16 } 16 }
17 17
18 gfx::Rect ConvertRectFromCocoaCoordinates(NSRect bounds) { 18 gfx::Rect ConvertRectFromCocoaCoordinates(NSRect bounds) {
19 // Flip coordinates based on the primary screen. 19 // Flip coordinates based on the primary screen.
20 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 20 NSScreen* screen = [[NSScreen screens] firstObject];
21 21
22 return gfx::Rect( 22 return gfx::Rect(
23 NSMinX(bounds), NSHeight([screen frame]) - NSMaxY(bounds), 23 NSMinX(bounds), NSHeight([screen frame]) - NSMaxY(bounds),
24 NSWidth(bounds), NSHeight(bounds)); 24 NSWidth(bounds), NSHeight(bounds));
25 } 25 }
26 26
27 NSPoint ConvertPointToCocoaCoordinates(const gfx::Point& point) { 27 NSPoint ConvertPointToCocoaCoordinates(const gfx::Point& point) {
28 // Flip coordinates based on the primary screen. 28 // Flip coordinates based on the primary screen.
29 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 29 NSScreen* screen = [[NSScreen screens] firstObject];
30 30
31 return NSMakePoint(point.x(), NSHeight([screen frame]) - point.y()); 31 return NSMakePoint(point.x(), NSHeight([screen frame]) - point.y());
32 } 32 }
33 33
34 gfx::Point ConvertPointFromCocoaCoordinates(NSPoint point) { 34 gfx::Point ConvertPointFromCocoaCoordinates(NSPoint point) {
35 // Flip coordinates based on the primary screen. 35 // Flip coordinates based on the primary screen.
36 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 36 NSScreen* screen = [[NSScreen screens] firstObject];
37 37
38 return gfx::Point(point.x, NSHeight([screen frame]) - point.y); 38 return gfx::Point(point.x, NSHeight([screen frame]) - point.y);
39 } 39 }
40 40
41 } // namespace cocoa_utils 41 } // namespace cocoa_utils
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm ('k') | chrome/browser/ui/cocoa/presentation_mode_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698