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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <QuartzCore/QuartzCore.h> 10 #include <QuartzCore/QuartzCore.h>
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 bool RenderWidgetHostViewMac::IsSurfaceAvailableForCopy() const { 875 bool RenderWidgetHostViewMac::IsSurfaceAvailableForCopy() const {
876 return browser_compositor_->GetDelegatedFrameHost()->CanCopyToBitmap(); 876 return browser_compositor_->GetDelegatedFrameHost()->CanCopyToBitmap();
877 } 877 }
878 878
879 bool RenderWidgetHostViewMac::IsShowing() { 879 bool RenderWidgetHostViewMac::IsShowing() {
880 return ![cocoa_view_ isHidden]; 880 return ![cocoa_view_ isHidden];
881 } 881 }
882 882
883 gfx::Rect RenderWidgetHostViewMac::GetViewBounds() const { 883 gfx::Rect RenderWidgetHostViewMac::GetViewBounds() const {
884 NSRect bounds = [cocoa_view_ bounds]; 884 NSRect bounds = [cocoa_view_ bounds];
885 const gfx::Size size(NSWidth(bounds), NSHeight(bounds));
885 // TODO(shess): In case of !window, the view has been removed from 886 // TODO(shess): In case of !window, the view has been removed from
886 // the view hierarchy because the tab isn't main. Could retrieve 887 // the view hierarchy because the tab isn't main. Could retrieve
887 // the information from the main tab for our window. 888 // the information from the main tab for our window.
888 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_); 889 NSWindow* enclosing_window = ApparentWindowForView(cocoa_view_);
889 if (!enclosing_window) 890 if (!enclosing_window)
890 return gfx::Rect(gfx::Size(NSWidth(bounds), NSHeight(bounds))); 891 return gfx::Rect(size);
891 892
892 bounds = [cocoa_view_ convertRect:bounds toView:nil]; 893 NSRect boundsInScreen = [cocoa_view_ convertRect:bounds toView:nil];
893 bounds = [enclosing_window convertRectToScreen:bounds]; 894 boundsInScreen = [enclosing_window convertRectToScreen:boundsInScreen];
894 return FlipNSRectToRectScreen(bounds); 895 const gfx::Point origin = FlipNSRectToRectScreen(boundsInScreen).origin();
896
897 // Note: The GetViewBounds() API is a bit weird: The origin of the Rect is a
898 // point on the screen, in the screen's coordinate system. However, the size
899 // of the Rect is the rendering size, and not necessarily the size this view
900 // will occupy in the screen. The two may be different whenever this view is
901 // being scaled by any layer transforms in the ancestors in the hierarchy.
902 //
903 // TODO(miu): GetViewBounds() should be fixed because it's really returning
904 // two different things in one return value. Perhaps it should be deprecated
905 // in favor of GetRequestedRendererSize() and something new like
906 // GetPositionOnScreen()?
907 return gfx::Rect(origin, size);
895 } 908 }
896 909
897 void RenderWidgetHostViewMac::UpdateCursor(const WebCursor& cursor) { 910 void RenderWidgetHostViewMac::UpdateCursor(const WebCursor& cursor) {
898 WebCursor web_cursor = cursor; 911 WebCursor web_cursor = cursor;
899 [cocoa_view_ updateCursor:web_cursor.GetNativeCursor()]; 912 [cocoa_view_ updateCursor:web_cursor.GetNativeCursor()];
900 } 913 }
901 914
902 void RenderWidgetHostViewMac::SetIsLoading(bool is_loading) { 915 void RenderWidgetHostViewMac::SetIsLoading(bool is_loading) {
903 is_loading_ = is_loading; 916 is_loading_ = is_loading;
904 // If we ever decide to show the waiting cursor while the page is loading 917 // If we ever decide to show the waiting cursor while the page is loading
(...skipping 2549 matching lines...) Expand 10 before | Expand all | Expand 10 after
3454 3467
3455 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3468 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3456 // regions that are not draggable. (See ControlRegionView in 3469 // regions that are not draggable. (See ControlRegionView in
3457 // native_app_window_cocoa.mm). This requires the render host view to be 3470 // native_app_window_cocoa.mm). This requires the render host view to be
3458 // draggable by default. 3471 // draggable by default.
3459 - (BOOL)mouseDownCanMoveWindow { 3472 - (BOOL)mouseDownCanMoveWindow {
3460 return YES; 3473 return YES;
3461 } 3474 }
3462 3475
3463 @end 3476 @end
OLDNEW
« 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