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

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

Issue 10908074: mac: Use convertSizeFromBacking: instead of the deprecated ...FromBase: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 3 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 | « chrome/browser/ui/cocoa/nsview_additions.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) || \
10 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
11
9 @interface NSScreen (LionAPI) 12 @interface NSScreen (LionAPI)
10 - (CGFloat)backingScaleFactor; 13 - (CGFloat)backingScaleFactor;
11 @end 14 @end
12 15
13 @interface NSWindow (LionAPI) 16 @interface NSWindow (LionAPI)
14 - (CGFloat)backingScaleFactor; 17 - (CGFloat)backingScaleFactor;
15 @end 18 @end
16 19
20 #endif // 10.7
21
17 namespace { 22 namespace {
18 23
19 float GetScaleFactorScaleForNativeView(gfx::NativeView view) { 24 float GetScaleFactorScaleForNativeView(gfx::NativeView view) {
20 if (NSWindow* window = [view window]) { 25 if (NSWindow* window = [view window]) {
21 if ([window respondsToSelector:@selector(backingScaleFactor)]) 26 if ([window respondsToSelector:@selector(backingScaleFactor)])
22 return [window backingScaleFactor]; 27 return [window backingScaleFactor];
23 return [window userSpaceScaleFactor]; 28 return [window userSpaceScaleFactor];
24 } 29 }
25 30
26 NSArray* screens = [NSScreen screens]; 31 NSArray* screens = [NSScreen screens];
27 if (![screens count]) 32 if (![screens count])
28 return 1.0f; 33 return 1.0f;
29 34
30 NSScreen* screen = [screens objectAtIndex:0]; 35 NSScreen* screen = [screens objectAtIndex:0];
31 if ([screen respondsToSelector:@selector(backingScaleFactor)]) 36 if ([screen respondsToSelector:@selector(backingScaleFactor)])
32 return [screen backingScaleFactor]; 37 return [screen backingScaleFactor];
33 return [screen userSpaceScaleFactor]; 38 return [screen userSpaceScaleFactor];
34 } 39 }
35 40
36 } // namespace 41 } // namespace
37 42
38 namespace ui { 43 namespace ui {
39 44
40 ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view) { 45 ScaleFactor GetScaleFactorForNativeView(gfx::NativeView view) {
41 return GetScaleFactorFromScale(GetScaleFactorScaleForNativeView(view)); 46 return GetScaleFactorFromScale(GetScaleFactorScaleForNativeView(view));
42 } 47 }
43 48
44 } // namespace ui 49 } // namespace ui
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/nsview_additions.mm ('k') | ui/gfx/screen_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698