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

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

Issue 2016243002: Mac a11y: Add RoleDescription and Value attributes to accessibility information. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: TODO for comparing against Cocoa. Created 4 years, 6 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 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 #include "ui/gfx/geometry/size.h"
11 12
12 namespace gfx { 13 namespace gfx {
13 14
14 namespace { 15 namespace {
15 16
16 // The height of the primary display, which OSX defines as the monitor with the 17 // The height of the primary display, which OSX defines as the monitor with the
17 // menubar. This is always at index 0. 18 // menubar. This is always at index 0.
18 CGFloat PrimaryDisplayHeight() { 19 CGFloat PrimaryDisplayHeight() {
19 return NSMaxY([[[NSScreen screens] firstObject] frame]); 20 return NSMaxY([[[NSScreen screens] firstObject] frame]);
20 } 21 }
21 22
22 } // namespace 23 } // namespace
23 24
24 NSRect ScreenRectToNSRect(const Rect& rect) { 25 NSRect ScreenRectToNSRect(const Rect& rect) {
25 return NSMakeRect(rect.x(), 26 return NSMakeRect(rect.x(),
26 PrimaryDisplayHeight() - rect.y() - rect.height(), 27 PrimaryDisplayHeight() - rect.y() - rect.height(),
27 rect.width(), 28 rect.width(),
28 rect.height()); 29 rect.height());
29 } 30 }
30 31
31 Rect ScreenRectFromNSRect(const NSRect& rect) { 32 Rect ScreenRectFromNSRect(const NSRect& rect) {
32 return Rect(rect.origin.x, 33 return Rect(rect.origin.x,
33 PrimaryDisplayHeight() - rect.origin.y - rect.size.height, 34 PrimaryDisplayHeight() - rect.origin.y - rect.size.height,
34 rect.size.width, rect.size.height); 35 rect.size.width, rect.size.height);
35 } 36 }
36 37
38 NSSize ScreenSizeToNSSize(const Size& size) {
39 return NSMakeSize(size.width(), size.height());
40 }
41
42 Size ScreenSizeFromNSSize(const NSSize& size) {
43 return Size(size.width, size.height);
44 }
45
37 NSPoint ScreenPointToNSPoint(const Point& point) { 46 NSPoint ScreenPointToNSPoint(const Point& point) {
38 return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y()); 47 return NSMakePoint(point.x(), PrimaryDisplayHeight() - point.y());
39 } 48 }
40 49
41 Point ScreenPointFromNSPoint(const NSPoint& point) { 50 Point ScreenPointFromNSPoint(const NSPoint& point) {
42 return Point(point.x, PrimaryDisplayHeight() - point.y); 51 return Point(point.x, PrimaryDisplayHeight() - point.y);
43 } 52 }
44 53
45 } // namespace gfx 54 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698