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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 6676094: Fix for "Mouseovers follow the cursor even when there's a find bar in the way" (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <QuartzCore/QuartzCore.h> 5 #include <QuartzCore/QuartzCore.h>
6 6
7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" 7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
8 8
9 #include "app/surface/io_surface_support_mac.h" 9 #include "app/surface/io_surface_support_mac.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 @synthesize caretRect = caretRect_; 1410 @synthesize caretRect = caretRect_;
1411 1411
1412 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r { 1412 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r {
1413 self = [super initWithFrame:NSZeroRect]; 1413 self = [super initWithFrame:NSZeroRect];
1414 if (self) { 1414 if (self) {
1415 editCommand_helper_.reset(new RWHVMEditCommandHelper); 1415 editCommand_helper_.reset(new RWHVMEditCommandHelper);
1416 editCommand_helper_->AddEditingSelectorsToClass([self class]); 1416 editCommand_helper_->AddEditingSelectorsToClass([self class]);
1417 1417
1418 renderWidgetHostView_.reset(r); 1418 renderWidgetHostView_.reset(r);
1419 canBeKeyView_ = YES; 1419 canBeKeyView_ = YES;
1420 takesFocusOnlyOnMouseDown_ = NO;
1421 closeOnDeactivate_ = NO;
1422 focusedPluginIdentifier_ = -1; 1420 focusedPluginIdentifier_ = -1;
1423 } 1421 }
1424 return self; 1422 return self;
1425 } 1423 }
1426 1424
1427 - (void)setCanBeKeyView:(BOOL)can { 1425 - (void)setCanBeKeyView:(BOOL)can {
1428 canBeKeyView_ = can; 1426 canBeKeyView_ = can;
1429 } 1427 }
1430 1428
1431 - (void)setTakesFocusOnlyOnMouseDown:(BOOL)b { 1429 - (void)setTakesFocusOnlyOnMouseDown:(BOOL)b {
1432 takesFocusOnlyOnMouseDown_ = b; 1430 takesFocusOnlyOnMouseDown_ = b;
1433 } 1431 }
1434 1432
1435 - (void)setCloseOnDeactivate:(BOOL)b { 1433 - (void)setCloseOnDeactivate:(BOOL)b {
1436 closeOnDeactivate_ = b; 1434 closeOnDeactivate_ = b;
1437 } 1435 }
1438 1436
1439 - (void)mouseEvent:(NSEvent*)theEvent { 1437 - (void)mouseEvent:(NSEvent*)theEvent {
1438 // Use hitTest to check whether the mouse is over a nonWebContentView - in
1439 // which case the mouse event should not be handled by the render host.
1440 const SEL nonWebContentViewSelector = @selector(nonWebContentView);
1441 NSView* contentView = [[self window] contentView];
1442 NSView* view = [contentView hitTest:[theEvent locationInWindow]];
1443 // Traverse the superview hierarchy as the hitTest will return the frontmost
1444 // view, such as an NSTextView, while nonWebContentView may be specified by
1445 // its parent view.
1446 while (view) {
1447 if ([view respondsToSelector:nonWebContentViewSelector] &&
1448 [view performSelector:nonWebContentViewSelector]) {
1449 // The cursor is over a nonWebContentView - ignore this mouse event.
1450 // If this is the first such event, send a mouse exit to the host view.
1451 if (!mouseEventWasIgnored_ &&
1452 renderWidgetHostView_->render_widget_host_) {
1453 WebMouseEvent exitEvent =
1454 WebInputEventFactory::mouseEvent(theEvent, self);
1455 exitEvent.type = WebInputEvent::MouseLeave;
1456 exitEvent.button = WebMouseEvent::ButtonNone;
1457 renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(
1458 exitEvent);
1459 }
1460 mouseEventWasIgnored_ = YES;
1461 return;
1462 }
1463 view = [view superview];
1464 }
1465
1466 if (mouseEventWasIgnored_) {
1467 // If this is the first mouse event after a previous event that was ignored
1468 // due to the hitTest, send a mouse enter event to the host view.
1469 if (renderWidgetHostView_->render_widget_host_) {
1470 WebMouseEvent enterEvent =
1471 WebInputEventFactory::mouseEvent(theEvent, self);
1472 enterEvent.type = WebInputEvent::MouseMove;
1473 enterEvent.button = WebMouseEvent::ButtonNone;
1474 renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(enterEvent);
1475 }
1476 }
1477 mouseEventWasIgnored_ = NO;
1478
1440 // TODO(rohitrao): Probably need to handle other mouse down events here. 1479 // TODO(rohitrao): Probably need to handle other mouse down events here.
1441 if ([theEvent type] == NSLeftMouseDown && takesFocusOnlyOnMouseDown_) { 1480 if ([theEvent type] == NSLeftMouseDown && takesFocusOnlyOnMouseDown_) {
1442 if (renderWidgetHostView_->render_widget_host_) 1481 if (renderWidgetHostView_->render_widget_host_)
1443 renderWidgetHostView_->render_widget_host_->OnMouseActivate(); 1482 renderWidgetHostView_->render_widget_host_->OnMouseActivate();
1444 1483
1445 // Manually take focus after the click but before forwarding it to the 1484 // Manually take focus after the click but before forwarding it to the
1446 // renderer. 1485 // renderer.
1447 [[self window] makeFirstResponder:self]; 1486 [[self window] makeFirstResponder:self];
1448 } 1487 }
1449 1488
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2863 if (!string) return NO; 2902 if (!string) return NO;
2864 2903
2865 // If the user is currently using an IME, confirm the IME input, 2904 // If the user is currently using an IME, confirm the IME input,
2866 // and then insert the text from the service, the same as TextEdit and Safari. 2905 // and then insert the text from the service, the same as TextEdit and Safari.
2867 [self confirmComposition]; 2906 [self confirmComposition];
2868 [self insertText:string]; 2907 [self insertText:string];
2869 return YES; 2908 return YES;
2870 } 2909 }
2871 2910
2872 @end 2911 @end
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_mac.h ('k') | chrome/browser/ui/cocoa/find_bar/find_bar_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698