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 1893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1904 if (responderDelegate_ && | 1904 if (responderDelegate_ && |
1905 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) { | 1905 [responderDelegate_ respondsToSelector:@selector(handleEvent:)]) { |
1906 BOOL handled = [responderDelegate_ handleEvent:theEvent]; | 1906 BOOL handled = [responderDelegate_ handleEvent:theEvent]; |
1907 if (handled) | 1907 if (handled) |
1908 return; | 1908 return; |
1909 } | 1909 } |
1910 | 1910 |
1911 // Set the pointer type when we are receiving a NSMouseEntered event and the | 1911 // Set the pointer type when we are receiving a NSMouseEntered event and the |
1912 // following NSMouseExited event should have the same pointer type. | 1912 // following NSMouseExited event should have the same pointer type. |
1913 NSEventType type = [theEvent type]; | 1913 NSEventType type = [theEvent type]; |
1914 if (type == NSMouseEntered) { | 1914 if (type == NSMouseEntered || type == NSMouseExited) { |
1915 pointerType_ = isStylusEnteringProximity_ | 1915 pointerType_ = isStylusEnteringProximity_ |
Navid Zolghadr
2017/03/08 19:30:27
Can we just use an if statement here and not set p
lanwei
2017/03/08 21:01:19
I thought it was clearer to set the pointer type f
| |
1916 ? blink::WebPointerProperties::PointerType::Pen | 1916 ? pointerType_ |
1917 : blink::WebPointerProperties::PointerType::Mouse; | 1917 : blink::WebPointerProperties::PointerType::Mouse; |
1918 } else { | |
1919 NSEventSubtype subtype = [theEvent subtype]; | |
1920 if (subtype != NSTabletPointEventSubtype && | |
1921 subtype != NSTabletProximityEventSubtype) { | |
1922 pointerType_ = blink::WebPointerProperties::PointerType::Mouse; | |
Navid Zolghadr
2017/03/08 19:30:27
Why did we make this change here along with the er
lanwei
2017/03/08 21:01:19
I moved all the logic of setting the pointer type
| |
1923 } | |
1918 } | 1924 } |
1919 | 1925 |
1920 if ([self shouldIgnoreMouseEvent:theEvent]) { | 1926 if ([self shouldIgnoreMouseEvent:theEvent]) { |
1921 // If this is the first such event, send a mouse exit to the host view. | 1927 // If this is the first such event, send a mouse exit to the host view. |
1922 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { | 1928 if (!mouseEventWasIgnored_ && renderWidgetHostView_->render_widget_host_) { |
1923 WebMouseEvent exitEvent = | 1929 WebMouseEvent exitEvent = |
1924 WebMouseEventBuilder::Build(theEvent, self, pointerType_); | 1930 WebMouseEventBuilder::Build(theEvent, self, pointerType_); |
1925 exitEvent.setType(WebInputEvent::MouseLeave); | 1931 exitEvent.setType(WebInputEvent::MouseLeave); |
1926 exitEvent.button = WebMouseEvent::Button::NoButton; | 1932 exitEvent.button = WebMouseEvent::Button::NoButton; |
1927 renderWidgetHostView_->ForwardMouseEvent(exitEvent); | 1933 renderWidgetHostView_->ForwardMouseEvent(exitEvent); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1980 if (renderWidgetHostView_->ShouldRouteEvent(event)) { | 1986 if (renderWidgetHostView_->ShouldRouteEvent(event)) { |
1981 renderWidgetHostView_->render_widget_host_->delegate() | 1987 renderWidgetHostView_->render_widget_host_->delegate() |
1982 ->GetInputEventRouter() | 1988 ->GetInputEventRouter() |
1983 ->RouteMouseEvent(renderWidgetHostView_.get(), &event, latency_info); | 1989 ->RouteMouseEvent(renderWidgetHostView_.get(), &event, latency_info); |
1984 } else { | 1990 } else { |
1985 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); | 1991 renderWidgetHostView_->ProcessMouseEvent(event, latency_info); |
1986 } | 1992 } |
1987 } | 1993 } |
1988 | 1994 |
1989 - (void)tabletEvent:(NSEvent*)theEvent { | 1995 - (void)tabletEvent:(NSEvent*)theEvent { |
1990 if ([theEvent type] == NSTabletProximity) | 1996 if ([theEvent type] == NSTabletProximity) { |
1991 isStylusEnteringProximity_ = [theEvent isEnteringProximity]; | 1997 isStylusEnteringProximity_ = [theEvent isEnteringProximity]; |
1998 NSPointingDeviceType deviceType = [theEvent pointingDeviceType]; | |
1999 pointerType_ = deviceType == NSEraserPointingDevice | |
2000 ? blink::WebPointerProperties::PointerType::Eraser | |
2001 : blink::WebPointerProperties::PointerType::Pen; | |
2002 } | |
1992 } | 2003 } |
1993 | 2004 |
1994 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { | 2005 - (BOOL)performKeyEquivalent:(NSEvent*)theEvent { |
1995 // |performKeyEquivalent:| is sent to all views of a window, not only down the | 2006 // |performKeyEquivalent:| is sent to all views of a window, not only down the |
1996 // responder chain (cf. "Handling Key Equivalents" in | 2007 // responder chain (cf. "Handling Key Equivalents" in |
1997 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html | 2008 // http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/Event Overview/HandlingKeyEvents/HandlingKeyEvents.html |
1998 // ). We only want to handle key equivalents if we're first responder. | 2009 // ). We only want to handle key equivalents if we're first responder. |
1999 if ([[self window] firstResponder] != self) | 2010 if ([[self window] firstResponder] != self) |
2000 return NO; | 2011 return NO; |
2001 | 2012 |
(...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3489 | 3500 |
3490 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3501 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3491 // regions that are not draggable. (See ControlRegionView in | 3502 // regions that are not draggable. (See ControlRegionView in |
3492 // native_app_window_cocoa.mm). This requires the render host view to be | 3503 // native_app_window_cocoa.mm). This requires the render host view to be |
3493 // draggable by default. | 3504 // draggable by default. |
3494 - (BOOL)mouseDownCanMoveWindow { | 3505 - (BOOL)mouseDownCanMoveWindow { |
3495 return YES; | 3506 return YES; |
3496 } | 3507 } |
3497 | 3508 |
3498 @end | 3509 @end |
OLD | NEW |