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

Side by Side Diff: ui/base/layout_mac.mm

Issue 15870009: mac: Move more 10.7 api stuff into sdk_forward_declarations.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | ui/gfx/screen_mac.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 (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/base/layout.h" 5 #include "ui/base/layout.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 8
9 #if !defined(MAC_OS_X_VERSION_10_7) || \ 9 #include "base/mac/sdk_forward_declarations.h"
10 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
11
12 @interface NSScreen (LionAPI)
13 - (CGFloat)backingScaleFactor;
14 @end
15
16 @interface NSWindow (LionAPI)
17 - (CGFloat)backingScaleFactor;
18 @end
19
20 #endif // 10.7
21 10
22 namespace { 11 namespace {
23 12
24 float GetScaleFactorScaleForNativeView(gfx::NativeView view) { 13 float GetScaleFactorScaleForNativeView(gfx::NativeView view) {
25 if (NSWindow* window = [view window]) { 14 if (NSWindow* window = [view window]) {
26 if ([window respondsToSelector:@selector(backingScaleFactor)]) 15 if ([window respondsToSelector:@selector(backingScaleFactor)])
27 return [window backingScaleFactor]; 16 return [window backingScaleFactor];
28 return [window userSpaceScaleFactor]; 17 return [window userSpaceScaleFactor];
29 } 18 }
30 19
31 NSArray* screens = [NSScreen screens]; 20 NSArray* screens = [NSScreen screens];
32 if (![screens count]) 21 if (![screens count])
33 return 1.0f; 22 return 1.0f;
34 23
35 NSScreen* screen = [screens objectAtIndex:0]; 24 NSScreen* screen = [screens objectAtIndex:0];
36 if ([screen respondsToSelector:@selector(backingScaleFactor)]) 25 if ([screen respondsToSelector:@selector(backingScaleFactor)])
37 return [screen backingScaleFactor]; 26 return [screen backingScaleFactor];
38 return [screen userSpaceScaleFactor]; 27 return [screen userSpaceScaleFactor];
39 } 28 }
40 29
41 } // namespace 30 } // namespace
42 31
43 namespace ui { 32 namespace ui {
44 33
45 ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view) { 34 ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view) {
46 return GetScaleFactorFromScale(GetScaleFactorScaleForNativeView(view)); 35 return GetScaleFactorFromScale(GetScaleFactorScaleForNativeView(view));
47 } 36 }
48 37
49 } // namespace ui 38 } // namespace ui
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | ui/gfx/screen_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698