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

Side by Side Diff: content/browser/web_contents/web_contents_view_mac.mm

Issue 2592243002: Perform direct routing of mouse events when the pointer is locked. (Closed)
Patch Set: addressing comments 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
« no previous file with comments | « content/browser/web_contents/web_contents_view_mac.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import <Carbon/Carbon.h> 5 #import <Carbon/Carbon.h>
6 6
7 #import "content/browser/web_contents/web_contents_view_mac.h" 7 #import "content/browser/web_contents/web_contents_view_mac.h"
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 - (void)cancelDeferredClose; 73 - (void)cancelDeferredClose;
74 - (void)clearWebContentsView; 74 - (void)clearWebContentsView;
75 - (void)closeTabAfterEvent; 75 - (void)closeTabAfterEvent;
76 - (void)updateWebContentsVisibility; 76 - (void)updateWebContentsVisibility;
77 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; 77 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification;
78 - (content::WebContentsImpl*)webContents; 78 - (content::WebContentsImpl*)webContents;
79 @end 79 @end
80 80
81 namespace { 81 namespace {
82 82
83 WebContentsViewMac::RenderWidgetHostViewCreateFunction
84 g_create_render_widget_host_view = nullptr;
85
83 content::ScreenInfo GetNSViewScreenInfo(NSView* view) { 86 content::ScreenInfo GetNSViewScreenInfo(NSView* view) {
84 display::Display display = 87 display::Display display =
85 display::Screen::GetScreen()->GetDisplayNearestWindow(view); 88 display::Screen::GetScreen()->GetDisplayNearestWindow(view);
86 89
87 content::ScreenInfo results; 90 content::ScreenInfo results;
88 results.device_scale_factor = static_cast<int>(display.device_scale_factor()); 91 results.device_scale_factor = static_cast<int>(display.device_scale_factor());
89 results.icc_profile = display.icc_profile(); 92 results.icc_profile = display.icc_profile();
90 results.depth = display.color_depth(); 93 results.depth = display.color_depth();
91 results.depth_per_component = display.depth_per_component(); 94 results.depth_per_component = display.depth_per_component();
92 results.is_monochrome = display.is_monochrome(); 95 results.is_monochrome = display.is_monochrome();
93 results.rect = display.bounds(); 96 results.rect = display.bounds();
94 results.available_rect = display.work_area(); 97 results.available_rect = display.work_area();
95 results.orientation_angle = display.RotationAsDegree(); 98 results.orientation_angle = display.RotationAsDegree();
96 results.orientation_type = 99 results.orientation_type =
97 content::RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display); 100 content::RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display);
98 101
99 return results; 102 return results;
100 } 103 }
101 104
102 } // namespace 105 } // namespace
103 106
104 namespace content { 107 namespace content {
105 108
106 // static 109 // static
110 void WebContentsViewMac::InstallCreateHookForTests(
111 RenderWidgetHostViewCreateFunction create_render_widget_host_view) {
112 CHECK_EQ(nullptr, g_create_render_widget_host_view);
113 g_create_render_widget_host_view = create_render_widget_host_view;
114 }
115
116 // static
107 void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) { 117 void WebContentsView::GetDefaultScreenInfo(ScreenInfo* results) {
108 *results = GetNSViewScreenInfo(nil); 118 *results = GetNSViewScreenInfo(nil);
109 } 119 }
110 120
111 WebContentsView* CreateWebContentsView( 121 WebContentsView* CreateWebContentsView(
112 WebContentsImpl* web_contents, 122 WebContentsImpl* web_contents,
113 WebContentsViewDelegate* delegate, 123 WebContentsViewDelegate* delegate,
114 RenderViewHostDelegateView** render_view_host_delegate_view) { 124 RenderViewHostDelegateView** render_view_host_delegate_view) {
115 WebContentsViewMac* rv = new WebContentsViewMac(web_contents, delegate); 125 WebContentsViewMac* rv = new WebContentsViewMac(web_contents, delegate);
116 *render_view_host_delegate_view = rv; 126 *render_view_host_delegate_view = rv;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 // During testing, the view will already be set up in most cases to the 353 // During testing, the view will already be set up in most cases to the
344 // test view, so we don't want to clobber it with a real one. To verify that 354 // test view, so we don't want to clobber it with a real one. To verify that
345 // this actually is happening (and somebody isn't accidentally creating the 355 // this actually is happening (and somebody isn't accidentally creating the
346 // view twice), we check for the RVH Factory, which will be set when we're 356 // view twice), we check for the RVH Factory, which will be set when we're
347 // making special ones (which go along with the special views). 357 // making special ones (which go along with the special views).
348 DCHECK(RenderViewHostFactory::has_factory()); 358 DCHECK(RenderViewHostFactory::has_factory());
349 return static_cast<RenderWidgetHostViewBase*>( 359 return static_cast<RenderWidgetHostViewBase*>(
350 render_widget_host->GetView()); 360 render_widget_host->GetView());
351 } 361 }
352 362
353 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac( 363 RenderWidgetHostViewMac* view =
354 render_widget_host, is_guest_view_hack); 364 g_create_render_widget_host_view
365 ? g_create_render_widget_host_view(render_widget_host,
366 is_guest_view_hack)
367 : new RenderWidgetHostViewMac(render_widget_host, is_guest_view_hack);
355 if (delegate()) { 368 if (delegate()) {
356 base::scoped_nsobject<NSObject<RenderWidgetHostViewMacDelegate> > 369 base::scoped_nsobject<NSObject<RenderWidgetHostViewMacDelegate> >
357 rw_delegate( 370 rw_delegate(
358 delegate()->CreateRenderWidgetHostViewDelegate(render_widget_host)); 371 delegate()->CreateRenderWidgetHostViewDelegate(render_widget_host));
359 372
360 view->SetDelegate(rw_delegate.get()); 373 view->SetDelegate(rw_delegate.get());
361 } 374 }
362 view->SetAllowPauseForResizeOrRepaint(!allow_other_views_); 375 view->SetAllowPauseForResizeOrRepaint(!allow_other_views_);
363 376
364 // Fancy layout comes later; for now just make it our size and resize it 377 // Fancy layout comes later; for now just make it our size and resize it
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 734
722 - (void)viewDidHide { 735 - (void)viewDidHide {
723 [self updateWebContentsVisibility]; 736 [self updateWebContentsVisibility];
724 } 737 }
725 738
726 - (void)viewDidUnhide { 739 - (void)viewDidUnhide {
727 [self updateWebContentsVisibility]; 740 [self updateWebContentsVisibility];
728 } 741 }
729 742
730 @end 743 @end
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_mac.h ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698