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

Side by Side Diff: webkit/glue/webkit_glue_mac.mm

Issue 58008: Replace webkit/glue/screen_info.h with WebKit/chromium/public/WebScreenInfo.h... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 8 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
OLDNEW
(Empty)
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4
5 #include "config.h"
6
7 #include "webkit/glue/webkit_glue.h"
8
9 #import <AppKit/AppKit.h>
10
11 #include "webkit/glue/screen_info.h"
12
13 namespace webkit_glue {
14
15 static NSScreen *ScreenForWindow(NSWindow *window) {
16 NSScreen *screen = [window screen]; // nil if the window is off-screen
17 if (screen)
18 return screen;
19
20 NSArray *screens = [NSScreen screens];
21 if ([screens count] > 0)
22 return [screens objectAtIndex:0]; // screen containing the menubar
23
24 return nil;
25 }
26
27 static gfx::Rect ToUserSpace(const NSRect& rect, NSWindow *destination) {
28 CGRect user_rect = NSRectToCGRect(rect);
29
30 user_rect.origin.y =
31 NSMaxY([ScreenForWindow(destination) frame]) -
32 (user_rect.origin.y + user_rect.size.height); // flip
33
34 if (destination) {
35 CGFloat scale = 1 / [destination userSpaceScaleFactor]; // scale down
36 user_rect.origin.x *= scale;
37 user_rect.origin.y *= scale;
38 user_rect.size.width *= scale;
39 user_rect.size.height *= scale;
40 }
41
42 return gfx::Rect(user_rect);
43 }
44
45 ScreenInfo GetScreenInfoHelper(gfx::NativeView view) {
46 NSString *color_space = NSColorSpaceFromDepth([[NSScreen deepestScreen] depth] );
47 bool monochrome = color_space == NSCalibratedWhiteColorSpace ||
48 color_space == NSCalibratedBlackColorSpace ||
49 color_space == NSDeviceWhiteColorSpace ||
50 color_space == NSDeviceBlackColorSpace;
51
52 ScreenInfo results;
53 results.depth =
54 NSBitsPerPixelFromDepth([[NSScreen deepestScreen] depth]);
55 results.depth_per_component =
56 NSBitsPerSampleFromDepth([[NSScreen deepestScreen] depth]);
57 results.is_monochrome =
58 color_space == NSCalibratedWhiteColorSpace ||
59 color_space == NSCalibratedBlackColorSpace ||
60 color_space == NSDeviceWhiteColorSpace ||
61 color_space == NSDeviceBlackColorSpace;
62 results.rect =
63 ToUserSpace([ScreenForWindow([view window]) frame], [view window]);
64 results.available_rect =
65 ToUserSpace([ScreenForWindow([view window]) visibleFrame], [view window]);
66 return results;
67 }
68
69 } // namespace webkit_glue
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698