Chromium Code Reviews| Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm |
| =================================================================== |
| --- chrome/browser/renderer_host/render_widget_host_view_mac.mm (revision 91505) |
| +++ chrome/browser/renderer_host/render_widget_host_view_mac.mm (working copy) |
| @@ -237,6 +237,7 @@ |
| spellcheck_checked_(false), |
| is_loading_(false), |
| is_hidden_(false), |
| + is_showing_context_menu_(false), |
| shutdown_factory_(this), |
| needs_gpu_visibility_update_after_repaint_(false), |
| compositing_surface_(gfx::kNullPluginWindow) { |
| @@ -473,6 +474,11 @@ |
| void RenderWidgetHostViewMac::UpdateCursorIfNecessary() { |
| // Do something special (as Win Chromium does) for arrow cursor while loading |
| // a page? TODO(avi): decide |
| + |
| + // Don't update the cursor if a context menu is being shown. |
| + if (is_showing_context_menu_) |
| + return; |
| + |
| // Can we synchronize to the event stream? Switch to -[NSWindow |
| // mouseLocationOutsideOfEventStream] if we cannot. TODO(avi): test and see |
| NSEvent* event = [[cocoa_view_ window] currentEvent]; |
| @@ -642,6 +648,30 @@ |
| [cocoa_view_ setSelectedRange:range.ToNSRange()]; |
| } |
| +void RenderWidgetHostViewMac::ShowingContextMenu(bool showing) { |
| + DCHECK_NE(is_showing_context_menu_, showing); |
| + is_showing_context_menu_ = showing; |
| + |
| + // Create a fake mouse event to inform the render widget that the mouse |
| + // left or entered. |
| + NSWindow* window = [cocoa_view_ window]; |
| + NSPoint location = [window mouseLocationOutsideOfEventStream]; |
|
Mark Mentovai
2011/07/12 14:06:57
“outside of event stream”—is this a good idea? Wha
|
| + NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved |
| + location:location |
| + modifierFlags:0 |
| + timestamp:0 |
| + windowNumber:[window windowNumber] |
| + context:nil |
| + eventNumber:0 |
| + clickCount:0 |
| + pressure:0]; |
| + WebMouseEvent web_event = |
| + WebInputEventFactory::mouseEvent(event, cocoa_view_); |
| + if (showing) |
| + web_event.type = WebInputEvent::MouseLeave; |
| + render_widget_host_->ForwardMouseEvent(web_event); |
| +} |
| + |
| bool RenderWidgetHostViewMac::IsPopup() const { |
| return popup_type_ != WebKit::WebPopupTypeNone; |
| } |