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

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

Issue 2654413002: Stretching NativeViewHost, and misc tab capture fixes.
Patch Set: Gettin' it all working on ui/cocoa and MacViews too. Created 3 years, 10 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: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 79061b448a4830f99fb8958cb6b72d51a3b1ced9..79681423257ca1db220520e90791515cda526fcb 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -882,16 +882,29 @@ new BrowserCompositorMac(this, this, render_widget_host_->is_hidden(),
gfx::Rect RenderWidgetHostViewMac::GetViewBounds() const {
NSRect bounds = [cocoa_view_ bounds];
+ const gfx::Size size(NSWidth(bounds), NSHeight(bounds));
// 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.
NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_);
if (!enclosing_window)
- return gfx::Rect(gfx::Size(NSWidth(bounds), NSHeight(bounds)));
+ return gfx::Rect(size);
- bounds = [cocoa_view_ convertRect:bounds toView:nil];
- bounds = [enclosing_window convertRectToScreen:bounds];
- return FlipNSRectToRectScreen(bounds);
+ NSRect boundsInScreen = [cocoa_view_ convertRect:bounds toView:nil];
+ boundsInScreen = [enclosing_window convertRectToScreen:boundsInScreen];
+ const gfx::Point origin = FlipNSRectToRectScreen(boundsInScreen).origin();
+
+ // Note: The GetViewBounds() API is a bit weird: The origin of the Rect is a
+ // point on the screen, in the screen's coordinate system. However, the size
+ // of the Rect is the rendering size, and not necessarily the size this view
+ // will occupy in the screen. The two may be different whenever this view is
+ // being scaled by any layer transforms in the ancestors in the hierarchy.
+ //
+ // TODO(miu): GetViewBounds() should be fixed because it's really returning
+ // two different things in one return value. Perhaps it should be deprecated
+ // in favor of GetRequestedRendererSize() and something new like
+ // GetPositionOnScreen()?
+ return gfx::Rect(origin, size);
}
void RenderWidgetHostViewMac::UpdateCursor(const WebCursor& cursor) {
« no previous file with comments | « content/browser/renderer_host/delegated_frame_host.cc ('k') | content/browser/web_contents/web_contents_view_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698