Chromium Code Reviews| 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 <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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 729 : nullptr; | 729 : nullptr; |
| 730 } | 730 } |
| 731 | 731 |
| 732 RenderWidgetHostDelegate* | 732 RenderWidgetHostDelegate* |
| 733 RenderWidgetHostViewMac::GetFocusedRenderWidgetHostDelegate() { | 733 RenderWidgetHostViewMac::GetFocusedRenderWidgetHostDelegate() { |
| 734 if (auto* focused_widget = GetFocusedWidget()) | 734 if (auto* focused_widget = GetFocusedWidget()) |
| 735 return focused_widget->delegate(); | 735 return focused_widget->delegate(); |
| 736 return render_widget_host_->delegate(); | 736 return render_widget_host_->delegate(); |
| 737 } | 737 } |
| 738 | 738 |
| 739 void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) { | |
|
kenrb
2017/06/05 17:39:16
Is this change intentional? It looks like you just
EhsanK
2017/06/06 12:34:46
Thanks! Moved it back where it used to be. The onl
| |
| 740 // Create a fake mouse event to inform the render widget that the mouse | |
| 741 // left or entered. | |
| 742 NSWindow* window = [cocoa_view_ window]; | |
| 743 // TODO(asvitkine): If the location outside of the event stream doesn't | |
| 744 // correspond to the current event (due to delayed event processing), then | |
| 745 // this may result in a cursor flicker if there are later mouse move events | |
| 746 // in the pipeline. Find a way to use the mouse location from the event that | |
| 747 // dismissed the context menu. | |
| 748 NSPoint location = [window mouseLocationOutsideOfEventStream]; | |
| 749 NSTimeInterval event_time = [[NSApp currentEvent] timestamp]; | |
| 750 NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved | |
| 751 location:location | |
| 752 modifierFlags:0 | |
| 753 timestamp:event_time | |
| 754 windowNumber:window_number() | |
| 755 context:nil | |
| 756 eventNumber:0 | |
| 757 clickCount:0 | |
| 758 pressure:0]; | |
| 759 WebMouseEvent web_event = WebMouseEventBuilder::Build(event, cocoa_view_); | |
| 760 if (showing) | |
| 761 web_event.SetType(WebInputEvent::kMouseLeave); | |
| 762 ForwardMouseEvent(web_event); | |
| 763 } | |
| 764 | |
| 739 void RenderWidgetHostViewMac::UpdateBackingStoreProperties() { | 765 void RenderWidgetHostViewMac::UpdateBackingStoreProperties() { |
| 740 if (!render_widget_host_) | 766 if (!render_widget_host_) |
| 741 return; | 767 return; |
| 742 render_widget_host_->NotifyScreenInfoChanged(); | 768 render_widget_host_->NotifyScreenInfoChanged(); |
| 743 } | 769 } |
| 744 | 770 |
| 745 RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const { | 771 RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const { |
| 746 return render_widget_host_; | 772 return render_widget_host_; |
| 747 } | 773 } |
| 748 | 774 |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1129 void RenderWidgetHostViewMac::StopSpeaking() { | 1155 void RenderWidgetHostViewMac::StopSpeaking() { |
| 1130 if ([NSApp respondsToSelector:@selector(stopSpeaking:)]) | 1156 if ([NSApp respondsToSelector:@selector(stopSpeaking:)]) |
| 1131 [NSApp stopSpeaking:cocoa_view_]; | 1157 [NSApp stopSpeaking:cocoa_view_]; |
| 1132 } | 1158 } |
| 1133 | 1159 |
| 1134 // | 1160 // |
| 1135 // RenderWidgetHostViewCocoa uses the stored selection text, | 1161 // RenderWidgetHostViewCocoa uses the stored selection text, |
| 1136 // which implements NSServicesRequests protocol. | 1162 // which implements NSServicesRequests protocol. |
| 1137 // | 1163 // |
| 1138 | 1164 |
| 1139 void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) { | |
| 1140 RenderWidgetHostViewBase::SetShowingContextMenu(showing); | |
| 1141 | |
| 1142 // Create a fake mouse event to inform the render widget that the mouse | |
| 1143 // left or entered. | |
| 1144 NSWindow* window = [cocoa_view_ window]; | |
| 1145 // TODO(asvitkine): If the location outside of the event stream doesn't | |
| 1146 // correspond to the current event (due to delayed event processing), then | |
| 1147 // this may result in a cursor flicker if there are later mouse move events | |
| 1148 // in the pipeline. Find a way to use the mouse location from the event that | |
| 1149 // dismissed the context menu. | |
| 1150 NSPoint location = [window mouseLocationOutsideOfEventStream]; | |
| 1151 NSTimeInterval event_time = [[NSApp currentEvent] timestamp]; | |
| 1152 NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved | |
| 1153 location:location | |
| 1154 modifierFlags:0 | |
| 1155 timestamp:event_time | |
| 1156 windowNumber:window_number() | |
| 1157 context:nil | |
| 1158 eventNumber:0 | |
| 1159 clickCount:0 | |
| 1160 pressure:0]; | |
| 1161 WebMouseEvent web_event = WebMouseEventBuilder::Build(event, cocoa_view_); | |
| 1162 if (showing) | |
| 1163 web_event.SetType(WebInputEvent::kMouseLeave); | |
| 1164 ForwardMouseEvent(web_event); | |
| 1165 } | |
| 1166 | |
| 1167 bool RenderWidgetHostViewMac::IsPopup() const { | 1165 bool RenderWidgetHostViewMac::IsPopup() const { |
| 1168 return popup_type_ != blink::kWebPopupTypeNone; | 1166 return popup_type_ != blink::kWebPopupTypeNone; |
| 1169 } | 1167 } |
| 1170 | 1168 |
| 1171 void RenderWidgetHostViewMac::CopyFromSurface( | 1169 void RenderWidgetHostViewMac::CopyFromSurface( |
| 1172 const gfx::Rect& src_subrect, | 1170 const gfx::Rect& src_subrect, |
| 1173 const gfx::Size& dst_size, | 1171 const gfx::Size& dst_size, |
| 1174 const ReadbackRequestCallback& callback, | 1172 const ReadbackRequestCallback& callback, |
| 1175 const SkColorType preferred_color_type) { | 1173 const SkColorType preferred_color_type) { |
| 1176 browser_compositor_->CopyFromCompositingSurface( | 1174 browser_compositor_->CopyFromCompositingSurface( |
| (...skipping 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3524 | 3522 |
| 3525 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3523 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3526 // regions that are not draggable. (See ControlRegionView in | 3524 // regions that are not draggable. (See ControlRegionView in |
| 3527 // native_app_window_cocoa.mm). This requires the render host view to be | 3525 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3528 // draggable by default. | 3526 // draggable by default. |
| 3529 - (BOOL)mouseDownCanMoveWindow { | 3527 - (BOOL)mouseDownCanMoveWindow { |
| 3530 return YES; | 3528 return YES; |
| 3531 } | 3529 } |
| 3532 | 3530 |
| 3533 @end | 3531 @end |
| OLD | NEW |