Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm |
=================================================================== |
--- chrome/browser/renderer_host/render_widget_host_view_mac.mm (revision 79160) |
+++ chrome/browser/renderer_host/render_widget_host_view_mac.mm (working copy) |
@@ -1420,6 +1420,7 @@ |
takesFocusOnlyOnMouseDown_ = NO; |
closeOnDeactivate_ = NO; |
focusedPluginIdentifier_ = -1; |
+ mouseEventWasIgnored_ = NO; |
Mark Mentovai
2011/03/24 18:44:40
Is NO really the right thing to initialize this to
Alexei Svitkine (slow)
2011/03/24 19:04:56
Done.
|
} |
return self; |
} |
@@ -1437,6 +1438,36 @@ |
} |
- (void)mouseEvent:(NSEvent*)theEvent { |
+ // Use hitTest to check whether we're the frontmost view for this mouse |
Mark Mentovai
2011/03/24 18:44:40
s/we're/this is/
Alexei Svitkine (slow)
2011/03/24 19:04:56
Done.
|
+ // location. If this is not the frontmost view, don't handle the event |
+ // here - let the frontmost view handle it. |
+ NSView* contentView = [[self window] contentView]; |
+ if ([contentView hitTest:[theEvent locationInWindow]] != self) { |
+ // If this is the first such event, send a mouse exit to the host view. |
+ if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { |
+ WebMouseEvent exitEvent = |
+ WebInputEventFactory::mouseEvent(theEvent, self); |
+ exitEvent.type = WebInputEvent::MouseLeave; |
+ exitEvent.button = WebMouseEvent::ButtonNone; |
+ renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(exitEvent); |
+ } |
+ mouseEventWasIgnored_ = YES; |
+ return; |
+ } |
+ |
+ // If the previous event was ignored as a result of the hitTest, send a mouse |
+ // event to the host view. |
+ if (mouseEventWasIgnored_) { |
+ if (renderWidgetHostView_->render_widget_host_) { |
+ WebMouseEvent enterEvent = |
+ WebInputEventFactory::mouseEvent(theEvent, self); |
+ enterEvent.type = WebInputEvent::MouseMove; |
+ enterEvent.button = WebMouseEvent::ButtonNone; |
+ renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(enterEvent); |
+ } |
+ mouseEventWasIgnored_ = NO; |
+ } |
+ |
// TODO(rohitrao): Probably need to handle other mouse down events here. |
if ([theEvent type] == NSLeftMouseDown && takesFocusOnlyOnMouseDown_) { |
if (renderWidgetHostView_->render_widget_host_) |