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

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 151130: Wire GetWindowRect, GetRootWindowRect, and GetScreenInfo out to the UI thread. (Closed)
Patch Set: Darin's suggestions. Created 11 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/chrome/browser/renderer_host/render_widget_host_view_mac.mm b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
index d5082a2450ae076e1a2d16bc77e266455b004fc4..a039497887bc2bcc8ebf934d1734af715e5fd62e 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/chrome/browser/renderer_host/render_widget_host_view_mac.mm
@@ -338,6 +338,44 @@ void RenderWidgetHostViewMac::ShutdownHost() {
// Do not touch any members at this point, |this| has been deleted.
}
+namespace {
+
+// Adjusts an NSRect in screen coordinates to have an origin in the upper left,
+// and stuffs it into a gfx::Rect. This is likely incorrect for a multiple-
+// monitor setup.
+gfx::Rect NSRectToRect(const NSRect rect, NSScreen* screen) {
+ gfx::Rect new_rect(NSRectToCGRect(rect));
+ new_rect.set_y([screen frame].size.height - new_rect.y() - new_rect.height());
+ return new_rect;
+}
+
+} // namespace
+
+gfx::Rect RenderWidgetHostViewMac::GetWindowRect() {
+ // TODO(shess): In case of !window, the view has been removed from
+ // the view hierarchy because the tab isn't main. Could retrieve
+ // the information from the main tab for our window.
+ if (!cocoa_view_ || ![cocoa_view_ window]) {
+ return gfx::Rect();
+ }
+
+ NSRect bounds = [cocoa_view_ bounds];
+ bounds = [cocoa_view_ convertRect:bounds toView:nil];
+ bounds.origin = [[cocoa_view_ window] convertBaseToScreen:bounds.origin];
+ return NSRectToRect(bounds, [[cocoa_view_ window] screen]);
+}
+
+gfx::Rect RenderWidgetHostViewMac::GetRootWindowRect() {
+ // TODO(shess): In case of !window, the view has been removed from
+ // the view hierarchy because the tab isn't main. Could retrieve
+ // the information from the main tab for our window.
+ if (!cocoa_view_ || ![cocoa_view_ window]) {
+ return gfx::Rect();
+ }
+
+ NSRect bounds = [[cocoa_view_ window] frame];
+ return NSRectToRect(bounds, [[cocoa_view_ window] screen]);
+}
// RenderWidgetHostViewCocoa ---------------------------------------------------
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_mac.h ('k') | chrome/browser/renderer_host/resource_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698