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

Side by Side Diff: chrome/browser/renderer_host/resource_message_filter_mac.mm

Issue 67145: Linux: move X operations from the IO to UI2 thread. (Closed)
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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/resource_message_filter.h" 5 #include "chrome/browser/renderer_host/resource_message_filter.h"
6 #include "chrome/common/render_messages.h"
6 7
7 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
8 9
9 namespace { 10 namespace {
10 11
11 // Adjusts an NSRect in screen coordinates to have an origin in the upper left, 12 // Adjusts an NSRect in screen coordinates to have an origin in the upper left,
12 // and stuffs it into a gfx::Rect. This is likely incorrect for a multiple- 13 // and stuffs it into a gfx::Rect. This is likely incorrect for a multiple-
13 // monitor setup. 14 // monitor setup.
14 gfx::Rect NSRectToRect(const NSRect rect, NSScreen* screen) { 15 gfx::Rect NSRectToRect(const NSRect rect, NSScreen* screen) {
15 gfx::Rect new_rect(NSRectToCGRect(rect)); 16 gfx::Rect new_rect(NSRectToCGRect(rect));
16 new_rect.set_y([screen frame].size.height - new_rect.y() - new_rect.height()); 17 new_rect.set_y([screen frame].size.height - new_rect.y() - new_rect.height());
17 return new_rect; 18 return new_rect;
18 } 19 }
19 20
20 } 21 }
21 22
22 // We get null window_ids passed into the two functions below; please see 23 // We get null window_ids passed into the two functions below; please see
23 // http://crbug.com/9060 for more details. 24 // http://crbug.com/9060 for more details.
24 25
25 void ResourceMessageFilter::OnGetWindowRect(gfx::NativeViewId window_id, 26 void ResourceMessageFilter::OnGetWindowRect(gfx::NativeViewId window_id,
26 gfx::Rect* rect) { 27 IPC::Message* reply_msg) {
27 NSView* view = gfx::NativeViewFromId(window_id); 28 NSView* view = gfx::NativeViewFromId(window_id);
28 if (!view) { 29 gfx::Rect rect;
29 *rect = gfx::Rect(); 30
30 return; 31 if (view) {
32 NSRect bounds = [view bounds];
33 bounds = [view convertRect:bounds toView:nil];
34 bounds.origin = [[view window] convertBaseToScreen:bounds.origin];
35 rect = NSRectToRect(bounds, [[view window] screen]);
31 } 36 }
32 37
33 NSRect bounds = [view bounds]; 38 ViewHostMsg_GetWindowRect::WriteReplyParams(reply_msg, rect);
34 bounds = [view convertRect:bounds toView:nil]; 39 Send(reply_msg);
35 bounds.origin = [[view window] convertBaseToScreen:bounds.origin];
36 *rect = NSRectToRect(bounds, [[view window] screen]);
37 } 40 }
38 41
39 void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId window_id, 42 void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId window_id,
40 gfx::Rect* rect) { 43 IPC::Message* reply_msg) {
41 NSView* view = gfx::NativeViewFromId(window_id); 44 NSView* view = gfx::NativeViewFromId(window_id);
42 if (!view) { 45 gfx::Rect rect;
43 *rect = gfx::Rect(); 46 if (view) {
44 return; 47 NSWindow* window = [view window];
48 NSRect bounds = [window frame];
49 gfx::Rect rect = NSRectToRect(bounds, [window screen]);
45 } 50 }
46 51
47 NSWindow* window = [view window]; 52 ViewHostMsg_GetRootWindowRect::WriteReplyParams(reply_msg, rect);
48 NSRect bounds = [window frame]; 53 Send(reply_msg);
49 *rect = NSRectToRect(bounds, [window screen]);
50 } 54 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698