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

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

Issue 42336: Adds Get(Root)WindowRect handlers for the Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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/resource_message_filter_mac.mm
===================================================================
--- chrome/browser/renderer_host/resource_message_filter_mac.mm (revision 0)
+++ chrome/browser/renderer_host/resource_message_filter_mac.mm (revision 0)
@@ -0,0 +1,51 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/renderer_host/resource_message_filter.h"
+
+#import <Cocoa/Cocoa.h>
+
+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;
+}
+
+}
+
+void ResourceMessageFilter::OnGetWindowRect(gfx::NativeViewId window_id,
+ gfx::Rect* rect) {
+ NSView* view = gfx::NativeViewFromId(window_id);
+ DCHECK(view);
+
+ if (!view) { // paranoia
+ *rect = gfx::Rect();
+ return;
+ }
+
+ NSRect bounds = [view bounds];
+ bounds = [view convertRect:bounds toView:nil];
+ bounds.origin = [[view window] convertBaseToScreen:bounds.origin];
+ *rect = NSRectToRect(bounds, [[view window] screen]);
+}
+
+void ResourceMessageFilter::OnGetRootWindowRect(gfx::NativeViewId window_id,
+ gfx::Rect* rect) {
+ NSView* view = gfx::NativeViewFromId(window_id);
+ DCHECK(view);
+
+ if (!view) { // paranoia
+ *rect = gfx::Rect();
+ return;
+ }
+
+ NSWindow* window = [view window];
+ NSRect bounds = [window frame];
+ *rect = NSRectToRect(bounds, [window screen]);
+}
Property changes on: chrome/browser/renderer_host/resource_message_filter_mac.mm
___________________________________________________________________
Name: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698