OLD | NEW |
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 <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 #include <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 517 |
518 if (!is_guest_view_hack_) | 518 if (!is_guest_view_hack_) |
519 render_widget_host_->SetView(this); | 519 render_widget_host_->SetView(this); |
520 | 520 |
521 // Let the page-level input event router know about our surface ID | 521 // Let the page-level input event router know about our surface ID |
522 // namespace for surface-based hit testing. | 522 // namespace for surface-based hit testing. |
523 if (render_widget_host_->delegate() && | 523 if (render_widget_host_->delegate() && |
524 render_widget_host_->delegate()->GetInputEventRouter()) { | 524 render_widget_host_->delegate()->GetInputEventRouter()) { |
525 render_widget_host_->delegate() | 525 render_widget_host_->delegate() |
526 ->GetInputEventRouter() | 526 ->GetInputEventRouter() |
527 ->AddSurfaceIdNamespaceOwner(GetSurfaceIdNamespace(), this); | 527 ->AddSurfaceClientIdOwner(GetSurfaceClientId(), this); |
528 } | 528 } |
529 } | 529 } |
530 | 530 |
531 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 531 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
532 display::Screen::GetScreen()->RemoveObserver(this); | 532 display::Screen::GetScreen()->RemoveObserver(this); |
533 | 533 |
534 // This is being called from |cocoa_view_|'s destructor, so invalidate the | 534 // This is being called from |cocoa_view_|'s destructor, so invalidate the |
535 // pointer. | 535 // pointer. |
536 cocoa_view_ = nil; | 536 cocoa_view_ = nil; |
537 | 537 |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 composition_range_ = range; | 913 composition_range_ = range; |
914 composition_bounds_ = character_bounds; | 914 composition_bounds_ = character_bounds; |
915 } | 915 } |
916 | 916 |
917 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, | 917 void RenderWidgetHostViewMac::RenderProcessGone(base::TerminationStatus status, |
918 int error_code) { | 918 int error_code) { |
919 Destroy(); | 919 Destroy(); |
920 } | 920 } |
921 | 921 |
922 void RenderWidgetHostViewMac::Destroy() { | 922 void RenderWidgetHostViewMac::Destroy() { |
923 // SurfaceIdNamespaces registered with RenderWidgetHostInputEventRouter | 923 // SurfaceClientIds registered with RenderWidgetHostInputEventRouter |
924 // have already been cleared when RenderWidgetHostViewBase notified its | 924 // have already been cleared when RenderWidgetHostViewBase notified its |
925 // observers of our impending destruction. | 925 // observers of our impending destruction. |
926 [[NSNotificationCenter defaultCenter] | 926 [[NSNotificationCenter defaultCenter] |
927 removeObserver:cocoa_view_ | 927 removeObserver:cocoa_view_ |
928 name:NSWindowWillCloseNotification | 928 name:NSWindowWillCloseNotification |
929 object:popup_window_]; | 929 object:popup_window_]; |
930 | 930 |
931 // We've been told to destroy. | 931 // We've been told to destroy. |
932 [cocoa_view_ retain]; | 932 [cocoa_view_ retain]; |
933 [cocoa_view_ removeFromSuperview]; | 933 [cocoa_view_ removeFromSuperview]; |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 } | 1384 } |
1385 | 1385 |
1386 std::unique_ptr<SyntheticGestureTarget> | 1386 std::unique_ptr<SyntheticGestureTarget> |
1387 RenderWidgetHostViewMac::CreateSyntheticGestureTarget() { | 1387 RenderWidgetHostViewMac::CreateSyntheticGestureTarget() { |
1388 RenderWidgetHostImpl* host = | 1388 RenderWidgetHostImpl* host = |
1389 RenderWidgetHostImpl::From(GetRenderWidgetHost()); | 1389 RenderWidgetHostImpl::From(GetRenderWidgetHost()); |
1390 return std::unique_ptr<SyntheticGestureTarget>( | 1390 return std::unique_ptr<SyntheticGestureTarget>( |
1391 new SyntheticGestureTargetMac(host, cocoa_view_)); | 1391 new SyntheticGestureTargetMac(host, cocoa_view_)); |
1392 } | 1392 } |
1393 | 1393 |
1394 uint32_t RenderWidgetHostViewMac::GetSurfaceIdNamespace() { | 1394 uint32_t RenderWidgetHostViewMac::GetSurfaceClientId() { |
1395 return browser_compositor_->GetDelegatedFrameHost()->GetSurfaceIdNamespace(); | 1395 return browser_compositor_->GetDelegatedFrameHost()->GetSurfaceClientId(); |
1396 } | 1396 } |
1397 | 1397 |
1398 uint32_t RenderWidgetHostViewMac::SurfaceIdNamespaceAtPoint( | 1398 uint32_t RenderWidgetHostViewMac::SurfaceClientIdAtPoint( |
1399 cc::SurfaceHittestDelegate* delegate, | 1399 cc::SurfaceHittestDelegate* delegate, |
1400 const gfx::Point& point, | 1400 const gfx::Point& point, |
1401 gfx::Point* transformed_point) { | 1401 gfx::Point* transformed_point) { |
1402 // The surface hittest happens in device pixels, so we need to convert the | 1402 // The surface hittest happens in device pixels, so we need to convert the |
1403 // |point| from DIPs to pixels before hittesting. | 1403 // |point| from DIPs to pixels before hittesting. |
1404 float scale_factor = display::Screen::GetScreen() | 1404 float scale_factor = display::Screen::GetScreen() |
1405 ->GetDisplayNearestWindow(cocoa_view_) | 1405 ->GetDisplayNearestWindow(cocoa_view_) |
1406 .device_scale_factor(); | 1406 .device_scale_factor(); |
1407 gfx::Point point_in_pixels = gfx::ConvertPointToPixel(scale_factor, point); | 1407 gfx::Point point_in_pixels = gfx::ConvertPointToPixel(scale_factor, point); |
1408 cc::SurfaceId id = | 1408 cc::SurfaceId id = |
1409 browser_compositor_->GetDelegatedFrameHost()->SurfaceIdAtPoint( | 1409 browser_compositor_->GetDelegatedFrameHost()->SurfaceIdAtPoint( |
1410 delegate, point_in_pixels, transformed_point); | 1410 delegate, point_in_pixels, transformed_point); |
1411 *transformed_point = gfx::ConvertPointToDIP(scale_factor, *transformed_point); | 1411 *transformed_point = gfx::ConvertPointToDIP(scale_factor, *transformed_point); |
1412 | 1412 |
1413 // It is possible that the renderer has not yet produced a surface, in which | 1413 // It is possible that the renderer has not yet produced a surface, in which |
1414 // case we return our current namespace. | 1414 // case we return our current namespace. |
1415 if (id.is_null()) | 1415 if (id.is_null()) |
1416 return GetSurfaceIdNamespace(); | 1416 return GetSurfaceClientId(); |
1417 return id.id_namespace(); | 1417 return id.client_id(); |
1418 } | 1418 } |
1419 | 1419 |
1420 bool RenderWidgetHostViewMac::ShouldRouteEvent( | 1420 bool RenderWidgetHostViewMac::ShouldRouteEvent( |
1421 const WebInputEvent& event) const { | 1421 const WebInputEvent& event) const { |
1422 // See also RenderWidgetHostViewAura::ShouldRouteEvent. | 1422 // See also RenderWidgetHostViewAura::ShouldRouteEvent. |
1423 // TODO(wjmaclean): Update this function if RenderWidgetHostViewMac implements | 1423 // TODO(wjmaclean): Update this function if RenderWidgetHostViewMac implements |
1424 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura. | 1424 // OnTouchEvent(), to match what we are doing in RenderWidgetHostViewAura. |
1425 DCHECK(WebInputEvent::isMouseEventType(event.type) || | 1425 DCHECK(WebInputEvent::isMouseEventType(event.type) || |
1426 event.type == WebInputEvent::MouseWheel); | 1426 event.type == WebInputEvent::MouseWheel); |
1427 return render_widget_host_->delegate() && | 1427 return render_widget_host_->delegate() && |
(...skipping 1804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3232 | 3232 |
3233 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3233 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3234 // regions that are not draggable. (See ControlRegionView in | 3234 // regions that are not draggable. (See ControlRegionView in |
3235 // native_app_window_cocoa.mm). This requires the render host view to be | 3235 // native_app_window_cocoa.mm). This requires the render host view to be |
3236 // draggable by default. | 3236 // draggable by default. |
3237 - (BOOL)mouseDownCanMoveWindow { | 3237 - (BOOL)mouseDownCanMoveWindow { |
3238 return YES; | 3238 return YES; |
3239 } | 3239 } |
3240 | 3240 |
3241 @end | 3241 @end |
OLD | NEW |