Add ICU message format support
[chromium-blink-merge.git] / ui / base / layout_mac.mm
blob62331e99f0d79311bb60d26761a56adffb4402d2
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
3 // found in the LICENSE file.
5 #include "ui/base/layout.h"
7 #include <Cocoa/Cocoa.h>
9 #include "base/mac/sdk_forward_declarations.h"
11 namespace {
13 float GetScaleFactorScaleForNativeView(gfx::NativeView view) {
14   if (NSWindow* window = [view window]) {
15     if ([window respondsToSelector:@selector(backingScaleFactor)])
16       return [window backingScaleFactor];
17     return [window userSpaceScaleFactor];
18   }
20   NSArray* screens = [NSScreen screens];
21   if (![screens count])
22     return 1.0f;
24   NSScreen* screen = [screens objectAtIndex:0];
25   if ([screen respondsToSelector:@selector(backingScaleFactor)])
26     return [screen backingScaleFactor];
27   return [screen userSpaceScaleFactor];
30 }  // namespace
32 namespace ui {
34 float GetScaleFactorForNativeView(gfx::NativeView view) {
35   return GetScaleFactorScaleForNativeView(view);
38 }  // namespace ui