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

Unified Diff: ui/views/cocoa/bridged_content_view.mm

Issue 2448173002: Fix processing of mouse events on MacViews.
Patch Set: Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/cocoa/bridged_content_view.mm
diff --git a/ui/views/cocoa/bridged_content_view.mm b/ui/views/cocoa/bridged_content_view.mm
index 7c49cd0444346d7291793796970f16a6d7a7c505..023b0e5d5a1251c12f4ca8c8bcaf66c7232e2054 100644
--- a/ui/views/cocoa/bridged_content_view.mm
+++ b/ui/views/cocoa/bridged_content_view.mm
@@ -55,6 +55,7 @@ bool IsRectInsidePath(NSRect rect, NSBezierPath* path) {
rect.origin.y + rect.size.height)];
}
+#if 0 // BROWSER-55005
Avi (use Gerrit) 2016/10/25 15:34:50 Don't commit commented-out code.
snake 2016/10/25 15:46:18 Done.
// Convert a |point| in |source_window|'s AppKit coordinate system (origin at
// the bottom left of the window) to |target_window|'s content rect, with the
// origin at the top left of the content area.
@@ -73,6 +74,7 @@ bool IsRectInsidePath(NSRect rect, NSBezierPath* path) {
return gfx::Point(point_in_window.x,
NSHeight(content_rect) - point_in_window.y);
}
+#endif // BROWSER-55005
// Dispatch |event| to |menu_controller| and return true if |event| is
// swallowed.
@@ -345,26 +347,6 @@ - (void)clearView {
[self removeTrackingArea:cursorTrackingArea_.get()];
}
-- (void)processCapturedMouseEvent:(NSEvent*)theEvent {
- if (!hostedView_)
- return;
-
- NSWindow* source = [theEvent window];
- NSWindow* target = [self window];
- DCHECK(target);
-
- // If it's the view's window, process normally.
- if ([target isEqual:source]) {
- [self mouseEvent:theEvent];
- return;
- }
-
- ui::MouseEvent event(theEvent);
- event.set_location(
- MovePointToWindow([theEvent locationInWindow], source, target));
- hostedView_->GetWidget()->OnMouseEvent(&event);
-}
-
- (void)updateTooltipIfRequiredAt:(const gfx::Point&)locationInContent {
DCHECK(hostedView_);
base::string16 newTooltipText;
@@ -383,6 +365,13 @@ - (void)updateTooltipIfRequiredAt:(const gfx::Point&)locationInContent {
}
}
+- (void)hideTooltipIfRequired {
+ if (!lastTooltipText_.empty()) {
+ lastTooltipText_.clear();
+ [self setToolTipAtMousePoint:nil];
+ }
+}
+
- (void)updateWindowMask {
DCHECK(![self inLiveResize]);
DCHECK(base::mac::IsOS10_9());
@@ -580,19 +569,18 @@ - (void)selectAll:(id)sender {
- (void)enableTracking {
}
+// Explicitly ignore BaseView's |dragging_| logic
+- (void)mouseDown:(NSEvent*)theEvent {
+ [self mouseEvent:theEvent];
+}
+
// Translates the location of |theEvent| to toolkit-views coordinates and passes
// the event to NativeWidgetMac for handling.
- (void)mouseEvent:(NSEvent*)theEvent {
if (!hostedView_)
return;
-
- ui::MouseEvent event(theEvent);
-
- // Aura updates tooltips with the help of aura::Window::AddPreTargetHandler().
- // Mac hooks in here.
- [self updateTooltipIfRequiredAt:event.location()];
-
- hostedView_->GetWidget()->OnMouseEvent(&event);
+ views::NativeWidgetMac::GetBridgeForNativeWindow([self window])
+ ->OnMouseEvent(theEvent);
}
// NSView implementation.
@@ -776,8 +764,9 @@ - (void)scrollWheel:(NSEvent*)theEvent {
if (!hostedView_)
return;
- ui::ScrollEvent event(theEvent);
- hostedView_->GetWidget()->OnScrollEvent(&event);
+ // Passes the event to BridgedNativeWidget for handling.
+ views::NativeWidgetMac::GetBridgeForNativeWindow([self window])
+ ->OnMouseEvent(theEvent);
}
- (void)quickLookWithEvent:(NSEvent*)theEvent {

Powered by Google App Engine
This is Rietveld 408576698